babylon.d.txt 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918
  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. * Creates a new observable
  4354. * @param onObserverAdded defines a callback to call when a new observer is added
  4355. */
  4356. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4357. /**
  4358. * Create a new Observer with the specified callback
  4359. * @param callback the callback that will be executed for that Observer
  4360. * @param mask the mask used to filter observers
  4361. * @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.
  4362. * @param scope optional scope for the callback to be called from
  4363. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4364. * @returns the new observer created for the callback
  4365. */
  4366. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4367. /**
  4368. * Create a new Observer with the specified callback and unregisters after the next notification
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @returns the new observer created for the callback
  4371. */
  4372. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4373. /**
  4374. * Remove an Observer from the Observable object
  4375. * @param observer the instance of the Observer to remove
  4376. * @returns false if it doesn't belong to this Observable
  4377. */
  4378. remove(observer: Nullable<Observer<T>>): boolean;
  4379. /**
  4380. * Remove a callback from the Observable object
  4381. * @param callback the callback to remove
  4382. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4383. * @returns false if it doesn't belong to this Observable
  4384. */
  4385. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4386. private _deferUnregister;
  4387. private _remove;
  4388. /**
  4389. * Moves the observable to the top of the observer list making it get called first when notified
  4390. * @param observer the observer to move
  4391. */
  4392. makeObserverTopPriority(observer: Observer<T>): void;
  4393. /**
  4394. * Moves the observable to the bottom of the observer list making it get called last when notified
  4395. * @param observer the observer to move
  4396. */
  4397. makeObserverBottomPriority(observer: Observer<T>): void;
  4398. /**
  4399. * Notify all Observers by calling their respective callback with the given data
  4400. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4401. * @param eventData defines the data to send to all observers
  4402. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4403. * @param target defines the original target of the state
  4404. * @param currentTarget defines the current target of the state
  4405. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4406. */
  4407. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4408. /**
  4409. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4410. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4411. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4412. * and it is crucial that all callbacks will be executed.
  4413. * The order of the callbacks is kept, callbacks are not executed parallel.
  4414. *
  4415. * @param eventData The data to be sent to each callback
  4416. * @param mask is used to filter observers defaults to -1
  4417. * @param target defines the callback target (see EventState)
  4418. * @param currentTarget defines he current object in the bubbling phase
  4419. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4420. */
  4421. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4422. /**
  4423. * Notify a specific observer
  4424. * @param observer defines the observer to notify
  4425. * @param eventData defines the data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. */
  4428. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4429. /**
  4430. * Gets a boolean indicating if the observable has at least one observer
  4431. * @returns true is the Observable has at least one Observer registered
  4432. */
  4433. hasObservers(): boolean;
  4434. /**
  4435. * Clear the list of observers
  4436. */
  4437. clear(): void;
  4438. /**
  4439. * Clone the current observable
  4440. * @returns a new observable
  4441. */
  4442. clone(): Observable<T>;
  4443. /**
  4444. * Does this observable handles observer registered with a given mask
  4445. * @param mask defines the mask to be tested
  4446. * @return whether or not one observer registered with the given mask is handeled
  4447. **/
  4448. hasSpecificMask(mask?: number): boolean;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to help managing file picking and drag'n'drop
  4454. * File Storage
  4455. */
  4456. export class FilesInputStore {
  4457. /**
  4458. * List of files ready to be loaded
  4459. */
  4460. static FilesToLoad: {
  4461. [key: string]: File;
  4462. };
  4463. }
  4464. }
  4465. declare module BABYLON {
  4466. /** Defines the cross module used constants to avoid circular dependncies */
  4467. export class Constants {
  4468. /** Defines that alpha blending is disabled */
  4469. static readonly ALPHA_DISABLE: number;
  4470. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4471. static readonly ALPHA_ADD: number;
  4472. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4473. static readonly ALPHA_COMBINE: number;
  4474. /** Defines that alpha blending to DEST - SRC * DEST */
  4475. static readonly ALPHA_SUBTRACT: number;
  4476. /** Defines that alpha blending to SRC * DEST */
  4477. static readonly ALPHA_MULTIPLY: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4479. static readonly ALPHA_MAXIMIZED: number;
  4480. /** Defines that alpha blending to SRC + DEST */
  4481. static readonly ALPHA_ONEONE: number;
  4482. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_PREMULTIPLIED: number;
  4484. /**
  4485. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4486. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4487. */
  4488. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4489. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4490. static readonly ALPHA_INTERPOLATE: number;
  4491. /**
  4492. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4493. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4494. */
  4495. static readonly ALPHA_SCREENMODE: number;
  4496. /** Defines that the ressource is not delayed*/
  4497. static readonly DELAYLOADSTATE_NONE: number;
  4498. /** Defines that the ressource was successfully delay loaded */
  4499. static readonly DELAYLOADSTATE_LOADED: number;
  4500. /** Defines that the ressource is currently delay loading */
  4501. static readonly DELAYLOADSTATE_LOADING: number;
  4502. /** Defines that the ressource is delayed and has not started loading */
  4503. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4504. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4505. static readonly NEVER: number;
  4506. /** 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 */
  4507. static readonly ALWAYS: number;
  4508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4509. static readonly LESS: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4511. static readonly EQUAL: number;
  4512. /** 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 */
  4513. static readonly LEQUAL: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4515. static readonly GREATER: number;
  4516. /** 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 */
  4517. static readonly GEQUAL: number;
  4518. /** 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 */
  4519. static readonly NOTEQUAL: number;
  4520. /** Passed to stencilOperation to specify that stencil value must be kept */
  4521. static readonly KEEP: number;
  4522. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4523. static readonly REPLACE: number;
  4524. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4525. static readonly INCR: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4527. static readonly DECR: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4529. static readonly INVERT: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4531. static readonly INCR_WRAP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4533. static readonly DECR_WRAP: number;
  4534. /** Texture is not repeating outside of 0..1 UVs */
  4535. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4536. /** Texture is repeating outside of 0..1 UVs */
  4537. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4538. /** Texture is repeating and mirrored */
  4539. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4540. /** ALPHA */
  4541. static readonly TEXTUREFORMAT_ALPHA: number;
  4542. /** LUMINANCE */
  4543. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4544. /** LUMINANCE_ALPHA */
  4545. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4546. /** RGB */
  4547. static readonly TEXTUREFORMAT_RGB: number;
  4548. /** RGBA */
  4549. static readonly TEXTUREFORMAT_RGBA: number;
  4550. /** RED */
  4551. static readonly TEXTUREFORMAT_RED: number;
  4552. /** RED (2nd reference) */
  4553. static readonly TEXTUREFORMAT_R: number;
  4554. /** RG */
  4555. static readonly TEXTUREFORMAT_RG: number;
  4556. /** RED_INTEGER */
  4557. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4558. /** RED_INTEGER (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4560. /** RG_INTEGER */
  4561. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4562. /** RGB_INTEGER */
  4563. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4564. /** RGBA_INTEGER */
  4565. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4566. /** UNSIGNED_BYTE */
  4567. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4568. /** UNSIGNED_BYTE (2nd reference) */
  4569. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4570. /** FLOAT */
  4571. static readonly TEXTURETYPE_FLOAT: number;
  4572. /** HALF_FLOAT */
  4573. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4574. /** BYTE */
  4575. static readonly TEXTURETYPE_BYTE: number;
  4576. /** SHORT */
  4577. static readonly TEXTURETYPE_SHORT: number;
  4578. /** UNSIGNED_SHORT */
  4579. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4580. /** INT */
  4581. static readonly TEXTURETYPE_INT: number;
  4582. /** UNSIGNED_INT */
  4583. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4584. /** UNSIGNED_SHORT_4_4_4_4 */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4586. /** UNSIGNED_SHORT_5_5_5_1 */
  4587. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4588. /** UNSIGNED_SHORT_5_6_5 */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4590. /** UNSIGNED_INT_2_10_10_10_REV */
  4591. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4592. /** UNSIGNED_INT_24_8 */
  4593. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4594. /** UNSIGNED_INT_10F_11F_11F_REV */
  4595. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4596. /** UNSIGNED_INT_5_9_9_9_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4598. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4599. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4600. /** nearest is mag = nearest and min = nearest and mip = linear */
  4601. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4602. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4603. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4604. /** Trilinear is mag = linear and min = linear and mip = linear */
  4605. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4612. /** mag = nearest and min = nearest and mip = nearest */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4614. /** mag = nearest and min = linear and mip = nearest */
  4615. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4616. /** mag = nearest and min = linear and mip = linear */
  4617. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = linear and mip = none */
  4619. static readonly TEXTURE_NEAREST_LINEAR: number;
  4620. /** mag = nearest and min = nearest and mip = none */
  4621. static readonly TEXTURE_NEAREST_NEAREST: number;
  4622. /** mag = linear and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4624. /** mag = linear and min = nearest and mip = linear */
  4625. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4626. /** mag = linear and min = linear and mip = none */
  4627. static readonly TEXTURE_LINEAR_LINEAR: number;
  4628. /** mag = linear and min = nearest and mip = none */
  4629. static readonly TEXTURE_LINEAR_NEAREST: number;
  4630. /** Explicit coordinates mode */
  4631. static readonly TEXTURE_EXPLICIT_MODE: number;
  4632. /** Spherical coordinates mode */
  4633. static readonly TEXTURE_SPHERICAL_MODE: number;
  4634. /** Planar coordinates mode */
  4635. static readonly TEXTURE_PLANAR_MODE: number;
  4636. /** Cubic coordinates mode */
  4637. static readonly TEXTURE_CUBIC_MODE: number;
  4638. /** Projection coordinates mode */
  4639. static readonly TEXTURE_PROJECTION_MODE: number;
  4640. /** Skybox coordinates mode */
  4641. static readonly TEXTURE_SKYBOX_MODE: number;
  4642. /** Inverse Cubic coordinates mode */
  4643. static readonly TEXTURE_INVCUBIC_MODE: number;
  4644. /** Equirectangular coordinates mode */
  4645. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4646. /** Equirectangular Fixed coordinates mode */
  4647. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4648. /** Equirectangular Fixed Mirrored coordinates mode */
  4649. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4650. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4651. static readonly SCALEMODE_FLOOR: number;
  4652. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4653. static readonly SCALEMODE_NEAREST: number;
  4654. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4655. static readonly SCALEMODE_CEILING: number;
  4656. /**
  4657. * The dirty texture flag value
  4658. */
  4659. static readonly MATERIAL_TextureDirtyFlag: number;
  4660. /**
  4661. * The dirty light flag value
  4662. */
  4663. static readonly MATERIAL_LightDirtyFlag: number;
  4664. /**
  4665. * The dirty fresnel flag value
  4666. */
  4667. static readonly MATERIAL_FresnelDirtyFlag: number;
  4668. /**
  4669. * The dirty attribute flag value
  4670. */
  4671. static readonly MATERIAL_AttributesDirtyFlag: number;
  4672. /**
  4673. * The dirty misc flag value
  4674. */
  4675. static readonly MATERIAL_MiscDirtyFlag: number;
  4676. /**
  4677. * The all dirty flag value
  4678. */
  4679. static readonly MATERIAL_AllDirtyFlag: number;
  4680. /**
  4681. * Returns the triangle fill mode
  4682. */
  4683. static readonly MATERIAL_TriangleFillMode: number;
  4684. /**
  4685. * Returns the wireframe mode
  4686. */
  4687. static readonly MATERIAL_WireFrameFillMode: number;
  4688. /**
  4689. * Returns the point fill mode
  4690. */
  4691. static readonly MATERIAL_PointFillMode: number;
  4692. /**
  4693. * Returns the point list draw mode
  4694. */
  4695. static readonly MATERIAL_PointListDrawMode: number;
  4696. /**
  4697. * Returns the line list draw mode
  4698. */
  4699. static readonly MATERIAL_LineListDrawMode: number;
  4700. /**
  4701. * Returns the line loop draw mode
  4702. */
  4703. static readonly MATERIAL_LineLoopDrawMode: number;
  4704. /**
  4705. * Returns the line strip draw mode
  4706. */
  4707. static readonly MATERIAL_LineStripDrawMode: number;
  4708. /**
  4709. * Returns the triangle strip draw mode
  4710. */
  4711. static readonly MATERIAL_TriangleStripDrawMode: number;
  4712. /**
  4713. * Returns the triangle fan draw mode
  4714. */
  4715. static readonly MATERIAL_TriangleFanDrawMode: number;
  4716. /**
  4717. * Stores the clock-wise side orientation
  4718. */
  4719. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4720. /**
  4721. * Stores the counter clock-wise side orientation
  4722. */
  4723. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4724. /**
  4725. * Nothing
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_NothingTrigger: number;
  4729. /**
  4730. * On pick
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickTrigger: number;
  4734. /**
  4735. * On left pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLeftPickTrigger: number;
  4739. /**
  4740. * On right pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnRightPickTrigger: number;
  4744. /**
  4745. * On center pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnCenterPickTrigger: number;
  4749. /**
  4750. * On pick down
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnPickDownTrigger: number;
  4754. /**
  4755. * On double pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnDoublePickTrigger: number;
  4759. /**
  4760. * On pick up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickUpTrigger: number;
  4764. /**
  4765. * On pick out.
  4766. * This trigger will only be raised if you also declared a OnPickDown
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickOutTrigger: number;
  4770. /**
  4771. * On long press
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnLongPressTrigger: number;
  4775. /**
  4776. * On pointer over
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPointerOverTrigger: number;
  4780. /**
  4781. * On pointer out
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnPointerOutTrigger: number;
  4785. /**
  4786. * On every frame
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnEveryFrameTrigger: number;
  4790. /**
  4791. * On intersection enter
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4795. /**
  4796. * On intersection exit
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnIntersectionExitTrigger: number;
  4800. /**
  4801. * On key down
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnKeyDownTrigger: number;
  4805. /**
  4806. * On key up
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnKeyUpTrigger: number;
  4810. /**
  4811. * Billboard mode will only apply to Y axis
  4812. */
  4813. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4814. /**
  4815. * Billboard mode will apply to all axes
  4816. */
  4817. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4818. /**
  4819. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4820. */
  4821. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4822. /**
  4823. * Gets or sets base Assets URL
  4824. */
  4825. static PARTICLES_BaseAssetsUrl: string;
  4826. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4827. * Test order :
  4828. * Is the bounding sphere outside the frustum ?
  4829. * If not, are the bounding box vertices outside the frustum ?
  4830. * It not, then the cullable object is in the frustum.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4833. /** Culling strategy : Bounding Sphere Only.
  4834. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4835. * It's also less accurate than the standard because some not visible objects can still be selected.
  4836. * Test : is the bounding sphere outside the frustum ?
  4837. * If not, then the cullable object is in the frustum.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4840. /** Culling strategy : Optimistic Inclusion.
  4841. * This in an inclusion test first, then the standard exclusion test.
  4842. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4843. * 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.
  4844. * Anyway, it's as accurate as the standard strategy.
  4845. * Test :
  4846. * Is the cullable object bounding sphere center in the frustum ?
  4847. * If not, apply the default culling strategy.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4850. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4851. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4852. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4860. /**
  4861. * No logging while loading
  4862. */
  4863. static readonly SCENELOADER_NO_LOGGING: number;
  4864. /**
  4865. * Minimal logging while loading
  4866. */
  4867. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4868. /**
  4869. * Summary logging while loading
  4870. */
  4871. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4872. /**
  4873. * Detailled logging while loading
  4874. */
  4875. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4876. }
  4877. }
  4878. declare module BABYLON {
  4879. /**
  4880. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4881. * Babylon.js
  4882. */
  4883. export class DomManagement {
  4884. /**
  4885. * Checks if the window object exists
  4886. * @returns true if the window object exists
  4887. */
  4888. static IsWindowObjectExist(): boolean;
  4889. /**
  4890. * Extracts text content from a DOM element hierarchy
  4891. * @param element defines the root element
  4892. * @returns a string
  4893. */
  4894. static GetDOMTextContent(element: HTMLElement): string;
  4895. }
  4896. }
  4897. declare module BABYLON {
  4898. /**
  4899. * Logger used througouht the application to allow configuration of
  4900. * the log level required for the messages.
  4901. */
  4902. export class Logger {
  4903. /**
  4904. * No log
  4905. */
  4906. static readonly NoneLogLevel: number;
  4907. /**
  4908. * Only message logs
  4909. */
  4910. static readonly MessageLogLevel: number;
  4911. /**
  4912. * Only warning logs
  4913. */
  4914. static readonly WarningLogLevel: number;
  4915. /**
  4916. * Only error logs
  4917. */
  4918. static readonly ErrorLogLevel: number;
  4919. /**
  4920. * All logs
  4921. */
  4922. static readonly AllLogLevel: number;
  4923. private static _LogCache;
  4924. /**
  4925. * Gets a value indicating the number of loading errors
  4926. * @ignorenaming
  4927. */
  4928. static errorsCount: number;
  4929. /**
  4930. * Callback called when a new log is added
  4931. */
  4932. static OnNewCacheEntry: (entry: string) => void;
  4933. private static _AddLogEntry;
  4934. private static _FormatMessage;
  4935. private static _LogDisabled;
  4936. private static _LogEnabled;
  4937. private static _WarnDisabled;
  4938. private static _WarnEnabled;
  4939. private static _ErrorDisabled;
  4940. private static _ErrorEnabled;
  4941. /**
  4942. * Log a message to the console
  4943. */
  4944. static Log: (message: string) => void;
  4945. /**
  4946. * Write a warning message to the console
  4947. */
  4948. static Warn: (message: string) => void;
  4949. /**
  4950. * Write an error message to the console
  4951. */
  4952. static Error: (message: string) => void;
  4953. /**
  4954. * Gets current log cache (list of logs)
  4955. */
  4956. static readonly LogCache: string;
  4957. /**
  4958. * Clears the log cache
  4959. */
  4960. static ClearLogCache(): void;
  4961. /**
  4962. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4963. */
  4964. static LogLevels: number;
  4965. }
  4966. }
  4967. declare module BABYLON {
  4968. /** @hidden */
  4969. export class _TypeStore {
  4970. /** @hidden */
  4971. static RegisteredTypes: {
  4972. [key: string]: Object;
  4973. };
  4974. /** @hidden */
  4975. static GetClass(fqdn: string): any;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. /**
  4980. * Class containing a set of static utilities functions for deep copy.
  4981. */
  4982. export class DeepCopier {
  4983. /**
  4984. * Tries to copy an object by duplicating every property
  4985. * @param source defines the source object
  4986. * @param destination defines the target object
  4987. * @param doNotCopyList defines a list of properties to avoid
  4988. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4989. */
  4990. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4991. }
  4992. }
  4993. declare module BABYLON {
  4994. /**
  4995. * Class containing a set of static utilities functions for precision date
  4996. */
  4997. export class PrecisionDate {
  4998. /**
  4999. * Gets either window.performance.now() if supported or Date.now() else
  5000. */
  5001. static readonly Now: number;
  5002. }
  5003. }
  5004. declare module BABYLON {
  5005. /** @hidden */
  5006. export class _DevTools {
  5007. static WarnImport(name: string): string;
  5008. }
  5009. }
  5010. declare module BABYLON {
  5011. /**
  5012. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5013. */
  5014. export class WebRequest {
  5015. private _xhr;
  5016. /**
  5017. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5018. * i.e. when loading files, where the server/service expects an Authorization header
  5019. */
  5020. static CustomRequestHeaders: {
  5021. [key: string]: string;
  5022. };
  5023. /**
  5024. * Add callback functions in this array to update all the requests before they get sent to the network
  5025. */
  5026. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5027. private _injectCustomRequestHeaders;
  5028. /**
  5029. * Gets or sets a function to be called when loading progress changes
  5030. */
  5031. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5032. /**
  5033. * Returns client's state
  5034. */
  5035. readonly readyState: number;
  5036. /**
  5037. * Returns client's status
  5038. */
  5039. readonly status: number;
  5040. /**
  5041. * Returns client's status as a text
  5042. */
  5043. readonly statusText: string;
  5044. /**
  5045. * Returns client's response
  5046. */
  5047. readonly response: any;
  5048. /**
  5049. * Returns client's response url
  5050. */
  5051. readonly responseURL: string;
  5052. /**
  5053. * Returns client's response as text
  5054. */
  5055. readonly responseText: string;
  5056. /**
  5057. * Gets or sets the expected response type
  5058. */
  5059. responseType: XMLHttpRequestResponseType;
  5060. /** @hidden */
  5061. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5062. /** @hidden */
  5063. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5064. /**
  5065. * Cancels any network activity
  5066. */
  5067. abort(): void;
  5068. /**
  5069. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5070. * @param body defines an optional request body
  5071. */
  5072. send(body?: Document | BodyInit | null): void;
  5073. /**
  5074. * Sets the request method, request URL
  5075. * @param method defines the method to use (GET, POST, etc..)
  5076. * @param url defines the url to connect with
  5077. */
  5078. open(method: string, url: string): void;
  5079. }
  5080. }
  5081. declare module BABYLON {
  5082. /**
  5083. * Class used to evalaute queries containing `and` and `or` operators
  5084. */
  5085. export class AndOrNotEvaluator {
  5086. /**
  5087. * Evaluate a query
  5088. * @param query defines the query to evaluate
  5089. * @param evaluateCallback defines the callback used to filter result
  5090. * @returns true if the query matches
  5091. */
  5092. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5093. private static _HandleParenthesisContent;
  5094. private static _SimplifyNegation;
  5095. }
  5096. }
  5097. declare module BABYLON {
  5098. /**
  5099. * Class used to store custom tags
  5100. */
  5101. export class Tags {
  5102. /**
  5103. * Adds support for tags on the given object
  5104. * @param obj defines the object to use
  5105. */
  5106. static EnableFor(obj: any): void;
  5107. /**
  5108. * Removes tags support
  5109. * @param obj defines the object to use
  5110. */
  5111. static DisableFor(obj: any): void;
  5112. /**
  5113. * Gets a boolean indicating if the given object has tags
  5114. * @param obj defines the object to use
  5115. * @returns a boolean
  5116. */
  5117. static HasTags(obj: any): boolean;
  5118. /**
  5119. * Gets the tags available on a given object
  5120. * @param obj defines the object to use
  5121. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5122. * @returns the tags
  5123. */
  5124. static GetTags(obj: any, asString?: boolean): any;
  5125. /**
  5126. * Adds tags to an object
  5127. * @param obj defines the object to use
  5128. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5129. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5130. */
  5131. static AddTagsTo(obj: any, tagsString: string): void;
  5132. /**
  5133. * @hidden
  5134. */ private static _AddTagTo(obj: any, tag: string): void;
  5135. /**
  5136. * Removes specific tags from a specific object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tags to remove
  5139. */
  5140. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5141. /**
  5142. * @hidden
  5143. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5144. /**
  5145. * Defines if tags hosted on an object match a given query
  5146. * @param obj defines the object to use
  5147. * @param tagsQuery defines the tag query
  5148. * @returns a boolean
  5149. */
  5150. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5151. }
  5152. }
  5153. declare module BABYLON {
  5154. /**
  5155. * Manages the defines for the Material
  5156. */
  5157. export class MaterialDefines {
  5158. /** @hidden */
  5159. protected _keys: string[];
  5160. private _isDirty;
  5161. /** @hidden */ private _renderId: number;
  5162. /** @hidden */ private _areLightsDirty: boolean;
  5163. /** @hidden */ private _areAttributesDirty: boolean;
  5164. /** @hidden */ private _areTexturesDirty: boolean;
  5165. /** @hidden */ private _areFresnelDirty: boolean;
  5166. /** @hidden */ private _areMiscDirty: boolean;
  5167. /** @hidden */ private _areImageProcessingDirty: boolean;
  5168. /** @hidden */ private _normals: boolean;
  5169. /** @hidden */ private _uvs: boolean;
  5170. /** @hidden */ private _needNormals: boolean;
  5171. /** @hidden */ private _needUVs: boolean;
  5172. [id: string]: any;
  5173. /**
  5174. * Specifies if the material needs to be re-calculated
  5175. */
  5176. readonly isDirty: boolean;
  5177. /**
  5178. * Marks the material to indicate that it has been re-calculated
  5179. */
  5180. markAsProcessed(): void;
  5181. /**
  5182. * Marks the material to indicate that it needs to be re-calculated
  5183. */
  5184. markAsUnprocessed(): void;
  5185. /**
  5186. * Marks the material to indicate all of its defines need to be re-calculated
  5187. */
  5188. markAllAsDirty(): void;
  5189. /**
  5190. * Marks the material to indicate that image processing needs to be re-calculated
  5191. */
  5192. markAsImageProcessingDirty(): void;
  5193. /**
  5194. * Marks the material to indicate the lights need to be re-calculated
  5195. */
  5196. markAsLightDirty(): void;
  5197. /**
  5198. * Marks the attribute state as changed
  5199. */
  5200. markAsAttributesDirty(): void;
  5201. /**
  5202. * Marks the texture state as changed
  5203. */
  5204. markAsTexturesDirty(): void;
  5205. /**
  5206. * Marks the fresnel state as changed
  5207. */
  5208. markAsFresnelDirty(): void;
  5209. /**
  5210. * Marks the misc state as changed
  5211. */
  5212. markAsMiscDirty(): void;
  5213. /**
  5214. * Rebuilds the material defines
  5215. */
  5216. rebuild(): void;
  5217. /**
  5218. * Specifies if two material defines are equal
  5219. * @param other - A material define instance to compare to
  5220. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5221. */
  5222. isEqual(other: MaterialDefines): boolean;
  5223. /**
  5224. * Clones this instance's defines to another instance
  5225. * @param other - material defines to clone values to
  5226. */
  5227. cloneTo(other: MaterialDefines): void;
  5228. /**
  5229. * Resets the material define values
  5230. */
  5231. reset(): void;
  5232. /**
  5233. * Converts the material define values to a string
  5234. * @returns - String of material define information
  5235. */
  5236. toString(): string;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. /**
  5241. * Class used to store and describe the pipeline context associated with an effect
  5242. */
  5243. export interface IPipelineContext {
  5244. /**
  5245. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5246. */
  5247. isAsync: boolean;
  5248. /**
  5249. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5250. */
  5251. isReady: boolean;
  5252. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store gfx data (like WebGLBuffer)
  5258. */
  5259. export class DataBuffer {
  5260. /**
  5261. * Gets or sets the number of objects referencing this buffer
  5262. */
  5263. references: number;
  5264. /** Gets or sets the size of the underlying buffer */
  5265. capacity: number;
  5266. /**
  5267. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5268. */
  5269. is32Bits: boolean;
  5270. /**
  5271. * Gets the underlying buffer
  5272. */
  5273. readonly underlyingResource: any;
  5274. }
  5275. }
  5276. declare module BABYLON {
  5277. /** @hidden */
  5278. export interface IShaderProcessor {
  5279. attributeProcessor?: (attribute: string) => string;
  5280. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5281. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5282. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5283. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5284. lineProcessor?: (line: string, isFragment: boolean) => string;
  5285. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5286. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /** @hidden */
  5291. export interface ProcessingOptions {
  5292. defines: string[];
  5293. indexParameters: any;
  5294. isFragment: boolean;
  5295. shouldUseHighPrecisionShader: boolean;
  5296. supportsUniformBuffers: boolean;
  5297. shadersRepository: string;
  5298. includesShadersStore: {
  5299. [key: string]: string;
  5300. };
  5301. processor?: IShaderProcessor;
  5302. version: string;
  5303. platformName: string;
  5304. lookForClosingBracketForUniformBuffer?: boolean;
  5305. }
  5306. }
  5307. declare module BABYLON {
  5308. /** @hidden */
  5309. export class ShaderCodeNode {
  5310. line: string;
  5311. children: ShaderCodeNode[];
  5312. additionalDefineKey?: string;
  5313. additionalDefineValue?: string;
  5314. isValid(preprocessors: {
  5315. [key: string]: string;
  5316. }): boolean;
  5317. process(preprocessors: {
  5318. [key: string]: string;
  5319. }, options: ProcessingOptions): string;
  5320. }
  5321. }
  5322. declare module BABYLON {
  5323. /** @hidden */
  5324. export class ShaderCodeCursor {
  5325. private _lines;
  5326. lineIndex: number;
  5327. readonly currentLine: string;
  5328. readonly canRead: boolean;
  5329. lines: string[];
  5330. }
  5331. }
  5332. declare module BABYLON {
  5333. /** @hidden */
  5334. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5335. process(preprocessors: {
  5336. [key: string]: string;
  5337. }, options: ProcessingOptions): string;
  5338. }
  5339. }
  5340. declare module BABYLON {
  5341. /** @hidden */
  5342. export class ShaderDefineExpression {
  5343. isTrue(preprocessors: {
  5344. [key: string]: string;
  5345. }): boolean;
  5346. }
  5347. }
  5348. declare module BABYLON {
  5349. /** @hidden */
  5350. export class ShaderCodeTestNode extends ShaderCodeNode {
  5351. testExpression: ShaderDefineExpression;
  5352. isValid(preprocessors: {
  5353. [key: string]: string;
  5354. }): boolean;
  5355. }
  5356. }
  5357. declare module BABYLON {
  5358. /** @hidden */
  5359. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5360. define: string;
  5361. not: boolean;
  5362. constructor(define: string, not?: boolean);
  5363. isTrue(preprocessors: {
  5364. [key: string]: string;
  5365. }): boolean;
  5366. }
  5367. }
  5368. declare module BABYLON {
  5369. /** @hidden */
  5370. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5371. leftOperand: ShaderDefineExpression;
  5372. rightOperand: ShaderDefineExpression;
  5373. isTrue(preprocessors: {
  5374. [key: string]: string;
  5375. }): boolean;
  5376. }
  5377. }
  5378. declare module BABYLON {
  5379. /** @hidden */
  5380. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5381. leftOperand: ShaderDefineExpression;
  5382. rightOperand: ShaderDefineExpression;
  5383. isTrue(preprocessors: {
  5384. [key: string]: string;
  5385. }): boolean;
  5386. }
  5387. }
  5388. declare module BABYLON {
  5389. /** @hidden */
  5390. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5391. define: string;
  5392. operand: string;
  5393. testValue: string;
  5394. constructor(define: string, operand: string, testValue: string);
  5395. isTrue(preprocessors: {
  5396. [key: string]: string;
  5397. }): boolean;
  5398. }
  5399. }
  5400. declare module BABYLON {
  5401. /** @hidden */
  5402. export class ShaderProcessor {
  5403. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5404. private static _ProcessPrecision;
  5405. private static _ExtractOperation;
  5406. private static _BuildSubExpression;
  5407. private static _BuildExpression;
  5408. private static _MoveCursorWithinIf;
  5409. private static _MoveCursor;
  5410. private static _EvaluatePreProcessors;
  5411. private static _PreparePreProcessors;
  5412. private static _ProcessShaderConversion;
  5413. private static _ProcessIncludes;
  5414. }
  5415. }
  5416. declare module BABYLON {
  5417. /**
  5418. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5419. */
  5420. export class PerformanceMonitor {
  5421. private _enabled;
  5422. private _rollingFrameTime;
  5423. private _lastFrameTimeMs;
  5424. /**
  5425. * constructor
  5426. * @param frameSampleSize The number of samples required to saturate the sliding window
  5427. */
  5428. constructor(frameSampleSize?: number);
  5429. /**
  5430. * Samples current frame
  5431. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5432. */
  5433. sampleFrame(timeMs?: number): void;
  5434. /**
  5435. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5436. */
  5437. readonly averageFrameTime: number;
  5438. /**
  5439. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5440. */
  5441. readonly averageFrameTimeVariance: number;
  5442. /**
  5443. * Returns the frame time of the most recent frame
  5444. */
  5445. readonly instantaneousFrameTime: number;
  5446. /**
  5447. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5448. */
  5449. readonly averageFPS: number;
  5450. /**
  5451. * Returns the average framerate in frames per second using the most recent frame time
  5452. */
  5453. readonly instantaneousFPS: number;
  5454. /**
  5455. * Returns true if enough samples have been taken to completely fill the sliding window
  5456. */
  5457. readonly isSaturated: boolean;
  5458. /**
  5459. * Enables contributions to the sliding window sample set
  5460. */
  5461. enable(): void;
  5462. /**
  5463. * Disables contributions to the sliding window sample set
  5464. * Samples will not be interpolated over the disabled period
  5465. */
  5466. disable(): void;
  5467. /**
  5468. * Returns true if sampling is enabled
  5469. */
  5470. readonly isEnabled: boolean;
  5471. /**
  5472. * Resets performance monitor
  5473. */
  5474. reset(): void;
  5475. }
  5476. /**
  5477. * RollingAverage
  5478. *
  5479. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5480. */
  5481. export class RollingAverage {
  5482. /**
  5483. * Current average
  5484. */
  5485. average: number;
  5486. /**
  5487. * Current variance
  5488. */
  5489. variance: number;
  5490. protected _samples: Array<number>;
  5491. protected _sampleCount: number;
  5492. protected _pos: number;
  5493. protected _m2: number;
  5494. /**
  5495. * constructor
  5496. * @param length The number of samples required to saturate the sliding window
  5497. */
  5498. constructor(length: number);
  5499. /**
  5500. * Adds a sample to the sample set
  5501. * @param v The sample value
  5502. */
  5503. add(v: number): void;
  5504. /**
  5505. * Returns previously added values or null if outside of history or outside the sliding window domain
  5506. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5507. * @return Value previously recorded with add() or null if outside of range
  5508. */
  5509. history(i: number): number;
  5510. /**
  5511. * Returns true if enough samples have been taken to completely fill the sliding window
  5512. * @return true if sample-set saturated
  5513. */
  5514. isSaturated(): boolean;
  5515. /**
  5516. * Resets the rolling average (equivalent to 0 samples taken so far)
  5517. */
  5518. reset(): void;
  5519. /**
  5520. * Wraps a value around the sample range boundaries
  5521. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5522. * @return Wrapped position in sample range
  5523. */
  5524. protected _wrapPosition(i: number): number;
  5525. }
  5526. }
  5527. declare module BABYLON {
  5528. /**
  5529. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5530. * The underlying implementation relies on an associative array to ensure the best performances.
  5531. * The value can be anything including 'null' but except 'undefined'
  5532. */
  5533. export class StringDictionary<T> {
  5534. /**
  5535. * This will clear this dictionary and copy the content from the 'source' one.
  5536. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5537. * @param source the dictionary to take the content from and copy to this dictionary
  5538. */
  5539. copyFrom(source: StringDictionary<T>): void;
  5540. /**
  5541. * Get a value based from its key
  5542. * @param key the given key to get the matching value from
  5543. * @return the value if found, otherwise undefined is returned
  5544. */
  5545. get(key: string): T | undefined;
  5546. /**
  5547. * Get a value from its key or add it if it doesn't exist.
  5548. * This method will ensure you that a given key/data will be present in the dictionary.
  5549. * @param key the given key to get the matching value from
  5550. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5551. * The factory will only be invoked if there's no data for the given key.
  5552. * @return the value corresponding to the key.
  5553. */
  5554. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5555. /**
  5556. * Get a value from its key if present in the dictionary otherwise add it
  5557. * @param key the key to get the value from
  5558. * @param val if there's no such key/value pair in the dictionary add it with this value
  5559. * @return the value corresponding to the key
  5560. */
  5561. getOrAdd(key: string, val: T): T;
  5562. /**
  5563. * Check if there's a given key in the dictionary
  5564. * @param key the key to check for
  5565. * @return true if the key is present, false otherwise
  5566. */
  5567. contains(key: string): boolean;
  5568. /**
  5569. * Add a new key and its corresponding value
  5570. * @param key the key to add
  5571. * @param value the value corresponding to the key
  5572. * @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
  5573. */
  5574. add(key: string, value: T): boolean;
  5575. /**
  5576. * Update a specific value associated to a key
  5577. * @param key defines the key to use
  5578. * @param value defines the value to store
  5579. * @returns true if the value was updated (or false if the key was not found)
  5580. */
  5581. set(key: string, value: T): boolean;
  5582. /**
  5583. * Get the element of the given key and remove it from the dictionary
  5584. * @param key defines the key to search
  5585. * @returns the value associated with the key or null if not found
  5586. */
  5587. getAndRemove(key: string): Nullable<T>;
  5588. /**
  5589. * Remove a key/value from the dictionary.
  5590. * @param key the key to remove
  5591. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5592. */
  5593. remove(key: string): boolean;
  5594. /**
  5595. * Clear the whole content of the dictionary
  5596. */
  5597. clear(): void;
  5598. /**
  5599. * Gets the current count
  5600. */
  5601. readonly count: number;
  5602. /**
  5603. * Execute a callback on each key/val of the dictionary.
  5604. * Note that you can remove any element in this dictionary in the callback implementation
  5605. * @param callback the callback to execute on a given key/value pair
  5606. */
  5607. forEach(callback: (key: string, val: T) => void): void;
  5608. /**
  5609. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5610. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5611. * Note that you can remove any element in this dictionary in the callback implementation
  5612. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5613. * @returns the first item
  5614. */
  5615. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5616. private _count;
  5617. private _data;
  5618. }
  5619. }
  5620. declare module BABYLON {
  5621. /**
  5622. * Helper class that provides a small promise polyfill
  5623. */
  5624. export class PromisePolyfill {
  5625. /**
  5626. * Static function used to check if the polyfill is required
  5627. * If this is the case then the function will inject the polyfill to window.Promise
  5628. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5629. */
  5630. static Apply(force?: boolean): void;
  5631. }
  5632. }
  5633. declare module BABYLON {
  5634. /**
  5635. * Class used to store data that will be store in GPU memory
  5636. */
  5637. export class Buffer {
  5638. private _engine;
  5639. private _buffer;
  5640. /** @hidden */ private _data: Nullable<DataArray>;
  5641. private _updatable;
  5642. private _instanced;
  5643. /**
  5644. * Gets the byte stride.
  5645. */
  5646. readonly byteStride: number;
  5647. /**
  5648. * Constructor
  5649. * @param engine the engine
  5650. * @param data the data to use for this buffer
  5651. * @param updatable whether the data is updatable
  5652. * @param stride the stride (optional)
  5653. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5654. * @param instanced whether the buffer is instanced (optional)
  5655. * @param useBytes set to true if the stride in in bytes (optional)
  5656. */
  5657. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5658. /**
  5659. * Create a new VertexBuffer based on the current buffer
  5660. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5661. * @param offset defines offset in the buffer (0 by default)
  5662. * @param size defines the size in floats of attributes (position is 3 for instance)
  5663. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5664. * @param instanced defines if the vertex buffer contains indexed data
  5665. * @param useBytes defines if the offset and stride are in bytes
  5666. * @returns the new vertex buffer
  5667. */
  5668. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5669. /**
  5670. * Gets a boolean indicating if the Buffer is updatable?
  5671. * @returns true if the buffer is updatable
  5672. */
  5673. isUpdatable(): boolean;
  5674. /**
  5675. * Gets current buffer's data
  5676. * @returns a DataArray or null
  5677. */
  5678. getData(): Nullable<DataArray>;
  5679. /**
  5680. * Gets underlying native buffer
  5681. * @returns underlying native buffer
  5682. */
  5683. getBuffer(): Nullable<DataBuffer>;
  5684. /**
  5685. * Gets the stride in float32 units (i.e. byte stride / 4).
  5686. * May not be an integer if the byte stride is not divisible by 4.
  5687. * DEPRECATED. Use byteStride instead.
  5688. * @returns the stride in float32 units
  5689. */
  5690. getStrideSize(): number;
  5691. /**
  5692. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5693. * @param data defines the data to store
  5694. */
  5695. create(data?: Nullable<DataArray>): void;
  5696. /** @hidden */ private _rebuild(): void;
  5697. /**
  5698. * Update current buffer data
  5699. * @param data defines the data to store
  5700. */
  5701. update(data: DataArray): void;
  5702. /**
  5703. * Updates the data directly.
  5704. * @param data the new data
  5705. * @param offset the new offset
  5706. * @param vertexCount the vertex count (optional)
  5707. * @param useBytes set to true if the offset is in bytes
  5708. */
  5709. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5710. /**
  5711. * Release all resources
  5712. */
  5713. dispose(): void;
  5714. }
  5715. /**
  5716. * Specialized buffer used to store vertex data
  5717. */
  5718. export class VertexBuffer {
  5719. /** @hidden */ private _buffer: Buffer;
  5720. private _kind;
  5721. private _size;
  5722. private _ownsBuffer;
  5723. private _instanced;
  5724. private _instanceDivisor;
  5725. /**
  5726. * The byte type.
  5727. */
  5728. static readonly BYTE: number;
  5729. /**
  5730. * The unsigned byte type.
  5731. */
  5732. static readonly UNSIGNED_BYTE: number;
  5733. /**
  5734. * The short type.
  5735. */
  5736. static readonly SHORT: number;
  5737. /**
  5738. * The unsigned short type.
  5739. */
  5740. static readonly UNSIGNED_SHORT: number;
  5741. /**
  5742. * The integer type.
  5743. */
  5744. static readonly INT: number;
  5745. /**
  5746. * The unsigned integer type.
  5747. */
  5748. static readonly UNSIGNED_INT: number;
  5749. /**
  5750. * The float type.
  5751. */
  5752. static readonly FLOAT: number;
  5753. /**
  5754. * Gets or sets the instance divisor when in instanced mode
  5755. */
  5756. instanceDivisor: number;
  5757. /**
  5758. * Gets the byte stride.
  5759. */
  5760. readonly byteStride: number;
  5761. /**
  5762. * Gets the byte offset.
  5763. */
  5764. readonly byteOffset: number;
  5765. /**
  5766. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5767. */
  5768. readonly normalized: boolean;
  5769. /**
  5770. * Gets the data type of each component in the array.
  5771. */
  5772. readonly type: number;
  5773. /**
  5774. * Constructor
  5775. * @param engine the engine
  5776. * @param data the data to use for this vertex buffer
  5777. * @param kind the vertex buffer kind
  5778. * @param updatable whether the data is updatable
  5779. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5780. * @param stride the stride (optional)
  5781. * @param instanced whether the buffer is instanced (optional)
  5782. * @param offset the offset of the data (optional)
  5783. * @param size the number of components (optional)
  5784. * @param type the type of the component (optional)
  5785. * @param normalized whether the data contains normalized data (optional)
  5786. * @param useBytes set to true if stride and offset are in bytes (optional)
  5787. */
  5788. 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);
  5789. /** @hidden */ private _rebuild(): void;
  5790. /**
  5791. * Returns the kind of the VertexBuffer (string)
  5792. * @returns a string
  5793. */
  5794. getKind(): string;
  5795. /**
  5796. * Gets a boolean indicating if the VertexBuffer is updatable?
  5797. * @returns true if the buffer is updatable
  5798. */
  5799. isUpdatable(): boolean;
  5800. /**
  5801. * Gets current buffer's data
  5802. * @returns a DataArray or null
  5803. */
  5804. getData(): Nullable<DataArray>;
  5805. /**
  5806. * Gets underlying native buffer
  5807. * @returns underlying native buffer
  5808. */
  5809. getBuffer(): Nullable<DataBuffer>;
  5810. /**
  5811. * Gets the stride in float32 units (i.e. byte stride / 4).
  5812. * May not be an integer if the byte stride is not divisible by 4.
  5813. * DEPRECATED. Use byteStride instead.
  5814. * @returns the stride in float32 units
  5815. */
  5816. getStrideSize(): number;
  5817. /**
  5818. * Returns the offset as a multiple of the type byte length.
  5819. * DEPRECATED. Use byteOffset instead.
  5820. * @returns the offset in bytes
  5821. */
  5822. getOffset(): number;
  5823. /**
  5824. * Returns the number of components per vertex attribute (integer)
  5825. * @returns the size in float
  5826. */
  5827. getSize(): number;
  5828. /**
  5829. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5830. * @returns true if this buffer is instanced
  5831. */
  5832. getIsInstanced(): boolean;
  5833. /**
  5834. * Returns the instancing divisor, zero for non-instanced (integer).
  5835. * @returns a number
  5836. */
  5837. getInstanceDivisor(): number;
  5838. /**
  5839. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5840. * @param data defines the data to store
  5841. */
  5842. create(data?: DataArray): void;
  5843. /**
  5844. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5845. * This function will create a new buffer if the current one is not updatable
  5846. * @param data defines the data to store
  5847. */
  5848. update(data: DataArray): void;
  5849. /**
  5850. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5851. * Returns the directly updated WebGLBuffer.
  5852. * @param data the new data
  5853. * @param offset the new offset
  5854. * @param useBytes set to true if the offset is in bytes
  5855. */
  5856. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5857. /**
  5858. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5859. */
  5860. dispose(): void;
  5861. /**
  5862. * Enumerates each value of this vertex buffer as numbers.
  5863. * @param count the number of values to enumerate
  5864. * @param callback the callback function called for each value
  5865. */
  5866. forEach(count: number, callback: (value: number, index: number) => void): void;
  5867. /**
  5868. * Positions
  5869. */
  5870. static readonly PositionKind: string;
  5871. /**
  5872. * Normals
  5873. */
  5874. static readonly NormalKind: string;
  5875. /**
  5876. * Tangents
  5877. */
  5878. static readonly TangentKind: string;
  5879. /**
  5880. * Texture coordinates
  5881. */
  5882. static readonly UVKind: string;
  5883. /**
  5884. * Texture coordinates 2
  5885. */
  5886. static readonly UV2Kind: string;
  5887. /**
  5888. * Texture coordinates 3
  5889. */
  5890. static readonly UV3Kind: string;
  5891. /**
  5892. * Texture coordinates 4
  5893. */
  5894. static readonly UV4Kind: string;
  5895. /**
  5896. * Texture coordinates 5
  5897. */
  5898. static readonly UV5Kind: string;
  5899. /**
  5900. * Texture coordinates 6
  5901. */
  5902. static readonly UV6Kind: string;
  5903. /**
  5904. * Colors
  5905. */
  5906. static readonly ColorKind: string;
  5907. /**
  5908. * Matrix indices (for bones)
  5909. */
  5910. static readonly MatricesIndicesKind: string;
  5911. /**
  5912. * Matrix weights (for bones)
  5913. */
  5914. static readonly MatricesWeightsKind: string;
  5915. /**
  5916. * Additional matrix indices (for bones)
  5917. */
  5918. static readonly MatricesIndicesExtraKind: string;
  5919. /**
  5920. * Additional matrix weights (for bones)
  5921. */
  5922. static readonly MatricesWeightsExtraKind: string;
  5923. /**
  5924. * Deduces the stride given a kind.
  5925. * @param kind The kind string to deduce
  5926. * @returns The deduced stride
  5927. */
  5928. static DeduceStride(kind: string): number;
  5929. /**
  5930. * Gets the byte length of the given type.
  5931. * @param type the type
  5932. * @returns the number of bytes
  5933. */
  5934. static GetTypeByteLength(type: number): number;
  5935. /**
  5936. * Enumerates each value of the given parameters as numbers.
  5937. * @param data the data to enumerate
  5938. * @param byteOffset the byte offset of the data
  5939. * @param byteStride the byte stride of the data
  5940. * @param componentCount the number of components per element
  5941. * @param componentType the type of the component
  5942. * @param count the number of values to enumerate
  5943. * @param normalized whether the data is normalized
  5944. * @param callback the callback function called for each value
  5945. */
  5946. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5947. private static _GetFloatValue;
  5948. }
  5949. }
  5950. declare module BABYLON {
  5951. /**
  5952. * Class representing spherical harmonics coefficients to the 3rd degree
  5953. */
  5954. export class SphericalHarmonics {
  5955. /**
  5956. * Defines whether or not the harmonics have been prescaled for rendering.
  5957. */
  5958. preScaled: boolean;
  5959. /**
  5960. * The l0,0 coefficients of the spherical harmonics
  5961. */
  5962. l00: Vector3;
  5963. /**
  5964. * The l1,-1 coefficients of the spherical harmonics
  5965. */
  5966. l1_1: Vector3;
  5967. /**
  5968. * The l1,0 coefficients of the spherical harmonics
  5969. */
  5970. l10: Vector3;
  5971. /**
  5972. * The l1,1 coefficients of the spherical harmonics
  5973. */
  5974. l11: Vector3;
  5975. /**
  5976. * The l2,-2 coefficients of the spherical harmonics
  5977. */
  5978. l2_2: Vector3;
  5979. /**
  5980. * The l2,-1 coefficients of the spherical harmonics
  5981. */
  5982. l2_1: Vector3;
  5983. /**
  5984. * The l2,0 coefficients of the spherical harmonics
  5985. */
  5986. l20: Vector3;
  5987. /**
  5988. * The l2,1 coefficients of the spherical harmonics
  5989. */
  5990. l21: Vector3;
  5991. /**
  5992. * The l2,2 coefficients of the spherical harmonics
  5993. */
  5994. l22: Vector3;
  5995. /**
  5996. * Adds a light to the spherical harmonics
  5997. * @param direction the direction of the light
  5998. * @param color the color of the light
  5999. * @param deltaSolidAngle the delta solid angle of the light
  6000. */
  6001. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6002. /**
  6003. * Scales the spherical harmonics by the given amount
  6004. * @param scale the amount to scale
  6005. */
  6006. scaleInPlace(scale: number): void;
  6007. /**
  6008. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6009. *
  6010. * ```
  6011. * E_lm = A_l * L_lm
  6012. * ```
  6013. *
  6014. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6015. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6016. * the scaling factors are given in equation 9.
  6017. */
  6018. convertIncidentRadianceToIrradiance(): void;
  6019. /**
  6020. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6021. *
  6022. * ```
  6023. * L = (1/pi) * E * rho
  6024. * ```
  6025. *
  6026. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6027. */
  6028. convertIrradianceToLambertianRadiance(): void;
  6029. /**
  6030. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6031. * required operations at run time.
  6032. *
  6033. * This is simply done by scaling back the SH with Ylm constants parameter.
  6034. * The trigonometric part being applied by the shader at run time.
  6035. */
  6036. preScaleForRendering(): void;
  6037. /**
  6038. * Constructs a spherical harmonics from an array.
  6039. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6040. * @returns the spherical harmonics
  6041. */
  6042. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6043. /**
  6044. * Gets the spherical harmonics from polynomial
  6045. * @param polynomial the spherical polynomial
  6046. * @returns the spherical harmonics
  6047. */
  6048. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6049. }
  6050. /**
  6051. * Class representing spherical polynomial coefficients to the 3rd degree
  6052. */
  6053. export class SphericalPolynomial {
  6054. private _harmonics;
  6055. /**
  6056. * The spherical harmonics used to create the polynomials.
  6057. */
  6058. readonly preScaledHarmonics: SphericalHarmonics;
  6059. /**
  6060. * The x coefficients of the spherical polynomial
  6061. */
  6062. x: Vector3;
  6063. /**
  6064. * The y coefficients of the spherical polynomial
  6065. */
  6066. y: Vector3;
  6067. /**
  6068. * The z coefficients of the spherical polynomial
  6069. */
  6070. z: Vector3;
  6071. /**
  6072. * The xx coefficients of the spherical polynomial
  6073. */
  6074. xx: Vector3;
  6075. /**
  6076. * The yy coefficients of the spherical polynomial
  6077. */
  6078. yy: Vector3;
  6079. /**
  6080. * The zz coefficients of the spherical polynomial
  6081. */
  6082. zz: Vector3;
  6083. /**
  6084. * The xy coefficients of the spherical polynomial
  6085. */
  6086. xy: Vector3;
  6087. /**
  6088. * The yz coefficients of the spherical polynomial
  6089. */
  6090. yz: Vector3;
  6091. /**
  6092. * The zx coefficients of the spherical polynomial
  6093. */
  6094. zx: Vector3;
  6095. /**
  6096. * Adds an ambient color to the spherical polynomial
  6097. * @param color the color to add
  6098. */
  6099. addAmbient(color: Color3): void;
  6100. /**
  6101. * Scales the spherical polynomial by the given amount
  6102. * @param scale the amount to scale
  6103. */
  6104. scaleInPlace(scale: number): void;
  6105. /**
  6106. * Gets the spherical polynomial from harmonics
  6107. * @param harmonics the spherical harmonics
  6108. * @returns the spherical polynomial
  6109. */
  6110. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6111. /**
  6112. * Constructs a spherical polynomial from an array.
  6113. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6114. * @returns the spherical polynomial
  6115. */
  6116. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6117. }
  6118. }
  6119. declare module BABYLON {
  6120. /**
  6121. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6122. */
  6123. export interface CubeMapInfo {
  6124. /**
  6125. * The pixel array for the front face.
  6126. * This is stored in format, left to right, up to down format.
  6127. */
  6128. front: Nullable<ArrayBufferView>;
  6129. /**
  6130. * The pixel array for the back face.
  6131. * This is stored in format, left to right, up to down format.
  6132. */
  6133. back: Nullable<ArrayBufferView>;
  6134. /**
  6135. * The pixel array for the left face.
  6136. * This is stored in format, left to right, up to down format.
  6137. */
  6138. left: Nullable<ArrayBufferView>;
  6139. /**
  6140. * The pixel array for the right face.
  6141. * This is stored in format, left to right, up to down format.
  6142. */
  6143. right: Nullable<ArrayBufferView>;
  6144. /**
  6145. * The pixel array for the up face.
  6146. * This is stored in format, left to right, up to down format.
  6147. */
  6148. up: Nullable<ArrayBufferView>;
  6149. /**
  6150. * The pixel array for the down face.
  6151. * This is stored in format, left to right, up to down format.
  6152. */
  6153. down: Nullable<ArrayBufferView>;
  6154. /**
  6155. * The size of the cubemap stored.
  6156. *
  6157. * Each faces will be size * size pixels.
  6158. */
  6159. size: number;
  6160. /**
  6161. * The format of the texture.
  6162. *
  6163. * RGBA, RGB.
  6164. */
  6165. format: number;
  6166. /**
  6167. * The type of the texture data.
  6168. *
  6169. * UNSIGNED_INT, FLOAT.
  6170. */
  6171. type: number;
  6172. /**
  6173. * Specifies whether the texture is in gamma space.
  6174. */
  6175. gammaSpace: boolean;
  6176. }
  6177. /**
  6178. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6179. */
  6180. export class PanoramaToCubeMapTools {
  6181. private static FACE_FRONT;
  6182. private static FACE_BACK;
  6183. private static FACE_RIGHT;
  6184. private static FACE_LEFT;
  6185. private static FACE_DOWN;
  6186. private static FACE_UP;
  6187. /**
  6188. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6189. *
  6190. * @param float32Array The source data.
  6191. * @param inputWidth The width of the input panorama.
  6192. * @param inputHeight The height of the input panorama.
  6193. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6194. * @return The cubemap data
  6195. */
  6196. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6197. private static CreateCubemapTexture;
  6198. private static CalcProjectionSpherical;
  6199. }
  6200. }
  6201. declare module BABYLON {
  6202. /**
  6203. * Helper class dealing with the extraction of spherical polynomial dataArray
  6204. * from a cube map.
  6205. */
  6206. export class CubeMapToSphericalPolynomialTools {
  6207. private static FileFaces;
  6208. /**
  6209. * Converts a texture to the according Spherical Polynomial data.
  6210. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6211. *
  6212. * @param texture The texture to extract the information from.
  6213. * @return The Spherical Polynomial data.
  6214. */
  6215. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6216. /**
  6217. * Converts a cubemap to the according Spherical Polynomial data.
  6218. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6219. *
  6220. * @param cubeInfo The Cube map to extract the information from.
  6221. * @return The Spherical Polynomial data.
  6222. */
  6223. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6224. }
  6225. }
  6226. declare module BABYLON {
  6227. /**
  6228. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6229. * during the life time of the application.
  6230. */
  6231. export class EngineStore {
  6232. /** Gets the list of created engines */
  6233. static Instances: Engine[];
  6234. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  6235. /**
  6236. * Gets the latest created engine
  6237. */
  6238. static readonly LastCreatedEngine: Nullable<Engine>;
  6239. /**
  6240. * Gets the latest created scene
  6241. */
  6242. static readonly LastCreatedScene: Nullable<Scene>;
  6243. }
  6244. }
  6245. declare module BABYLON {
  6246. /**
  6247. * Define options used to create a render target texture
  6248. */
  6249. export class RenderTargetCreationOptions {
  6250. /**
  6251. * Specifies is mipmaps must be generated
  6252. */
  6253. generateMipMaps?: boolean;
  6254. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6255. generateDepthBuffer?: boolean;
  6256. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6257. generateStencilBuffer?: boolean;
  6258. /** Defines texture type (int by default) */
  6259. type?: number;
  6260. /** Defines sampling mode (trilinear by default) */
  6261. samplingMode?: number;
  6262. /** Defines format (RGBA by default) */
  6263. format?: number;
  6264. }
  6265. }
  6266. declare module BABYLON {
  6267. /**
  6268. * @hidden
  6269. **/
  6270. export class _AlphaState {
  6271. private _isAlphaBlendDirty;
  6272. private _isBlendFunctionParametersDirty;
  6273. private _isBlendEquationParametersDirty;
  6274. private _isBlendConstantsDirty;
  6275. private _alphaBlend;
  6276. private _blendFunctionParameters;
  6277. private _blendEquationParameters;
  6278. private _blendConstants;
  6279. /**
  6280. * Initializes the state.
  6281. */
  6282. constructor();
  6283. readonly isDirty: boolean;
  6284. alphaBlend: boolean;
  6285. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6286. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6287. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6288. reset(): void;
  6289. apply(gl: WebGLRenderingContext): void;
  6290. }
  6291. }
  6292. declare module BABYLON {
  6293. /**
  6294. * @hidden
  6295. **/
  6296. export class _DepthCullingState {
  6297. private _isDepthTestDirty;
  6298. private _isDepthMaskDirty;
  6299. private _isDepthFuncDirty;
  6300. private _isCullFaceDirty;
  6301. private _isCullDirty;
  6302. private _isZOffsetDirty;
  6303. private _isFrontFaceDirty;
  6304. private _depthTest;
  6305. private _depthMask;
  6306. private _depthFunc;
  6307. private _cull;
  6308. private _cullFace;
  6309. private _zOffset;
  6310. private _frontFace;
  6311. /**
  6312. * Initializes the state.
  6313. */
  6314. constructor();
  6315. readonly isDirty: boolean;
  6316. zOffset: number;
  6317. cullFace: Nullable<number>;
  6318. cull: Nullable<boolean>;
  6319. depthFunc: Nullable<number>;
  6320. depthMask: boolean;
  6321. depthTest: boolean;
  6322. frontFace: Nullable<number>;
  6323. reset(): void;
  6324. apply(gl: WebGLRenderingContext): void;
  6325. }
  6326. }
  6327. declare module BABYLON {
  6328. /**
  6329. * @hidden
  6330. **/
  6331. export class _StencilState {
  6332. /** 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 */
  6333. static readonly ALWAYS: number;
  6334. /** Passed to stencilOperation to specify that stencil value must be kept */
  6335. static readonly KEEP: number;
  6336. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6337. static readonly REPLACE: number;
  6338. private _isStencilTestDirty;
  6339. private _isStencilMaskDirty;
  6340. private _isStencilFuncDirty;
  6341. private _isStencilOpDirty;
  6342. private _stencilTest;
  6343. private _stencilMask;
  6344. private _stencilFunc;
  6345. private _stencilFuncRef;
  6346. private _stencilFuncMask;
  6347. private _stencilOpStencilFail;
  6348. private _stencilOpDepthFail;
  6349. private _stencilOpStencilDepthPass;
  6350. readonly isDirty: boolean;
  6351. stencilFunc: number;
  6352. stencilFuncRef: number;
  6353. stencilFuncMask: number;
  6354. stencilOpStencilFail: number;
  6355. stencilOpDepthFail: number;
  6356. stencilOpStencilDepthPass: number;
  6357. stencilMask: number;
  6358. stencilTest: boolean;
  6359. constructor();
  6360. reset(): void;
  6361. apply(gl: WebGLRenderingContext): void;
  6362. }
  6363. }
  6364. declare module BABYLON {
  6365. /**
  6366. * @hidden
  6367. **/
  6368. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  6369. }
  6370. }
  6371. declare module BABYLON {
  6372. /**
  6373. * Class used to store data associated with WebGL texture data for the engine
  6374. * This class should not be used directly
  6375. */
  6376. export class InternalTexture {
  6377. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6378. /**
  6379. * The source of the texture data is unknown
  6380. */
  6381. static DATASOURCE_UNKNOWN: number;
  6382. /**
  6383. * Texture data comes from an URL
  6384. */
  6385. static DATASOURCE_URL: number;
  6386. /**
  6387. * Texture data is only used for temporary storage
  6388. */
  6389. static DATASOURCE_TEMP: number;
  6390. /**
  6391. * Texture data comes from raw data (ArrayBuffer)
  6392. */
  6393. static DATASOURCE_RAW: number;
  6394. /**
  6395. * Texture content is dynamic (video or dynamic texture)
  6396. */
  6397. static DATASOURCE_DYNAMIC: number;
  6398. /**
  6399. * Texture content is generated by rendering to it
  6400. */
  6401. static DATASOURCE_RENDERTARGET: number;
  6402. /**
  6403. * Texture content is part of a multi render target process
  6404. */
  6405. static DATASOURCE_MULTIRENDERTARGET: number;
  6406. /**
  6407. * Texture data comes from a cube data file
  6408. */
  6409. static DATASOURCE_CUBE: number;
  6410. /**
  6411. * Texture data comes from a raw cube data
  6412. */
  6413. static DATASOURCE_CUBERAW: number;
  6414. /**
  6415. * Texture data come from a prefiltered cube data file
  6416. */
  6417. static DATASOURCE_CUBEPREFILTERED: number;
  6418. /**
  6419. * Texture content is raw 3D data
  6420. */
  6421. static DATASOURCE_RAW3D: number;
  6422. /**
  6423. * Texture content is a depth texture
  6424. */
  6425. static DATASOURCE_DEPTHTEXTURE: number;
  6426. /**
  6427. * Texture data comes from a raw cube data encoded with RGBD
  6428. */
  6429. static DATASOURCE_CUBERAW_RGBD: number;
  6430. /**
  6431. * Defines if the texture is ready
  6432. */
  6433. isReady: boolean;
  6434. /**
  6435. * Defines if the texture is a cube texture
  6436. */
  6437. isCube: boolean;
  6438. /**
  6439. * Defines if the texture contains 3D data
  6440. */
  6441. is3D: boolean;
  6442. /**
  6443. * Defines if the texture contains multiview data
  6444. */
  6445. isMultiview: boolean;
  6446. /**
  6447. * Gets the URL used to load this texture
  6448. */
  6449. url: string;
  6450. /**
  6451. * Gets the sampling mode of the texture
  6452. */
  6453. samplingMode: number;
  6454. /**
  6455. * Gets a boolean indicating if the texture needs mipmaps generation
  6456. */
  6457. generateMipMaps: boolean;
  6458. /**
  6459. * Gets the number of samples used by the texture (WebGL2+ only)
  6460. */
  6461. samples: number;
  6462. /**
  6463. * Gets the type of the texture (int, float...)
  6464. */
  6465. type: number;
  6466. /**
  6467. * Gets the format of the texture (RGB, RGBA...)
  6468. */
  6469. format: number;
  6470. /**
  6471. * Observable called when the texture is loaded
  6472. */
  6473. onLoadedObservable: Observable<InternalTexture>;
  6474. /**
  6475. * Gets the width of the texture
  6476. */
  6477. width: number;
  6478. /**
  6479. * Gets the height of the texture
  6480. */
  6481. height: number;
  6482. /**
  6483. * Gets the depth of the texture
  6484. */
  6485. depth: number;
  6486. /**
  6487. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6488. */
  6489. baseWidth: number;
  6490. /**
  6491. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6492. */
  6493. baseHeight: number;
  6494. /**
  6495. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6496. */
  6497. baseDepth: number;
  6498. /**
  6499. * Gets a boolean indicating if the texture is inverted on Y axis
  6500. */
  6501. invertY: boolean;
  6502. /** @hidden */ private _invertVScale: boolean;
  6503. /** @hidden */ private _associatedChannel: number;
  6504. /** @hidden */ private _dataSource: number;
  6505. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6506. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  6507. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  6508. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6509. /** @hidden */ private _size: number;
  6510. /** @hidden */ private _extension: string;
  6511. /** @hidden */ private _files: Nullable<string[]>;
  6512. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  6513. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  6514. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  6515. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6516. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6517. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6518. /** @hidden */ private _attachments: Nullable<number[]>;
  6519. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  6520. /** @hidden */ private _cachedWrapU: Nullable<number>;
  6521. /** @hidden */ private _cachedWrapV: Nullable<number>;
  6522. /** @hidden */ private _cachedWrapR: Nullable<number>;
  6523. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  6524. /** @hidden */ private _isDisabled: boolean;
  6525. /** @hidden */ private _compression: Nullable<string>;
  6526. /** @hidden */ private _generateStencilBuffer: boolean;
  6527. /** @hidden */ private _generateDepthBuffer: boolean;
  6528. /** @hidden */ private _comparisonFunction: number;
  6529. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6530. /** @hidden */ private _lodGenerationScale: number;
  6531. /** @hidden */ private _lodGenerationOffset: number;
  6532. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  6533. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  6534. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  6535. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  6536. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  6537. /** @hidden */ private _isRGBD: boolean;
  6538. /** @hidden */ private _linearSpecularLOD: boolean;
  6539. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  6540. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  6541. /** @hidden */ private _references: number;
  6542. private _engine;
  6543. /**
  6544. * Gets the Engine the texture belongs to.
  6545. * @returns The babylon engine
  6546. */
  6547. getEngine(): Engine;
  6548. /**
  6549. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6550. */
  6551. readonly dataSource: number;
  6552. /**
  6553. * Creates a new InternalTexture
  6554. * @param engine defines the engine to use
  6555. * @param dataSource defines the type of data that will be used
  6556. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6557. */
  6558. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6559. /**
  6560. * Increments the number of references (ie. the number of Texture that point to it)
  6561. */
  6562. incrementReferences(): void;
  6563. /**
  6564. * Change the size of the texture (not the size of the content)
  6565. * @param width defines the new width
  6566. * @param height defines the new height
  6567. * @param depth defines the new depth (1 by default)
  6568. */
  6569. updateSize(width: int, height: int, depth?: int): void;
  6570. /** @hidden */ private _rebuild(): void;
  6571. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  6572. /**
  6573. * Dispose the current allocated resources
  6574. */
  6575. dispose(): void;
  6576. }
  6577. }
  6578. declare module BABYLON {
  6579. /**
  6580. * This represents the main contract an easing function should follow.
  6581. * Easing functions are used throughout the animation system.
  6582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6583. */
  6584. export interface IEasingFunction {
  6585. /**
  6586. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6587. * of the easing function.
  6588. * The link below provides some of the most common examples of easing functions.
  6589. * @see https://easings.net/
  6590. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6591. * @returns the corresponding value on the curve defined by the easing function
  6592. */
  6593. ease(gradient: number): number;
  6594. }
  6595. /**
  6596. * Base class used for every default easing function.
  6597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6598. */
  6599. export class EasingFunction implements IEasingFunction {
  6600. /**
  6601. * Interpolation follows the mathematical formula associated with the easing function.
  6602. */
  6603. static readonly EASINGMODE_EASEIN: number;
  6604. /**
  6605. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6606. */
  6607. static readonly EASINGMODE_EASEOUT: number;
  6608. /**
  6609. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6610. */
  6611. static readonly EASINGMODE_EASEINOUT: number;
  6612. private _easingMode;
  6613. /**
  6614. * Sets the easing mode of the current function.
  6615. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6616. */
  6617. setEasingMode(easingMode: number): void;
  6618. /**
  6619. * Gets the current easing mode.
  6620. * @returns the easing mode
  6621. */
  6622. getEasingMode(): number;
  6623. /**
  6624. * @hidden
  6625. */
  6626. easeInCore(gradient: number): number;
  6627. /**
  6628. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6629. * of the easing function.
  6630. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6631. * @returns the corresponding value on the curve defined by the easing function
  6632. */
  6633. ease(gradient: number): number;
  6634. }
  6635. /**
  6636. * Easing function with a circle shape (see link below).
  6637. * @see https://easings.net/#easeInCirc
  6638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6639. */
  6640. export class CircleEase extends EasingFunction implements IEasingFunction {
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a ease back shape (see link below).
  6646. * @see https://easings.net/#easeInBack
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class BackEase extends EasingFunction implements IEasingFunction {
  6650. /** Defines the amplitude of the function */
  6651. amplitude: number;
  6652. /**
  6653. * Instantiates a back ease easing
  6654. * @see https://easings.net/#easeInBack
  6655. * @param amplitude Defines the amplitude of the function
  6656. */
  6657. constructor(
  6658. /** Defines the amplitude of the function */
  6659. amplitude?: number);
  6660. /** @hidden */
  6661. easeInCore(gradient: number): number;
  6662. }
  6663. /**
  6664. * Easing function with a bouncing shape (see link below).
  6665. * @see https://easings.net/#easeInBounce
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class BounceEase extends EasingFunction implements IEasingFunction {
  6669. /** Defines the number of bounces */
  6670. bounces: number;
  6671. /** Defines the amplitude of the bounce */
  6672. bounciness: number;
  6673. /**
  6674. * Instantiates a bounce easing
  6675. * @see https://easings.net/#easeInBounce
  6676. * @param bounces Defines the number of bounces
  6677. * @param bounciness Defines the amplitude of the bounce
  6678. */
  6679. constructor(
  6680. /** Defines the number of bounces */
  6681. bounces?: number,
  6682. /** Defines the amplitude of the bounce */
  6683. bounciness?: number);
  6684. /** @hidden */
  6685. easeInCore(gradient: number): number;
  6686. }
  6687. /**
  6688. * Easing function with a power of 3 shape (see link below).
  6689. * @see https://easings.net/#easeInCubic
  6690. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6691. */
  6692. export class CubicEase extends EasingFunction implements IEasingFunction {
  6693. /** @hidden */
  6694. easeInCore(gradient: number): number;
  6695. }
  6696. /**
  6697. * Easing function with an elastic shape (see link below).
  6698. * @see https://easings.net/#easeInElastic
  6699. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6700. */
  6701. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6702. /** Defines the number of oscillations*/
  6703. oscillations: number;
  6704. /** Defines the amplitude of the oscillations*/
  6705. springiness: number;
  6706. /**
  6707. * Instantiates an elastic easing function
  6708. * @see https://easings.net/#easeInElastic
  6709. * @param oscillations Defines the number of oscillations
  6710. * @param springiness Defines the amplitude of the oscillations
  6711. */
  6712. constructor(
  6713. /** Defines the number of oscillations*/
  6714. oscillations?: number,
  6715. /** Defines the amplitude of the oscillations*/
  6716. springiness?: number);
  6717. /** @hidden */
  6718. easeInCore(gradient: number): number;
  6719. }
  6720. /**
  6721. * Easing function with an exponential shape (see link below).
  6722. * @see https://easings.net/#easeInExpo
  6723. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6724. */
  6725. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6726. /** Defines the exponent of the function */
  6727. exponent: number;
  6728. /**
  6729. * Instantiates an exponential easing function
  6730. * @see https://easings.net/#easeInExpo
  6731. * @param exponent Defines the exponent of the function
  6732. */
  6733. constructor(
  6734. /** Defines the exponent of the function */
  6735. exponent?: number);
  6736. /** @hidden */
  6737. easeInCore(gradient: number): number;
  6738. }
  6739. /**
  6740. * Easing function with a power shape (see link below).
  6741. * @see https://easings.net/#easeInQuad
  6742. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6743. */
  6744. export class PowerEase extends EasingFunction implements IEasingFunction {
  6745. /** Defines the power of the function */
  6746. power: number;
  6747. /**
  6748. * Instantiates an power base easing function
  6749. * @see https://easings.net/#easeInQuad
  6750. * @param power Defines the power of the function
  6751. */
  6752. constructor(
  6753. /** Defines the power of the function */
  6754. power?: number);
  6755. /** @hidden */
  6756. easeInCore(gradient: number): number;
  6757. }
  6758. /**
  6759. * Easing function with a power of 2 shape (see link below).
  6760. * @see https://easings.net/#easeInQuad
  6761. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6762. */
  6763. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6764. /** @hidden */
  6765. easeInCore(gradient: number): number;
  6766. }
  6767. /**
  6768. * Easing function with a power of 4 shape (see link below).
  6769. * @see https://easings.net/#easeInQuart
  6770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6771. */
  6772. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6773. /** @hidden */
  6774. easeInCore(gradient: number): number;
  6775. }
  6776. /**
  6777. * Easing function with a power of 5 shape (see link below).
  6778. * @see https://easings.net/#easeInQuint
  6779. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6780. */
  6781. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6782. /** @hidden */
  6783. easeInCore(gradient: number): number;
  6784. }
  6785. /**
  6786. * Easing function with a sin shape (see link below).
  6787. * @see https://easings.net/#easeInSine
  6788. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6789. */
  6790. export class SineEase extends EasingFunction implements IEasingFunction {
  6791. /** @hidden */
  6792. easeInCore(gradient: number): number;
  6793. }
  6794. /**
  6795. * Easing function with a bezier shape (see link below).
  6796. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6798. */
  6799. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6800. /** Defines the x component of the start tangent in the bezier curve */
  6801. x1: number;
  6802. /** Defines the y component of the start tangent in the bezier curve */
  6803. y1: number;
  6804. /** Defines the x component of the end tangent in the bezier curve */
  6805. x2: number;
  6806. /** Defines the y component of the end tangent in the bezier curve */
  6807. y2: number;
  6808. /**
  6809. * Instantiates a bezier function
  6810. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6811. * @param x1 Defines the x component of the start tangent in the bezier curve
  6812. * @param y1 Defines the y component of the start tangent in the bezier curve
  6813. * @param x2 Defines the x component of the end tangent in the bezier curve
  6814. * @param y2 Defines the y component of the end tangent in the bezier curve
  6815. */
  6816. constructor(
  6817. /** Defines the x component of the start tangent in the bezier curve */
  6818. x1?: number,
  6819. /** Defines the y component of the start tangent in the bezier curve */
  6820. y1?: number,
  6821. /** Defines the x component of the end tangent in the bezier curve */
  6822. x2?: number,
  6823. /** Defines the y component of the end tangent in the bezier curve */
  6824. y2?: number);
  6825. /** @hidden */
  6826. easeInCore(gradient: number): number;
  6827. }
  6828. }
  6829. declare module BABYLON {
  6830. /**
  6831. * Defines an interface which represents an animation key frame
  6832. */
  6833. export interface IAnimationKey {
  6834. /**
  6835. * Frame of the key frame
  6836. */
  6837. frame: number;
  6838. /**
  6839. * Value at the specifies key frame
  6840. */
  6841. value: any;
  6842. /**
  6843. * The input tangent for the cubic hermite spline
  6844. */
  6845. inTangent?: any;
  6846. /**
  6847. * The output tangent for the cubic hermite spline
  6848. */
  6849. outTangent?: any;
  6850. /**
  6851. * The animation interpolation type
  6852. */
  6853. interpolation?: AnimationKeyInterpolation;
  6854. }
  6855. /**
  6856. * Enum for the animation key frame interpolation type
  6857. */
  6858. export enum AnimationKeyInterpolation {
  6859. /**
  6860. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6861. */
  6862. STEP = 1
  6863. }
  6864. }
  6865. declare module BABYLON {
  6866. /**
  6867. * Represents the range of an animation
  6868. */
  6869. export class AnimationRange {
  6870. /**The name of the animation range**/
  6871. name: string;
  6872. /**The starting frame of the animation */
  6873. from: number;
  6874. /**The ending frame of the animation*/
  6875. to: number;
  6876. /**
  6877. * Initializes the range of an animation
  6878. * @param name The name of the animation range
  6879. * @param from The starting frame of the animation
  6880. * @param to The ending frame of the animation
  6881. */
  6882. constructor(
  6883. /**The name of the animation range**/
  6884. name: string,
  6885. /**The starting frame of the animation */
  6886. from: number,
  6887. /**The ending frame of the animation*/
  6888. to: number);
  6889. /**
  6890. * Makes a copy of the animation range
  6891. * @returns A copy of the animation range
  6892. */
  6893. clone(): AnimationRange;
  6894. }
  6895. }
  6896. declare module BABYLON {
  6897. /**
  6898. * Composed of a frame, and an action function
  6899. */
  6900. export class AnimationEvent {
  6901. /** The frame for which the event is triggered **/
  6902. frame: number;
  6903. /** The event to perform when triggered **/
  6904. action: (currentFrame: number) => void;
  6905. /** Specifies if the event should be triggered only once**/
  6906. onlyOnce?: boolean | undefined;
  6907. /**
  6908. * Specifies if the animation event is done
  6909. */
  6910. isDone: boolean;
  6911. /**
  6912. * Initializes the animation event
  6913. * @param frame The frame for which the event is triggered
  6914. * @param action The event to perform when triggered
  6915. * @param onlyOnce Specifies if the event should be triggered only once
  6916. */
  6917. constructor(
  6918. /** The frame for which the event is triggered **/
  6919. frame: number,
  6920. /** The event to perform when triggered **/
  6921. action: (currentFrame: number) => void,
  6922. /** Specifies if the event should be triggered only once**/
  6923. onlyOnce?: boolean | undefined);
  6924. /** @hidden */ private _clone(): AnimationEvent;
  6925. }
  6926. }
  6927. declare module BABYLON {
  6928. /**
  6929. * Interface used to define a behavior
  6930. */
  6931. export interface Behavior<T> {
  6932. /** gets or sets behavior's name */
  6933. name: string;
  6934. /**
  6935. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6936. */
  6937. init(): void;
  6938. /**
  6939. * Called when the behavior is attached to a target
  6940. * @param target defines the target where the behavior is attached to
  6941. */
  6942. attach(target: T): void;
  6943. /**
  6944. * Called when the behavior is detached from its target
  6945. */
  6946. detach(): void;
  6947. }
  6948. /**
  6949. * Interface implemented by classes supporting behaviors
  6950. */
  6951. export interface IBehaviorAware<T> {
  6952. /**
  6953. * Attach a behavior
  6954. * @param behavior defines the behavior to attach
  6955. * @returns the current host
  6956. */
  6957. addBehavior(behavior: Behavior<T>): T;
  6958. /**
  6959. * Remove a behavior from the current object
  6960. * @param behavior defines the behavior to detach
  6961. * @returns the current host
  6962. */
  6963. removeBehavior(behavior: Behavior<T>): T;
  6964. /**
  6965. * Gets a behavior using its name to search
  6966. * @param name defines the name to search
  6967. * @returns the behavior or null if not found
  6968. */
  6969. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6970. }
  6971. }
  6972. declare module BABYLON {
  6973. /**
  6974. * @hidden
  6975. */
  6976. export class IntersectionInfo {
  6977. bu: Nullable<number>;
  6978. bv: Nullable<number>;
  6979. distance: number;
  6980. faceId: number;
  6981. subMeshId: number;
  6982. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6983. }
  6984. }
  6985. declare module BABYLON {
  6986. /**
  6987. * Class used to store bounding sphere information
  6988. */
  6989. export class BoundingSphere {
  6990. /**
  6991. * Gets the center of the bounding sphere in local space
  6992. */
  6993. readonly center: Vector3;
  6994. /**
  6995. * Radius of the bounding sphere in local space
  6996. */
  6997. radius: number;
  6998. /**
  6999. * Gets the center of the bounding sphere in world space
  7000. */
  7001. readonly centerWorld: Vector3;
  7002. /**
  7003. * Radius of the bounding sphere in world space
  7004. */
  7005. radiusWorld: number;
  7006. /**
  7007. * Gets the minimum vector in local space
  7008. */
  7009. readonly minimum: Vector3;
  7010. /**
  7011. * Gets the maximum vector in local space
  7012. */
  7013. readonly maximum: Vector3;
  7014. private _worldMatrix;
  7015. private static readonly TmpVector3;
  7016. /**
  7017. * Creates a new bounding sphere
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding sphere by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingSphere;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Tests if the bounding sphere is intersecting the frustum planes
  7044. * @param frustumPlanes defines the frustum planes to test
  7045. * @returns true if there is an intersection
  7046. */
  7047. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7048. /**
  7049. * Tests if the bounding sphere center is in between the frustum planes.
  7050. * Used for optimistic fast inclusion.
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if the sphere center is in between the frustum planes
  7053. */
  7054. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding sphere
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding sphere
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Checks if two sphere intersct
  7063. * @param sphere0 sphere 0
  7064. * @param sphere1 sphere 1
  7065. * @returns true if the speres intersect
  7066. */
  7067. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7068. }
  7069. }
  7070. declare module BABYLON {
  7071. /**
  7072. * Class used to store bounding box information
  7073. */
  7074. export class BoundingBox implements ICullable {
  7075. /**
  7076. * Gets the 8 vectors representing the bounding box in local space
  7077. */
  7078. readonly vectors: Vector3[];
  7079. /**
  7080. * Gets the center of the bounding box in local space
  7081. */
  7082. readonly center: Vector3;
  7083. /**
  7084. * Gets the center of the bounding box in world space
  7085. */
  7086. readonly centerWorld: Vector3;
  7087. /**
  7088. * Gets the extend size in local space
  7089. */
  7090. readonly extendSize: Vector3;
  7091. /**
  7092. * Gets the extend size in world space
  7093. */
  7094. readonly extendSizeWorld: Vector3;
  7095. /**
  7096. * Gets the OBB (object bounding box) directions
  7097. */
  7098. readonly directions: Vector3[];
  7099. /**
  7100. * Gets the 8 vectors representing the bounding box in world space
  7101. */
  7102. readonly vectorsWorld: Vector3[];
  7103. /**
  7104. * Gets the minimum vector in world space
  7105. */
  7106. readonly minimumWorld: Vector3;
  7107. /**
  7108. * Gets the maximum vector in world space
  7109. */
  7110. readonly maximumWorld: Vector3;
  7111. /**
  7112. * Gets the minimum vector in local space
  7113. */
  7114. readonly minimum: Vector3;
  7115. /**
  7116. * Gets the maximum vector in local space
  7117. */
  7118. readonly maximum: Vector3;
  7119. private _worldMatrix;
  7120. private static readonly TmpVector3;
  7121. /**
  7122. * @hidden
  7123. */ private _tag: number;
  7124. /**
  7125. * Creates a new bounding box
  7126. * @param min defines the minimum vector (in local space)
  7127. * @param max defines the maximum vector (in local space)
  7128. * @param worldMatrix defines the new world matrix
  7129. */
  7130. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7131. /**
  7132. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7133. * @param min defines the new minimum vector (in local space)
  7134. * @param max defines the new maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7138. /**
  7139. * Scale the current bounding box by applying a scale factor
  7140. * @param factor defines the scale factor to apply
  7141. * @returns the current bounding box
  7142. */
  7143. scale(factor: number): BoundingBox;
  7144. /**
  7145. * Gets the world matrix of the bounding box
  7146. * @returns a matrix
  7147. */
  7148. getWorldMatrix(): DeepImmutable<Matrix>;
  7149. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  7150. /**
  7151. * Tests if the bounding box is intersecting the frustum planes
  7152. * @param frustumPlanes defines the frustum planes to test
  7153. * @returns true if there is an intersection
  7154. */
  7155. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7156. /**
  7157. * Tests if the bounding box is entirely inside the frustum planes
  7158. * @param frustumPlanes defines the frustum planes to test
  7159. * @returns true if there is an inclusion
  7160. */
  7161. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7162. /**
  7163. * Tests if a point is inside the bounding box
  7164. * @param point defines the point to test
  7165. * @returns true if the point is inside the bounding box
  7166. */
  7167. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7168. /**
  7169. * Tests if the bounding box intersects with a bounding sphere
  7170. * @param sphere defines the sphere to test
  7171. * @returns true if there is an intersection
  7172. */
  7173. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7174. /**
  7175. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7176. * @param min defines the min vector to use
  7177. * @param max defines the max vector to use
  7178. * @returns true if there is an intersection
  7179. */
  7180. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7181. /**
  7182. * Tests if two bounding boxes are intersections
  7183. * @param box0 defines the first box to test
  7184. * @param box1 defines the second box to test
  7185. * @returns true if there is an intersection
  7186. */
  7187. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7188. /**
  7189. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7190. * @param minPoint defines the minimum vector of the bounding box
  7191. * @param maxPoint defines the maximum vector of the bounding box
  7192. * @param sphereCenter defines the sphere center
  7193. * @param sphereRadius defines the sphere radius
  7194. * @returns true if there is an intersection
  7195. */
  7196. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7197. /**
  7198. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7199. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7200. * @param frustumPlanes defines the frustum planes to test
  7201. * @return true if there is an inclusion
  7202. */
  7203. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7204. /**
  7205. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7206. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7207. * @param frustumPlanes defines the frustum planes to test
  7208. * @return true if there is an intersection
  7209. */
  7210. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. }
  7212. }
  7213. declare module BABYLON {
  7214. /** @hidden */
  7215. export class Collider {
  7216. /** Define if a collision was found */
  7217. collisionFound: boolean;
  7218. /**
  7219. * Define last intersection point in local space
  7220. */
  7221. intersectionPoint: Vector3;
  7222. /**
  7223. * Define last collided mesh
  7224. */
  7225. collidedMesh: Nullable<AbstractMesh>;
  7226. private _collisionPoint;
  7227. private _planeIntersectionPoint;
  7228. private _tempVector;
  7229. private _tempVector2;
  7230. private _tempVector3;
  7231. private _tempVector4;
  7232. private _edge;
  7233. private _baseToVertex;
  7234. private _destinationPoint;
  7235. private _slidePlaneNormal;
  7236. private _displacementVector;
  7237. /** @hidden */ private _radius: Vector3;
  7238. /** @hidden */ private _retry: number;
  7239. private _velocity;
  7240. private _basePoint;
  7241. private _epsilon;
  7242. /** @hidden */ private _velocityWorldLength: number;
  7243. /** @hidden */ private _basePointWorld: Vector3;
  7244. private _velocityWorld;
  7245. private _normalizedVelocity;
  7246. /** @hidden */ private _initialVelocity: Vector3;
  7247. /** @hidden */ private _initialPosition: Vector3;
  7248. private _nearestDistance;
  7249. private _collisionMask;
  7250. collisionMask: number;
  7251. /**
  7252. * Gets the plane normal used to compute the sliding response (in local space)
  7253. */
  7254. readonly slidePlaneNormal: Vector3;
  7255. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7256. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7257. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7258. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7259. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7260. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7261. }
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * Interface for cullable objects
  7266. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7267. */
  7268. export interface ICullable {
  7269. /**
  7270. * Checks if the object or part of the object is in the frustum
  7271. * @param frustumPlanes Camera near/planes
  7272. * @returns true if the object is in frustum otherwise false
  7273. */
  7274. isInFrustum(frustumPlanes: Plane[]): boolean;
  7275. /**
  7276. * Checks if a cullable object (mesh...) is in the camera frustum
  7277. * Unlike isInFrustum this cheks the full bounding box
  7278. * @param frustumPlanes Camera near/planes
  7279. * @returns true if the object is in frustum otherwise false
  7280. */
  7281. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7282. }
  7283. /**
  7284. * Info for a bounding data of a mesh
  7285. */
  7286. export class BoundingInfo implements ICullable {
  7287. /**
  7288. * Bounding box for the mesh
  7289. */
  7290. readonly boundingBox: BoundingBox;
  7291. /**
  7292. * Bounding sphere for the mesh
  7293. */
  7294. readonly boundingSphere: BoundingSphere;
  7295. private _isLocked;
  7296. private static readonly TmpVector3;
  7297. /**
  7298. * Constructs bounding info
  7299. * @param minimum min vector of the bounding box/sphere
  7300. * @param maximum max vector of the bounding box/sphere
  7301. * @param worldMatrix defines the new world matrix
  7302. */
  7303. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7304. /**
  7305. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7306. * @param min defines the new minimum vector (in local space)
  7307. * @param max defines the new maximum vector (in local space)
  7308. * @param worldMatrix defines the new world matrix
  7309. */
  7310. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7311. /**
  7312. * min vector of the bounding box/sphere
  7313. */
  7314. readonly minimum: Vector3;
  7315. /**
  7316. * max vector of the bounding box/sphere
  7317. */
  7318. readonly maximum: Vector3;
  7319. /**
  7320. * If the info is locked and won't be updated to avoid perf overhead
  7321. */
  7322. isLocked: boolean;
  7323. /**
  7324. * Updates the bounding sphere and box
  7325. * @param world world matrix to be used to update
  7326. */
  7327. update(world: DeepImmutable<Matrix>): void;
  7328. /**
  7329. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7330. * @param center New center of the bounding info
  7331. * @param extend New extend of the bounding info
  7332. * @returns the current bounding info
  7333. */
  7334. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7335. /**
  7336. * Scale the current bounding info by applying a scale factor
  7337. * @param factor defines the scale factor to apply
  7338. * @returns the current bounding info
  7339. */
  7340. scale(factor: number): BoundingInfo;
  7341. /**
  7342. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7343. * @param frustumPlanes defines the frustum to test
  7344. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7345. * @returns true if the bounding info is in the frustum planes
  7346. */
  7347. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7348. /**
  7349. * Gets the world distance between the min and max points of the bounding box
  7350. */
  7351. readonly diagonalLength: number;
  7352. /**
  7353. * Checks if a cullable object (mesh...) is in the camera frustum
  7354. * Unlike isInFrustum this cheks the full bounding box
  7355. * @param frustumPlanes Camera near/planes
  7356. * @returns true if the object is in frustum otherwise false
  7357. */
  7358. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7359. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7360. /**
  7361. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7362. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7363. * @param point the point to check intersection with
  7364. * @returns if the point intersects
  7365. */
  7366. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7367. /**
  7368. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7369. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7370. * @param boundingInfo the bounding info to check intersection with
  7371. * @param precise if the intersection should be done using OBB
  7372. * @returns if the bounding info intersects
  7373. */
  7374. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7375. }
  7376. }
  7377. declare module BABYLON {
  7378. /**
  7379. * Defines an array and its length.
  7380. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7381. */
  7382. export interface ISmartArrayLike<T> {
  7383. /**
  7384. * The data of the array.
  7385. */
  7386. data: Array<T>;
  7387. /**
  7388. * The active length of the array.
  7389. */
  7390. length: number;
  7391. }
  7392. /**
  7393. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7394. */
  7395. export class SmartArray<T> implements ISmartArrayLike<T> {
  7396. /**
  7397. * The full set of data from the array.
  7398. */
  7399. data: Array<T>;
  7400. /**
  7401. * The active length of the array.
  7402. */
  7403. length: number;
  7404. protected _id: number;
  7405. /**
  7406. * Instantiates a Smart Array.
  7407. * @param capacity defines the default capacity of the array.
  7408. */
  7409. constructor(capacity: number);
  7410. /**
  7411. * Pushes a value at the end of the active data.
  7412. * @param value defines the object to push in the array.
  7413. */
  7414. push(value: T): void;
  7415. /**
  7416. * Iterates over the active data and apply the lambda to them.
  7417. * @param func defines the action to apply on each value.
  7418. */
  7419. forEach(func: (content: T) => void): void;
  7420. /**
  7421. * Sorts the full sets of data.
  7422. * @param compareFn defines the comparison function to apply.
  7423. */
  7424. sort(compareFn: (a: T, b: T) => number): void;
  7425. /**
  7426. * Resets the active data to an empty array.
  7427. */
  7428. reset(): void;
  7429. /**
  7430. * Releases all the data from the array as well as the array.
  7431. */
  7432. dispose(): void;
  7433. /**
  7434. * Concats the active data with a given array.
  7435. * @param array defines the data to concatenate with.
  7436. */
  7437. concat(array: any): void;
  7438. /**
  7439. * Returns the position of a value in the active data.
  7440. * @param value defines the value to find the index for
  7441. * @returns the index if found in the active data otherwise -1
  7442. */
  7443. indexOf(value: T): number;
  7444. /**
  7445. * Returns whether an element is part of the active data.
  7446. * @param value defines the value to look for
  7447. * @returns true if found in the active data otherwise false
  7448. */
  7449. contains(value: T): boolean;
  7450. private static _GlobalId;
  7451. }
  7452. /**
  7453. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7454. * The data in this array can only be present once
  7455. */
  7456. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7457. private _duplicateId;
  7458. /**
  7459. * Pushes a value at the end of the active data.
  7460. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7461. * @param value defines the object to push in the array.
  7462. */
  7463. push(value: T): void;
  7464. /**
  7465. * Pushes a value at the end of the active data.
  7466. * If the data is already present, it won t be added again
  7467. * @param value defines the object to push in the array.
  7468. * @returns true if added false if it was already present
  7469. */
  7470. pushNoDuplicate(value: T): boolean;
  7471. /**
  7472. * Resets the active data to an empty array.
  7473. */
  7474. reset(): void;
  7475. /**
  7476. * Concats the active data with a given array.
  7477. * This ensures no dupplicate will be present in the result.
  7478. * @param array defines the data to concatenate with.
  7479. */
  7480. concatWithNoDuplicate(array: any): void;
  7481. }
  7482. }
  7483. declare module BABYLON {
  7484. /**
  7485. * Enum that determines the text-wrapping mode to use.
  7486. */
  7487. export enum InspectableType {
  7488. /**
  7489. * Checkbox for booleans
  7490. */
  7491. Checkbox = 0,
  7492. /**
  7493. * Sliders for numbers
  7494. */
  7495. Slider = 1,
  7496. /**
  7497. * Vector3
  7498. */
  7499. Vector3 = 2,
  7500. /**
  7501. * Quaternions
  7502. */
  7503. Quaternion = 3,
  7504. /**
  7505. * Color3
  7506. */
  7507. Color3 = 4
  7508. }
  7509. /**
  7510. * Interface used to define custom inspectable properties.
  7511. * This interface is used by the inspector to display custom property grids
  7512. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7513. */
  7514. export interface IInspectable {
  7515. /**
  7516. * Gets the label to display
  7517. */
  7518. label: string;
  7519. /**
  7520. * Gets the name of the property to edit
  7521. */
  7522. propertyName: string;
  7523. /**
  7524. * Gets the type of the editor to use
  7525. */
  7526. type: InspectableType;
  7527. /**
  7528. * Gets the minimum value of the property when using in "slider" mode
  7529. */
  7530. min?: number;
  7531. /**
  7532. * Gets the maximum value of the property when using in "slider" mode
  7533. */
  7534. max?: number;
  7535. /**
  7536. * Gets the setp to use when using in "slider" mode
  7537. */
  7538. step?: number;
  7539. }
  7540. }
  7541. declare module BABYLON {
  7542. /**
  7543. * This represents the required contract to create a new type of texture loader.
  7544. */
  7545. export interface IInternalTextureLoader {
  7546. /**
  7547. * Defines wether the loader supports cascade loading the different faces.
  7548. */
  7549. supportCascades: boolean;
  7550. /**
  7551. * This returns if the loader support the current file information.
  7552. * @param extension defines the file extension of the file being loaded
  7553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7554. * @param fallback defines the fallback internal texture if any
  7555. * @param isBase64 defines whether the texture is encoded as a base64
  7556. * @param isBuffer defines whether the texture data are stored as a buffer
  7557. * @returns true if the loader can load the specified file
  7558. */
  7559. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7560. /**
  7561. * Transform the url before loading if required.
  7562. * @param rootUrl the url of the texture
  7563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7564. * @returns the transformed texture
  7565. */
  7566. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7567. /**
  7568. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7569. * @param rootUrl the url of the texture
  7570. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7571. * @returns the fallback texture
  7572. */
  7573. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7574. /**
  7575. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7576. * @param data contains the texture data
  7577. * @param texture defines the BabylonJS internal texture
  7578. * @param createPolynomials will be true if polynomials have been requested
  7579. * @param onLoad defines the callback to trigger once the texture is ready
  7580. * @param onError defines the callback to trigger in case of error
  7581. */
  7582. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7583. /**
  7584. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7585. * @param data contains the texture data
  7586. * @param texture defines the BabylonJS internal texture
  7587. * @param callback defines the method to call once ready to upload
  7588. */
  7589. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7590. }
  7591. }
  7592. declare module BABYLON {
  7593. interface Engine {
  7594. /**
  7595. * Creates a depth stencil cube texture.
  7596. * This is only available in WebGL 2.
  7597. * @param size The size of face edge in the cube texture.
  7598. * @param options The options defining the cube texture.
  7599. * @returns The cube texture
  7600. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7601. /**
  7602. * Creates a cube texture
  7603. * @param rootUrl defines the url where the files to load is located
  7604. * @param scene defines the current scene
  7605. * @param files defines the list of files to load (1 per face)
  7606. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7607. * @param onLoad defines an optional callback raised when the texture is loaded
  7608. * @param onError defines an optional callback raised if there is an issue to load the texture
  7609. * @param format defines the format of the data
  7610. * @param forcedExtension defines the extension to use to pick the right loader
  7611. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7612. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7613. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7614. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7615. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7616. * @returns the cube texture as an InternalTexture
  7617. */
  7618. 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;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @returns the cube texture as an InternalTexture
  7630. */
  7631. 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;
  7632. /**
  7633. * Creates a cube texture
  7634. * @param rootUrl defines the url where the files to load is located
  7635. * @param scene defines the current scene
  7636. * @param files defines the list of files to load (1 per face)
  7637. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7638. * @param onLoad defines an optional callback raised when the texture is loaded
  7639. * @param onError defines an optional callback raised if there is an issue to load the texture
  7640. * @param format defines the format of the data
  7641. * @param forcedExtension defines the extension to use to pick the right loader
  7642. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7643. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7644. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7645. * @returns the cube texture as an InternalTexture
  7646. */
  7647. 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;
  7648. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7649. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7650. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7651. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7652. }
  7653. }
  7654. declare module BABYLON {
  7655. /**
  7656. * Class for creating a cube texture
  7657. */
  7658. export class CubeTexture extends BaseTexture {
  7659. private _delayedOnLoad;
  7660. /**
  7661. * The url of the texture
  7662. */
  7663. url: string;
  7664. /**
  7665. * Gets or sets the center of the bounding box associated with the cube texture.
  7666. * It must define where the camera used to render the texture was set
  7667. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7668. */
  7669. boundingBoxPosition: Vector3;
  7670. private _boundingBoxSize;
  7671. /**
  7672. * Gets or sets the size of the bounding box associated with the cube texture
  7673. * When defined, the cubemap will switch to local mode
  7674. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7675. * @example https://www.babylonjs-playground.com/#RNASML
  7676. */
  7677. /**
  7678. * Returns the bounding box size
  7679. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7680. */
  7681. boundingBoxSize: Vector3;
  7682. protected _rotationY: number;
  7683. /**
  7684. * Sets texture matrix rotation angle around Y axis in radians.
  7685. */
  7686. /**
  7687. * Gets texture matrix rotation angle around Y axis radians.
  7688. */
  7689. rotationY: number;
  7690. /**
  7691. * Are mip maps generated for this texture or not.
  7692. */
  7693. readonly noMipmap: boolean;
  7694. private _noMipmap;
  7695. private _files;
  7696. private _extensions;
  7697. private _textureMatrix;
  7698. private _format;
  7699. private _createPolynomials;
  7700. /** @hidden */ private _prefiltered: boolean;
  7701. /**
  7702. * Creates a cube texture from an array of image urls
  7703. * @param files defines an array of image urls
  7704. * @param scene defines the hosting scene
  7705. * @param noMipmap specifies if mip maps are not used
  7706. * @returns a cube texture
  7707. */
  7708. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7709. /**
  7710. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7711. * @param url defines the url of the prefiltered texture
  7712. * @param scene defines the scene the texture is attached to
  7713. * @param forcedExtension defines the extension of the file if different from the url
  7714. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7715. * @return the prefiltered texture
  7716. */
  7717. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7718. /**
  7719. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7720. * as prefiltered data.
  7721. * @param rootUrl defines the url of the texture or the root name of the six images
  7722. * @param scene defines the scene the texture is attached to
  7723. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7724. * @param noMipmap defines if mipmaps should be created or not
  7725. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7726. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7727. * @param onError defines a callback triggered in case of error during load
  7728. * @param format defines the internal format to use for the texture once loaded
  7729. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7730. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7731. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7732. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7733. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7734. * @return the cube texture
  7735. */
  7736. 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);
  7737. /**
  7738. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7739. */
  7740. readonly isPrefiltered: boolean;
  7741. /**
  7742. * Get the current class name of the texture useful for serialization or dynamic coding.
  7743. * @returns "CubeTexture"
  7744. */
  7745. getClassName(): string;
  7746. /**
  7747. * Update the url (and optional buffer) of this texture if url was null during construction.
  7748. * @param url the url of the texture
  7749. * @param forcedExtension defines the extension to use
  7750. * @param onLoad callback called when the texture is loaded (defaults to null)
  7751. */
  7752. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7753. /**
  7754. * Delays loading of the cube texture
  7755. * @param forcedExtension defines the extension to use
  7756. */
  7757. delayLoad(forcedExtension?: string): void;
  7758. /**
  7759. * Returns the reflection texture matrix
  7760. * @returns the reflection texture matrix
  7761. */
  7762. getReflectionTextureMatrix(): Matrix;
  7763. /**
  7764. * Sets the reflection texture matrix
  7765. * @param value Reflection texture matrix
  7766. */
  7767. setReflectionTextureMatrix(value: Matrix): void;
  7768. /**
  7769. * Parses text to create a cube texture
  7770. * @param parsedTexture define the serialized text to read from
  7771. * @param scene defines the hosting scene
  7772. * @param rootUrl defines the root url of the cube texture
  7773. * @returns a cube texture
  7774. */
  7775. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7776. /**
  7777. * Makes a clone, or deep copy, of the cube texture
  7778. * @returns a new cube texture
  7779. */
  7780. clone(): CubeTexture;
  7781. }
  7782. }
  7783. declare module BABYLON {
  7784. /** @hidden */
  7785. export var postprocessVertexShader: {
  7786. name: string;
  7787. shader: string;
  7788. };
  7789. }
  7790. declare module BABYLON {
  7791. /**
  7792. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7793. * This is the base of the follow, arc rotate cameras and Free camera
  7794. * @see http://doc.babylonjs.com/features/cameras
  7795. */
  7796. export class TargetCamera extends Camera {
  7797. private static _RigCamTransformMatrix;
  7798. private static _TargetTransformMatrix;
  7799. private static _TargetFocalPoint;
  7800. /**
  7801. * Define the current direction the camera is moving to
  7802. */
  7803. cameraDirection: Vector3;
  7804. /**
  7805. * Define the current rotation the camera is rotating to
  7806. */
  7807. cameraRotation: Vector2;
  7808. /**
  7809. * When set, the up vector of the camera will be updated by the rotation of the camera
  7810. */
  7811. updateUpVectorFromRotation: boolean;
  7812. private _tmpQuaternion;
  7813. /**
  7814. * Define the current rotation of the camera
  7815. */
  7816. rotation: Vector3;
  7817. /**
  7818. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7819. */
  7820. rotationQuaternion: Quaternion;
  7821. /**
  7822. * Define the current speed of the camera
  7823. */
  7824. speed: number;
  7825. /**
  7826. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7827. * around all axis.
  7828. */
  7829. noRotationConstraint: boolean;
  7830. /**
  7831. * Define the current target of the camera as an object or a position.
  7832. */
  7833. lockedTarget: any;
  7834. /** @hidden */ private _currentTarget: Vector3;
  7835. /** @hidden */ private _initialFocalDistance: number;
  7836. /** @hidden */ private _viewMatrix: Matrix;
  7837. /** @hidden */ private _camMatrix: Matrix;
  7838. /** @hidden */ private _cameraTransformMatrix: Matrix;
  7839. /** @hidden */ private _cameraRotationMatrix: Matrix;
  7840. /** @hidden */ private _referencePoint: Vector3;
  7841. /** @hidden */ private _transformedReferencePoint: Vector3;
  7842. protected _globalCurrentTarget: Vector3;
  7843. protected _globalCurrentUpVector: Vector3;
  7844. /** @hidden */ private _reset: () => void;
  7845. private _defaultUp;
  7846. /**
  7847. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7848. * This is the base of the follow, arc rotate cameras and Free camera
  7849. * @see http://doc.babylonjs.com/features/cameras
  7850. * @param name Defines the name of the camera in the scene
  7851. * @param position Defines the start position of the camera in the scene
  7852. * @param scene Defines the scene the camera belongs to
  7853. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7854. */
  7855. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7856. /**
  7857. * Gets the position in front of the camera at a given distance.
  7858. * @param distance The distance from the camera we want the position to be
  7859. * @returns the position
  7860. */
  7861. getFrontPosition(distance: number): Vector3;
  7862. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  7863. private _storedPosition;
  7864. private _storedRotation;
  7865. private _storedRotationQuaternion;
  7866. /**
  7867. * Store current camera state of the camera (fov, position, rotation, etc..)
  7868. * @returns the camera
  7869. */
  7870. storeState(): Camera;
  7871. /**
  7872. * Restored camera state. You must call storeState() first
  7873. * @returns whether it was successful or not
  7874. * @hidden
  7875. */ private _restoreStateValues(): boolean;
  7876. /** @hidden */ private _initCache(): void;
  7877. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  7878. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  7879. /** @hidden */ private _computeLocalCameraSpeed(): number;
  7880. /**
  7881. * Defines the target the camera should look at.
  7882. * This will automatically adapt alpha beta and radius to fit within the new target.
  7883. * @param target Defines the new target as a Vector or a mesh
  7884. */
  7885. setTarget(target: Vector3): void;
  7886. /**
  7887. * Return the current target position of the camera. This value is expressed in local space.
  7888. * @returns the target position
  7889. */
  7890. getTarget(): Vector3;
  7891. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  7892. /** @hidden */ private _updatePosition(): void;
  7893. /** @hidden */ private _checkInputs(): void;
  7894. protected _updateCameraRotationMatrix(): void;
  7895. /**
  7896. * 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)
  7897. * @returns the current camera
  7898. */
  7899. private _rotateUpVectorWithCameraRotationMatrix;
  7900. private _cachedRotationZ;
  7901. private _cachedQuaternionRotationZ;
  7902. /** @hidden */ private _getViewMatrix(): Matrix;
  7903. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7904. /**
  7905. * @hidden
  7906. */
  7907. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7908. /**
  7909. * @hidden
  7910. */ private _updateRigCameras(): void;
  7911. private _getRigCamPositionAndTarget;
  7912. /**
  7913. * Gets the current object class name.
  7914. * @return the class name
  7915. */
  7916. getClassName(): string;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * @ignore
  7922. * This is a list of all the different input types that are available in the application.
  7923. * Fo instance: ArcRotateCameraGamepadInput...
  7924. */
  7925. export var CameraInputTypes: {};
  7926. /**
  7927. * This is the contract to implement in order to create a new input class.
  7928. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7929. */
  7930. export interface ICameraInput<TCamera extends Camera> {
  7931. /**
  7932. * Defines the camera the input is attached to.
  7933. */
  7934. camera: Nullable<TCamera>;
  7935. /**
  7936. * Gets the class name of the current intput.
  7937. * @returns the class name
  7938. */
  7939. getClassName(): string;
  7940. /**
  7941. * Get the friendly name associated with the input class.
  7942. * @returns the input friendly name
  7943. */
  7944. getSimpleName(): string;
  7945. /**
  7946. * Attach the input controls to a specific dom element to get the input from.
  7947. * @param element Defines the element the controls should be listened from
  7948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7949. */
  7950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7951. /**
  7952. * Detach the current controls from the specified dom element.
  7953. * @param element Defines the element to stop listening the inputs from
  7954. */
  7955. detachControl(element: Nullable<HTMLElement>): void;
  7956. /**
  7957. * Update the current camera state depending on the inputs that have been used this frame.
  7958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7959. */
  7960. checkInputs?: () => void;
  7961. }
  7962. /**
  7963. * Represents a map of input types to input instance or input index to input instance.
  7964. */
  7965. export interface CameraInputsMap<TCamera extends Camera> {
  7966. /**
  7967. * Accessor to the input by input type.
  7968. */
  7969. [name: string]: ICameraInput<TCamera>;
  7970. /**
  7971. * Accessor to the input by input index.
  7972. */
  7973. [idx: number]: ICameraInput<TCamera>;
  7974. }
  7975. /**
  7976. * This represents the input manager used within a camera.
  7977. * It helps dealing with all the different kind of input attached to a camera.
  7978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7979. */
  7980. export class CameraInputsManager<TCamera extends Camera> {
  7981. /**
  7982. * Defines the list of inputs attahed to the camera.
  7983. */
  7984. attached: CameraInputsMap<TCamera>;
  7985. /**
  7986. * Defines the dom element the camera is collecting inputs from.
  7987. * This is null if the controls have not been attached.
  7988. */
  7989. attachedElement: Nullable<HTMLElement>;
  7990. /**
  7991. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7992. */
  7993. noPreventDefault: boolean;
  7994. /**
  7995. * Defined the camera the input manager belongs to.
  7996. */
  7997. camera: TCamera;
  7998. /**
  7999. * Update the current camera state depending on the inputs that have been used this frame.
  8000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8001. */
  8002. checkInputs: () => void;
  8003. /**
  8004. * Instantiate a new Camera Input Manager.
  8005. * @param camera Defines the camera the input manager blongs to
  8006. */
  8007. constructor(camera: TCamera);
  8008. /**
  8009. * Add an input method to a camera
  8010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8011. * @param input camera input method
  8012. */
  8013. add(input: ICameraInput<TCamera>): void;
  8014. /**
  8015. * Remove a specific input method from a camera
  8016. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8017. * @param inputToRemove camera input method
  8018. */
  8019. remove(inputToRemove: ICameraInput<TCamera>): void;
  8020. /**
  8021. * Remove a specific input type from a camera
  8022. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8023. * @param inputType the type of the input to remove
  8024. */
  8025. removeByType(inputType: string): void;
  8026. private _addCheckInputs;
  8027. /**
  8028. * Attach the input controls to the currently attached dom element to listen the events from.
  8029. * @param input Defines the input to attach
  8030. */
  8031. attachInput(input: ICameraInput<TCamera>): void;
  8032. /**
  8033. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8034. * @param element Defines the dom element to collect the events from
  8035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8036. */
  8037. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8038. /**
  8039. * Detach the current manager inputs controls from a specific dom element.
  8040. * @param element Defines the dom element to collect the events from
  8041. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8042. */
  8043. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8044. /**
  8045. * Rebuild the dynamic inputCheck function from the current list of
  8046. * defined inputs in the manager.
  8047. */
  8048. rebuildInputCheck(): void;
  8049. /**
  8050. * Remove all attached input methods from a camera
  8051. */
  8052. clear(): void;
  8053. /**
  8054. * Serialize the current input manager attached to a camera.
  8055. * This ensures than once parsed,
  8056. * the input associated to the camera will be identical to the current ones
  8057. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8058. */
  8059. serialize(serializedCamera: any): void;
  8060. /**
  8061. * Parses an input manager serialized JSON to restore the previous list of inputs
  8062. * and states associated to a camera.
  8063. * @param parsedCamera Defines the JSON to parse
  8064. */
  8065. parse(parsedCamera: any): void;
  8066. }
  8067. }
  8068. declare module BABYLON {
  8069. /**
  8070. * Gather the list of keyboard event types as constants.
  8071. */
  8072. export class KeyboardEventTypes {
  8073. /**
  8074. * The keydown event is fired when a key becomes active (pressed).
  8075. */
  8076. static readonly KEYDOWN: number;
  8077. /**
  8078. * The keyup event is fired when a key has been released.
  8079. */
  8080. static readonly KEYUP: number;
  8081. }
  8082. /**
  8083. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8084. */
  8085. export class KeyboardInfo {
  8086. /**
  8087. * Defines the type of event (KeyboardEventTypes)
  8088. */
  8089. type: number;
  8090. /**
  8091. * Defines the related dom event
  8092. */
  8093. event: KeyboardEvent;
  8094. /**
  8095. * Instantiates a new keyboard info.
  8096. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8097. * @param type Defines the type of event (KeyboardEventTypes)
  8098. * @param event Defines the related dom event
  8099. */
  8100. constructor(
  8101. /**
  8102. * Defines the type of event (KeyboardEventTypes)
  8103. */
  8104. type: number,
  8105. /**
  8106. * Defines the related dom event
  8107. */
  8108. event: KeyboardEvent);
  8109. }
  8110. /**
  8111. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8112. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8113. */
  8114. export class KeyboardInfoPre extends KeyboardInfo {
  8115. /**
  8116. * Defines the type of event (KeyboardEventTypes)
  8117. */
  8118. type: number;
  8119. /**
  8120. * Defines the related dom event
  8121. */
  8122. event: KeyboardEvent;
  8123. /**
  8124. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8125. */
  8126. skipOnPointerObservable: boolean;
  8127. /**
  8128. * Instantiates a new keyboard pre info.
  8129. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8130. * @param type Defines the type of event (KeyboardEventTypes)
  8131. * @param event Defines the related dom event
  8132. */
  8133. constructor(
  8134. /**
  8135. * Defines the type of event (KeyboardEventTypes)
  8136. */
  8137. type: number,
  8138. /**
  8139. * Defines the related dom event
  8140. */
  8141. event: KeyboardEvent);
  8142. }
  8143. }
  8144. declare module BABYLON {
  8145. /**
  8146. * Manage the keyboard inputs to control the movement of a free camera.
  8147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8148. */
  8149. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8150. /**
  8151. * Defines the camera the input is attached to.
  8152. */
  8153. camera: FreeCamera;
  8154. /**
  8155. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8156. */
  8157. keysUp: number[];
  8158. /**
  8159. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8160. */
  8161. keysDown: number[];
  8162. /**
  8163. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8164. */
  8165. keysLeft: number[];
  8166. /**
  8167. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8168. */
  8169. keysRight: number[];
  8170. private _keys;
  8171. private _onCanvasBlurObserver;
  8172. private _onKeyboardObserver;
  8173. private _engine;
  8174. private _scene;
  8175. /**
  8176. * Attach the input controls to a specific dom element to get the input from.
  8177. * @param element Defines the element the controls should be listened from
  8178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8179. */
  8180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8181. /**
  8182. * Detach the current controls from the specified dom element.
  8183. * @param element Defines the element to stop listening the inputs from
  8184. */
  8185. detachControl(element: Nullable<HTMLElement>): void;
  8186. /**
  8187. * Update the current camera state depending on the inputs that have been used this frame.
  8188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8189. */
  8190. checkInputs(): void;
  8191. /**
  8192. * Gets the class name of the current intput.
  8193. * @returns the class name
  8194. */
  8195. getClassName(): string;
  8196. /** @hidden */ private _onLostFocus(): void;
  8197. /**
  8198. * Get the friendly name associated with the input class.
  8199. * @returns the input friendly name
  8200. */
  8201. getSimpleName(): string;
  8202. }
  8203. }
  8204. declare module BABYLON {
  8205. /**
  8206. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8207. * separate meshes. This can be use to improve performances.
  8208. * @see http://doc.babylonjs.com/how_to/multi_materials
  8209. */
  8210. export class MultiMaterial extends Material {
  8211. private _subMaterials;
  8212. /**
  8213. * Gets or Sets the list of Materials used within the multi material.
  8214. * They need to be ordered according to the submeshes order in the associated mesh
  8215. */
  8216. subMaterials: Nullable<Material>[];
  8217. /**
  8218. * Function used to align with Node.getChildren()
  8219. * @returns the list of Materials used within the multi material
  8220. */
  8221. getChildren(): Nullable<Material>[];
  8222. /**
  8223. * Instantiates a new Multi Material
  8224. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8225. * separate meshes. This can be use to improve performances.
  8226. * @see http://doc.babylonjs.com/how_to/multi_materials
  8227. * @param name Define the name in the scene
  8228. * @param scene Define the scene the material belongs to
  8229. */
  8230. constructor(name: string, scene: Scene);
  8231. private _hookArray;
  8232. /**
  8233. * Get one of the submaterial by its index in the submaterials array
  8234. * @param index The index to look the sub material at
  8235. * @returns The Material if the index has been defined
  8236. */
  8237. getSubMaterial(index: number): Nullable<Material>;
  8238. /**
  8239. * Get the list of active textures for the whole sub materials list.
  8240. * @returns All the textures that will be used during the rendering
  8241. */
  8242. getActiveTextures(): BaseTexture[];
  8243. /**
  8244. * Gets the current class name of the material e.g. "MultiMaterial"
  8245. * Mainly use in serialization.
  8246. * @returns the class name
  8247. */
  8248. getClassName(): string;
  8249. /**
  8250. * Checks if the material is ready to render the requested sub mesh
  8251. * @param mesh Define the mesh the submesh belongs to
  8252. * @param subMesh Define the sub mesh to look readyness for
  8253. * @param useInstances Define whether or not the material is used with instances
  8254. * @returns true if ready, otherwise false
  8255. */
  8256. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8257. /**
  8258. * Clones the current material and its related sub materials
  8259. * @param name Define the name of the newly cloned material
  8260. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8261. * @returns the cloned material
  8262. */
  8263. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8264. /**
  8265. * Serializes the materials into a JSON representation.
  8266. * @returns the JSON representation
  8267. */
  8268. serialize(): any;
  8269. /**
  8270. * Dispose the material and release its associated resources
  8271. * @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)
  8272. * @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)
  8273. * @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)
  8274. */
  8275. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8276. /**
  8277. * Creates a MultiMaterial from parsed MultiMaterial data.
  8278. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8279. * @param scene defines the hosting scene
  8280. * @returns a new MultiMaterial
  8281. */
  8282. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8283. }
  8284. }
  8285. declare module BABYLON {
  8286. /**
  8287. * Class used to represent data loading progression
  8288. */
  8289. export class SceneLoaderFlags {
  8290. private static _ForceFullSceneLoadingForIncremental;
  8291. private static _ShowLoadingScreen;
  8292. private static _CleanBoneMatrixWeights;
  8293. private static _loggingLevel;
  8294. /**
  8295. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8296. */
  8297. static ForceFullSceneLoadingForIncremental: boolean;
  8298. /**
  8299. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8300. */
  8301. static ShowLoadingScreen: boolean;
  8302. /**
  8303. * Defines the current logging level (while loading the scene)
  8304. * @ignorenaming
  8305. */
  8306. static loggingLevel: number;
  8307. /**
  8308. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8309. */
  8310. static CleanBoneMatrixWeights: boolean;
  8311. }
  8312. }
  8313. declare module BABYLON {
  8314. /**
  8315. * 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.
  8316. * @see https://doc.babylonjs.com/how_to/transformnode
  8317. */
  8318. export class TransformNode extends Node {
  8319. /**
  8320. * Object will not rotate to face the camera
  8321. */
  8322. static BILLBOARDMODE_NONE: number;
  8323. /**
  8324. * Object will rotate to face the camera but only on the x axis
  8325. */
  8326. static BILLBOARDMODE_X: number;
  8327. /**
  8328. * Object will rotate to face the camera but only on the y axis
  8329. */
  8330. static BILLBOARDMODE_Y: number;
  8331. /**
  8332. * Object will rotate to face the camera but only on the z axis
  8333. */
  8334. static BILLBOARDMODE_Z: number;
  8335. /**
  8336. * Object will rotate to face the camera
  8337. */
  8338. static BILLBOARDMODE_ALL: number;
  8339. private _forward;
  8340. private _forwardInverted;
  8341. private _up;
  8342. private _right;
  8343. private _rightInverted;
  8344. private _position;
  8345. private _rotation;
  8346. private _rotationQuaternion;
  8347. protected _scaling: Vector3;
  8348. protected _isDirty: boolean;
  8349. private _transformToBoneReferal;
  8350. private _billboardMode;
  8351. /**
  8352. * Gets or sets the billboard mode. Default is 0.
  8353. *
  8354. * | Value | Type | Description |
  8355. * | --- | --- | --- |
  8356. * | 0 | BILLBOARDMODE_NONE | |
  8357. * | 1 | BILLBOARDMODE_X | |
  8358. * | 2 | BILLBOARDMODE_Y | |
  8359. * | 4 | BILLBOARDMODE_Z | |
  8360. * | 7 | BILLBOARDMODE_ALL | |
  8361. *
  8362. */
  8363. billboardMode: number;
  8364. private _preserveParentRotationForBillboard;
  8365. /**
  8366. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8367. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8368. */
  8369. preserveParentRotationForBillboard: boolean;
  8370. /**
  8371. * 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
  8372. */
  8373. scalingDeterminant: number;
  8374. private _infiniteDistance;
  8375. /**
  8376. * Gets or sets the distance of the object to max, often used by skybox
  8377. */
  8378. infiniteDistance: boolean;
  8379. /**
  8380. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8381. * By default the system will update normals to compensate
  8382. */
  8383. ignoreNonUniformScaling: boolean;
  8384. /**
  8385. * 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
  8386. */
  8387. reIntegrateRotationIntoRotationQuaternion: boolean;
  8388. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  8389. /** @hidden */ private _localMatrix: Matrix;
  8390. private _usePivotMatrix;
  8391. private _absolutePosition;
  8392. private _pivotMatrix;
  8393. private _pivotMatrixInverse;
  8394. protected _postMultiplyPivotMatrix: boolean;
  8395. protected _isWorldMatrixFrozen: boolean;
  8396. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  8397. /**
  8398. * An event triggered after the world matrix is updated
  8399. */
  8400. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8401. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8402. /**
  8403. * Gets a string identifying the name of the class
  8404. * @returns "TransformNode" string
  8405. */
  8406. getClassName(): string;
  8407. /**
  8408. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8409. */
  8410. position: Vector3;
  8411. /**
  8412. * 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)).
  8413. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8414. */
  8415. rotation: Vector3;
  8416. /**
  8417. * 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)).
  8418. */
  8419. scaling: Vector3;
  8420. /**
  8421. * 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).
  8422. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8423. */
  8424. rotationQuaternion: Nullable<Quaternion>;
  8425. /**
  8426. * The forward direction of that transform in world space.
  8427. */
  8428. readonly forward: Vector3;
  8429. /**
  8430. * The up direction of that transform in world space.
  8431. */
  8432. readonly up: Vector3;
  8433. /**
  8434. * The right direction of that transform in world space.
  8435. */
  8436. readonly right: Vector3;
  8437. /**
  8438. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8439. * @param matrix the matrix to copy the pose from
  8440. * @returns this TransformNode.
  8441. */
  8442. updatePoseMatrix(matrix: Matrix): TransformNode;
  8443. /**
  8444. * Returns the mesh Pose matrix.
  8445. * @returns the pose matrix
  8446. */
  8447. getPoseMatrix(): Matrix;
  8448. /** @hidden */ private _isSynchronized(): boolean;
  8449. /** @hidden */ private _initCache(): void;
  8450. /**
  8451. * Flag the transform node as dirty (Forcing it to update everything)
  8452. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8453. * @returns this transform node
  8454. */
  8455. markAsDirty(property: string): TransformNode;
  8456. /**
  8457. * Returns the current mesh absolute position.
  8458. * Returns a Vector3.
  8459. */
  8460. readonly absolutePosition: Vector3;
  8461. /**
  8462. * Sets a new matrix to apply before all other transformation
  8463. * @param matrix defines the transform matrix
  8464. * @returns the current TransformNode
  8465. */
  8466. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8467. /**
  8468. * Sets a new pivot matrix to the current node
  8469. * @param matrix defines the new pivot matrix to use
  8470. * @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
  8471. * @returns the current TransformNode
  8472. */
  8473. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8474. /**
  8475. * Returns the mesh pivot matrix.
  8476. * Default : Identity.
  8477. * @returns the matrix
  8478. */
  8479. getPivotMatrix(): Matrix;
  8480. /**
  8481. * Prevents the World matrix to be computed any longer.
  8482. * @returns the TransformNode.
  8483. */
  8484. freezeWorldMatrix(): TransformNode;
  8485. /**
  8486. * Allows back the World matrix computation.
  8487. * @returns the TransformNode.
  8488. */
  8489. unfreezeWorldMatrix(): this;
  8490. /**
  8491. * True if the World matrix has been frozen.
  8492. */
  8493. readonly isWorldMatrixFrozen: boolean;
  8494. /**
  8495. * Retuns the mesh absolute position in the World.
  8496. * @returns a Vector3.
  8497. */
  8498. getAbsolutePosition(): Vector3;
  8499. /**
  8500. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8501. * @param absolutePosition the absolute position to set
  8502. * @returns the TransformNode.
  8503. */
  8504. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8505. /**
  8506. * Sets the mesh position in its local space.
  8507. * @param vector3 the position to set in localspace
  8508. * @returns the TransformNode.
  8509. */
  8510. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8511. /**
  8512. * Returns the mesh position in the local space from the current World matrix values.
  8513. * @returns a new Vector3.
  8514. */
  8515. getPositionExpressedInLocalSpace(): Vector3;
  8516. /**
  8517. * Translates the mesh along the passed Vector3 in its local space.
  8518. * @param vector3 the distance to translate in localspace
  8519. * @returns the TransformNode.
  8520. */
  8521. locallyTranslate(vector3: Vector3): TransformNode;
  8522. private static _lookAtVectorCache;
  8523. /**
  8524. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8525. * @param targetPoint the position (must be in same space as current mesh) to look at
  8526. * @param yawCor optional yaw (y-axis) correction in radians
  8527. * @param pitchCor optional pitch (x-axis) correction in radians
  8528. * @param rollCor optional roll (z-axis) correction in radians
  8529. * @param space the choosen space of the target
  8530. * @returns the TransformNode.
  8531. */
  8532. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8533. /**
  8534. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8535. * This Vector3 is expressed in the World space.
  8536. * @param localAxis axis to rotate
  8537. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8538. */
  8539. getDirection(localAxis: Vector3): Vector3;
  8540. /**
  8541. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8542. * localAxis is expressed in the mesh local space.
  8543. * result is computed in the Wordl space from the mesh World matrix.
  8544. * @param localAxis axis to rotate
  8545. * @param result the resulting transformnode
  8546. * @returns this TransformNode.
  8547. */
  8548. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8549. /**
  8550. * Sets this transform node rotation to the given local axis.
  8551. * @param localAxis the axis in local space
  8552. * @param yawCor optional yaw (y-axis) correction in radians
  8553. * @param pitchCor optional pitch (x-axis) correction in radians
  8554. * @param rollCor optional roll (z-axis) correction in radians
  8555. * @returns this TransformNode
  8556. */
  8557. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8558. /**
  8559. * Sets a new pivot point to the current node
  8560. * @param point defines the new pivot point to use
  8561. * @param space defines if the point is in world or local space (local by default)
  8562. * @returns the current TransformNode
  8563. */
  8564. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8565. /**
  8566. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8567. * @returns the pivot point
  8568. */
  8569. getPivotPoint(): Vector3;
  8570. /**
  8571. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8572. * @param result the vector3 to store the result
  8573. * @returns this TransformNode.
  8574. */
  8575. getPivotPointToRef(result: Vector3): TransformNode;
  8576. /**
  8577. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8578. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8579. */
  8580. getAbsolutePivotPoint(): Vector3;
  8581. /**
  8582. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8583. * @param result vector3 to store the result
  8584. * @returns this TransformNode.
  8585. */
  8586. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8587. /**
  8588. * Defines the passed node as the parent of the current node.
  8589. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8590. * @see https://doc.babylonjs.com/how_to/parenting
  8591. * @param node the node ot set as the parent
  8592. * @returns this TransformNode.
  8593. */
  8594. setParent(node: Nullable<Node>): TransformNode;
  8595. private _nonUniformScaling;
  8596. /**
  8597. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8598. */
  8599. readonly nonUniformScaling: boolean;
  8600. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  8601. /**
  8602. * Attach the current TransformNode to another TransformNode associated with a bone
  8603. * @param bone Bone affecting the TransformNode
  8604. * @param affectedTransformNode TransformNode associated with the bone
  8605. * @returns this object
  8606. */
  8607. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8608. /**
  8609. * Detach the transform node if its associated with a bone
  8610. * @returns this object
  8611. */
  8612. detachFromBone(): TransformNode;
  8613. private static _rotationAxisCache;
  8614. /**
  8615. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8616. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8617. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8618. * The passed axis is also normalized.
  8619. * @param axis the axis to rotate around
  8620. * @param amount the amount to rotate in radians
  8621. * @param space Space to rotate in (Default: local)
  8622. * @returns the TransformNode.
  8623. */
  8624. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8625. /**
  8626. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8627. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8628. * The passed axis is also normalized. .
  8629. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8630. * @param point the point to rotate around
  8631. * @param axis the axis to rotate around
  8632. * @param amount the amount to rotate in radians
  8633. * @returns the TransformNode
  8634. */
  8635. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8636. /**
  8637. * Translates the mesh along the axis vector for the passed distance in the given space.
  8638. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8639. * @param axis the axis to translate in
  8640. * @param distance the distance to translate
  8641. * @param space Space to rotate in (Default: local)
  8642. * @returns the TransformNode.
  8643. */
  8644. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8645. /**
  8646. * Adds a rotation step to the mesh current rotation.
  8647. * x, y, z are Euler angles expressed in radians.
  8648. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8649. * This means this rotation is made in the mesh local space only.
  8650. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8651. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8652. * ```javascript
  8653. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8654. * ```
  8655. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8656. * 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.
  8657. * @param x Rotation to add
  8658. * @param y Rotation to add
  8659. * @param z Rotation to add
  8660. * @returns the TransformNode.
  8661. */
  8662. addRotation(x: number, y: number, z: number): TransformNode;
  8663. /**
  8664. * @hidden
  8665. */
  8666. protected _getEffectiveParent(): Nullable<Node>;
  8667. /**
  8668. * Computes the world matrix of the node
  8669. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8670. * @returns the world matrix
  8671. */
  8672. computeWorldMatrix(force?: boolean): Matrix;
  8673. protected _afterComputeWorldMatrix(): void;
  8674. /**
  8675. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8676. * @param func callback function to add
  8677. *
  8678. * @returns the TransformNode.
  8679. */
  8680. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8681. /**
  8682. * Removes a registered callback function.
  8683. * @param func callback function to remove
  8684. * @returns the TransformNode.
  8685. */
  8686. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8687. /**
  8688. * Gets the position of the current mesh in camera space
  8689. * @param camera defines the camera to use
  8690. * @returns a position
  8691. */
  8692. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8693. /**
  8694. * Returns the distance from the mesh to the active camera
  8695. * @param camera defines the camera to use
  8696. * @returns the distance
  8697. */
  8698. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8699. /**
  8700. * Clone the current transform node
  8701. * @param name Name of the new clone
  8702. * @param newParent New parent for the clone
  8703. * @param doNotCloneChildren Do not clone children hierarchy
  8704. * @returns the new transform node
  8705. */
  8706. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8707. /**
  8708. * Serializes the objects information.
  8709. * @param currentSerializationObject defines the object to serialize in
  8710. * @returns the serialized object
  8711. */
  8712. serialize(currentSerializationObject?: any): any;
  8713. /**
  8714. * Returns a new TransformNode object parsed from the source provided.
  8715. * @param parsedTransformNode is the source.
  8716. * @param scene the scne the object belongs to
  8717. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8718. * @returns a new TransformNode object parsed from the source provided.
  8719. */
  8720. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8721. /**
  8722. * Get all child-transformNodes of this node
  8723. * @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
  8724. * @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
  8725. * @returns an array of TransformNode
  8726. */
  8727. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8728. /**
  8729. * Releases resources associated with this transform node.
  8730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8732. */
  8733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8734. /**
  8735. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8736. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8737. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8738. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8739. * @returns the current mesh
  8740. */
  8741. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8742. }
  8743. }
  8744. declare module BABYLON {
  8745. /**
  8746. * Class used to override all child animations of a given target
  8747. */
  8748. export class AnimationPropertiesOverride {
  8749. /**
  8750. * Gets or sets a value indicating if animation blending must be used
  8751. */
  8752. enableBlending: boolean;
  8753. /**
  8754. * Gets or sets the blending speed to use when enableBlending is true
  8755. */
  8756. blendingSpeed: number;
  8757. /**
  8758. * Gets or sets the default loop mode to use
  8759. */
  8760. loopMode: number;
  8761. }
  8762. }
  8763. declare module BABYLON {
  8764. /**
  8765. * Class used to store bone information
  8766. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8767. */
  8768. export class Bone extends Node {
  8769. /**
  8770. * defines the bone name
  8771. */
  8772. name: string;
  8773. private static _tmpVecs;
  8774. private static _tmpQuat;
  8775. private static _tmpMats;
  8776. /**
  8777. * Gets the list of child bones
  8778. */
  8779. children: Bone[];
  8780. /** Gets the animations associated with this bone */
  8781. animations: Animation[];
  8782. /**
  8783. * Gets or sets bone length
  8784. */
  8785. length: number;
  8786. /**
  8787. * @hidden Internal only
  8788. * Set this value to map this bone to a different index in the transform matrices
  8789. * Set this value to -1 to exclude the bone from the transform matrices
  8790. */ private _index: Nullable<number>;
  8791. private _skeleton;
  8792. private _localMatrix;
  8793. private _restPose;
  8794. private _baseMatrix;
  8795. private _absoluteTransform;
  8796. private _invertedAbsoluteTransform;
  8797. private _parent;
  8798. private _scalingDeterminant;
  8799. private _worldTransform;
  8800. private _localScaling;
  8801. private _localRotation;
  8802. private _localPosition;
  8803. private _needToDecompose;
  8804. private _needToCompose;
  8805. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  8806. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  8807. /** @hidden */
  8808. /** @hidden */ private _matrix: Matrix;
  8809. /**
  8810. * Create a new bone
  8811. * @param name defines the bone name
  8812. * @param skeleton defines the parent skeleton
  8813. * @param parentBone defines the parent (can be null if the bone is the root)
  8814. * @param localMatrix defines the local matrix
  8815. * @param restPose defines the rest pose matrix
  8816. * @param baseMatrix defines the base matrix
  8817. * @param index defines index of the bone in the hiearchy
  8818. */
  8819. constructor(
  8820. /**
  8821. * defines the bone name
  8822. */
  8823. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8824. /**
  8825. * Gets the current object class name.
  8826. * @return the class name
  8827. */
  8828. getClassName(): string;
  8829. /**
  8830. * Gets the parent skeleton
  8831. * @returns a skeleton
  8832. */
  8833. getSkeleton(): Skeleton;
  8834. /**
  8835. * Gets parent bone
  8836. * @returns a bone or null if the bone is the root of the bone hierarchy
  8837. */
  8838. getParent(): Nullable<Bone>;
  8839. /**
  8840. * Returns an array containing the root bones
  8841. * @returns an array containing the root bones
  8842. */
  8843. getChildren(): Array<Bone>;
  8844. /**
  8845. * Sets the parent bone
  8846. * @param parent defines the parent (can be null if the bone is the root)
  8847. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8848. */
  8849. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8850. /**
  8851. * Gets the local matrix
  8852. * @returns a matrix
  8853. */
  8854. getLocalMatrix(): Matrix;
  8855. /**
  8856. * Gets the base matrix (initial matrix which remains unchanged)
  8857. * @returns a matrix
  8858. */
  8859. getBaseMatrix(): Matrix;
  8860. /**
  8861. * Gets the rest pose matrix
  8862. * @returns a matrix
  8863. */
  8864. getRestPose(): Matrix;
  8865. /**
  8866. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8867. */
  8868. getWorldMatrix(): Matrix;
  8869. /**
  8870. * Sets the local matrix to rest pose matrix
  8871. */
  8872. returnToRest(): void;
  8873. /**
  8874. * Gets the inverse of the absolute transform matrix.
  8875. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8876. * @returns a matrix
  8877. */
  8878. getInvertedAbsoluteTransform(): Matrix;
  8879. /**
  8880. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8881. * @returns a matrix
  8882. */
  8883. getAbsoluteTransform(): Matrix;
  8884. /**
  8885. * Links with the given transform node.
  8886. * The local matrix of this bone is copied from the transform node every frame.
  8887. * @param transformNode defines the transform node to link to
  8888. */
  8889. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8890. /** Gets or sets current position (in local space) */
  8891. position: Vector3;
  8892. /** Gets or sets current rotation (in local space) */
  8893. rotation: Vector3;
  8894. /** Gets or sets current rotation quaternion (in local space) */
  8895. rotationQuaternion: Quaternion;
  8896. /** Gets or sets current scaling (in local space) */
  8897. scaling: Vector3;
  8898. /**
  8899. * Gets the animation properties override
  8900. */
  8901. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8902. private _decompose;
  8903. private _compose;
  8904. /**
  8905. * Update the base and local matrices
  8906. * @param matrix defines the new base or local matrix
  8907. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8908. * @param updateLocalMatrix defines if the local matrix should be updated
  8909. */
  8910. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8911. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8912. /**
  8913. * Flag the bone as dirty (Forcing it to update everything)
  8914. */
  8915. markAsDirty(): void;
  8916. /** @hidden */ private _markAsDirtyAndCompose(): void;
  8917. private _markAsDirtyAndDecompose;
  8918. /**
  8919. * Translate the bone in local or world space
  8920. * @param vec The amount to translate the bone
  8921. * @param space The space that the translation is in
  8922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8923. */
  8924. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8925. /**
  8926. * Set the postion of the bone in local or world space
  8927. * @param position The position to set the bone
  8928. * @param space The space that the position is in
  8929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8930. */
  8931. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8932. /**
  8933. * Set the absolute position of the bone (world space)
  8934. * @param position The position to set the bone
  8935. * @param mesh The mesh that this bone is attached to
  8936. */
  8937. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8938. /**
  8939. * Scale the bone on the x, y and z axes (in local space)
  8940. * @param x The amount to scale the bone on the x axis
  8941. * @param y The amount to scale the bone on the y axis
  8942. * @param z The amount to scale the bone on the z axis
  8943. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8944. */
  8945. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8946. /**
  8947. * Set the bone scaling in local space
  8948. * @param scale defines the scaling vector
  8949. */
  8950. setScale(scale: Vector3): void;
  8951. /**
  8952. * Gets the current scaling in local space
  8953. * @returns the current scaling vector
  8954. */
  8955. getScale(): Vector3;
  8956. /**
  8957. * Gets the current scaling in local space and stores it in a target vector
  8958. * @param result defines the target vector
  8959. */
  8960. getScaleToRef(result: Vector3): void;
  8961. /**
  8962. * Set the yaw, pitch, and roll of the bone in local or world space
  8963. * @param yaw The rotation of the bone on the y axis
  8964. * @param pitch The rotation of the bone on the x axis
  8965. * @param roll The rotation of the bone on the z axis
  8966. * @param space The space that the axes of rotation are in
  8967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8968. */
  8969. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8970. /**
  8971. * Add a rotation to the bone on an axis in local or world space
  8972. * @param axis The axis to rotate the bone on
  8973. * @param amount The amount to rotate the bone
  8974. * @param space The space that the axis is in
  8975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8976. */
  8977. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8978. /**
  8979. * Set the rotation of the bone to a particular axis angle in local or world space
  8980. * @param axis The axis to rotate the bone on
  8981. * @param angle The angle that the bone should be rotated to
  8982. * @param space The space that the axis is in
  8983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8984. */
  8985. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8986. /**
  8987. * Set the euler rotation of the bone in local of world space
  8988. * @param rotation The euler rotation that the bone should be set to
  8989. * @param space The space that the rotation is in
  8990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8991. */
  8992. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8993. /**
  8994. * Set the quaternion rotation of the bone in local of world space
  8995. * @param quat The quaternion rotation that the bone should be set to
  8996. * @param space The space that the rotation is in
  8997. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8998. */
  8999. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9000. /**
  9001. * Set the rotation matrix of the bone in local of world space
  9002. * @param rotMat The rotation matrix that the bone should be set to
  9003. * @param space The space that the rotation is in
  9004. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9005. */
  9006. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9007. private _rotateWithMatrix;
  9008. private _getNegativeRotationToRef;
  9009. /**
  9010. * Get the position of the bone in local or world space
  9011. * @param space The space that the returned position is in
  9012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9013. * @returns The position of the bone
  9014. */
  9015. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9016. /**
  9017. * Copy the position of the bone to a vector3 in local or world space
  9018. * @param space The space that the returned position is in
  9019. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9020. * @param result The vector3 to copy the position to
  9021. */
  9022. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9023. /**
  9024. * Get the absolute position of the bone (world space)
  9025. * @param mesh The mesh that this bone is attached to
  9026. * @returns The absolute position of the bone
  9027. */
  9028. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9029. /**
  9030. * Copy the absolute position of the bone (world space) to the result param
  9031. * @param mesh The mesh that this bone is attached to
  9032. * @param result The vector3 to copy the absolute position to
  9033. */
  9034. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9035. /**
  9036. * Compute the absolute transforms of this bone and its children
  9037. */
  9038. computeAbsoluteTransforms(): void;
  9039. /**
  9040. * Get the world direction from an axis that is in the local space of the bone
  9041. * @param localAxis The local direction that is used to compute the world direction
  9042. * @param mesh The mesh that this bone is attached to
  9043. * @returns The world direction
  9044. */
  9045. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9046. /**
  9047. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9048. * @param localAxis The local direction that is used to compute the world direction
  9049. * @param mesh The mesh that this bone is attached to
  9050. * @param result The vector3 that the world direction will be copied to
  9051. */
  9052. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9053. /**
  9054. * Get the euler rotation of the bone in local or world space
  9055. * @param space The space that the rotation should be in
  9056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9057. * @returns The euler rotation
  9058. */
  9059. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9060. /**
  9061. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9062. * @param space The space that the rotation should be in
  9063. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9064. * @param result The vector3 that the rotation should be copied to
  9065. */
  9066. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9067. /**
  9068. * Get the quaternion rotation of the bone in either local or world space
  9069. * @param space The space that the rotation should be in
  9070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9071. * @returns The quaternion rotation
  9072. */
  9073. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9074. /**
  9075. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9076. * @param space The space that the rotation should be in
  9077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9078. * @param result The quaternion that the rotation should be copied to
  9079. */
  9080. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9081. /**
  9082. * Get the rotation matrix of the bone in local or world space
  9083. * @param space The space that the rotation should be in
  9084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9085. * @returns The rotation matrix
  9086. */
  9087. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9088. /**
  9089. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9090. * @param space The space that the rotation should be in
  9091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9092. * @param result The quaternion that the rotation should be copied to
  9093. */
  9094. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9095. /**
  9096. * Get the world position of a point that is in the local space of the bone
  9097. * @param position The local position
  9098. * @param mesh The mesh that this bone is attached to
  9099. * @returns The world position
  9100. */
  9101. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9102. /**
  9103. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9104. * @param position The local position
  9105. * @param mesh The mesh that this bone is attached to
  9106. * @param result The vector3 that the world position should be copied to
  9107. */
  9108. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9109. /**
  9110. * Get the local position of a point that is in world space
  9111. * @param position The world position
  9112. * @param mesh The mesh that this bone is attached to
  9113. * @returns The local position
  9114. */
  9115. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9116. /**
  9117. * Get the local position of a point that is in world space and copy it to the result param
  9118. * @param position The world position
  9119. * @param mesh The mesh that this bone is attached to
  9120. * @param result The vector3 that the local position should be copied to
  9121. */
  9122. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9123. }
  9124. }
  9125. declare module BABYLON {
  9126. interface Engine {
  9127. /**
  9128. * Creates a raw texture
  9129. * @param data defines the data to store in the texture
  9130. * @param width defines the width of the texture
  9131. * @param height defines the height of the texture
  9132. * @param format defines the format of the data
  9133. * @param generateMipMaps defines if the engine should generate the mip levels
  9134. * @param invertY defines if data must be stored with Y axis inverted
  9135. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9136. * @param compression defines the compression used (null by default)
  9137. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9138. * @returns the raw texture inside an InternalTexture
  9139. */
  9140. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9141. /**
  9142. * Update a raw texture
  9143. * @param texture defines the texture to update
  9144. * @param data defines the data to store in the texture
  9145. * @param format defines the format of the data
  9146. * @param invertY defines if data must be stored with Y axis inverted
  9147. */
  9148. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9149. /**
  9150. * Update a raw texture
  9151. * @param texture defines the texture to update
  9152. * @param data defines the data to store in the texture
  9153. * @param format defines the format of the data
  9154. * @param invertY defines if data must be stored with Y axis inverted
  9155. * @param compression defines the compression used (null by default)
  9156. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9157. */
  9158. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9159. /**
  9160. * Creates a new raw cube texture
  9161. * @param data defines the array of data to use to create each face
  9162. * @param size defines the size of the textures
  9163. * @param format defines the format of the data
  9164. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9165. * @param generateMipMaps defines if the engine should generate the mip levels
  9166. * @param invertY defines if data must be stored with Y axis inverted
  9167. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9168. * @param compression defines the compression used (null by default)
  9169. * @returns the cube texture as an InternalTexture
  9170. */
  9171. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9172. /**
  9173. * Update a raw cube texture
  9174. * @param texture defines the texture to udpdate
  9175. * @param data defines the data to store
  9176. * @param format defines the data format
  9177. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9178. * @param invertY defines if data must be stored with Y axis inverted
  9179. */
  9180. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9181. /**
  9182. * Update a raw cube texture
  9183. * @param texture defines the texture to udpdate
  9184. * @param data defines the data to store
  9185. * @param format defines the data format
  9186. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9187. * @param invertY defines if data must be stored with Y axis inverted
  9188. * @param compression defines the compression used (null by default)
  9189. */
  9190. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9191. /**
  9192. * Update a raw cube texture
  9193. * @param texture defines the texture to udpdate
  9194. * @param data defines the data to store
  9195. * @param format defines the data format
  9196. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9197. * @param invertY defines if data must be stored with Y axis inverted
  9198. * @param compression defines the compression used (null by default)
  9199. * @param level defines which level of the texture to update
  9200. */
  9201. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9202. /**
  9203. * Creates a new raw cube texture from a specified url
  9204. * @param url defines the url where the data is located
  9205. * @param scene defines the current scene
  9206. * @param size defines the size of the textures
  9207. * @param format defines the format of the data
  9208. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9209. * @param noMipmap defines if the engine should avoid generating the mip levels
  9210. * @param callback defines a callback used to extract texture data from loaded data
  9211. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9212. * @param onLoad defines a callback called when texture is loaded
  9213. * @param onError defines a callback called if there is an error
  9214. * @returns the cube texture as an InternalTexture
  9215. */
  9216. 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;
  9217. /**
  9218. * Creates a new raw cube texture from a specified url
  9219. * @param url defines the url where the data is located
  9220. * @param scene defines the current scene
  9221. * @param size defines the size of the textures
  9222. * @param format defines the format of the data
  9223. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9224. * @param noMipmap defines if the engine should avoid generating the mip levels
  9225. * @param callback defines a callback used to extract texture data from loaded data
  9226. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9227. * @param onLoad defines a callback called when texture is loaded
  9228. * @param onError defines a callback called if there is an error
  9229. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9230. * @param invertY defines if data must be stored with Y axis inverted
  9231. * @returns the cube texture as an InternalTexture
  9232. */
  9233. 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;
  9234. /**
  9235. * Creates a new raw 3D texture
  9236. * @param data defines the data used to create the texture
  9237. * @param width defines the width of the texture
  9238. * @param height defines the height of the texture
  9239. * @param depth defines the depth of the texture
  9240. * @param format defines the format of the texture
  9241. * @param generateMipMaps defines if the engine must generate mip levels
  9242. * @param invertY defines if data must be stored with Y axis inverted
  9243. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9244. * @param compression defines the compressed used (can be null)
  9245. * @param textureType defines the compressed used (can be null)
  9246. * @returns a new raw 3D texture (stored in an InternalTexture)
  9247. */
  9248. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9249. /**
  9250. * Update a raw 3D texture
  9251. * @param texture defines the texture to update
  9252. * @param data defines the data to store
  9253. * @param format defines the data format
  9254. * @param invertY defines if data must be stored with Y axis inverted
  9255. */
  9256. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9257. /**
  9258. * Update a raw 3D texture
  9259. * @param texture defines the texture to update
  9260. * @param data defines the data to store
  9261. * @param format defines the data format
  9262. * @param invertY defines if data must be stored with Y axis inverted
  9263. * @param compression defines the used compression (can be null)
  9264. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9265. */
  9266. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9267. }
  9268. }
  9269. declare module BABYLON {
  9270. /**
  9271. * Raw texture can help creating a texture directly from an array of data.
  9272. * This can be super useful if you either get the data from an uncompressed source or
  9273. * if you wish to create your texture pixel by pixel.
  9274. */
  9275. export class RawTexture extends Texture {
  9276. /**
  9277. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9278. */
  9279. format: number;
  9280. private _engine;
  9281. /**
  9282. * Instantiates a new RawTexture.
  9283. * Raw texture can help creating a texture directly from an array of data.
  9284. * This can be super useful if you either get the data from an uncompressed source or
  9285. * if you wish to create your texture pixel by pixel.
  9286. * @param data define the array of data to use to create the texture
  9287. * @param width define the width of the texture
  9288. * @param height define the height of the texture
  9289. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9290. * @param scene define the scene the texture belongs to
  9291. * @param generateMipMaps define whether mip maps should be generated or not
  9292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9294. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9295. */
  9296. constructor(data: ArrayBufferView, width: number, height: number,
  9297. /**
  9298. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9299. */
  9300. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9301. /**
  9302. * Updates the texture underlying data.
  9303. * @param data Define the new data of the texture
  9304. */
  9305. update(data: ArrayBufferView): void;
  9306. /**
  9307. * Creates a luminance texture from some data.
  9308. * @param data Define the texture data
  9309. * @param width Define the width of the texture
  9310. * @param height Define the height of the texture
  9311. * @param scene Define the scene the texture belongs to
  9312. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9315. * @returns the luminance texture
  9316. */
  9317. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9318. /**
  9319. * Creates a luminance alpha texture from some data.
  9320. * @param data Define the texture data
  9321. * @param width Define the width of the texture
  9322. * @param height Define the height of the texture
  9323. * @param scene Define the scene the texture belongs to
  9324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9327. * @returns the luminance alpha texture
  9328. */
  9329. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9330. /**
  9331. * Creates an alpha texture from some data.
  9332. * @param data Define the texture data
  9333. * @param width Define the width of the texture
  9334. * @param height Define the height of the texture
  9335. * @param scene Define the scene the texture belongs to
  9336. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9337. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9338. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9339. * @returns the alpha texture
  9340. */
  9341. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9342. /**
  9343. * Creates a RGB texture from some data.
  9344. * @param data Define the texture data
  9345. * @param width Define the width of the texture
  9346. * @param height Define the height of the texture
  9347. * @param scene Define the scene the texture belongs to
  9348. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9349. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9350. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9351. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9352. * @returns the RGB alpha texture
  9353. */
  9354. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9355. /**
  9356. * Creates a RGBA texture from some data.
  9357. * @param data Define the texture data
  9358. * @param width Define the width of the texture
  9359. * @param height Define the height of the texture
  9360. * @param scene Define the scene the texture belongs to
  9361. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9362. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9363. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9364. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9365. * @returns the RGBA texture
  9366. */
  9367. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9368. /**
  9369. * Creates a R texture from some data.
  9370. * @param data Define the texture data
  9371. * @param width Define the width of the texture
  9372. * @param height Define the height of the texture
  9373. * @param scene Define the scene the texture belongs to
  9374. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9375. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9376. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9377. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9378. * @returns the R texture
  9379. */
  9380. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9381. }
  9382. }
  9383. declare module BABYLON {
  9384. /**
  9385. * Defines a runtime animation
  9386. */
  9387. export class RuntimeAnimation {
  9388. private _events;
  9389. /**
  9390. * The current frame of the runtime animation
  9391. */
  9392. private _currentFrame;
  9393. /**
  9394. * The animation used by the runtime animation
  9395. */
  9396. private _animation;
  9397. /**
  9398. * The target of the runtime animation
  9399. */
  9400. private _target;
  9401. /**
  9402. * The initiating animatable
  9403. */
  9404. private _host;
  9405. /**
  9406. * The original value of the runtime animation
  9407. */
  9408. private _originalValue;
  9409. /**
  9410. * The original blend value of the runtime animation
  9411. */
  9412. private _originalBlendValue;
  9413. /**
  9414. * The offsets cache of the runtime animation
  9415. */
  9416. private _offsetsCache;
  9417. /**
  9418. * The high limits cache of the runtime animation
  9419. */
  9420. private _highLimitsCache;
  9421. /**
  9422. * Specifies if the runtime animation has been stopped
  9423. */
  9424. private _stopped;
  9425. /**
  9426. * The blending factor of the runtime animation
  9427. */
  9428. private _blendingFactor;
  9429. /**
  9430. * The BabylonJS scene
  9431. */
  9432. private _scene;
  9433. /**
  9434. * The current value of the runtime animation
  9435. */
  9436. private _currentValue;
  9437. /** @hidden */ private _animationState: _IAnimationState;
  9438. /**
  9439. * The active target of the runtime animation
  9440. */
  9441. private _activeTargets;
  9442. private _currentActiveTarget;
  9443. private _directTarget;
  9444. /**
  9445. * The target path of the runtime animation
  9446. */
  9447. private _targetPath;
  9448. /**
  9449. * The weight of the runtime animation
  9450. */
  9451. private _weight;
  9452. /**
  9453. * The ratio offset of the runtime animation
  9454. */
  9455. private _ratioOffset;
  9456. /**
  9457. * The previous delay of the runtime animation
  9458. */
  9459. private _previousDelay;
  9460. /**
  9461. * The previous ratio of the runtime animation
  9462. */
  9463. private _previousRatio;
  9464. private _enableBlending;
  9465. private _keys;
  9466. private _minFrame;
  9467. private _maxFrame;
  9468. private _minValue;
  9469. private _maxValue;
  9470. private _targetIsArray;
  9471. /**
  9472. * Gets the current frame of the runtime animation
  9473. */
  9474. readonly currentFrame: number;
  9475. /**
  9476. * Gets the weight of the runtime animation
  9477. */
  9478. readonly weight: number;
  9479. /**
  9480. * Gets the current value of the runtime animation
  9481. */
  9482. readonly currentValue: any;
  9483. /**
  9484. * Gets the target path of the runtime animation
  9485. */
  9486. readonly targetPath: string;
  9487. /**
  9488. * Gets the actual target of the runtime animation
  9489. */
  9490. readonly target: any;
  9491. /** @hidden */ private _onLoop: () => void;
  9492. /**
  9493. * Create a new RuntimeAnimation object
  9494. * @param target defines the target of the animation
  9495. * @param animation defines the source animation object
  9496. * @param scene defines the hosting scene
  9497. * @param host defines the initiating Animatable
  9498. */
  9499. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9500. private _preparePath;
  9501. /**
  9502. * Gets the animation from the runtime animation
  9503. */
  9504. readonly animation: Animation;
  9505. /**
  9506. * Resets the runtime animation to the beginning
  9507. * @param restoreOriginal defines whether to restore the target property to the original value
  9508. */
  9509. reset(restoreOriginal?: boolean): void;
  9510. /**
  9511. * Specifies if the runtime animation is stopped
  9512. * @returns Boolean specifying if the runtime animation is stopped
  9513. */
  9514. isStopped(): boolean;
  9515. /**
  9516. * Disposes of the runtime animation
  9517. */
  9518. dispose(): void;
  9519. /**
  9520. * Apply the interpolated value to the target
  9521. * @param currentValue defines the value computed by the animation
  9522. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9523. */
  9524. setValue(currentValue: any, weight: number): void;
  9525. private _getOriginalValues;
  9526. private _setValue;
  9527. /**
  9528. * Gets the loop pmode of the runtime animation
  9529. * @returns Loop Mode
  9530. */
  9531. private _getCorrectLoopMode;
  9532. /**
  9533. * Move the current animation to a given frame
  9534. * @param frame defines the frame to move to
  9535. */
  9536. goToFrame(frame: number): void;
  9537. /**
  9538. * @hidden Internal use only
  9539. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9540. /**
  9541. * Execute the current animation
  9542. * @param delay defines the delay to add to the current frame
  9543. * @param from defines the lower bound of the animation range
  9544. * @param to defines the upper bound of the animation range
  9545. * @param loop defines if the current animation must loop
  9546. * @param speedRatio defines the current speed ratio
  9547. * @param weight defines the weight of the animation (default is -1 so no weight)
  9548. * @param onLoop optional callback called when animation loops
  9549. * @returns a boolean indicating if the animation is running
  9550. */
  9551. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9552. }
  9553. }
  9554. declare module BABYLON {
  9555. /**
  9556. * Class used to store an actual running animation
  9557. */
  9558. export class Animatable {
  9559. /** defines the target object */
  9560. target: any;
  9561. /** defines the starting frame number (default is 0) */
  9562. fromFrame: number;
  9563. /** defines the ending frame number (default is 100) */
  9564. toFrame: number;
  9565. /** defines if the animation must loop (default is false) */
  9566. loopAnimation: boolean;
  9567. /** defines a callback to call when animation ends if it is not looping */
  9568. onAnimationEnd?: (() => void) | null | undefined;
  9569. /** defines a callback to call when animation loops */
  9570. onAnimationLoop?: (() => void) | null | undefined;
  9571. private _localDelayOffset;
  9572. private _pausedDelay;
  9573. private _runtimeAnimations;
  9574. private _paused;
  9575. private _scene;
  9576. private _speedRatio;
  9577. private _weight;
  9578. private _syncRoot;
  9579. /**
  9580. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9581. * This will only apply for non looping animation (default is true)
  9582. */
  9583. disposeOnEnd: boolean;
  9584. /**
  9585. * Gets a boolean indicating if the animation has started
  9586. */
  9587. animationStarted: boolean;
  9588. /**
  9589. * Observer raised when the animation ends
  9590. */
  9591. onAnimationEndObservable: Observable<Animatable>;
  9592. /**
  9593. * Observer raised when the animation loops
  9594. */
  9595. onAnimationLoopObservable: Observable<Animatable>;
  9596. /**
  9597. * Gets the root Animatable used to synchronize and normalize animations
  9598. */
  9599. readonly syncRoot: Nullable<Animatable>;
  9600. /**
  9601. * Gets the current frame of the first RuntimeAnimation
  9602. * Used to synchronize Animatables
  9603. */
  9604. readonly masterFrame: number;
  9605. /**
  9606. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9607. */
  9608. weight: number;
  9609. /**
  9610. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9611. */
  9612. speedRatio: number;
  9613. /**
  9614. * Creates a new Animatable
  9615. * @param scene defines the hosting scene
  9616. * @param target defines the target object
  9617. * @param fromFrame defines the starting frame number (default is 0)
  9618. * @param toFrame defines the ending frame number (default is 100)
  9619. * @param loopAnimation defines if the animation must loop (default is false)
  9620. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9621. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9622. * @param animations defines a group of animation to add to the new Animatable
  9623. * @param onAnimationLoop defines a callback to call when animation loops
  9624. */
  9625. constructor(scene: Scene,
  9626. /** defines the target object */
  9627. target: any,
  9628. /** defines the starting frame number (default is 0) */
  9629. fromFrame?: number,
  9630. /** defines the ending frame number (default is 100) */
  9631. toFrame?: number,
  9632. /** defines if the animation must loop (default is false) */
  9633. loopAnimation?: boolean, speedRatio?: number,
  9634. /** defines a callback to call when animation ends if it is not looping */
  9635. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9636. /** defines a callback to call when animation loops */
  9637. onAnimationLoop?: (() => void) | null | undefined);
  9638. /**
  9639. * Synchronize and normalize current Animatable with a source Animatable
  9640. * This is useful when using animation weights and when animations are not of the same length
  9641. * @param root defines the root Animatable to synchronize with
  9642. * @returns the current Animatable
  9643. */
  9644. syncWith(root: Animatable): Animatable;
  9645. /**
  9646. * Gets the list of runtime animations
  9647. * @returns an array of RuntimeAnimation
  9648. */
  9649. getAnimations(): RuntimeAnimation[];
  9650. /**
  9651. * Adds more animations to the current animatable
  9652. * @param target defines the target of the animations
  9653. * @param animations defines the new animations to add
  9654. */
  9655. appendAnimations(target: any, animations: Animation[]): void;
  9656. /**
  9657. * Gets the source animation for a specific property
  9658. * @param property defines the propertyu to look for
  9659. * @returns null or the source animation for the given property
  9660. */
  9661. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9662. /**
  9663. * Gets the runtime animation for a specific property
  9664. * @param property defines the propertyu to look for
  9665. * @returns null or the runtime animation for the given property
  9666. */
  9667. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9668. /**
  9669. * Resets the animatable to its original state
  9670. */
  9671. reset(): void;
  9672. /**
  9673. * Allows the animatable to blend with current running animations
  9674. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9675. * @param blendingSpeed defines the blending speed to use
  9676. */
  9677. enableBlending(blendingSpeed: number): void;
  9678. /**
  9679. * Disable animation blending
  9680. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9681. */
  9682. disableBlending(): void;
  9683. /**
  9684. * Jump directly to a given frame
  9685. * @param frame defines the frame to jump to
  9686. */
  9687. goToFrame(frame: number): void;
  9688. /**
  9689. * Pause the animation
  9690. */
  9691. pause(): void;
  9692. /**
  9693. * Restart the animation
  9694. */
  9695. restart(): void;
  9696. private _raiseOnAnimationEnd;
  9697. /**
  9698. * Stop and delete the current animation
  9699. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9700. * @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)
  9701. */
  9702. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9703. /**
  9704. * Wait asynchronously for the animation to end
  9705. * @returns a promise which will be fullfilled when the animation ends
  9706. */
  9707. waitAsync(): Promise<Animatable>;
  9708. /** @hidden */ private _animate(delay: number): boolean;
  9709. }
  9710. interface Scene {
  9711. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9712. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  9713. totalWeight: number;
  9714. animations: RuntimeAnimation[];
  9715. originalValue: Matrix;
  9716. }): any;
  9717. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  9718. totalWeight: number;
  9719. animations: RuntimeAnimation[];
  9720. originalValue: Quaternion;
  9721. }, refQuaternion: Quaternion): Quaternion;
  9722. /** @hidden */ private _processLateAnimationBindings(): void;
  9723. /**
  9724. * Will start the animation sequence of a given target
  9725. * @param target defines the target
  9726. * @param from defines from which frame should animation start
  9727. * @param to defines until which frame should animation run.
  9728. * @param weight defines the weight to apply to the animation (1.0 by default)
  9729. * @param loop defines if the animation loops
  9730. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9731. * @param onAnimationEnd defines the function to be executed when the animation ends
  9732. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9733. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9734. * @param onAnimationLoop defines the callback to call when an animation loops
  9735. * @returns the animatable object created for this animation
  9736. */
  9737. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9738. /**
  9739. * Will start the animation sequence of a given target
  9740. * @param target defines the target
  9741. * @param from defines from which frame should animation start
  9742. * @param to defines until which frame should animation run.
  9743. * @param loop defines if the animation loops
  9744. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9745. * @param onAnimationEnd defines the function to be executed when the animation ends
  9746. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9747. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9748. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9749. * @param onAnimationLoop defines the callback to call when an animation loops
  9750. * @returns the animatable object created for this animation
  9751. */
  9752. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9753. /**
  9754. * Will start the animation sequence of a given target and its hierarchy
  9755. * @param target defines the target
  9756. * @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.
  9757. * @param from defines from which frame should animation start
  9758. * @param to defines until which frame should animation run.
  9759. * @param loop defines if the animation loops
  9760. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9761. * @param onAnimationEnd defines the function to be executed when the animation ends
  9762. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9763. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9764. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9765. * @param onAnimationLoop defines the callback to call when an animation loops
  9766. * @returns the list of created animatables
  9767. */
  9768. 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[];
  9769. /**
  9770. * Begin a new animation on a given node
  9771. * @param target defines the target where the animation will take place
  9772. * @param animations defines the list of animations to start
  9773. * @param from defines the initial value
  9774. * @param to defines the final value
  9775. * @param loop defines if you want animation to loop (off by default)
  9776. * @param speedRatio defines the speed ratio to apply to all animations
  9777. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9778. * @param onAnimationLoop defines the callback to call when an animation loops
  9779. * @returns the list of created animatables
  9780. */
  9781. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9782. /**
  9783. * Begin a new animation on a given node and its hierarchy
  9784. * @param target defines the root node where the animation will take place
  9785. * @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.
  9786. * @param animations defines the list of animations to start
  9787. * @param from defines the initial value
  9788. * @param to defines the final value
  9789. * @param loop defines if you want animation to loop (off by default)
  9790. * @param speedRatio defines the speed ratio to apply to all animations
  9791. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9792. * @param onAnimationLoop defines the callback to call when an animation loops
  9793. * @returns the list of animatables created for all nodes
  9794. */
  9795. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9796. /**
  9797. * Gets the animatable associated with a specific target
  9798. * @param target defines the target of the animatable
  9799. * @returns the required animatable if found
  9800. */
  9801. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9802. /**
  9803. * Gets all animatables associated with a given target
  9804. * @param target defines the target to look animatables for
  9805. * @returns an array of Animatables
  9806. */
  9807. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9808. /**
  9809. * Stops and removes all animations that have been applied to the scene
  9810. */
  9811. stopAllAnimations(): void;
  9812. }
  9813. interface Bone {
  9814. /**
  9815. * Copy an animation range from another bone
  9816. * @param source defines the source bone
  9817. * @param rangeName defines the range name to copy
  9818. * @param frameOffset defines the frame offset
  9819. * @param rescaleAsRequired defines if rescaling must be applied if required
  9820. * @param skelDimensionsRatio defines the scaling ratio
  9821. * @returns true if operation was successful
  9822. */
  9823. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9824. }
  9825. }
  9826. declare module BABYLON {
  9827. /**
  9828. * Class used to handle skinning animations
  9829. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9830. */
  9831. export class Skeleton implements IAnimatable {
  9832. /** defines the skeleton name */
  9833. name: string;
  9834. /** defines the skeleton Id */
  9835. id: string;
  9836. /**
  9837. * Defines the list of child bones
  9838. */
  9839. bones: Bone[];
  9840. /**
  9841. * Defines an estimate of the dimension of the skeleton at rest
  9842. */
  9843. dimensionsAtRest: Vector3;
  9844. /**
  9845. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9846. */
  9847. needInitialSkinMatrix: boolean;
  9848. /**
  9849. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9850. */
  9851. overrideMesh: Nullable<AbstractMesh>;
  9852. /**
  9853. * Gets the list of animations attached to this skeleton
  9854. */
  9855. animations: Array<Animation>;
  9856. private _scene;
  9857. private _isDirty;
  9858. private _transformMatrices;
  9859. private _transformMatrixTexture;
  9860. private _meshesWithPoseMatrix;
  9861. private _animatables;
  9862. private _identity;
  9863. private _synchronizedWithMesh;
  9864. private _ranges;
  9865. private _lastAbsoluteTransformsUpdateId;
  9866. private _canUseTextureForBones;
  9867. private _uniqueId;
  9868. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  9869. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  9870. /**
  9871. * Specifies if the skeleton should be serialized
  9872. */
  9873. doNotSerialize: boolean;
  9874. private _useTextureToStoreBoneMatrices;
  9875. /**
  9876. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  9877. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  9878. */
  9879. useTextureToStoreBoneMatrices: boolean;
  9880. private _animationPropertiesOverride;
  9881. /**
  9882. * Gets or sets the animation properties override
  9883. */
  9884. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9885. /**
  9886. * List of inspectable custom properties (used by the Inspector)
  9887. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  9888. */
  9889. inspectableCustomProperties: IInspectable[];
  9890. /**
  9891. * An observable triggered before computing the skeleton's matrices
  9892. */
  9893. onBeforeComputeObservable: Observable<Skeleton>;
  9894. /**
  9895. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  9896. */
  9897. readonly isUsingTextureForMatrices: boolean;
  9898. /**
  9899. * Gets the unique ID of this skeleton
  9900. */
  9901. readonly uniqueId: number;
  9902. /**
  9903. * Creates a new skeleton
  9904. * @param name defines the skeleton name
  9905. * @param id defines the skeleton Id
  9906. * @param scene defines the hosting scene
  9907. */
  9908. constructor(
  9909. /** defines the skeleton name */
  9910. name: string,
  9911. /** defines the skeleton Id */
  9912. id: string, scene: Scene);
  9913. /**
  9914. * Gets the current object class name.
  9915. * @return the class name
  9916. */
  9917. getClassName(): string;
  9918. /**
  9919. * Returns an array containing the root bones
  9920. * @returns an array containing the root bones
  9921. */
  9922. getChildren(): Array<Bone>;
  9923. /**
  9924. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9925. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9926. * @returns a Float32Array containing matrices data
  9927. */
  9928. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9929. /**
  9930. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  9931. * @returns a raw texture containing the data
  9932. */
  9933. getTransformMatrixTexture(): Nullable<RawTexture>;
  9934. /**
  9935. * Gets the current hosting scene
  9936. * @returns a scene object
  9937. */
  9938. getScene(): Scene;
  9939. /**
  9940. * Gets a string representing the current skeleton data
  9941. * @param fullDetails defines a boolean indicating if we want a verbose version
  9942. * @returns a string representing the current skeleton data
  9943. */
  9944. toString(fullDetails?: boolean): string;
  9945. /**
  9946. * Get bone's index searching by name
  9947. * @param name defines bone's name to search for
  9948. * @return the indice of the bone. Returns -1 if not found
  9949. */
  9950. getBoneIndexByName(name: string): number;
  9951. /**
  9952. * Creater a new animation range
  9953. * @param name defines the name of the range
  9954. * @param from defines the start key
  9955. * @param to defines the end key
  9956. */
  9957. createAnimationRange(name: string, from: number, to: number): void;
  9958. /**
  9959. * Delete a specific animation range
  9960. * @param name defines the name of the range
  9961. * @param deleteFrames defines if frames must be removed as well
  9962. */
  9963. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9964. /**
  9965. * Gets a specific animation range
  9966. * @param name defines the name of the range to look for
  9967. * @returns the requested animation range or null if not found
  9968. */
  9969. getAnimationRange(name: string): Nullable<AnimationRange>;
  9970. /**
  9971. * Gets the list of all animation ranges defined on this skeleton
  9972. * @returns an array
  9973. */
  9974. getAnimationRanges(): Nullable<AnimationRange>[];
  9975. /**
  9976. * Copy animation range from a source skeleton.
  9977. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9978. * @param source defines the source skeleton
  9979. * @param name defines the name of the range to copy
  9980. * @param rescaleAsRequired defines if rescaling must be applied if required
  9981. * @returns true if operation was successful
  9982. */
  9983. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9984. /**
  9985. * Forces the skeleton to go to rest pose
  9986. */
  9987. returnToRest(): void;
  9988. private _getHighestAnimationFrame;
  9989. /**
  9990. * Begin a specific animation range
  9991. * @param name defines the name of the range to start
  9992. * @param loop defines if looping must be turned on (false by default)
  9993. * @param speedRatio defines the speed ratio to apply (1 by default)
  9994. * @param onAnimationEnd defines a callback which will be called when animation will end
  9995. * @returns a new animatable
  9996. */
  9997. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  9998. /** @hidden */ private _markAsDirty(): void;
  9999. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10000. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10001. private _computeTransformMatrices;
  10002. /**
  10003. * Build all resources required to render a skeleton
  10004. */
  10005. prepare(): void;
  10006. /**
  10007. * Gets the list of animatables currently running for this skeleton
  10008. * @returns an array of animatables
  10009. */
  10010. getAnimatables(): IAnimatable[];
  10011. /**
  10012. * Clone the current skeleton
  10013. * @param name defines the name of the new skeleton
  10014. * @param id defines the id of the new skeleton
  10015. * @returns the new skeleton
  10016. */
  10017. clone(name: string, id: string): Skeleton;
  10018. /**
  10019. * Enable animation blending for this skeleton
  10020. * @param blendingSpeed defines the blending speed to apply
  10021. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10022. */
  10023. enableBlending(blendingSpeed?: number): void;
  10024. /**
  10025. * Releases all resources associated with the current skeleton
  10026. */
  10027. dispose(): void;
  10028. /**
  10029. * Serialize the skeleton in a JSON object
  10030. * @returns a JSON object
  10031. */
  10032. serialize(): any;
  10033. /**
  10034. * Creates a new skeleton from serialized data
  10035. * @param parsedSkeleton defines the serialized data
  10036. * @param scene defines the hosting scene
  10037. * @returns a new skeleton
  10038. */
  10039. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10040. /**
  10041. * Compute all node absolute transforms
  10042. * @param forceUpdate defines if computation must be done even if cache is up to date
  10043. */
  10044. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10045. /**
  10046. * Gets the root pose matrix
  10047. * @returns a matrix
  10048. */
  10049. getPoseMatrix(): Nullable<Matrix>;
  10050. /**
  10051. * Sorts bones per internal index
  10052. */
  10053. sortBones(): void;
  10054. private _sortBones;
  10055. }
  10056. }
  10057. declare module BABYLON {
  10058. /**
  10059. * Defines a target to use with MorphTargetManager
  10060. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10061. */
  10062. export class MorphTarget implements IAnimatable {
  10063. /** defines the name of the target */
  10064. name: string;
  10065. /**
  10066. * Gets or sets the list of animations
  10067. */
  10068. animations: Animation[];
  10069. private _scene;
  10070. private _positions;
  10071. private _normals;
  10072. private _tangents;
  10073. private _uvs;
  10074. private _influence;
  10075. /**
  10076. * Observable raised when the influence changes
  10077. */
  10078. onInfluenceChanged: Observable<boolean>;
  10079. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  10080. /**
  10081. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10082. */
  10083. influence: number;
  10084. /**
  10085. * Gets or sets the id of the morph Target
  10086. */
  10087. id: string;
  10088. private _animationPropertiesOverride;
  10089. /**
  10090. * Gets or sets the animation properties override
  10091. */
  10092. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10093. /**
  10094. * Creates a new MorphTarget
  10095. * @param name defines the name of the target
  10096. * @param influence defines the influence to use
  10097. * @param scene defines the scene the morphtarget belongs to
  10098. */
  10099. constructor(
  10100. /** defines the name of the target */
  10101. name: string, influence?: number, scene?: Nullable<Scene>);
  10102. /**
  10103. * Gets a boolean defining if the target contains position data
  10104. */
  10105. readonly hasPositions: boolean;
  10106. /**
  10107. * Gets a boolean defining if the target contains normal data
  10108. */
  10109. readonly hasNormals: boolean;
  10110. /**
  10111. * Gets a boolean defining if the target contains tangent data
  10112. */
  10113. readonly hasTangents: boolean;
  10114. /**
  10115. * Gets a boolean defining if the target contains texture coordinates data
  10116. */
  10117. readonly hasUVs: boolean;
  10118. /**
  10119. * Affects position data to this target
  10120. * @param data defines the position data to use
  10121. */
  10122. setPositions(data: Nullable<FloatArray>): void;
  10123. /**
  10124. * Gets the position data stored in this target
  10125. * @returns a FloatArray containing the position data (or null if not present)
  10126. */
  10127. getPositions(): Nullable<FloatArray>;
  10128. /**
  10129. * Affects normal data to this target
  10130. * @param data defines the normal data to use
  10131. */
  10132. setNormals(data: Nullable<FloatArray>): void;
  10133. /**
  10134. * Gets the normal data stored in this target
  10135. * @returns a FloatArray containing the normal data (or null if not present)
  10136. */
  10137. getNormals(): Nullable<FloatArray>;
  10138. /**
  10139. * Affects tangent data to this target
  10140. * @param data defines the tangent data to use
  10141. */
  10142. setTangents(data: Nullable<FloatArray>): void;
  10143. /**
  10144. * Gets the tangent data stored in this target
  10145. * @returns a FloatArray containing the tangent data (or null if not present)
  10146. */
  10147. getTangents(): Nullable<FloatArray>;
  10148. /**
  10149. * Affects texture coordinates data to this target
  10150. * @param data defines the texture coordinates data to use
  10151. */
  10152. setUVs(data: Nullable<FloatArray>): void;
  10153. /**
  10154. * Gets the texture coordinates data stored in this target
  10155. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10156. */
  10157. getUVs(): Nullable<FloatArray>;
  10158. /**
  10159. * Serializes the current target into a Serialization object
  10160. * @returns the serialized object
  10161. */
  10162. serialize(): any;
  10163. /**
  10164. * Returns the string "MorphTarget"
  10165. * @returns "MorphTarget"
  10166. */
  10167. getClassName(): string;
  10168. /**
  10169. * Creates a new target from serialized data
  10170. * @param serializationObject defines the serialized data to use
  10171. * @returns a new MorphTarget
  10172. */
  10173. static Parse(serializationObject: any): MorphTarget;
  10174. /**
  10175. * Creates a MorphTarget from mesh data
  10176. * @param mesh defines the source mesh
  10177. * @param name defines the name to use for the new target
  10178. * @param influence defines the influence to attach to the target
  10179. * @returns a new MorphTarget
  10180. */
  10181. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10182. }
  10183. }
  10184. declare module BABYLON {
  10185. /**
  10186. * This class is used to deform meshes using morphing between different targets
  10187. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10188. */
  10189. export class MorphTargetManager {
  10190. private _targets;
  10191. private _targetInfluenceChangedObservers;
  10192. private _targetDataLayoutChangedObservers;
  10193. private _activeTargets;
  10194. private _scene;
  10195. private _influences;
  10196. private _supportsNormals;
  10197. private _supportsTangents;
  10198. private _supportsUVs;
  10199. private _vertexCount;
  10200. private _uniqueId;
  10201. private _tempInfluences;
  10202. /**
  10203. * Creates a new MorphTargetManager
  10204. * @param scene defines the current scene
  10205. */
  10206. constructor(scene?: Nullable<Scene>);
  10207. /**
  10208. * Gets the unique ID of this manager
  10209. */
  10210. readonly uniqueId: number;
  10211. /**
  10212. * Gets the number of vertices handled by this manager
  10213. */
  10214. readonly vertexCount: number;
  10215. /**
  10216. * Gets a boolean indicating if this manager supports morphing of normals
  10217. */
  10218. readonly supportsNormals: boolean;
  10219. /**
  10220. * Gets a boolean indicating if this manager supports morphing of tangents
  10221. */
  10222. readonly supportsTangents: boolean;
  10223. /**
  10224. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10225. */
  10226. readonly supportsUVs: boolean;
  10227. /**
  10228. * Gets the number of targets stored in this manager
  10229. */
  10230. readonly numTargets: number;
  10231. /**
  10232. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10233. */
  10234. readonly numInfluencers: number;
  10235. /**
  10236. * Gets the list of influences (one per target)
  10237. */
  10238. readonly influences: Float32Array;
  10239. /**
  10240. * Gets the active target at specified index. An active target is a target with an influence > 0
  10241. * @param index defines the index to check
  10242. * @returns the requested target
  10243. */
  10244. getActiveTarget(index: number): MorphTarget;
  10245. /**
  10246. * Gets the target at specified index
  10247. * @param index defines the index to check
  10248. * @returns the requested target
  10249. */
  10250. getTarget(index: number): MorphTarget;
  10251. /**
  10252. * Add a new target to this manager
  10253. * @param target defines the target to add
  10254. */
  10255. addTarget(target: MorphTarget): void;
  10256. /**
  10257. * Removes a target from the manager
  10258. * @param target defines the target to remove
  10259. */
  10260. removeTarget(target: MorphTarget): void;
  10261. /**
  10262. * Serializes the current manager into a Serialization object
  10263. * @returns the serialized object
  10264. */
  10265. serialize(): any;
  10266. private _syncActiveTargets;
  10267. /**
  10268. * Syncrhonize the targets with all the meshes using this morph target manager
  10269. */
  10270. synchronize(): void;
  10271. /**
  10272. * Creates a new MorphTargetManager from serialized data
  10273. * @param serializationObject defines the serialized data
  10274. * @param scene defines the hosting scene
  10275. * @returns the new MorphTargetManager
  10276. */
  10277. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Groups all the scene component constants in one place to ease maintenance.
  10283. * @hidden
  10284. */
  10285. export class SceneComponentConstants {
  10286. static readonly NAME_EFFECTLAYER: string;
  10287. static readonly NAME_LAYER: string;
  10288. static readonly NAME_LENSFLARESYSTEM: string;
  10289. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10290. static readonly NAME_PARTICLESYSTEM: string;
  10291. static readonly NAME_GAMEPAD: string;
  10292. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10293. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10294. static readonly NAME_DEPTHRENDERER: string;
  10295. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10296. static readonly NAME_SPRITE: string;
  10297. static readonly NAME_OUTLINERENDERER: string;
  10298. static readonly NAME_PROCEDURALTEXTURE: string;
  10299. static readonly NAME_SHADOWGENERATOR: string;
  10300. static readonly NAME_OCTREE: string;
  10301. static readonly NAME_PHYSICSENGINE: string;
  10302. static readonly NAME_AUDIO: string;
  10303. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10304. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10305. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10306. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10307. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10308. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10309. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10310. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10311. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10312. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10313. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10314. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10315. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10316. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10317. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10318. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10319. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10320. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10321. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10322. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10323. static readonly STEP_AFTERRENDER_AUDIO: number;
  10324. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10325. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10326. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10327. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10328. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10329. static readonly STEP_POINTERMOVE_SPRITE: number;
  10330. static readonly STEP_POINTERDOWN_SPRITE: number;
  10331. static readonly STEP_POINTERUP_SPRITE: number;
  10332. }
  10333. /**
  10334. * This represents a scene component.
  10335. *
  10336. * This is used to decouple the dependency the scene is having on the different workloads like
  10337. * layers, post processes...
  10338. */
  10339. export interface ISceneComponent {
  10340. /**
  10341. * The name of the component. Each component must have a unique name.
  10342. */
  10343. name: string;
  10344. /**
  10345. * The scene the component belongs to.
  10346. */
  10347. scene: Scene;
  10348. /**
  10349. * Register the component to one instance of a scene.
  10350. */
  10351. register(): void;
  10352. /**
  10353. * Rebuilds the elements related to this component in case of
  10354. * context lost for instance.
  10355. */
  10356. rebuild(): void;
  10357. /**
  10358. * Disposes the component and the associated ressources.
  10359. */
  10360. dispose(): void;
  10361. }
  10362. /**
  10363. * This represents a SERIALIZABLE scene component.
  10364. *
  10365. * This extends Scene Component to add Serialization methods on top.
  10366. */
  10367. export interface ISceneSerializableComponent extends ISceneComponent {
  10368. /**
  10369. * Adds all the elements from the container to the scene
  10370. * @param container the container holding the elements
  10371. */
  10372. addFromContainer(container: AbstractScene): void;
  10373. /**
  10374. * Removes all the elements in the container from the scene
  10375. * @param container contains the elements to remove
  10376. * @param dispose if the removed element should be disposed (default: false)
  10377. */
  10378. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10379. /**
  10380. * Serializes the component data to the specified json object
  10381. * @param serializationObject The object to serialize to
  10382. */
  10383. serialize(serializationObject: any): void;
  10384. }
  10385. /**
  10386. * Strong typing of a Mesh related stage step action
  10387. */
  10388. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10389. /**
  10390. * Strong typing of a Evaluate Sub Mesh related stage step action
  10391. */
  10392. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10393. /**
  10394. * Strong typing of a Active Mesh related stage step action
  10395. */
  10396. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10397. /**
  10398. * Strong typing of a Camera related stage step action
  10399. */
  10400. export type CameraStageAction = (camera: Camera) => void;
  10401. /**
  10402. * Strong typing of a Camera Frame buffer related stage step action
  10403. */
  10404. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10405. /**
  10406. * Strong typing of a Render Target related stage step action
  10407. */
  10408. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10409. /**
  10410. * Strong typing of a RenderingGroup related stage step action
  10411. */
  10412. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10413. /**
  10414. * Strong typing of a Mesh Render related stage step action
  10415. */
  10416. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10417. /**
  10418. * Strong typing of a simple stage step action
  10419. */
  10420. export type SimpleStageAction = () => void;
  10421. /**
  10422. * Strong typing of a render target action.
  10423. */
  10424. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10425. /**
  10426. * Strong typing of a pointer move action.
  10427. */
  10428. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10429. /**
  10430. * Strong typing of a pointer up/down action.
  10431. */
  10432. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10433. /**
  10434. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10435. * @hidden
  10436. */
  10437. export class Stage<T extends Function> extends Array<{
  10438. index: number;
  10439. component: ISceneComponent;
  10440. action: T;
  10441. }> {
  10442. /**
  10443. * Hide ctor from the rest of the world.
  10444. * @param items The items to add.
  10445. */
  10446. private constructor();
  10447. /**
  10448. * Creates a new Stage.
  10449. * @returns A new instance of a Stage
  10450. */
  10451. static Create<T extends Function>(): Stage<T>;
  10452. /**
  10453. * Registers a step in an ordered way in the targeted stage.
  10454. * @param index Defines the position to register the step in
  10455. * @param component Defines the component attached to the step
  10456. * @param action Defines the action to launch during the step
  10457. */
  10458. registerStep(index: number, component: ISceneComponent, action: T): void;
  10459. /**
  10460. * Clears all the steps from the stage.
  10461. */
  10462. clear(): void;
  10463. }
  10464. }
  10465. declare module BABYLON {
  10466. /**
  10467. * Class used to represent a specific level of detail of a mesh
  10468. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10469. */
  10470. export class MeshLODLevel {
  10471. /** Defines the distance where this level should star being displayed */
  10472. distance: number;
  10473. /** Defines the mesh to use to render this level */
  10474. mesh: Nullable<Mesh>;
  10475. /**
  10476. * Creates a new LOD level
  10477. * @param distance defines the distance where this level should star being displayed
  10478. * @param mesh defines the mesh to use to render this level
  10479. */
  10480. constructor(
  10481. /** Defines the distance where this level should star being displayed */
  10482. distance: number,
  10483. /** Defines the mesh to use to render this level */
  10484. mesh: Nullable<Mesh>);
  10485. }
  10486. }
  10487. declare module BABYLON {
  10488. /**
  10489. * Interface describing all the common properties and methods a shadow light needs to implement.
  10490. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10491. * as well as binding the different shadow properties to the effects.
  10492. */
  10493. export interface IShadowLight extends Light {
  10494. /**
  10495. * The light id in the scene (used in scene.findLighById for instance)
  10496. */
  10497. id: string;
  10498. /**
  10499. * The position the shdow will be casted from.
  10500. */
  10501. position: Vector3;
  10502. /**
  10503. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10504. */
  10505. direction: Vector3;
  10506. /**
  10507. * The transformed position. Position of the light in world space taking parenting in account.
  10508. */
  10509. transformedPosition: Vector3;
  10510. /**
  10511. * The transformed direction. Direction of the light in world space taking parenting in account.
  10512. */
  10513. transformedDirection: Vector3;
  10514. /**
  10515. * The friendly name of the light in the scene.
  10516. */
  10517. name: string;
  10518. /**
  10519. * Defines the shadow projection clipping minimum z value.
  10520. */
  10521. shadowMinZ: number;
  10522. /**
  10523. * Defines the shadow projection clipping maximum z value.
  10524. */
  10525. shadowMaxZ: number;
  10526. /**
  10527. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10528. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10529. */
  10530. computeTransformedInformation(): boolean;
  10531. /**
  10532. * Gets the scene the light belongs to.
  10533. * @returns The scene
  10534. */
  10535. getScene(): Scene;
  10536. /**
  10537. * Callback defining a custom Projection Matrix Builder.
  10538. * This can be used to override the default projection matrix computation.
  10539. */
  10540. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10541. /**
  10542. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10543. * @param matrix The materix to updated with the projection information
  10544. * @param viewMatrix The transform matrix of the light
  10545. * @param renderList The list of mesh to render in the map
  10546. * @returns The current light
  10547. */
  10548. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10549. /**
  10550. * Gets the current depth scale used in ESM.
  10551. * @returns The scale
  10552. */
  10553. getDepthScale(): number;
  10554. /**
  10555. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10556. * @returns true if a cube texture needs to be use
  10557. */
  10558. needCube(): boolean;
  10559. /**
  10560. * Detects if the projection matrix requires to be recomputed this frame.
  10561. * @returns true if it requires to be recomputed otherwise, false.
  10562. */
  10563. needProjectionMatrixCompute(): boolean;
  10564. /**
  10565. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10566. */
  10567. forceProjectionMatrixCompute(): void;
  10568. /**
  10569. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10570. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10571. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10572. */
  10573. getShadowDirection(faceIndex?: number): Vector3;
  10574. /**
  10575. * Gets the minZ used for shadow according to both the scene and the light.
  10576. * @param activeCamera The camera we are returning the min for
  10577. * @returns the depth min z
  10578. */
  10579. getDepthMinZ(activeCamera: Camera): number;
  10580. /**
  10581. * Gets the maxZ used for shadow according to both the scene and the light.
  10582. * @param activeCamera The camera we are returning the max for
  10583. * @returns the depth max z
  10584. */
  10585. getDepthMaxZ(activeCamera: Camera): number;
  10586. }
  10587. /**
  10588. * Base implementation IShadowLight
  10589. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10590. */
  10591. export abstract class ShadowLight extends Light implements IShadowLight {
  10592. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10593. protected _position: Vector3;
  10594. protected _setPosition(value: Vector3): void;
  10595. /**
  10596. * Sets the position the shadow will be casted from. Also use as the light position for both
  10597. * point and spot lights.
  10598. */
  10599. /**
  10600. * Sets the position the shadow will be casted from. Also use as the light position for both
  10601. * point and spot lights.
  10602. */
  10603. position: Vector3;
  10604. protected _direction: Vector3;
  10605. protected _setDirection(value: Vector3): void;
  10606. /**
  10607. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10608. * Also use as the light direction on spot and directional lights.
  10609. */
  10610. /**
  10611. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10612. * Also use as the light direction on spot and directional lights.
  10613. */
  10614. direction: Vector3;
  10615. private _shadowMinZ;
  10616. /**
  10617. * Gets the shadow projection clipping minimum z value.
  10618. */
  10619. /**
  10620. * Sets the shadow projection clipping minimum z value.
  10621. */
  10622. shadowMinZ: number;
  10623. private _shadowMaxZ;
  10624. /**
  10625. * Sets the shadow projection clipping maximum z value.
  10626. */
  10627. /**
  10628. * Gets the shadow projection clipping maximum z value.
  10629. */
  10630. shadowMaxZ: number;
  10631. /**
  10632. * Callback defining a custom Projection Matrix Builder.
  10633. * This can be used to override the default projection matrix computation.
  10634. */
  10635. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10636. /**
  10637. * The transformed position. Position of the light in world space taking parenting in account.
  10638. */
  10639. transformedPosition: Vector3;
  10640. /**
  10641. * The transformed direction. Direction of the light in world space taking parenting in account.
  10642. */
  10643. transformedDirection: Vector3;
  10644. private _needProjectionMatrixCompute;
  10645. /**
  10646. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10647. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10648. */
  10649. computeTransformedInformation(): boolean;
  10650. /**
  10651. * Return the depth scale used for the shadow map.
  10652. * @returns the depth scale.
  10653. */
  10654. getDepthScale(): number;
  10655. /**
  10656. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10657. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10658. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10659. */
  10660. getShadowDirection(faceIndex?: number): Vector3;
  10661. /**
  10662. * Returns the ShadowLight absolute position in the World.
  10663. * @returns the position vector in world space
  10664. */
  10665. getAbsolutePosition(): Vector3;
  10666. /**
  10667. * Sets the ShadowLight direction toward the passed target.
  10668. * @param target The point to target in local space
  10669. * @returns the updated ShadowLight direction
  10670. */
  10671. setDirectionToTarget(target: Vector3): Vector3;
  10672. /**
  10673. * Returns the light rotation in euler definition.
  10674. * @returns the x y z rotation in local space.
  10675. */
  10676. getRotation(): Vector3;
  10677. /**
  10678. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10679. * @returns true if a cube texture needs to be use
  10680. */
  10681. needCube(): boolean;
  10682. /**
  10683. * Detects if the projection matrix requires to be recomputed this frame.
  10684. * @returns true if it requires to be recomputed otherwise, false.
  10685. */
  10686. needProjectionMatrixCompute(): boolean;
  10687. /**
  10688. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10689. */
  10690. forceProjectionMatrixCompute(): void;
  10691. /** @hidden */ private _initCache(): void;
  10692. /** @hidden */ private _isSynchronized(): boolean;
  10693. /**
  10694. * Computes the world matrix of the node
  10695. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10696. * @returns the world matrix
  10697. */
  10698. computeWorldMatrix(force?: boolean): Matrix;
  10699. /**
  10700. * Gets the minZ used for shadow according to both the scene and the light.
  10701. * @param activeCamera The camera we are returning the min for
  10702. * @returns the depth min z
  10703. */
  10704. getDepthMinZ(activeCamera: Camera): number;
  10705. /**
  10706. * Gets the maxZ used for shadow according to both the scene and the light.
  10707. * @param activeCamera The camera we are returning the max for
  10708. * @returns the depth max z
  10709. */
  10710. getDepthMaxZ(activeCamera: Camera): number;
  10711. /**
  10712. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10713. * @param matrix The materix to updated with the projection information
  10714. * @param viewMatrix The transform matrix of the light
  10715. * @param renderList The list of mesh to render in the map
  10716. * @returns The current light
  10717. */
  10718. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10719. }
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * "Static Class" containing the most commonly used helper while dealing with material for
  10724. * rendering purpose.
  10725. *
  10726. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10727. *
  10728. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10729. */
  10730. export class MaterialHelper {
  10731. /**
  10732. * Bind the current view position to an effect.
  10733. * @param effect The effect to be bound
  10734. * @param scene The scene the eyes position is used from
  10735. */
  10736. static BindEyePosition(effect: Effect, scene: Scene): void;
  10737. /**
  10738. * Helps preparing the defines values about the UVs in used in the effect.
  10739. * UVs are shared as much as we can accross channels in the shaders.
  10740. * @param texture The texture we are preparing the UVs for
  10741. * @param defines The defines to update
  10742. * @param key The channel key "diffuse", "specular"... used in the shader
  10743. */
  10744. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10745. /**
  10746. * Binds a texture matrix value to its corrsponding uniform
  10747. * @param texture The texture to bind the matrix for
  10748. * @param uniformBuffer The uniform buffer receivin the data
  10749. * @param key The channel key "diffuse", "specular"... used in the shader
  10750. */
  10751. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10752. /**
  10753. * Gets the current status of the fog (should it be enabled?)
  10754. * @param mesh defines the mesh to evaluate for fog support
  10755. * @param scene defines the hosting scene
  10756. * @returns true if fog must be enabled
  10757. */
  10758. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10759. /**
  10760. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10761. * @param mesh defines the current mesh
  10762. * @param scene defines the current scene
  10763. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10764. * @param pointsCloud defines if point cloud rendering has to be turned on
  10765. * @param fogEnabled defines if fog has to be turned on
  10766. * @param alphaTest defines if alpha testing has to be turned on
  10767. * @param defines defines the current list of defines
  10768. */
  10769. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10770. /**
  10771. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10772. * @param scene defines the current scene
  10773. * @param engine defines the current engine
  10774. * @param defines specifies the list of active defines
  10775. * @param useInstances defines if instances have to be turned on
  10776. * @param useClipPlane defines if clip plane have to be turned on
  10777. */
  10778. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10779. /**
  10780. * Prepares the defines for bones
  10781. * @param mesh The mesh containing the geometry data we will draw
  10782. * @param defines The defines to update
  10783. */
  10784. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10785. /**
  10786. * Prepares the defines for morph targets
  10787. * @param mesh The mesh containing the geometry data we will draw
  10788. * @param defines The defines to update
  10789. */
  10790. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10791. /**
  10792. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10793. * @param mesh The mesh containing the geometry data we will draw
  10794. * @param defines The defines to update
  10795. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10796. * @param useBones Precise whether bones should be used or not (override mesh info)
  10797. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10798. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10799. * @returns false if defines are considered not dirty and have not been checked
  10800. */
  10801. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10802. /**
  10803. * Prepares the defines related to multiview
  10804. * @param scene The scene we are intending to draw
  10805. * @param defines The defines to update
  10806. */
  10807. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10808. /**
  10809. * Prepares the defines related to the light information passed in parameter
  10810. * @param scene The scene we are intending to draw
  10811. * @param mesh The mesh the effect is compiling for
  10812. * @param light The light the effect is compiling for
  10813. * @param lightIndex The index of the light
  10814. * @param defines The defines to update
  10815. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10816. * @param state Defines the current state regarding what is needed (normals, etc...)
  10817. */
  10818. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10819. needNormals: boolean;
  10820. needRebuild: boolean;
  10821. shadowEnabled: boolean;
  10822. specularEnabled: boolean;
  10823. lightmapMode: boolean;
  10824. }): void;
  10825. /**
  10826. * Prepares the defines related to the light information passed in parameter
  10827. * @param scene The scene we are intending to draw
  10828. * @param mesh The mesh the effect is compiling for
  10829. * @param defines The defines to update
  10830. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10831. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10832. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10833. * @returns true if normals will be required for the rest of the effect
  10834. */
  10835. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10836. /**
  10837. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10838. * @param lightIndex defines the light index
  10839. * @param uniformsList The uniform list
  10840. * @param samplersList The sampler list
  10841. * @param projectedLightTexture defines if projected texture must be used
  10842. * @param uniformBuffersList defines an optional list of uniform buffers
  10843. */
  10844. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  10845. /**
  10846. * Prepares the uniforms and samplers list to be used in the effect
  10847. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10848. * @param samplersList The sampler list
  10849. * @param defines The defines helping in the list generation
  10850. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10851. */
  10852. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10853. /**
  10854. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10855. * @param defines The defines to update while falling back
  10856. * @param fallbacks The authorized effect fallbacks
  10857. * @param maxSimultaneousLights The maximum number of lights allowed
  10858. * @param rank the current rank of the Effect
  10859. * @returns The newly affected rank
  10860. */
  10861. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10862. /**
  10863. * Prepares the list of attributes required for morph targets according to the effect defines.
  10864. * @param attribs The current list of supported attribs
  10865. * @param mesh The mesh to prepare the morph targets attributes for
  10866. * @param defines The current Defines of the effect
  10867. */
  10868. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10869. /**
  10870. * Prepares the list of attributes required for bones according to the effect defines.
  10871. * @param attribs The current list of supported attribs
  10872. * @param mesh The mesh to prepare the bones attributes for
  10873. * @param defines The current Defines of the effect
  10874. * @param fallbacks The current efffect fallback strategy
  10875. */
  10876. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10877. /**
  10878. * Check and prepare the list of attributes required for instances according to the effect defines.
  10879. * @param attribs The current list of supported attribs
  10880. * @param defines The current MaterialDefines of the effect
  10881. */
  10882. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  10883. /**
  10884. * Add the list of attributes required for instances to the attribs array.
  10885. * @param attribs The current list of supported attribs
  10886. */
  10887. static PushAttributesForInstances(attribs: string[]): void;
  10888. /**
  10889. * Binds the light shadow information to the effect for the given mesh.
  10890. * @param light The light containing the generator
  10891. * @param scene The scene the lights belongs to
  10892. * @param mesh The mesh we are binding the information to render
  10893. * @param lightIndex The light index in the effect used to render the mesh
  10894. * @param effect The effect we are binding the data to
  10895. */
  10896. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10897. /**
  10898. * Binds the light information to the effect.
  10899. * @param light The light containing the generator
  10900. * @param effect The effect we are binding the data to
  10901. * @param lightIndex The light index in the effect used to render
  10902. */
  10903. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10904. /**
  10905. * Binds the lights information from the scene to the effect for the given mesh.
  10906. * @param light Light to bind
  10907. * @param lightIndex Light index
  10908. * @param scene The scene where the light belongs to
  10909. * @param mesh The mesh we are binding the information to render
  10910. * @param effect The effect we are binding the data to
  10911. * @param useSpecular Defines if specular is supported
  10912. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10913. */
  10914. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  10915. /**
  10916. * Binds the lights information from the scene to the effect for the given mesh.
  10917. * @param scene The scene the lights belongs to
  10918. * @param mesh The mesh we are binding the information to render
  10919. * @param effect The effect we are binding the data to
  10920. * @param defines The generated defines for the effect
  10921. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10922. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10923. */
  10924. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10925. private static _tempFogColor;
  10926. /**
  10927. * Binds the fog information from the scene to the effect for the given mesh.
  10928. * @param scene The scene the lights belongs to
  10929. * @param mesh The mesh we are binding the information to render
  10930. * @param effect The effect we are binding the data to
  10931. * @param linearSpace Defines if the fog effect is applied in linear space
  10932. */
  10933. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10934. /**
  10935. * Binds the bones information from the mesh to the effect.
  10936. * @param mesh The mesh we are binding the information to render
  10937. * @param effect The effect we are binding the data to
  10938. */
  10939. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10940. /**
  10941. * Binds the morph targets information from the mesh to the effect.
  10942. * @param abstractMesh The mesh we are binding the information to render
  10943. * @param effect The effect we are binding the data to
  10944. */
  10945. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10946. /**
  10947. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10948. * @param defines The generated defines used in the effect
  10949. * @param effect The effect we are binding the data to
  10950. * @param scene The scene we are willing to render with logarithmic scale for
  10951. */
  10952. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10953. /**
  10954. * Binds the clip plane information from the scene to the effect.
  10955. * @param scene The scene the clip plane information are extracted from
  10956. * @param effect The effect we are binding the data to
  10957. */
  10958. static BindClipPlane(effect: Effect, scene: Scene): void;
  10959. }
  10960. }
  10961. declare module BABYLON {
  10962. /** @hidden */
  10963. export var shadowMapPixelShader: {
  10964. name: string;
  10965. shader: string;
  10966. };
  10967. }
  10968. declare module BABYLON {
  10969. /** @hidden */
  10970. export var bonesDeclaration: {
  10971. name: string;
  10972. shader: string;
  10973. };
  10974. }
  10975. declare module BABYLON {
  10976. /** @hidden */
  10977. export var morphTargetsVertexGlobalDeclaration: {
  10978. name: string;
  10979. shader: string;
  10980. };
  10981. }
  10982. declare module BABYLON {
  10983. /** @hidden */
  10984. export var morphTargetsVertexDeclaration: {
  10985. name: string;
  10986. shader: string;
  10987. };
  10988. }
  10989. declare module BABYLON {
  10990. /** @hidden */
  10991. export var instancesDeclaration: {
  10992. name: string;
  10993. shader: string;
  10994. };
  10995. }
  10996. declare module BABYLON {
  10997. /** @hidden */
  10998. export var helperFunctions: {
  10999. name: string;
  11000. shader: string;
  11001. };
  11002. }
  11003. declare module BABYLON {
  11004. /** @hidden */
  11005. export var morphTargetsVertex: {
  11006. name: string;
  11007. shader: string;
  11008. };
  11009. }
  11010. declare module BABYLON {
  11011. /** @hidden */
  11012. export var instancesVertex: {
  11013. name: string;
  11014. shader: string;
  11015. };
  11016. }
  11017. declare module BABYLON {
  11018. /** @hidden */
  11019. export var bonesVertex: {
  11020. name: string;
  11021. shader: string;
  11022. };
  11023. }
  11024. declare module BABYLON {
  11025. /** @hidden */
  11026. export var shadowMapVertexShader: {
  11027. name: string;
  11028. shader: string;
  11029. };
  11030. }
  11031. declare module BABYLON {
  11032. /** @hidden */
  11033. export var depthBoxBlurPixelShader: {
  11034. name: string;
  11035. shader: string;
  11036. };
  11037. }
  11038. declare module BABYLON {
  11039. /**
  11040. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11041. */
  11042. export interface ICustomShaderOptions {
  11043. /**
  11044. * Gets or sets the custom shader name to use
  11045. */
  11046. shaderName: string;
  11047. /**
  11048. * The list of attribute names used in the shader
  11049. */
  11050. attributes?: string[];
  11051. /**
  11052. * The list of unifrom names used in the shader
  11053. */
  11054. uniforms?: string[];
  11055. /**
  11056. * The list of sampler names used in the shader
  11057. */
  11058. samplers?: string[];
  11059. /**
  11060. * The list of defines used in the shader
  11061. */
  11062. defines?: string[];
  11063. }
  11064. /**
  11065. * Interface to implement to create a shadow generator compatible with BJS.
  11066. */
  11067. export interface IShadowGenerator {
  11068. /**
  11069. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11070. * @returns The render target texture if present otherwise, null
  11071. */
  11072. getShadowMap(): Nullable<RenderTargetTexture>;
  11073. /**
  11074. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11075. * @returns The render target texture if the shadow map is present otherwise, null
  11076. */
  11077. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11078. /**
  11079. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11080. * @param subMesh The submesh we want to render in the shadow map
  11081. * @param useInstances Defines wether will draw in the map using instances
  11082. * @returns true if ready otherwise, false
  11083. */
  11084. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11085. /**
  11086. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11087. * @param defines Defines of the material we want to update
  11088. * @param lightIndex Index of the light in the enabled light list of the material
  11089. */
  11090. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11091. /**
  11092. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11093. * defined in the generator but impacting the effect).
  11094. * It implies the unifroms available on the materials are the standard BJS ones.
  11095. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11096. * @param effect The effect we are binfing the information for
  11097. */
  11098. bindShadowLight(lightIndex: string, effect: Effect): void;
  11099. /**
  11100. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11101. * (eq to shadow prjection matrix * light transform matrix)
  11102. * @returns The transform matrix used to create the shadow map
  11103. */
  11104. getTransformMatrix(): Matrix;
  11105. /**
  11106. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11107. * Cube and 2D textures for instance.
  11108. */
  11109. recreateShadowMap(): void;
  11110. /**
  11111. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11112. * @param onCompiled Callback triggered at the and of the effects compilation
  11113. * @param options Sets of optional options forcing the compilation with different modes
  11114. */
  11115. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11116. useInstances: boolean;
  11117. }>): void;
  11118. /**
  11119. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11120. * @param options Sets of optional options forcing the compilation with different modes
  11121. * @returns A promise that resolves when the compilation completes
  11122. */
  11123. forceCompilationAsync(options?: Partial<{
  11124. useInstances: boolean;
  11125. }>): Promise<void>;
  11126. /**
  11127. * Serializes the shadow generator setup to a json object.
  11128. * @returns The serialized JSON object
  11129. */
  11130. serialize(): any;
  11131. /**
  11132. * Disposes the Shadow map and related Textures and effects.
  11133. */
  11134. dispose(): void;
  11135. }
  11136. /**
  11137. * Default implementation IShadowGenerator.
  11138. * This is the main object responsible of generating shadows in the framework.
  11139. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11140. */
  11141. export class ShadowGenerator implements IShadowGenerator {
  11142. /**
  11143. * Shadow generator mode None: no filtering applied.
  11144. */
  11145. static readonly FILTER_NONE: number;
  11146. /**
  11147. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11148. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11149. */
  11150. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11151. /**
  11152. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11153. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11154. */
  11155. static readonly FILTER_POISSONSAMPLING: number;
  11156. /**
  11157. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11158. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11159. */
  11160. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11161. /**
  11162. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11163. * edge artifacts on steep falloff.
  11164. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11165. */
  11166. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11167. /**
  11168. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11169. * edge artifacts on steep falloff.
  11170. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11171. */
  11172. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11173. /**
  11174. * Shadow generator mode PCF: Percentage Closer Filtering
  11175. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11176. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11177. */
  11178. static readonly FILTER_PCF: number;
  11179. /**
  11180. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11181. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11182. * Contact Hardening
  11183. */
  11184. static readonly FILTER_PCSS: number;
  11185. /**
  11186. * Reserved for PCF and PCSS
  11187. * Highest Quality.
  11188. *
  11189. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11190. *
  11191. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11192. */
  11193. static readonly QUALITY_HIGH: number;
  11194. /**
  11195. * Reserved for PCF and PCSS
  11196. * Good tradeoff for quality/perf cross devices
  11197. *
  11198. * Execute PCF on a 3*3 kernel.
  11199. *
  11200. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11201. */
  11202. static readonly QUALITY_MEDIUM: number;
  11203. /**
  11204. * Reserved for PCF and PCSS
  11205. * The lowest quality but the fastest.
  11206. *
  11207. * Execute PCF on a 1*1 kernel.
  11208. *
  11209. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11210. */
  11211. static readonly QUALITY_LOW: number;
  11212. /** Gets or sets the custom shader name to use */
  11213. customShaderOptions: ICustomShaderOptions;
  11214. /**
  11215. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11216. */
  11217. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11218. /**
  11219. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11220. */
  11221. onAfterShadowMapRenderObservable: Observable<Effect>;
  11222. /**
  11223. * Observable triggered before a mesh is rendered in the shadow map.
  11224. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11225. */
  11226. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11227. /**
  11228. * Observable triggered after a mesh is rendered in the shadow map.
  11229. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11230. */
  11231. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11232. private _bias;
  11233. /**
  11234. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11235. */
  11236. /**
  11237. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11238. */
  11239. bias: number;
  11240. private _normalBias;
  11241. /**
  11242. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11243. */
  11244. /**
  11245. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11246. */
  11247. normalBias: number;
  11248. private _blurBoxOffset;
  11249. /**
  11250. * Gets the blur box offset: offset applied during the blur pass.
  11251. * Only useful if useKernelBlur = false
  11252. */
  11253. /**
  11254. * Sets the blur box offset: offset applied during the blur pass.
  11255. * Only useful if useKernelBlur = false
  11256. */
  11257. blurBoxOffset: number;
  11258. private _blurScale;
  11259. /**
  11260. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11261. * 2 means half of the size.
  11262. */
  11263. /**
  11264. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11265. * 2 means half of the size.
  11266. */
  11267. blurScale: number;
  11268. private _blurKernel;
  11269. /**
  11270. * Gets the blur kernel: kernel size of the blur pass.
  11271. * Only useful if useKernelBlur = true
  11272. */
  11273. /**
  11274. * Sets the blur kernel: kernel size of the blur pass.
  11275. * Only useful if useKernelBlur = true
  11276. */
  11277. blurKernel: number;
  11278. private _useKernelBlur;
  11279. /**
  11280. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11281. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11282. */
  11283. /**
  11284. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11285. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11286. */
  11287. useKernelBlur: boolean;
  11288. private _depthScale;
  11289. /**
  11290. * Gets the depth scale used in ESM mode.
  11291. */
  11292. /**
  11293. * Sets the depth scale used in ESM mode.
  11294. * This can override the scale stored on the light.
  11295. */
  11296. depthScale: number;
  11297. private _filter;
  11298. /**
  11299. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11300. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11301. */
  11302. /**
  11303. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11304. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11305. */
  11306. filter: number;
  11307. /**
  11308. * Gets if the current filter is set to Poisson Sampling.
  11309. */
  11310. /**
  11311. * Sets the current filter to Poisson Sampling.
  11312. */
  11313. usePoissonSampling: boolean;
  11314. /**
  11315. * Gets if the current filter is set to ESM.
  11316. */
  11317. /**
  11318. * Sets the current filter is to ESM.
  11319. */
  11320. useExponentialShadowMap: boolean;
  11321. /**
  11322. * Gets if the current filter is set to filtered ESM.
  11323. */
  11324. /**
  11325. * Gets if the current filter is set to filtered ESM.
  11326. */
  11327. useBlurExponentialShadowMap: boolean;
  11328. /**
  11329. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11330. * exponential to prevent steep falloff artifacts).
  11331. */
  11332. /**
  11333. * Sets the current filter to "close ESM" (using the inverse of the
  11334. * exponential to prevent steep falloff artifacts).
  11335. */
  11336. useCloseExponentialShadowMap: boolean;
  11337. /**
  11338. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11339. * exponential to prevent steep falloff artifacts).
  11340. */
  11341. /**
  11342. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11343. * exponential to prevent steep falloff artifacts).
  11344. */
  11345. useBlurCloseExponentialShadowMap: boolean;
  11346. /**
  11347. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11348. */
  11349. /**
  11350. * Sets the current filter to "PCF" (percentage closer filtering).
  11351. */
  11352. usePercentageCloserFiltering: boolean;
  11353. private _filteringQuality;
  11354. /**
  11355. * Gets the PCF or PCSS Quality.
  11356. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11357. */
  11358. /**
  11359. * Sets the PCF or PCSS Quality.
  11360. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11361. */
  11362. filteringQuality: number;
  11363. /**
  11364. * Gets if the current filter is set to "PCSS" (contact hardening).
  11365. */
  11366. /**
  11367. * Sets the current filter to "PCSS" (contact hardening).
  11368. */
  11369. useContactHardeningShadow: boolean;
  11370. private _contactHardeningLightSizeUVRatio;
  11371. /**
  11372. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11373. * Using a ratio helps keeping shape stability independently of the map size.
  11374. *
  11375. * It does not account for the light projection as it was having too much
  11376. * instability during the light setup or during light position changes.
  11377. *
  11378. * Only valid if useContactHardeningShadow is true.
  11379. */
  11380. /**
  11381. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11382. * Using a ratio helps keeping shape stability independently of the map size.
  11383. *
  11384. * It does not account for the light projection as it was having too much
  11385. * instability during the light setup or during light position changes.
  11386. *
  11387. * Only valid if useContactHardeningShadow is true.
  11388. */
  11389. contactHardeningLightSizeUVRatio: number;
  11390. private _darkness;
  11391. /** Gets or sets the actual darkness of a shadow */
  11392. darkness: number;
  11393. /**
  11394. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11395. * 0 means strongest and 1 would means no shadow.
  11396. * @returns the darkness.
  11397. */
  11398. getDarkness(): number;
  11399. /**
  11400. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11401. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11402. * @returns the shadow generator allowing fluent coding.
  11403. */
  11404. setDarkness(darkness: number): ShadowGenerator;
  11405. private _transparencyShadow;
  11406. /** Gets or sets the ability to have transparent shadow */
  11407. transparencyShadow: boolean;
  11408. /**
  11409. * Sets the ability to have transparent shadow (boolean).
  11410. * @param transparent True if transparent else False
  11411. * @returns the shadow generator allowing fluent coding
  11412. */
  11413. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11414. private _shadowMap;
  11415. private _shadowMap2;
  11416. /**
  11417. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11418. * @returns The render target texture if present otherwise, null
  11419. */
  11420. getShadowMap(): Nullable<RenderTargetTexture>;
  11421. /**
  11422. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11423. * @returns The render target texture if the shadow map is present otherwise, null
  11424. */
  11425. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11426. /**
  11427. * Gets the class name of that object
  11428. * @returns "ShadowGenerator"
  11429. */
  11430. getClassName(): string;
  11431. /**
  11432. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11433. * @param mesh Mesh to add
  11434. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11435. * @returns the Shadow Generator itself
  11436. */
  11437. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11438. /**
  11439. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11440. * @param mesh Mesh to remove
  11441. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11442. * @returns the Shadow Generator itself
  11443. */
  11444. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11445. /**
  11446. * Controls the extent to which the shadows fade out at the edge of the frustum
  11447. * Used only by directionals and spots
  11448. */
  11449. frustumEdgeFalloff: number;
  11450. private _light;
  11451. /**
  11452. * Returns the associated light object.
  11453. * @returns the light generating the shadow
  11454. */
  11455. getLight(): IShadowLight;
  11456. /**
  11457. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11458. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11459. * It might on the other hand introduce peter panning.
  11460. */
  11461. forceBackFacesOnly: boolean;
  11462. private _scene;
  11463. private _lightDirection;
  11464. private _effect;
  11465. private _viewMatrix;
  11466. private _projectionMatrix;
  11467. private _transformMatrix;
  11468. private _cachedPosition;
  11469. private _cachedDirection;
  11470. private _cachedDefines;
  11471. private _currentRenderID;
  11472. private _boxBlurPostprocess;
  11473. private _kernelBlurXPostprocess;
  11474. private _kernelBlurYPostprocess;
  11475. private _blurPostProcesses;
  11476. private _mapSize;
  11477. private _currentFaceIndex;
  11478. private _currentFaceIndexCache;
  11479. private _textureType;
  11480. private _defaultTextureMatrix;
  11481. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  11482. /**
  11483. * Creates a ShadowGenerator object.
  11484. * A ShadowGenerator is the required tool to use the shadows.
  11485. * Each light casting shadows needs to use its own ShadowGenerator.
  11486. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11487. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11488. * @param light The light object generating the shadows.
  11489. * @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.
  11490. */
  11491. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11492. private _initializeGenerator;
  11493. private _initializeShadowMap;
  11494. private _initializeBlurRTTAndPostProcesses;
  11495. private _renderForShadowMap;
  11496. private _renderSubMeshForShadowMap;
  11497. private _applyFilterValues;
  11498. /**
  11499. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11500. * @param onCompiled Callback triggered at the and of the effects compilation
  11501. * @param options Sets of optional options forcing the compilation with different modes
  11502. */
  11503. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11504. useInstances: boolean;
  11505. }>): void;
  11506. /**
  11507. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11508. * @param options Sets of optional options forcing the compilation with different modes
  11509. * @returns A promise that resolves when the compilation completes
  11510. */
  11511. forceCompilationAsync(options?: Partial<{
  11512. useInstances: boolean;
  11513. }>): Promise<void>;
  11514. /**
  11515. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11516. * @param subMesh The submesh we want to render in the shadow map
  11517. * @param useInstances Defines wether will draw in the map using instances
  11518. * @returns true if ready otherwise, false
  11519. */
  11520. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11521. /**
  11522. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11523. * @param defines Defines of the material we want to update
  11524. * @param lightIndex Index of the light in the enabled light list of the material
  11525. */
  11526. prepareDefines(defines: any, lightIndex: number): void;
  11527. /**
  11528. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11529. * defined in the generator but impacting the effect).
  11530. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11531. * @param effect The effect we are binfing the information for
  11532. */
  11533. bindShadowLight(lightIndex: string, effect: Effect): void;
  11534. /**
  11535. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11536. * (eq to shadow prjection matrix * light transform matrix)
  11537. * @returns The transform matrix used to create the shadow map
  11538. */
  11539. getTransformMatrix(): Matrix;
  11540. /**
  11541. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11542. * Cube and 2D textures for instance.
  11543. */
  11544. recreateShadowMap(): void;
  11545. private _disposeBlurPostProcesses;
  11546. private _disposeRTTandPostProcesses;
  11547. /**
  11548. * Disposes the ShadowGenerator.
  11549. * Returns nothing.
  11550. */
  11551. dispose(): void;
  11552. /**
  11553. * Serializes the shadow generator setup to a json object.
  11554. * @returns The serialized JSON object
  11555. */
  11556. serialize(): any;
  11557. /**
  11558. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11559. * @param parsedShadowGenerator The JSON object to parse
  11560. * @param scene The scene to create the shadow map for
  11561. * @returns The parsed shadow generator
  11562. */
  11563. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11564. }
  11565. }
  11566. declare module BABYLON {
  11567. /**
  11568. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11569. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11570. * 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.
  11571. */
  11572. export abstract class Light extends Node {
  11573. /**
  11574. * Falloff Default: light is falling off following the material specification:
  11575. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11576. */
  11577. static readonly FALLOFF_DEFAULT: number;
  11578. /**
  11579. * Falloff Physical: light is falling off following the inverse squared distance law.
  11580. */
  11581. static readonly FALLOFF_PHYSICAL: number;
  11582. /**
  11583. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11584. * to enhance interoperability with other engines.
  11585. */
  11586. static readonly FALLOFF_GLTF: number;
  11587. /**
  11588. * Falloff Standard: light is falling off like in the standard material
  11589. * to enhance interoperability with other materials.
  11590. */
  11591. static readonly FALLOFF_STANDARD: number;
  11592. /**
  11593. * If every light affecting the material is in this lightmapMode,
  11594. * material.lightmapTexture adds or multiplies
  11595. * (depends on material.useLightmapAsShadowmap)
  11596. * after every other light calculations.
  11597. */
  11598. static readonly LIGHTMAP_DEFAULT: number;
  11599. /**
  11600. * material.lightmapTexture as only diffuse lighting from this light
  11601. * adds only specular lighting from this light
  11602. * adds dynamic shadows
  11603. */
  11604. static readonly LIGHTMAP_SPECULAR: number;
  11605. /**
  11606. * material.lightmapTexture as only lighting
  11607. * no light calculation from this light
  11608. * only adds dynamic shadows from this light
  11609. */
  11610. static readonly LIGHTMAP_SHADOWSONLY: number;
  11611. /**
  11612. * Each light type uses the default quantity according to its type:
  11613. * point/spot lights use luminous intensity
  11614. * directional lights use illuminance
  11615. */
  11616. static readonly INTENSITYMODE_AUTOMATIC: number;
  11617. /**
  11618. * lumen (lm)
  11619. */
  11620. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11621. /**
  11622. * candela (lm/sr)
  11623. */
  11624. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11625. /**
  11626. * lux (lm/m^2)
  11627. */
  11628. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11629. /**
  11630. * nit (cd/m^2)
  11631. */
  11632. static readonly INTENSITYMODE_LUMINANCE: number;
  11633. /**
  11634. * Light type const id of the point light.
  11635. */
  11636. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11637. /**
  11638. * Light type const id of the directional light.
  11639. */
  11640. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11641. /**
  11642. * Light type const id of the spot light.
  11643. */
  11644. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11645. /**
  11646. * Light type const id of the hemispheric light.
  11647. */
  11648. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11649. /**
  11650. * Diffuse gives the basic color to an object.
  11651. */
  11652. diffuse: Color3;
  11653. /**
  11654. * Specular produces a highlight color on an object.
  11655. * Note: This is note affecting PBR materials.
  11656. */
  11657. specular: Color3;
  11658. /**
  11659. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11660. * falling off base on range or angle.
  11661. * This can be set to any values in Light.FALLOFF_x.
  11662. *
  11663. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11664. * other types of materials.
  11665. */
  11666. falloffType: number;
  11667. /**
  11668. * Strength of the light.
  11669. * Note: By default it is define in the framework own unit.
  11670. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11671. */
  11672. intensity: number;
  11673. private _range;
  11674. protected _inverseSquaredRange: number;
  11675. /**
  11676. * Defines how far from the source the light is impacting in scene units.
  11677. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11678. */
  11679. /**
  11680. * Defines how far from the source the light is impacting in scene units.
  11681. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11682. */
  11683. range: number;
  11684. /**
  11685. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11686. * of light.
  11687. */
  11688. private _photometricScale;
  11689. private _intensityMode;
  11690. /**
  11691. * Gets the photometric scale used to interpret the intensity.
  11692. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11693. */
  11694. /**
  11695. * Sets the photometric scale used to interpret the intensity.
  11696. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11697. */
  11698. intensityMode: number;
  11699. private _radius;
  11700. /**
  11701. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11702. */
  11703. /**
  11704. * sets the light radius used by PBR Materials to simulate soft area lights.
  11705. */
  11706. radius: number;
  11707. private _renderPriority;
  11708. /**
  11709. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11710. * exceeding the number allowed of the materials.
  11711. */
  11712. renderPriority: number;
  11713. private _shadowEnabled;
  11714. /**
  11715. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11716. * the current shadow generator.
  11717. */
  11718. /**
  11719. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11720. * the current shadow generator.
  11721. */
  11722. shadowEnabled: boolean;
  11723. private _includedOnlyMeshes;
  11724. /**
  11725. * Gets the only meshes impacted by this light.
  11726. */
  11727. /**
  11728. * Sets the only meshes impacted by this light.
  11729. */
  11730. includedOnlyMeshes: AbstractMesh[];
  11731. private _excludedMeshes;
  11732. /**
  11733. * Gets the meshes not impacted by this light.
  11734. */
  11735. /**
  11736. * Sets the meshes not impacted by this light.
  11737. */
  11738. excludedMeshes: AbstractMesh[];
  11739. private _excludeWithLayerMask;
  11740. /**
  11741. * Gets the layer id use to find what meshes are not impacted by the light.
  11742. * Inactive if 0
  11743. */
  11744. /**
  11745. * Sets the layer id use to find what meshes are not impacted by the light.
  11746. * Inactive if 0
  11747. */
  11748. excludeWithLayerMask: number;
  11749. private _includeOnlyWithLayerMask;
  11750. /**
  11751. * Gets the layer id use to find what meshes are impacted by the light.
  11752. * Inactive if 0
  11753. */
  11754. /**
  11755. * Sets the layer id use to find what meshes are impacted by the light.
  11756. * Inactive if 0
  11757. */
  11758. includeOnlyWithLayerMask: number;
  11759. private _lightmapMode;
  11760. /**
  11761. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11762. */
  11763. /**
  11764. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11765. */
  11766. lightmapMode: number;
  11767. /**
  11768. * Shadow generator associted to the light.
  11769. * @hidden Internal use only.
  11770. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  11771. /**
  11772. * @hidden Internal use only.
  11773. */ private _excludedMeshesIds: string[];
  11774. /**
  11775. * @hidden Internal use only.
  11776. */ private _includedOnlyMeshesIds: string[];
  11777. /**
  11778. * The current light unifom buffer.
  11779. * @hidden Internal use only.
  11780. */ private _uniformBuffer: UniformBuffer;
  11781. /**
  11782. * Creates a Light object in the scene.
  11783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11784. * @param name The firendly name of the light
  11785. * @param scene The scene the light belongs too
  11786. */
  11787. constructor(name: string, scene: Scene);
  11788. protected abstract _buildUniformLayout(): void;
  11789. /**
  11790. * Sets the passed Effect "effect" with the Light information.
  11791. * @param effect The effect to update
  11792. * @param lightIndex The index of the light in the effect to update
  11793. * @returns The light
  11794. */
  11795. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11796. /**
  11797. * Returns the string "Light".
  11798. * @returns the class name
  11799. */
  11800. getClassName(): string;
  11801. /** @hidden */ protected readonly _isLight: boolean;
  11802. /**
  11803. * Converts the light information to a readable string for debug purpose.
  11804. * @param fullDetails Supports for multiple levels of logging within scene loading
  11805. * @returns the human readable light info
  11806. */
  11807. toString(fullDetails?: boolean): string;
  11808. /** @hidden */
  11809. protected _syncParentEnabledState(): void;
  11810. /**
  11811. * Set the enabled state of this node.
  11812. * @param value - the new enabled state
  11813. */
  11814. setEnabled(value: boolean): void;
  11815. /**
  11816. * Returns the Light associated shadow generator if any.
  11817. * @return the associated shadow generator.
  11818. */
  11819. getShadowGenerator(): Nullable<IShadowGenerator>;
  11820. /**
  11821. * Returns a Vector3, the absolute light position in the World.
  11822. * @returns the world space position of the light
  11823. */
  11824. getAbsolutePosition(): Vector3;
  11825. /**
  11826. * Specifies if the light will affect the passed mesh.
  11827. * @param mesh The mesh to test against the light
  11828. * @return true the mesh is affected otherwise, false.
  11829. */
  11830. canAffectMesh(mesh: AbstractMesh): boolean;
  11831. /**
  11832. * Sort function to order lights for rendering.
  11833. * @param a First Light object to compare to second.
  11834. * @param b Second Light object to compare first.
  11835. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11836. */
  11837. static CompareLightsPriority(a: Light, b: Light): number;
  11838. /**
  11839. * Releases resources associated with this node.
  11840. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11841. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11842. */
  11843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11844. /**
  11845. * Returns the light type ID (integer).
  11846. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11847. */
  11848. getTypeID(): number;
  11849. /**
  11850. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11851. * @returns the scaled intensity in intensity mode unit
  11852. */
  11853. getScaledIntensity(): number;
  11854. /**
  11855. * Returns a new Light object, named "name", from the current one.
  11856. * @param name The name of the cloned light
  11857. * @returns the new created light
  11858. */
  11859. clone(name: string): Nullable<Light>;
  11860. /**
  11861. * Serializes the current light into a Serialization object.
  11862. * @returns the serialized object.
  11863. */
  11864. serialize(): any;
  11865. /**
  11866. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11867. * This new light is named "name" and added to the passed scene.
  11868. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11869. * @param name The friendly name of the light
  11870. * @param scene The scene the new light will belong to
  11871. * @returns the constructor function
  11872. */
  11873. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11874. /**
  11875. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11876. * @param parsedLight The JSON representation of the light
  11877. * @param scene The scene to create the parsed light in
  11878. * @returns the created light after parsing
  11879. */
  11880. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11881. private _hookArrayForExcluded;
  11882. private _hookArrayForIncludedOnly;
  11883. private _resyncMeshes;
  11884. /**
  11885. * Forces the meshes to update their light related information in their rendering used effects
  11886. * @hidden Internal Use Only
  11887. */ private _markMeshesAsLightDirty(): void;
  11888. /**
  11889. * Recomputes the cached photometric scale if needed.
  11890. */
  11891. private _computePhotometricScale;
  11892. /**
  11893. * Returns the Photometric Scale according to the light type and intensity mode.
  11894. */
  11895. private _getPhotometricScale;
  11896. /**
  11897. * Reorder the light in the scene according to their defined priority.
  11898. * @hidden Internal Use Only
  11899. */ private _reorderLightsInScene(): void;
  11900. /**
  11901. * Prepares the list of defines specific to the light type.
  11902. * @param defines the list of defines
  11903. * @param lightIndex defines the index of the light for the effect
  11904. */
  11905. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11906. }
  11907. }
  11908. declare module BABYLON {
  11909. /**
  11910. * Creates an instance based on a source mesh.
  11911. */
  11912. export class InstancedMesh extends AbstractMesh {
  11913. private _sourceMesh;
  11914. private _currentLOD;
  11915. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  11916. constructor(name: string, source: Mesh);
  11917. /**
  11918. * Returns the string "InstancedMesh".
  11919. */
  11920. getClassName(): string;
  11921. /** Gets the list of lights affecting that mesh */
  11922. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  11923. /**
  11924. * If the source mesh receives shadows
  11925. */
  11926. readonly receiveShadows: boolean;
  11927. /**
  11928. * The material of the source mesh
  11929. */
  11930. readonly material: Nullable<Material>;
  11931. /**
  11932. * Visibility of the source mesh
  11933. */
  11934. readonly visibility: number;
  11935. /**
  11936. * Skeleton of the source mesh
  11937. */
  11938. readonly skeleton: Nullable<Skeleton>;
  11939. /**
  11940. * Rendering ground id of the source mesh
  11941. */
  11942. renderingGroupId: number;
  11943. /**
  11944. * Returns the total number of vertices (integer).
  11945. */
  11946. getTotalVertices(): number;
  11947. /**
  11948. * Returns a positive integer : the total number of indices in this mesh geometry.
  11949. * @returns the numner of indices or zero if the mesh has no geometry.
  11950. */
  11951. getTotalIndices(): number;
  11952. /**
  11953. * The source mesh of the instance
  11954. */
  11955. readonly sourceMesh: Mesh;
  11956. /**
  11957. * Is this node ready to be used/rendered
  11958. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  11959. * @return {boolean} is it ready
  11960. */
  11961. isReady(completeCheck?: boolean): boolean;
  11962. /**
  11963. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  11964. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  11965. * @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.
  11966. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  11967. */
  11968. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  11969. /**
  11970. * Sets the vertex data of the mesh geometry for the requested `kind`.
  11971. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  11972. * The `data` are either a numeric array either a Float32Array.
  11973. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  11974. * 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).
  11975. * Note that a new underlying VertexBuffer object is created each call.
  11976. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  11977. *
  11978. * Possible `kind` values :
  11979. * - VertexBuffer.PositionKind
  11980. * - VertexBuffer.UVKind
  11981. * - VertexBuffer.UV2Kind
  11982. * - VertexBuffer.UV3Kind
  11983. * - VertexBuffer.UV4Kind
  11984. * - VertexBuffer.UV5Kind
  11985. * - VertexBuffer.UV6Kind
  11986. * - VertexBuffer.ColorKind
  11987. * - VertexBuffer.MatricesIndicesKind
  11988. * - VertexBuffer.MatricesIndicesExtraKind
  11989. * - VertexBuffer.MatricesWeightsKind
  11990. * - VertexBuffer.MatricesWeightsExtraKind
  11991. *
  11992. * Returns the Mesh.
  11993. */
  11994. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  11995. /**
  11996. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  11997. * If the mesh has no geometry, it is simply returned as it is.
  11998. * The `data` are either a numeric array either a Float32Array.
  11999. * No new underlying VertexBuffer object is created.
  12000. * 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.
  12001. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12002. *
  12003. * Possible `kind` values :
  12004. * - VertexBuffer.PositionKind
  12005. * - VertexBuffer.UVKind
  12006. * - VertexBuffer.UV2Kind
  12007. * - VertexBuffer.UV3Kind
  12008. * - VertexBuffer.UV4Kind
  12009. * - VertexBuffer.UV5Kind
  12010. * - VertexBuffer.UV6Kind
  12011. * - VertexBuffer.ColorKind
  12012. * - VertexBuffer.MatricesIndicesKind
  12013. * - VertexBuffer.MatricesIndicesExtraKind
  12014. * - VertexBuffer.MatricesWeightsKind
  12015. * - VertexBuffer.MatricesWeightsExtraKind
  12016. *
  12017. * Returns the Mesh.
  12018. */
  12019. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12020. /**
  12021. * Sets the mesh indices.
  12022. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12023. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12024. * This method creates a new index buffer each call.
  12025. * Returns the Mesh.
  12026. */
  12027. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12028. /**
  12029. * Boolean : True if the mesh owns the requested kind of data.
  12030. */
  12031. isVerticesDataPresent(kind: string): boolean;
  12032. /**
  12033. * Returns an array of indices (IndicesArray).
  12034. */
  12035. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  12036. /**
  12037. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12038. * This means the mesh underlying bounding box and sphere are recomputed.
  12039. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12040. * @returns the current mesh
  12041. */
  12042. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12043. /** @hidden */ private _preActivate(): InstancedMesh;
  12044. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  12045. /** @hidden */ private _postActivate(): void;
  12046. getWorldMatrix(): Matrix;
  12047. readonly isAnInstance: boolean;
  12048. /**
  12049. * Returns the current associated LOD AbstractMesh.
  12050. */
  12051. getLOD(camera: Camera): AbstractMesh;
  12052. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  12053. /** @hidden */ private _generatePointsArray(): boolean;
  12054. /**
  12055. * Creates a new InstancedMesh from the current mesh.
  12056. * - name (string) : the cloned mesh name
  12057. * - newParent (optional Node) : the optional Node to parent the clone to.
  12058. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12059. *
  12060. * Returns the clone.
  12061. */
  12062. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12063. /**
  12064. * Disposes the InstancedMesh.
  12065. * Returns nothing.
  12066. */
  12067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12068. }
  12069. }
  12070. declare module BABYLON {
  12071. /**
  12072. * Defines the options associated with the creation of a shader material.
  12073. */
  12074. export interface IShaderMaterialOptions {
  12075. /**
  12076. * Does the material work in alpha blend mode
  12077. */
  12078. needAlphaBlending: boolean;
  12079. /**
  12080. * Does the material work in alpha test mode
  12081. */
  12082. needAlphaTesting: boolean;
  12083. /**
  12084. * The list of attribute names used in the shader
  12085. */
  12086. attributes: string[];
  12087. /**
  12088. * The list of unifrom names used in the shader
  12089. */
  12090. uniforms: string[];
  12091. /**
  12092. * The list of UBO names used in the shader
  12093. */
  12094. uniformBuffers: string[];
  12095. /**
  12096. * The list of sampler names used in the shader
  12097. */
  12098. samplers: string[];
  12099. /**
  12100. * The list of defines used in the shader
  12101. */
  12102. defines: string[];
  12103. }
  12104. /**
  12105. * 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.
  12106. *
  12107. * This returned material effects how the mesh will look based on the code in the shaders.
  12108. *
  12109. * @see http://doc.babylonjs.com/how_to/shader_material
  12110. */
  12111. export class ShaderMaterial extends Material {
  12112. private _shaderPath;
  12113. private _options;
  12114. private _textures;
  12115. private _textureArrays;
  12116. private _floats;
  12117. private _ints;
  12118. private _floatsArrays;
  12119. private _colors3;
  12120. private _colors3Arrays;
  12121. private _colors4;
  12122. private _colors4Arrays;
  12123. private _vectors2;
  12124. private _vectors3;
  12125. private _vectors4;
  12126. private _matrices;
  12127. private _matrices3x3;
  12128. private _matrices2x2;
  12129. private _vectors2Arrays;
  12130. private _vectors3Arrays;
  12131. private _vectors4Arrays;
  12132. private _cachedWorldViewMatrix;
  12133. private _cachedWorldViewProjectionMatrix;
  12134. private _renderId;
  12135. /**
  12136. * Instantiate a new shader material.
  12137. * 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.
  12138. * This returned material effects how the mesh will look based on the code in the shaders.
  12139. * @see http://doc.babylonjs.com/how_to/shader_material
  12140. * @param name Define the name of the material in the scene
  12141. * @param scene Define the scene the material belongs to
  12142. * @param shaderPath Defines the route to the shader code in one of three ways:
  12143. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12144. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12145. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12146. * @param options Define the options used to create the shader
  12147. */
  12148. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12149. /**
  12150. * Gets the options used to compile the shader.
  12151. * They can be modified to trigger a new compilation
  12152. */
  12153. readonly options: IShaderMaterialOptions;
  12154. /**
  12155. * Gets the current class name of the material e.g. "ShaderMaterial"
  12156. * Mainly use in serialization.
  12157. * @returns the class name
  12158. */
  12159. getClassName(): string;
  12160. /**
  12161. * Specifies if the material will require alpha blending
  12162. * @returns a boolean specifying if alpha blending is needed
  12163. */
  12164. needAlphaBlending(): boolean;
  12165. /**
  12166. * Specifies if this material should be rendered in alpha test mode
  12167. * @returns a boolean specifying if an alpha test is needed.
  12168. */
  12169. needAlphaTesting(): boolean;
  12170. private _checkUniform;
  12171. /**
  12172. * Set a texture in the shader.
  12173. * @param name Define the name of the uniform samplers as defined in the shader
  12174. * @param texture Define the texture to bind to this sampler
  12175. * @return the material itself allowing "fluent" like uniform updates
  12176. */
  12177. setTexture(name: string, texture: Texture): ShaderMaterial;
  12178. /**
  12179. * Set a texture array in the shader.
  12180. * @param name Define the name of the uniform sampler array as defined in the shader
  12181. * @param textures Define the list of textures to bind to this sampler
  12182. * @return the material itself allowing "fluent" like uniform updates
  12183. */
  12184. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12185. /**
  12186. * Set a float in the shader.
  12187. * @param name Define the name of the uniform as defined in the shader
  12188. * @param value Define the value to give to the uniform
  12189. * @return the material itself allowing "fluent" like uniform updates
  12190. */
  12191. setFloat(name: string, value: number): ShaderMaterial;
  12192. /**
  12193. * Set a int in the shader.
  12194. * @param name Define the name of the uniform as defined in the shader
  12195. * @param value Define the value to give to the uniform
  12196. * @return the material itself allowing "fluent" like uniform updates
  12197. */
  12198. setInt(name: string, value: number): ShaderMaterial;
  12199. /**
  12200. * Set an array of floats in the shader.
  12201. * @param name Define the name of the uniform as defined in the shader
  12202. * @param value Define the value to give to the uniform
  12203. * @return the material itself allowing "fluent" like uniform updates
  12204. */
  12205. setFloats(name: string, value: number[]): ShaderMaterial;
  12206. /**
  12207. * Set a vec3 in the shader from a Color3.
  12208. * @param name Define the name of the uniform as defined in the shader
  12209. * @param value Define the value to give to the uniform
  12210. * @return the material itself allowing "fluent" like uniform updates
  12211. */
  12212. setColor3(name: string, value: Color3): ShaderMaterial;
  12213. /**
  12214. * Set a vec3 array in the shader from a Color3 array.
  12215. * @param name Define the name of the uniform as defined in the shader
  12216. * @param value Define the value to give to the uniform
  12217. * @return the material itself allowing "fluent" like uniform updates
  12218. */
  12219. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12220. /**
  12221. * Set a vec4 in the shader from a Color4.
  12222. * @param name Define the name of the uniform as defined in the shader
  12223. * @param value Define the value to give to the uniform
  12224. * @return the material itself allowing "fluent" like uniform updates
  12225. */
  12226. setColor4(name: string, value: Color4): ShaderMaterial;
  12227. /**
  12228. * Set a vec4 array in the shader from a Color4 array.
  12229. * @param name Define the name of the uniform as defined in the shader
  12230. * @param value Define the value to give to the uniform
  12231. * @return the material itself allowing "fluent" like uniform updates
  12232. */
  12233. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12234. /**
  12235. * Set a vec2 in the shader from a Vector2.
  12236. * @param name Define the name of the uniform as defined in the shader
  12237. * @param value Define the value to give to the uniform
  12238. * @return the material itself allowing "fluent" like uniform updates
  12239. */
  12240. setVector2(name: string, value: Vector2): ShaderMaterial;
  12241. /**
  12242. * Set a vec3 in the shader from a Vector3.
  12243. * @param name Define the name of the uniform as defined in the shader
  12244. * @param value Define the value to give to the uniform
  12245. * @return the material itself allowing "fluent" like uniform updates
  12246. */
  12247. setVector3(name: string, value: Vector3): ShaderMaterial;
  12248. /**
  12249. * Set a vec4 in the shader from a Vector4.
  12250. * @param name Define the name of the uniform as defined in the shader
  12251. * @param value Define the value to give to the uniform
  12252. * @return the material itself allowing "fluent" like uniform updates
  12253. */
  12254. setVector4(name: string, value: Vector4): ShaderMaterial;
  12255. /**
  12256. * Set a mat4 in the shader from a Matrix.
  12257. * @param name Define the name of the uniform as defined in the shader
  12258. * @param value Define the value to give to the uniform
  12259. * @return the material itself allowing "fluent" like uniform updates
  12260. */
  12261. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12262. /**
  12263. * Set a mat3 in the shader from a Float32Array.
  12264. * @param name Define the name of the uniform as defined in the shader
  12265. * @param value Define the value to give to the uniform
  12266. * @return the material itself allowing "fluent" like uniform updates
  12267. */
  12268. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12269. /**
  12270. * Set a mat2 in the shader from a Float32Array.
  12271. * @param name Define the name of the uniform as defined in the shader
  12272. * @param value Define the value to give to the uniform
  12273. * @return the material itself allowing "fluent" like uniform updates
  12274. */
  12275. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12276. /**
  12277. * Set a vec2 array in the shader from a number array.
  12278. * @param name Define the name of the uniform as defined in the shader
  12279. * @param value Define the value to give to the uniform
  12280. * @return the material itself allowing "fluent" like uniform updates
  12281. */
  12282. setArray2(name: string, value: number[]): ShaderMaterial;
  12283. /**
  12284. * Set a vec3 array in the shader from a number array.
  12285. * @param name Define the name of the uniform as defined in the shader
  12286. * @param value Define the value to give to the uniform
  12287. * @return the material itself allowing "fluent" like uniform updates
  12288. */
  12289. setArray3(name: string, value: number[]): ShaderMaterial;
  12290. /**
  12291. * Set a vec4 array in the shader from a number array.
  12292. * @param name Define the name of the uniform as defined in the shader
  12293. * @param value Define the value to give to the uniform
  12294. * @return the material itself allowing "fluent" like uniform updates
  12295. */
  12296. setArray4(name: string, value: number[]): ShaderMaterial;
  12297. private _checkCache;
  12298. /**
  12299. * Specifies that the submesh is ready to be used
  12300. * @param mesh defines the mesh to check
  12301. * @param subMesh defines which submesh to check
  12302. * @param useInstances specifies that instances should be used
  12303. * @returns a boolean indicating that the submesh is ready or not
  12304. */
  12305. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12306. /**
  12307. * Checks if the material is ready to render the requested mesh
  12308. * @param mesh Define the mesh to render
  12309. * @param useInstances Define whether or not the material is used with instances
  12310. * @returns true if ready, otherwise false
  12311. */
  12312. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12313. /**
  12314. * Binds the world matrix to the material
  12315. * @param world defines the world transformation matrix
  12316. */
  12317. bindOnlyWorldMatrix(world: Matrix): void;
  12318. /**
  12319. * Binds the material to the mesh
  12320. * @param world defines the world transformation matrix
  12321. * @param mesh defines the mesh to bind the material to
  12322. */
  12323. bind(world: Matrix, mesh?: Mesh): void;
  12324. /**
  12325. * Gets the active textures from the material
  12326. * @returns an array of textures
  12327. */
  12328. getActiveTextures(): BaseTexture[];
  12329. /**
  12330. * Specifies if the material uses a texture
  12331. * @param texture defines the texture to check against the material
  12332. * @returns a boolean specifying if the material uses the texture
  12333. */
  12334. hasTexture(texture: BaseTexture): boolean;
  12335. /**
  12336. * Makes a duplicate of the material, and gives it a new name
  12337. * @param name defines the new name for the duplicated material
  12338. * @returns the cloned material
  12339. */
  12340. clone(name: string): ShaderMaterial;
  12341. /**
  12342. * Disposes the material
  12343. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12344. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12345. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12346. */
  12347. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12348. /**
  12349. * Serializes this material in a JSON representation
  12350. * @returns the serialized material object
  12351. */
  12352. serialize(): any;
  12353. /**
  12354. * Creates a shader material from parsed shader material data
  12355. * @param source defines the JSON represnetation of the material
  12356. * @param scene defines the hosting scene
  12357. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12358. * @returns a new material
  12359. */
  12360. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12361. }
  12362. }
  12363. declare module BABYLON {
  12364. /** @hidden */
  12365. export var clipPlaneFragmentDeclaration: {
  12366. name: string;
  12367. shader: string;
  12368. };
  12369. }
  12370. declare module BABYLON {
  12371. /** @hidden */
  12372. export var clipPlaneFragment: {
  12373. name: string;
  12374. shader: string;
  12375. };
  12376. }
  12377. declare module BABYLON {
  12378. /** @hidden */
  12379. export var colorPixelShader: {
  12380. name: string;
  12381. shader: string;
  12382. };
  12383. }
  12384. declare module BABYLON {
  12385. /** @hidden */
  12386. export var clipPlaneVertexDeclaration: {
  12387. name: string;
  12388. shader: string;
  12389. };
  12390. }
  12391. declare module BABYLON {
  12392. /** @hidden */
  12393. export var clipPlaneVertex: {
  12394. name: string;
  12395. shader: string;
  12396. };
  12397. }
  12398. declare module BABYLON {
  12399. /** @hidden */
  12400. export var colorVertexShader: {
  12401. name: string;
  12402. shader: string;
  12403. };
  12404. }
  12405. declare module BABYLON {
  12406. /**
  12407. * Line mesh
  12408. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12409. */
  12410. export class LinesMesh extends Mesh {
  12411. /**
  12412. * If vertex color should be applied to the mesh
  12413. */
  12414. readonly useVertexColor?: boolean | undefined;
  12415. /**
  12416. * If vertex alpha should be applied to the mesh
  12417. */
  12418. readonly useVertexAlpha?: boolean | undefined;
  12419. /**
  12420. * Color of the line (Default: White)
  12421. */
  12422. color: Color3;
  12423. /**
  12424. * Alpha of the line (Default: 1)
  12425. */
  12426. alpha: number;
  12427. /**
  12428. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12429. * This margin is expressed in world space coordinates, so its value may vary.
  12430. * Default value is 0.1
  12431. */
  12432. intersectionThreshold: number;
  12433. private _colorShader;
  12434. private color4;
  12435. /**
  12436. * Creates a new LinesMesh
  12437. * @param name defines the name
  12438. * @param scene defines the hosting scene
  12439. * @param parent defines the parent mesh if any
  12440. * @param source defines the optional source LinesMesh used to clone data from
  12441. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12442. * When false, achieved by calling a clone(), also passing False.
  12443. * This will make creation of children, recursive.
  12444. * @param useVertexColor defines if this LinesMesh supports vertex color
  12445. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12446. */
  12447. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12448. /**
  12449. * If vertex color should be applied to the mesh
  12450. */
  12451. useVertexColor?: boolean | undefined,
  12452. /**
  12453. * If vertex alpha should be applied to the mesh
  12454. */
  12455. useVertexAlpha?: boolean | undefined);
  12456. private _addClipPlaneDefine;
  12457. private _removeClipPlaneDefine;
  12458. isReady(): boolean;
  12459. /**
  12460. * Returns the string "LineMesh"
  12461. */
  12462. getClassName(): string;
  12463. /**
  12464. * @hidden
  12465. */
  12466. /**
  12467. * @hidden
  12468. */
  12469. material: Material;
  12470. /**
  12471. * @hidden
  12472. */
  12473. readonly checkCollisions: boolean;
  12474. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12475. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12476. /**
  12477. * Disposes of the line mesh
  12478. * @param doNotRecurse If children should be disposed
  12479. */
  12480. dispose(doNotRecurse?: boolean): void;
  12481. /**
  12482. * Returns a new LineMesh object cloned from the current one.
  12483. */
  12484. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12485. /**
  12486. * Creates a new InstancedLinesMesh object from the mesh model.
  12487. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12488. * @param name defines the name of the new instance
  12489. * @returns a new InstancedLinesMesh
  12490. */
  12491. createInstance(name: string): InstancedLinesMesh;
  12492. }
  12493. /**
  12494. * Creates an instance based on a source LinesMesh
  12495. */
  12496. export class InstancedLinesMesh extends InstancedMesh {
  12497. /**
  12498. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12499. * This margin is expressed in world space coordinates, so its value may vary.
  12500. * Initilized with the intersectionThreshold value of the source LinesMesh
  12501. */
  12502. intersectionThreshold: number;
  12503. constructor(name: string, source: LinesMesh);
  12504. /**
  12505. * Returns the string "InstancedLinesMesh".
  12506. */
  12507. getClassName(): string;
  12508. }
  12509. }
  12510. declare module BABYLON {
  12511. /**
  12512. * Mesh representing the gorund
  12513. */
  12514. export class GroundMesh extends Mesh {
  12515. /** If octree should be generated */
  12516. generateOctree: boolean;
  12517. private _heightQuads;
  12518. /** @hidden */ private _subdivisionsX: number;
  12519. /** @hidden */ private _subdivisionsY: number;
  12520. /** @hidden */ private _width: number;
  12521. /** @hidden */ private _height: number;
  12522. /** @hidden */ private _minX: number;
  12523. /** @hidden */ private _maxX: number;
  12524. /** @hidden */ private _minZ: number;
  12525. /** @hidden */ private _maxZ: number;
  12526. constructor(name: string, scene: Scene);
  12527. /**
  12528. * "GroundMesh"
  12529. * @returns "GroundMesh"
  12530. */
  12531. getClassName(): string;
  12532. /**
  12533. * The minimum of x and y subdivisions
  12534. */
  12535. readonly subdivisions: number;
  12536. /**
  12537. * X subdivisions
  12538. */
  12539. readonly subdivisionsX: number;
  12540. /**
  12541. * Y subdivisions
  12542. */
  12543. readonly subdivisionsY: number;
  12544. /**
  12545. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12546. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12547. * @param chunksCount the number of subdivisions for x and y
  12548. * @param octreeBlocksSize (Default: 32)
  12549. */
  12550. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12551. /**
  12552. * Returns a height (y) value in the Worl system :
  12553. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12554. * @param x x coordinate
  12555. * @param z z coordinate
  12556. * @returns the ground y position if (x, z) are outside the ground surface.
  12557. */
  12558. getHeightAtCoordinates(x: number, z: number): number;
  12559. /**
  12560. * Returns a normalized vector (Vector3) orthogonal to the ground
  12561. * at the ground coordinates (x, z) expressed in the World system.
  12562. * @param x x coordinate
  12563. * @param z z coordinate
  12564. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12565. */
  12566. getNormalAtCoordinates(x: number, z: number): Vector3;
  12567. /**
  12568. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12569. * at the ground coordinates (x, z) expressed in the World system.
  12570. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12571. * @param x x coordinate
  12572. * @param z z coordinate
  12573. * @param ref vector to store the result
  12574. * @returns the GroundMesh.
  12575. */
  12576. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12577. /**
  12578. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12579. * if the ground has been updated.
  12580. * This can be used in the render loop.
  12581. * @returns the GroundMesh.
  12582. */
  12583. updateCoordinateHeights(): GroundMesh;
  12584. private _getFacetAt;
  12585. private _initHeightQuads;
  12586. private _computeHeightQuads;
  12587. /**
  12588. * Serializes this ground mesh
  12589. * @param serializationObject object to write serialization to
  12590. */
  12591. serialize(serializationObject: any): void;
  12592. /**
  12593. * Parses a serialized ground mesh
  12594. * @param parsedMesh the serialized mesh
  12595. * @param scene the scene to create the ground mesh in
  12596. * @returns the created ground mesh
  12597. */
  12598. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * Interface for Physics-Joint data
  12604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12605. */
  12606. export interface PhysicsJointData {
  12607. /**
  12608. * The main pivot of the joint
  12609. */
  12610. mainPivot?: Vector3;
  12611. /**
  12612. * The connected pivot of the joint
  12613. */
  12614. connectedPivot?: Vector3;
  12615. /**
  12616. * The main axis of the joint
  12617. */
  12618. mainAxis?: Vector3;
  12619. /**
  12620. * The connected axis of the joint
  12621. */
  12622. connectedAxis?: Vector3;
  12623. /**
  12624. * The collision of the joint
  12625. */
  12626. collision?: boolean;
  12627. /**
  12628. * Native Oimo/Cannon/Energy data
  12629. */
  12630. nativeParams?: any;
  12631. }
  12632. /**
  12633. * This is a holder class for the physics joint created by the physics plugin
  12634. * It holds a set of functions to control the underlying joint
  12635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12636. */
  12637. export class PhysicsJoint {
  12638. /**
  12639. * The type of the physics joint
  12640. */
  12641. type: number;
  12642. /**
  12643. * The data for the physics joint
  12644. */
  12645. jointData: PhysicsJointData;
  12646. private _physicsJoint;
  12647. protected _physicsPlugin: IPhysicsEnginePlugin;
  12648. /**
  12649. * Initializes the physics joint
  12650. * @param type The type of the physics joint
  12651. * @param jointData The data for the physics joint
  12652. */
  12653. constructor(
  12654. /**
  12655. * The type of the physics joint
  12656. */
  12657. type: number,
  12658. /**
  12659. * The data for the physics joint
  12660. */
  12661. jointData: PhysicsJointData);
  12662. /**
  12663. * Gets the physics joint
  12664. */
  12665. /**
  12666. * Sets the physics joint
  12667. */
  12668. physicsJoint: any;
  12669. /**
  12670. * Sets the physics plugin
  12671. */
  12672. physicsPlugin: IPhysicsEnginePlugin;
  12673. /**
  12674. * Execute a function that is physics-plugin specific.
  12675. * @param {Function} func the function that will be executed.
  12676. * It accepts two parameters: the physics world and the physics joint
  12677. */
  12678. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12679. /**
  12680. * Distance-Joint type
  12681. */
  12682. static DistanceJoint: number;
  12683. /**
  12684. * Hinge-Joint type
  12685. */
  12686. static HingeJoint: number;
  12687. /**
  12688. * Ball-and-Socket joint type
  12689. */
  12690. static BallAndSocketJoint: number;
  12691. /**
  12692. * Wheel-Joint type
  12693. */
  12694. static WheelJoint: number;
  12695. /**
  12696. * Slider-Joint type
  12697. */
  12698. static SliderJoint: number;
  12699. /**
  12700. * Prismatic-Joint type
  12701. */
  12702. static PrismaticJoint: number;
  12703. /**
  12704. * Universal-Joint type
  12705. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12706. */
  12707. static UniversalJoint: number;
  12708. /**
  12709. * Hinge-Joint 2 type
  12710. */
  12711. static Hinge2Joint: number;
  12712. /**
  12713. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12714. */
  12715. static PointToPointJoint: number;
  12716. /**
  12717. * Spring-Joint type
  12718. */
  12719. static SpringJoint: number;
  12720. /**
  12721. * Lock-Joint type
  12722. */
  12723. static LockJoint: number;
  12724. }
  12725. /**
  12726. * A class representing a physics distance joint
  12727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12728. */
  12729. export class DistanceJoint extends PhysicsJoint {
  12730. /**
  12731. *
  12732. * @param jointData The data for the Distance-Joint
  12733. */
  12734. constructor(jointData: DistanceJointData);
  12735. /**
  12736. * Update the predefined distance.
  12737. * @param maxDistance The maximum preferred distance
  12738. * @param minDistance The minimum preferred distance
  12739. */
  12740. updateDistance(maxDistance: number, minDistance?: number): void;
  12741. }
  12742. /**
  12743. * Represents a Motor-Enabled Joint
  12744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12745. */
  12746. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12747. /**
  12748. * Initializes the Motor-Enabled Joint
  12749. * @param type The type of the joint
  12750. * @param jointData The physica joint data for the joint
  12751. */
  12752. constructor(type: number, jointData: PhysicsJointData);
  12753. /**
  12754. * Set the motor values.
  12755. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12756. * @param force the force to apply
  12757. * @param maxForce max force for this motor.
  12758. */
  12759. setMotor(force?: number, maxForce?: number): void;
  12760. /**
  12761. * Set the motor's limits.
  12762. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12763. * @param upperLimit The upper limit of the motor
  12764. * @param lowerLimit The lower limit of the motor
  12765. */
  12766. setLimit(upperLimit: number, lowerLimit?: number): void;
  12767. }
  12768. /**
  12769. * This class represents a single physics Hinge-Joint
  12770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12771. */
  12772. export class HingeJoint extends MotorEnabledJoint {
  12773. /**
  12774. * Initializes the Hinge-Joint
  12775. * @param jointData The joint data for the Hinge-Joint
  12776. */
  12777. constructor(jointData: PhysicsJointData);
  12778. /**
  12779. * Set the motor values.
  12780. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12781. * @param {number} force the force to apply
  12782. * @param {number} maxForce max force for this motor.
  12783. */
  12784. setMotor(force?: number, maxForce?: number): void;
  12785. /**
  12786. * Set the motor's limits.
  12787. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12788. * @param upperLimit The upper limit of the motor
  12789. * @param lowerLimit The lower limit of the motor
  12790. */
  12791. setLimit(upperLimit: number, lowerLimit?: number): void;
  12792. }
  12793. /**
  12794. * This class represents a dual hinge physics joint (same as wheel joint)
  12795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12796. */
  12797. export class Hinge2Joint extends MotorEnabledJoint {
  12798. /**
  12799. * Initializes the Hinge2-Joint
  12800. * @param jointData The joint data for the Hinge2-Joint
  12801. */
  12802. constructor(jointData: PhysicsJointData);
  12803. /**
  12804. * Set the motor values.
  12805. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12806. * @param {number} targetSpeed the speed the motor is to reach
  12807. * @param {number} maxForce max force for this motor.
  12808. * @param {motorIndex} the motor's index, 0 or 1.
  12809. */
  12810. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  12811. /**
  12812. * Set the motor limits.
  12813. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12814. * @param {number} upperLimit the upper limit
  12815. * @param {number} lowerLimit lower limit
  12816. * @param {motorIndex} the motor's index, 0 or 1.
  12817. */
  12818. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12819. }
  12820. /**
  12821. * Interface for a motor enabled joint
  12822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12823. */
  12824. export interface IMotorEnabledJoint {
  12825. /**
  12826. * Physics joint
  12827. */
  12828. physicsJoint: any;
  12829. /**
  12830. * Sets the motor of the motor-enabled joint
  12831. * @param force The force of the motor
  12832. * @param maxForce The maximum force of the motor
  12833. * @param motorIndex The index of the motor
  12834. */
  12835. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  12836. /**
  12837. * Sets the limit of the motor
  12838. * @param upperLimit The upper limit of the motor
  12839. * @param lowerLimit The lower limit of the motor
  12840. * @param motorIndex The index of the motor
  12841. */
  12842. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12843. }
  12844. /**
  12845. * Joint data for a Distance-Joint
  12846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12847. */
  12848. export interface DistanceJointData extends PhysicsJointData {
  12849. /**
  12850. * Max distance the 2 joint objects can be apart
  12851. */
  12852. maxDistance: number;
  12853. }
  12854. /**
  12855. * Joint data from a spring joint
  12856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12857. */
  12858. export interface SpringJointData extends PhysicsJointData {
  12859. /**
  12860. * Length of the spring
  12861. */
  12862. length: number;
  12863. /**
  12864. * Stiffness of the spring
  12865. */
  12866. stiffness: number;
  12867. /**
  12868. * Damping of the spring
  12869. */
  12870. damping: number;
  12871. /** this callback will be called when applying the force to the impostors. */
  12872. forceApplicationCallback: () => void;
  12873. }
  12874. }
  12875. declare module BABYLON {
  12876. /**
  12877. * Holds the data for the raycast result
  12878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12879. */
  12880. export class PhysicsRaycastResult {
  12881. private _hasHit;
  12882. private _hitDistance;
  12883. private _hitNormalWorld;
  12884. private _hitPointWorld;
  12885. private _rayFromWorld;
  12886. private _rayToWorld;
  12887. /**
  12888. * Gets if there was a hit
  12889. */
  12890. readonly hasHit: boolean;
  12891. /**
  12892. * Gets the distance from the hit
  12893. */
  12894. readonly hitDistance: number;
  12895. /**
  12896. * Gets the hit normal/direction in the world
  12897. */
  12898. readonly hitNormalWorld: Vector3;
  12899. /**
  12900. * Gets the hit point in the world
  12901. */
  12902. readonly hitPointWorld: Vector3;
  12903. /**
  12904. * Gets the ray "start point" of the ray in the world
  12905. */
  12906. readonly rayFromWorld: Vector3;
  12907. /**
  12908. * Gets the ray "end point" of the ray in the world
  12909. */
  12910. readonly rayToWorld: Vector3;
  12911. /**
  12912. * Sets the hit data (normal & point in world space)
  12913. * @param hitNormalWorld defines the normal in world space
  12914. * @param hitPointWorld defines the point in world space
  12915. */
  12916. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  12917. /**
  12918. * Sets the distance from the start point to the hit point
  12919. * @param distance
  12920. */
  12921. setHitDistance(distance: number): void;
  12922. /**
  12923. * Calculates the distance manually
  12924. */
  12925. calculateHitDistance(): void;
  12926. /**
  12927. * Resets all the values to default
  12928. * @param from The from point on world space
  12929. * @param to The to point on world space
  12930. */
  12931. reset(from?: Vector3, to?: Vector3): void;
  12932. }
  12933. /**
  12934. * Interface for the size containing width and height
  12935. */
  12936. interface IXYZ {
  12937. /**
  12938. * X
  12939. */
  12940. x: number;
  12941. /**
  12942. * Y
  12943. */
  12944. y: number;
  12945. /**
  12946. * Z
  12947. */
  12948. z: number;
  12949. }
  12950. }
  12951. declare module BABYLON {
  12952. /**
  12953. * Interface used to describe a physics joint
  12954. */
  12955. export interface PhysicsImpostorJoint {
  12956. /** Defines the main impostor to which the joint is linked */
  12957. mainImpostor: PhysicsImpostor;
  12958. /** Defines the impostor that is connected to the main impostor using this joint */
  12959. connectedImpostor: PhysicsImpostor;
  12960. /** Defines the joint itself */
  12961. joint: PhysicsJoint;
  12962. }
  12963. /** @hidden */
  12964. export interface IPhysicsEnginePlugin {
  12965. world: any;
  12966. name: string;
  12967. setGravity(gravity: Vector3): void;
  12968. setTimeStep(timeStep: number): void;
  12969. getTimeStep(): number;
  12970. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  12971. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  12972. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  12973. generatePhysicsBody(impostor: PhysicsImpostor): void;
  12974. removePhysicsBody(impostor: PhysicsImpostor): void;
  12975. generateJoint(joint: PhysicsImpostorJoint): void;
  12976. removeJoint(joint: PhysicsImpostorJoint): void;
  12977. isSupported(): boolean;
  12978. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  12979. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  12980. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  12981. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  12982. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  12983. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  12984. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  12985. getBodyMass(impostor: PhysicsImpostor): number;
  12986. getBodyFriction(impostor: PhysicsImpostor): number;
  12987. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  12988. getBodyRestitution(impostor: PhysicsImpostor): number;
  12989. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  12990. getBodyPressure?(impostor: PhysicsImpostor): number;
  12991. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  12992. getBodyStiffness?(impostor: PhysicsImpostor): number;
  12993. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  12994. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  12995. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  12996. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  12997. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  12998. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  12999. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13000. sleepBody(impostor: PhysicsImpostor): void;
  13001. wakeUpBody(impostor: PhysicsImpostor): void;
  13002. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13003. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13004. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13005. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13006. getRadius(impostor: PhysicsImpostor): number;
  13007. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13008. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13009. dispose(): void;
  13010. }
  13011. /**
  13012. * Interface used to define a physics engine
  13013. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13014. */
  13015. export interface IPhysicsEngine {
  13016. /**
  13017. * Gets the gravity vector used by the simulation
  13018. */
  13019. gravity: Vector3;
  13020. /**
  13021. * Sets the gravity vector used by the simulation
  13022. * @param gravity defines the gravity vector to use
  13023. */
  13024. setGravity(gravity: Vector3): void;
  13025. /**
  13026. * Set the time step of the physics engine.
  13027. * Default is 1/60.
  13028. * To slow it down, enter 1/600 for example.
  13029. * To speed it up, 1/30
  13030. * @param newTimeStep the new timestep to apply to this world.
  13031. */
  13032. setTimeStep(newTimeStep: number): void;
  13033. /**
  13034. * Get the time step of the physics engine.
  13035. * @returns the current time step
  13036. */
  13037. getTimeStep(): number;
  13038. /**
  13039. * Release all resources
  13040. */
  13041. dispose(): void;
  13042. /**
  13043. * Gets the name of the current physics plugin
  13044. * @returns the name of the plugin
  13045. */
  13046. getPhysicsPluginName(): string;
  13047. /**
  13048. * Adding a new impostor for the impostor tracking.
  13049. * This will be done by the impostor itself.
  13050. * @param impostor the impostor to add
  13051. */
  13052. addImpostor(impostor: PhysicsImpostor): void;
  13053. /**
  13054. * Remove an impostor from the engine.
  13055. * This impostor and its mesh will not longer be updated by the physics engine.
  13056. * @param impostor the impostor to remove
  13057. */
  13058. removeImpostor(impostor: PhysicsImpostor): void;
  13059. /**
  13060. * Add a joint to the physics engine
  13061. * @param mainImpostor defines the main impostor to which the joint is added.
  13062. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13063. * @param joint defines the joint that will connect both impostors.
  13064. */
  13065. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13066. /**
  13067. * Removes a joint from the simulation
  13068. * @param mainImpostor defines the impostor used with the joint
  13069. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13070. * @param joint defines the joint to remove
  13071. */
  13072. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13073. /**
  13074. * Gets the current plugin used to run the simulation
  13075. * @returns current plugin
  13076. */
  13077. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13078. /**
  13079. * Gets the list of physic impostors
  13080. * @returns an array of PhysicsImpostor
  13081. */
  13082. getImpostors(): Array<PhysicsImpostor>;
  13083. /**
  13084. * Gets the impostor for a physics enabled object
  13085. * @param object defines the object impersonated by the impostor
  13086. * @returns the PhysicsImpostor or null if not found
  13087. */
  13088. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13089. /**
  13090. * Gets the impostor for a physics body object
  13091. * @param body defines physics body used by the impostor
  13092. * @returns the PhysicsImpostor or null if not found
  13093. */
  13094. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13095. /**
  13096. * Does a raycast in the physics world
  13097. * @param from when should the ray start?
  13098. * @param to when should the ray end?
  13099. * @returns PhysicsRaycastResult
  13100. */
  13101. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13102. /**
  13103. * Called by the scene. No need to call it.
  13104. * @param delta defines the timespam between frames
  13105. */ private _step(delta: number): void;
  13106. }
  13107. }
  13108. declare module BABYLON {
  13109. /**
  13110. * The interface for the physics imposter parameters
  13111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13112. */
  13113. export interface PhysicsImpostorParameters {
  13114. /**
  13115. * The mass of the physics imposter
  13116. */
  13117. mass: number;
  13118. /**
  13119. * The friction of the physics imposter
  13120. */
  13121. friction?: number;
  13122. /**
  13123. * The coefficient of restitution of the physics imposter
  13124. */
  13125. restitution?: number;
  13126. /**
  13127. * The native options of the physics imposter
  13128. */
  13129. nativeOptions?: any;
  13130. /**
  13131. * Specifies if the parent should be ignored
  13132. */
  13133. ignoreParent?: boolean;
  13134. /**
  13135. * Specifies if bi-directional transformations should be disabled
  13136. */
  13137. disableBidirectionalTransformation?: boolean;
  13138. /**
  13139. * The pressure inside the physics imposter, soft object only
  13140. */
  13141. pressure?: number;
  13142. /**
  13143. * The stiffness the physics imposter, soft object only
  13144. */
  13145. stiffness?: number;
  13146. /**
  13147. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13148. */
  13149. velocityIterations?: number;
  13150. /**
  13151. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13152. */
  13153. positionIterations?: number;
  13154. /**
  13155. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13156. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13157. * Add to fix multiple points
  13158. */
  13159. fixedPoints?: number;
  13160. /**
  13161. * The collision margin around a soft object
  13162. */
  13163. margin?: number;
  13164. /**
  13165. * The collision margin around a soft object
  13166. */
  13167. damping?: number;
  13168. /**
  13169. * The path for a rope based on an extrusion
  13170. */
  13171. path?: any;
  13172. /**
  13173. * The shape of an extrusion used for a rope based on an extrusion
  13174. */
  13175. shape?: any;
  13176. }
  13177. /**
  13178. * Interface for a physics-enabled object
  13179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13180. */
  13181. export interface IPhysicsEnabledObject {
  13182. /**
  13183. * The position of the physics-enabled object
  13184. */
  13185. position: Vector3;
  13186. /**
  13187. * The rotation of the physics-enabled object
  13188. */
  13189. rotationQuaternion: Nullable<Quaternion>;
  13190. /**
  13191. * The scale of the physics-enabled object
  13192. */
  13193. scaling: Vector3;
  13194. /**
  13195. * The rotation of the physics-enabled object
  13196. */
  13197. rotation?: Vector3;
  13198. /**
  13199. * The parent of the physics-enabled object
  13200. */
  13201. parent?: any;
  13202. /**
  13203. * The bounding info of the physics-enabled object
  13204. * @returns The bounding info of the physics-enabled object
  13205. */
  13206. getBoundingInfo(): BoundingInfo;
  13207. /**
  13208. * Computes the world matrix
  13209. * @param force Specifies if the world matrix should be computed by force
  13210. * @returns A world matrix
  13211. */
  13212. computeWorldMatrix(force: boolean): Matrix;
  13213. /**
  13214. * Gets the world matrix
  13215. * @returns A world matrix
  13216. */
  13217. getWorldMatrix?(): Matrix;
  13218. /**
  13219. * Gets the child meshes
  13220. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13221. * @returns An array of abstract meshes
  13222. */
  13223. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13224. /**
  13225. * Gets the vertex data
  13226. * @param kind The type of vertex data
  13227. * @returns A nullable array of numbers, or a float32 array
  13228. */
  13229. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13230. /**
  13231. * Gets the indices from the mesh
  13232. * @returns A nullable array of index arrays
  13233. */
  13234. getIndices?(): Nullable<IndicesArray>;
  13235. /**
  13236. * Gets the scene from the mesh
  13237. * @returns the indices array or null
  13238. */
  13239. getScene?(): Scene;
  13240. /**
  13241. * Gets the absolute position from the mesh
  13242. * @returns the absolute position
  13243. */
  13244. getAbsolutePosition(): Vector3;
  13245. /**
  13246. * Gets the absolute pivot point from the mesh
  13247. * @returns the absolute pivot point
  13248. */
  13249. getAbsolutePivotPoint(): Vector3;
  13250. /**
  13251. * Rotates the mesh
  13252. * @param axis The axis of rotation
  13253. * @param amount The amount of rotation
  13254. * @param space The space of the rotation
  13255. * @returns The rotation transform node
  13256. */
  13257. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13258. /**
  13259. * Translates the mesh
  13260. * @param axis The axis of translation
  13261. * @param distance The distance of translation
  13262. * @param space The space of the translation
  13263. * @returns The transform node
  13264. */
  13265. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13266. /**
  13267. * Sets the absolute position of the mesh
  13268. * @param absolutePosition The absolute position of the mesh
  13269. * @returns The transform node
  13270. */
  13271. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13272. /**
  13273. * Gets the class name of the mesh
  13274. * @returns The class name
  13275. */
  13276. getClassName(): string;
  13277. }
  13278. /**
  13279. * Represents a physics imposter
  13280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13281. */
  13282. export class PhysicsImpostor {
  13283. /**
  13284. * The physics-enabled object used as the physics imposter
  13285. */
  13286. object: IPhysicsEnabledObject;
  13287. /**
  13288. * The type of the physics imposter
  13289. */
  13290. type: number;
  13291. private _options;
  13292. private _scene?;
  13293. /**
  13294. * The default object size of the imposter
  13295. */
  13296. static DEFAULT_OBJECT_SIZE: Vector3;
  13297. /**
  13298. * The identity quaternion of the imposter
  13299. */
  13300. static IDENTITY_QUATERNION: Quaternion;
  13301. /** @hidden */ private _pluginData: any;
  13302. private _physicsEngine;
  13303. private _physicsBody;
  13304. private _bodyUpdateRequired;
  13305. private _onBeforePhysicsStepCallbacks;
  13306. private _onAfterPhysicsStepCallbacks;
  13307. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  13308. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13309. otherImpostors: Array<PhysicsImpostor>;
  13310. }>;
  13311. private _deltaPosition;
  13312. private _deltaRotation;
  13313. private _deltaRotationConjugated;
  13314. /** @hidden */ private _isFromLine: boolean;
  13315. private _parent;
  13316. private _isDisposed;
  13317. private static _tmpVecs;
  13318. private static _tmpQuat;
  13319. /**
  13320. * Specifies if the physics imposter is disposed
  13321. */
  13322. readonly isDisposed: boolean;
  13323. /**
  13324. * Gets the mass of the physics imposter
  13325. */
  13326. mass: number;
  13327. /**
  13328. * Gets the coefficient of friction
  13329. */
  13330. /**
  13331. * Sets the coefficient of friction
  13332. */
  13333. friction: number;
  13334. /**
  13335. * Gets the coefficient of restitution
  13336. */
  13337. /**
  13338. * Sets the coefficient of restitution
  13339. */
  13340. restitution: number;
  13341. /**
  13342. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13343. */
  13344. /**
  13345. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13346. */
  13347. pressure: number;
  13348. /**
  13349. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13350. */
  13351. /**
  13352. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13353. */
  13354. stiffness: number;
  13355. /**
  13356. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13357. */
  13358. /**
  13359. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13360. */
  13361. velocityIterations: number;
  13362. /**
  13363. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13364. */
  13365. /**
  13366. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13367. */
  13368. positionIterations: number;
  13369. /**
  13370. * The unique id of the physics imposter
  13371. * set by the physics engine when adding this impostor to the array
  13372. */
  13373. uniqueId: number;
  13374. /**
  13375. * @hidden
  13376. */
  13377. soft: boolean;
  13378. /**
  13379. * @hidden
  13380. */
  13381. segments: number;
  13382. private _joints;
  13383. /**
  13384. * Initializes the physics imposter
  13385. * @param object The physics-enabled object used as the physics imposter
  13386. * @param type The type of the physics imposter
  13387. * @param _options The options for the physics imposter
  13388. * @param _scene The Babylon scene
  13389. */
  13390. constructor(
  13391. /**
  13392. * The physics-enabled object used as the physics imposter
  13393. */
  13394. object: IPhysicsEnabledObject,
  13395. /**
  13396. * The type of the physics imposter
  13397. */
  13398. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13399. /**
  13400. * This function will completly initialize this impostor.
  13401. * It will create a new body - but only if this mesh has no parent.
  13402. * If it has, this impostor will not be used other than to define the impostor
  13403. * of the child mesh.
  13404. * @hidden
  13405. */ private _init(): void;
  13406. private _getPhysicsParent;
  13407. /**
  13408. * Should a new body be generated.
  13409. * @returns boolean specifying if body initialization is required
  13410. */
  13411. isBodyInitRequired(): boolean;
  13412. /**
  13413. * Sets the updated scaling
  13414. * @param updated Specifies if the scaling is updated
  13415. */
  13416. setScalingUpdated(): void;
  13417. /**
  13418. * Force a regeneration of this or the parent's impostor's body.
  13419. * Use under cautious - This will remove all joints already implemented.
  13420. */
  13421. forceUpdate(): void;
  13422. /**
  13423. * Gets the body that holds this impostor. Either its own, or its parent.
  13424. */
  13425. /**
  13426. * Set the physics body. Used mainly by the physics engine/plugin
  13427. */
  13428. physicsBody: any;
  13429. /**
  13430. * Get the parent of the physics imposter
  13431. * @returns Physics imposter or null
  13432. */
  13433. /**
  13434. * Sets the parent of the physics imposter
  13435. */
  13436. parent: Nullable<PhysicsImpostor>;
  13437. /**
  13438. * Resets the update flags
  13439. */
  13440. resetUpdateFlags(): void;
  13441. /**
  13442. * Gets the object extend size
  13443. * @returns the object extend size
  13444. */
  13445. getObjectExtendSize(): Vector3;
  13446. /**
  13447. * Gets the object center
  13448. * @returns The object center
  13449. */
  13450. getObjectCenter(): Vector3;
  13451. /**
  13452. * Get a specific parametes from the options parameter
  13453. * @param paramName The object parameter name
  13454. * @returns The object parameter
  13455. */
  13456. getParam(paramName: string): any;
  13457. /**
  13458. * Sets a specific parameter in the options given to the physics plugin
  13459. * @param paramName The parameter name
  13460. * @param value The value of the parameter
  13461. */
  13462. setParam(paramName: string, value: number): void;
  13463. /**
  13464. * Specifically change the body's mass option. Won't recreate the physics body object
  13465. * @param mass The mass of the physics imposter
  13466. */
  13467. setMass(mass: number): void;
  13468. /**
  13469. * Gets the linear velocity
  13470. * @returns linear velocity or null
  13471. */
  13472. getLinearVelocity(): Nullable<Vector3>;
  13473. /**
  13474. * Sets the linear velocity
  13475. * @param velocity linear velocity or null
  13476. */
  13477. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13478. /**
  13479. * Gets the angular velocity
  13480. * @returns angular velocity or null
  13481. */
  13482. getAngularVelocity(): Nullable<Vector3>;
  13483. /**
  13484. * Sets the angular velocity
  13485. * @param velocity The velocity or null
  13486. */
  13487. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13488. /**
  13489. * Execute a function with the physics plugin native code
  13490. * Provide a function the will have two variables - the world object and the physics body object
  13491. * @param func The function to execute with the physics plugin native code
  13492. */
  13493. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13494. /**
  13495. * Register a function that will be executed before the physics world is stepping forward
  13496. * @param func The function to execute before the physics world is stepped forward
  13497. */
  13498. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13499. /**
  13500. * Unregister a function that will be executed before the physics world is stepping forward
  13501. * @param func The function to execute before the physics world is stepped forward
  13502. */
  13503. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13504. /**
  13505. * Register a function that will be executed after the physics step
  13506. * @param func The function to execute after physics step
  13507. */
  13508. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13509. /**
  13510. * Unregisters a function that will be executed after the physics step
  13511. * @param func The function to execute after physics step
  13512. */
  13513. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13514. /**
  13515. * register a function that will be executed when this impostor collides against a different body
  13516. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13517. * @param func Callback that is executed on collision
  13518. */
  13519. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13520. /**
  13521. * Unregisters the physics imposter on contact
  13522. * @param collideAgainst The physics object to collide against
  13523. * @param func Callback to execute on collision
  13524. */
  13525. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13526. private _tmpQuat;
  13527. private _tmpQuat2;
  13528. /**
  13529. * Get the parent rotation
  13530. * @returns The parent rotation
  13531. */
  13532. getParentsRotation(): Quaternion;
  13533. /**
  13534. * this function is executed by the physics engine.
  13535. */
  13536. beforeStep: () => void;
  13537. /**
  13538. * this function is executed by the physics engine
  13539. */
  13540. afterStep: () => void;
  13541. /**
  13542. * Legacy collision detection event support
  13543. */
  13544. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13545. /**
  13546. * event and body object due to cannon's event-based architecture.
  13547. */
  13548. onCollide: (e: {
  13549. body: any;
  13550. }) => void;
  13551. /**
  13552. * Apply a force
  13553. * @param force The force to apply
  13554. * @param contactPoint The contact point for the force
  13555. * @returns The physics imposter
  13556. */
  13557. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13558. /**
  13559. * Apply an impulse
  13560. * @param force The impulse force
  13561. * @param contactPoint The contact point for the impulse force
  13562. * @returns The physics imposter
  13563. */
  13564. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13565. /**
  13566. * A help function to create a joint
  13567. * @param otherImpostor A physics imposter used to create a joint
  13568. * @param jointType The type of joint
  13569. * @param jointData The data for the joint
  13570. * @returns The physics imposter
  13571. */
  13572. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13573. /**
  13574. * Add a joint to this impostor with a different impostor
  13575. * @param otherImpostor A physics imposter used to add a joint
  13576. * @param joint The joint to add
  13577. * @returns The physics imposter
  13578. */
  13579. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13580. /**
  13581. * Add an anchor to a cloth impostor
  13582. * @param otherImpostor rigid impostor to anchor to
  13583. * @param width ratio across width from 0 to 1
  13584. * @param height ratio up height from 0 to 1
  13585. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13586. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13587. * @returns impostor the soft imposter
  13588. */
  13589. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13590. /**
  13591. * Add a hook to a rope impostor
  13592. * @param otherImpostor rigid impostor to anchor to
  13593. * @param length ratio across rope from 0 to 1
  13594. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13595. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13596. * @returns impostor the rope imposter
  13597. */
  13598. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13599. /**
  13600. * Will keep this body still, in a sleep mode.
  13601. * @returns the physics imposter
  13602. */
  13603. sleep(): PhysicsImpostor;
  13604. /**
  13605. * Wake the body up.
  13606. * @returns The physics imposter
  13607. */
  13608. wakeUp(): PhysicsImpostor;
  13609. /**
  13610. * Clones the physics imposter
  13611. * @param newObject The physics imposter clones to this physics-enabled object
  13612. * @returns A nullable physics imposter
  13613. */
  13614. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13615. /**
  13616. * Disposes the physics imposter
  13617. */
  13618. dispose(): void;
  13619. /**
  13620. * Sets the delta position
  13621. * @param position The delta position amount
  13622. */
  13623. setDeltaPosition(position: Vector3): void;
  13624. /**
  13625. * Sets the delta rotation
  13626. * @param rotation The delta rotation amount
  13627. */
  13628. setDeltaRotation(rotation: Quaternion): void;
  13629. /**
  13630. * Gets the box size of the physics imposter and stores the result in the input parameter
  13631. * @param result Stores the box size
  13632. * @returns The physics imposter
  13633. */
  13634. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13635. /**
  13636. * Gets the radius of the physics imposter
  13637. * @returns Radius of the physics imposter
  13638. */
  13639. getRadius(): number;
  13640. /**
  13641. * Sync a bone with this impostor
  13642. * @param bone The bone to sync to the impostor.
  13643. * @param boneMesh The mesh that the bone is influencing.
  13644. * @param jointPivot The pivot of the joint / bone in local space.
  13645. * @param distToJoint Optional distance from the impostor to the joint.
  13646. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13647. */
  13648. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13649. /**
  13650. * Sync impostor to a bone
  13651. * @param bone The bone that the impostor will be synced to.
  13652. * @param boneMesh The mesh that the bone is influencing.
  13653. * @param jointPivot The pivot of the joint / bone in local space.
  13654. * @param distToJoint Optional distance from the impostor to the joint.
  13655. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13656. * @param boneAxis Optional vector3 axis the bone is aligned with
  13657. */
  13658. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13659. /**
  13660. * No-Imposter type
  13661. */
  13662. static NoImpostor: number;
  13663. /**
  13664. * Sphere-Imposter type
  13665. */
  13666. static SphereImpostor: number;
  13667. /**
  13668. * Box-Imposter type
  13669. */
  13670. static BoxImpostor: number;
  13671. /**
  13672. * Plane-Imposter type
  13673. */
  13674. static PlaneImpostor: number;
  13675. /**
  13676. * Mesh-imposter type
  13677. */
  13678. static MeshImpostor: number;
  13679. /**
  13680. * Capsule-Impostor type (Ammo.js plugin only)
  13681. */
  13682. static CapsuleImpostor: number;
  13683. /**
  13684. * Cylinder-Imposter type
  13685. */
  13686. static CylinderImpostor: number;
  13687. /**
  13688. * Particle-Imposter type
  13689. */
  13690. static ParticleImpostor: number;
  13691. /**
  13692. * Heightmap-Imposter type
  13693. */
  13694. static HeightmapImpostor: number;
  13695. /**
  13696. * ConvexHull-Impostor type (Ammo.js plugin only)
  13697. */
  13698. static ConvexHullImpostor: number;
  13699. /**
  13700. * Rope-Imposter type
  13701. */
  13702. static RopeImpostor: number;
  13703. /**
  13704. * Cloth-Imposter type
  13705. */
  13706. static ClothImpostor: number;
  13707. /**
  13708. * Softbody-Imposter type
  13709. */
  13710. static SoftbodyImpostor: number;
  13711. }
  13712. }
  13713. declare module BABYLON {
  13714. /**
  13715. * @hidden
  13716. **/
  13717. export class _CreationDataStorage {
  13718. closePath?: boolean;
  13719. closeArray?: boolean;
  13720. idx: number[];
  13721. dashSize: number;
  13722. gapSize: number;
  13723. path3D: Path3D;
  13724. pathArray: Vector3[][];
  13725. arc: number;
  13726. radius: number;
  13727. cap: number;
  13728. tessellation: number;
  13729. }
  13730. /**
  13731. * @hidden
  13732. **/ private class _InstanceDataStorage {
  13733. visibleInstances: any;
  13734. batchCache: _InstancesBatch;
  13735. instancesBufferSize: number;
  13736. instancesBuffer: Nullable<Buffer>;
  13737. instancesData: Float32Array;
  13738. overridenInstanceCount: number;
  13739. isFrozen: boolean;
  13740. previousBatch: Nullable<_InstancesBatch>;
  13741. hardwareInstancedRendering: boolean;
  13742. sideOrientation: number;
  13743. }
  13744. /**
  13745. * @hidden
  13746. **/
  13747. export class _InstancesBatch {
  13748. mustReturn: boolean;
  13749. visibleInstances: Nullable<InstancedMesh[]>[];
  13750. renderSelf: boolean[];
  13751. hardwareInstancedRendering: boolean[];
  13752. }
  13753. /**
  13754. * Class used to represent renderable models
  13755. */
  13756. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13757. /**
  13758. * Mesh side orientation : usually the external or front surface
  13759. */
  13760. static readonly FRONTSIDE: number;
  13761. /**
  13762. * Mesh side orientation : usually the internal or back surface
  13763. */
  13764. static readonly BACKSIDE: number;
  13765. /**
  13766. * Mesh side orientation : both internal and external or front and back surfaces
  13767. */
  13768. static readonly DOUBLESIDE: number;
  13769. /**
  13770. * Mesh side orientation : by default, `FRONTSIDE`
  13771. */
  13772. static readonly DEFAULTSIDE: number;
  13773. /**
  13774. * Mesh cap setting : no cap
  13775. */
  13776. static readonly NO_CAP: number;
  13777. /**
  13778. * Mesh cap setting : one cap at the beginning of the mesh
  13779. */
  13780. static readonly CAP_START: number;
  13781. /**
  13782. * Mesh cap setting : one cap at the end of the mesh
  13783. */
  13784. static readonly CAP_END: number;
  13785. /**
  13786. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13787. */
  13788. static readonly CAP_ALL: number;
  13789. /**
  13790. * Mesh pattern setting : no flip or rotate
  13791. */
  13792. static readonly NO_FLIP: number;
  13793. /**
  13794. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13795. */
  13796. static readonly FLIP_TILE: number;
  13797. /**
  13798. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13799. */
  13800. static readonly ROTATE_TILE: number;
  13801. /**
  13802. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  13803. */
  13804. static readonly FLIP_ROW: number;
  13805. /**
  13806. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  13807. */
  13808. static readonly ROTATE_ROW: number;
  13809. /**
  13810. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  13811. */
  13812. static readonly FLIP_N_ROTATE_TILE: number;
  13813. /**
  13814. * Mesh pattern setting : rotate pattern and rotate
  13815. */
  13816. static readonly FLIP_N_ROTATE_ROW: number;
  13817. /**
  13818. * Mesh tile positioning : part tiles same on left/right or top/bottom
  13819. */
  13820. static readonly CENTER: number;
  13821. /**
  13822. * Mesh tile positioning : part tiles on left
  13823. */
  13824. static readonly LEFT: number;
  13825. /**
  13826. * Mesh tile positioning : part tiles on right
  13827. */
  13828. static readonly RIGHT: number;
  13829. /**
  13830. * Mesh tile positioning : part tiles on top
  13831. */
  13832. static readonly TOP: number;
  13833. /**
  13834. * Mesh tile positioning : part tiles on bottom
  13835. */
  13836. static readonly BOTTOM: number;
  13837. /**
  13838. * Gets the default side orientation.
  13839. * @param orientation the orientation to value to attempt to get
  13840. * @returns the default orientation
  13841. * @hidden
  13842. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  13843. private _internalMeshDataInfo;
  13844. /**
  13845. * An event triggered before rendering the mesh
  13846. */
  13847. readonly onBeforeRenderObservable: Observable<Mesh>;
  13848. /**
  13849. * An event triggered before binding the mesh
  13850. */
  13851. readonly onBeforeBindObservable: Observable<Mesh>;
  13852. /**
  13853. * An event triggered after rendering the mesh
  13854. */
  13855. readonly onAfterRenderObservable: Observable<Mesh>;
  13856. /**
  13857. * An event triggered before drawing the mesh
  13858. */
  13859. readonly onBeforeDrawObservable: Observable<Mesh>;
  13860. private _onBeforeDrawObserver;
  13861. /**
  13862. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  13863. */
  13864. onBeforeDraw: () => void;
  13865. /**
  13866. * Gets the delay loading state of the mesh (when delay loading is turned on)
  13867. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  13868. */
  13869. delayLoadState: number;
  13870. /**
  13871. * Gets the list of instances created from this mesh
  13872. * it is not supposed to be modified manually.
  13873. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  13874. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  13875. */
  13876. instances: InstancedMesh[];
  13877. /**
  13878. * Gets the file containing delay loading data for this mesh
  13879. */
  13880. delayLoadingFile: string;
  13881. /** @hidden */ private _binaryInfo: any;
  13882. /**
  13883. * User defined function used to change how LOD level selection is done
  13884. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  13885. */
  13886. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  13887. /**
  13888. * Gets or sets the morph target manager
  13889. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  13890. */
  13891. morphTargetManager: Nullable<MorphTargetManager>;
  13892. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  13893. /** @hidden */ private _geometry: Nullable<Geometry>;
  13894. /** @hidden */ private _delayInfo: Array<string>;
  13895. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  13896. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  13897. private _effectiveMaterial;
  13898. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  13899. /** @hidden */ private _originalBuilderSideOrientation: number;
  13900. /**
  13901. * Use this property to change the original side orientation defined at construction time
  13902. */
  13903. overrideMaterialSideOrientation: Nullable<number>;
  13904. /**
  13905. * Gets the source mesh (the one used to clone this one from)
  13906. */
  13907. readonly source: Nullable<Mesh>;
  13908. /**
  13909. * Gets or sets a boolean indicating that this mesh does not use index buffer
  13910. */
  13911. isUnIndexed: boolean;
  13912. /**
  13913. * @constructor
  13914. * @param name The value used by scene.getMeshByName() to do a lookup.
  13915. * @param scene The scene to add this mesh to.
  13916. * @param parent The parent of this mesh, if it has one
  13917. * @param source An optional Mesh from which geometry is shared, cloned.
  13918. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  13919. * When false, achieved by calling a clone(), also passing False.
  13920. * This will make creation of children, recursive.
  13921. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  13922. */
  13923. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  13924. /**
  13925. * Gets the class name
  13926. * @returns the string "Mesh".
  13927. */
  13928. getClassName(): string;
  13929. /** @hidden */ protected readonly _isMesh: boolean;
  13930. /**
  13931. * Returns a description of this mesh
  13932. * @param fullDetails define if full details about this mesh must be used
  13933. * @returns a descriptive string representing this mesh
  13934. */
  13935. toString(fullDetails?: boolean): string;
  13936. /** @hidden */ private _unBindEffect(): void;
  13937. /**
  13938. * Gets a boolean indicating if this mesh has LOD
  13939. */
  13940. readonly hasLODLevels: boolean;
  13941. /**
  13942. * Gets the list of MeshLODLevel associated with the current mesh
  13943. * @returns an array of MeshLODLevel
  13944. */
  13945. getLODLevels(): MeshLODLevel[];
  13946. private _sortLODLevels;
  13947. /**
  13948. * Add a mesh as LOD level triggered at the given distance.
  13949. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13950. * @param distance The distance from the center of the object to show this level
  13951. * @param mesh The mesh to be added as LOD level (can be null)
  13952. * @return This mesh (for chaining)
  13953. */
  13954. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  13955. /**
  13956. * Returns the LOD level mesh at the passed distance or null if not found.
  13957. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13958. * @param distance The distance from the center of the object to show this level
  13959. * @returns a Mesh or `null`
  13960. */
  13961. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  13962. /**
  13963. * Remove a mesh from the LOD array
  13964. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13965. * @param mesh defines the mesh to be removed
  13966. * @return This mesh (for chaining)
  13967. */
  13968. removeLODLevel(mesh: Mesh): Mesh;
  13969. /**
  13970. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  13971. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13972. * @param camera defines the camera to use to compute distance
  13973. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  13974. * @return This mesh (for chaining)
  13975. */
  13976. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  13977. /**
  13978. * Gets the mesh internal Geometry object
  13979. */
  13980. readonly geometry: Nullable<Geometry>;
  13981. /**
  13982. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  13983. * @returns the total number of vertices
  13984. */
  13985. getTotalVertices(): number;
  13986. /**
  13987. * Returns the content of an associated vertex buffer
  13988. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  13989. * - VertexBuffer.PositionKind
  13990. * - VertexBuffer.UVKind
  13991. * - VertexBuffer.UV2Kind
  13992. * - VertexBuffer.UV3Kind
  13993. * - VertexBuffer.UV4Kind
  13994. * - VertexBuffer.UV5Kind
  13995. * - VertexBuffer.UV6Kind
  13996. * - VertexBuffer.ColorKind
  13997. * - VertexBuffer.MatricesIndicesKind
  13998. * - VertexBuffer.MatricesIndicesExtraKind
  13999. * - VertexBuffer.MatricesWeightsKind
  14000. * - VertexBuffer.MatricesWeightsExtraKind
  14001. * @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
  14002. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14003. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14004. */
  14005. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14006. /**
  14007. * Returns the mesh VertexBuffer object from the requested `kind`
  14008. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14009. * - VertexBuffer.PositionKind
  14010. * - VertexBuffer.NormalKind
  14011. * - VertexBuffer.UVKind
  14012. * - VertexBuffer.UV2Kind
  14013. * - VertexBuffer.UV3Kind
  14014. * - VertexBuffer.UV4Kind
  14015. * - VertexBuffer.UV5Kind
  14016. * - VertexBuffer.UV6Kind
  14017. * - VertexBuffer.ColorKind
  14018. * - VertexBuffer.MatricesIndicesKind
  14019. * - VertexBuffer.MatricesIndicesExtraKind
  14020. * - VertexBuffer.MatricesWeightsKind
  14021. * - VertexBuffer.MatricesWeightsExtraKind
  14022. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14023. */
  14024. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14025. /**
  14026. * Tests if a specific vertex buffer is associated with this mesh
  14027. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14028. * - VertexBuffer.PositionKind
  14029. * - VertexBuffer.NormalKind
  14030. * - VertexBuffer.UVKind
  14031. * - VertexBuffer.UV2Kind
  14032. * - VertexBuffer.UV3Kind
  14033. * - VertexBuffer.UV4Kind
  14034. * - VertexBuffer.UV5Kind
  14035. * - VertexBuffer.UV6Kind
  14036. * - VertexBuffer.ColorKind
  14037. * - VertexBuffer.MatricesIndicesKind
  14038. * - VertexBuffer.MatricesIndicesExtraKind
  14039. * - VertexBuffer.MatricesWeightsKind
  14040. * - VertexBuffer.MatricesWeightsExtraKind
  14041. * @returns a boolean
  14042. */
  14043. isVerticesDataPresent(kind: string): boolean;
  14044. /**
  14045. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14046. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14047. * - VertexBuffer.PositionKind
  14048. * - VertexBuffer.UVKind
  14049. * - VertexBuffer.UV2Kind
  14050. * - VertexBuffer.UV3Kind
  14051. * - VertexBuffer.UV4Kind
  14052. * - VertexBuffer.UV5Kind
  14053. * - VertexBuffer.UV6Kind
  14054. * - VertexBuffer.ColorKind
  14055. * - VertexBuffer.MatricesIndicesKind
  14056. * - VertexBuffer.MatricesIndicesExtraKind
  14057. * - VertexBuffer.MatricesWeightsKind
  14058. * - VertexBuffer.MatricesWeightsExtraKind
  14059. * @returns a boolean
  14060. */
  14061. isVertexBufferUpdatable(kind: string): boolean;
  14062. /**
  14063. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14064. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14065. * - VertexBuffer.PositionKind
  14066. * - VertexBuffer.NormalKind
  14067. * - VertexBuffer.UVKind
  14068. * - VertexBuffer.UV2Kind
  14069. * - VertexBuffer.UV3Kind
  14070. * - VertexBuffer.UV4Kind
  14071. * - VertexBuffer.UV5Kind
  14072. * - VertexBuffer.UV6Kind
  14073. * - VertexBuffer.ColorKind
  14074. * - VertexBuffer.MatricesIndicesKind
  14075. * - VertexBuffer.MatricesIndicesExtraKind
  14076. * - VertexBuffer.MatricesWeightsKind
  14077. * - VertexBuffer.MatricesWeightsExtraKind
  14078. * @returns an array of strings
  14079. */
  14080. getVerticesDataKinds(): string[];
  14081. /**
  14082. * Returns a positive integer : the total number of indices in this mesh geometry.
  14083. * @returns the numner of indices or zero if the mesh has no geometry.
  14084. */
  14085. getTotalIndices(): number;
  14086. /**
  14087. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14088. * @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.
  14089. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14090. * @returns the indices array or an empty array if the mesh has no geometry
  14091. */
  14092. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14093. readonly isBlocked: boolean;
  14094. /**
  14095. * Determine if the current mesh is ready to be rendered
  14096. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14097. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14098. * @returns true if all associated assets are ready (material, textures, shaders)
  14099. */
  14100. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14101. /**
  14102. * 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.
  14103. */
  14104. readonly areNormalsFrozen: boolean;
  14105. /**
  14106. * 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.
  14107. * @returns the current mesh
  14108. */
  14109. freezeNormals(): Mesh;
  14110. /**
  14111. * 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
  14112. * @returns the current mesh
  14113. */
  14114. unfreezeNormals(): Mesh;
  14115. /**
  14116. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14117. */
  14118. overridenInstanceCount: number;
  14119. /** @hidden */ private _preActivate(): Mesh;
  14120. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  14121. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14122. /**
  14123. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14124. * This means the mesh underlying bounding box and sphere are recomputed.
  14125. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14126. * @returns the current mesh
  14127. */
  14128. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14129. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14130. /**
  14131. * This function will subdivide the mesh into multiple submeshes
  14132. * @param count defines the expected number of submeshes
  14133. */
  14134. subdivide(count: number): void;
  14135. /**
  14136. * Copy a FloatArray into a specific associated vertex buffer
  14137. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14138. * - VertexBuffer.PositionKind
  14139. * - VertexBuffer.UVKind
  14140. * - VertexBuffer.UV2Kind
  14141. * - VertexBuffer.UV3Kind
  14142. * - VertexBuffer.UV4Kind
  14143. * - VertexBuffer.UV5Kind
  14144. * - VertexBuffer.UV6Kind
  14145. * - VertexBuffer.ColorKind
  14146. * - VertexBuffer.MatricesIndicesKind
  14147. * - VertexBuffer.MatricesIndicesExtraKind
  14148. * - VertexBuffer.MatricesWeightsKind
  14149. * - VertexBuffer.MatricesWeightsExtraKind
  14150. * @param data defines the data source
  14151. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14152. * @param stride defines the data stride size (can be null)
  14153. * @returns the current mesh
  14154. */
  14155. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14156. /**
  14157. * Flags an associated vertex buffer as updatable
  14158. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14159. * - VertexBuffer.PositionKind
  14160. * - VertexBuffer.UVKind
  14161. * - VertexBuffer.UV2Kind
  14162. * - VertexBuffer.UV3Kind
  14163. * - VertexBuffer.UV4Kind
  14164. * - VertexBuffer.UV5Kind
  14165. * - VertexBuffer.UV6Kind
  14166. * - VertexBuffer.ColorKind
  14167. * - VertexBuffer.MatricesIndicesKind
  14168. * - VertexBuffer.MatricesIndicesExtraKind
  14169. * - VertexBuffer.MatricesWeightsKind
  14170. * - VertexBuffer.MatricesWeightsExtraKind
  14171. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14172. */
  14173. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14174. /**
  14175. * Sets the mesh global Vertex Buffer
  14176. * @param buffer defines the buffer to use
  14177. * @returns the current mesh
  14178. */
  14179. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14180. /**
  14181. * Update a specific associated vertex buffer
  14182. * @param kind defines which buffer to write to (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 data defines the data source
  14196. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14197. * @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)
  14198. * @returns the current mesh
  14199. */
  14200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14201. /**
  14202. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14203. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14204. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14205. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14206. * @returns the current mesh
  14207. */
  14208. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14209. /**
  14210. * Creates a un-shared specific occurence of the geometry for the mesh.
  14211. * @returns the current mesh
  14212. */
  14213. makeGeometryUnique(): Mesh;
  14214. /**
  14215. * Set the index buffer of this mesh
  14216. * @param indices defines the source data
  14217. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14218. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14219. * @returns the current mesh
  14220. */
  14221. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14222. /**
  14223. * Update the current index buffer
  14224. * @param indices defines the source data
  14225. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14226. * @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)
  14227. * @returns the current mesh
  14228. */
  14229. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14230. /**
  14231. * Invert the geometry to move from a right handed system to a left handed one.
  14232. * @returns the current mesh
  14233. */
  14234. toLeftHanded(): Mesh;
  14235. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14236. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14237. /**
  14238. * Registers for this mesh a javascript function called just before the rendering process
  14239. * @param func defines the function to call before rendering this mesh
  14240. * @returns the current mesh
  14241. */
  14242. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14243. /**
  14244. * Disposes a previously registered javascript function called before the rendering
  14245. * @param func defines the function to remove
  14246. * @returns the current mesh
  14247. */
  14248. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14249. /**
  14250. * Registers for this mesh a javascript function called just after the rendering is complete
  14251. * @param func defines the function to call after rendering this mesh
  14252. * @returns the current mesh
  14253. */
  14254. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14255. /**
  14256. * Disposes a previously registered javascript function called after the rendering.
  14257. * @param func defines the function to remove
  14258. * @returns the current mesh
  14259. */
  14260. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14261. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14262. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14263. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14264. /** @hidden */ private _rebuild(): void;
  14265. /** @hidden */ private _freeze(): void;
  14266. /** @hidden */ private _unFreeze(): void;
  14267. /**
  14268. * 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
  14269. * @param subMesh defines the subMesh to render
  14270. * @param enableAlphaMode defines if alpha mode can be changed
  14271. * @returns the current mesh
  14272. */
  14273. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14274. private _onBeforeDraw;
  14275. /**
  14276. * Renormalize the mesh and patch it up if there are no weights
  14277. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14278. * However in the case of zero weights then we set just a single influence to 1.
  14279. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14280. */
  14281. cleanMatrixWeights(): void;
  14282. private normalizeSkinFourWeights;
  14283. private normalizeSkinWeightsAndExtra;
  14284. /**
  14285. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14286. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14287. * the user know there was an issue with importing the mesh
  14288. * @returns a validation object with skinned, valid and report string
  14289. */
  14290. validateSkinning(): {
  14291. skinned: boolean;
  14292. valid: boolean;
  14293. report: string;
  14294. };
  14295. /** @hidden */ private _checkDelayState(): Mesh;
  14296. private _queueLoad;
  14297. /**
  14298. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14299. * A mesh is in the frustum if its bounding box intersects the frustum
  14300. * @param frustumPlanes defines the frustum to test
  14301. * @returns true if the mesh is in the frustum planes
  14302. */
  14303. isInFrustum(frustumPlanes: Plane[]): boolean;
  14304. /**
  14305. * Sets the mesh material by the material or multiMaterial `id` property
  14306. * @param id is a string identifying the material or the multiMaterial
  14307. * @returns the current mesh
  14308. */
  14309. setMaterialByID(id: string): Mesh;
  14310. /**
  14311. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14312. * @returns an array of IAnimatable
  14313. */
  14314. getAnimatables(): IAnimatable[];
  14315. /**
  14316. * Modifies the mesh geometry according to the passed transformation matrix.
  14317. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14318. * The mesh normals are modified using the same transformation.
  14319. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14320. * @param transform defines the transform matrix to use
  14321. * @see http://doc.babylonjs.com/resources/baking_transformations
  14322. * @returns the current mesh
  14323. */
  14324. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14325. /**
  14326. * Modifies the mesh geometry according to its own current World Matrix.
  14327. * The mesh World Matrix is then reset.
  14328. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14329. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14330. * @see http://doc.babylonjs.com/resources/baking_transformations
  14331. * @returns the current mesh
  14332. */
  14333. bakeCurrentTransformIntoVertices(): Mesh;
  14334. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  14335. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  14336. /** @hidden */ private _generatePointsArray(): boolean;
  14337. /**
  14338. * Returns a new Mesh object generated from the current mesh properties.
  14339. * This method must not get confused with createInstance()
  14340. * @param name is a string, the name given to the new mesh
  14341. * @param newParent can be any Node object (default `null`)
  14342. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14343. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14344. * @returns a new mesh
  14345. */
  14346. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14347. /**
  14348. * Releases resources associated with this mesh.
  14349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14351. */
  14352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14353. /**
  14354. * Modifies the mesh geometry according to a displacement map.
  14355. * 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.
  14356. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14357. * @param url is a string, the URL from the image file is to be downloaded.
  14358. * @param minHeight is the lower limit of the displacement.
  14359. * @param maxHeight is the upper limit of the displacement.
  14360. * @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.
  14361. * @param uvOffset is an optional vector2 used to offset UV.
  14362. * @param uvScale is an optional vector2 used to scale UV.
  14363. * @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.
  14364. * @returns the Mesh.
  14365. */
  14366. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14367. /**
  14368. * Modifies the mesh geometry according to a displacementMap buffer.
  14369. * 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.
  14370. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14371. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14372. * @param heightMapWidth is the width of the buffer image.
  14373. * @param heightMapHeight is the height of the buffer image.
  14374. * @param minHeight is the lower limit of the displacement.
  14375. * @param maxHeight is the upper limit of the displacement.
  14376. * @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.
  14377. * @param uvOffset is an optional vector2 used to offset UV.
  14378. * @param uvScale is an optional vector2 used to scale UV.
  14379. * @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.
  14380. * @returns the Mesh.
  14381. */
  14382. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14383. /**
  14384. * Modify the mesh to get a flat shading rendering.
  14385. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14386. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14387. * @returns current mesh
  14388. */
  14389. convertToFlatShadedMesh(): Mesh;
  14390. /**
  14391. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14392. * In other words, more vertices, no more indices and a single bigger VBO.
  14393. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14394. * @returns current mesh
  14395. */
  14396. convertToUnIndexedMesh(): Mesh;
  14397. /**
  14398. * Inverses facet orientations.
  14399. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14400. * @param flipNormals will also inverts the normals
  14401. * @returns current mesh
  14402. */
  14403. flipFaces(flipNormals?: boolean): Mesh;
  14404. /**
  14405. * Increase the number of facets and hence vertices in a mesh
  14406. * Vertex normals are interpolated from existing vertex normals
  14407. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14408. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14409. */
  14410. increaseVertices(numberPerEdge: number): void;
  14411. /**
  14412. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14413. * This will undo any application of covertToFlatShadedMesh
  14414. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14415. */
  14416. forceSharedVertices(): void;
  14417. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14418. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14419. /**
  14420. * Creates a new InstancedMesh object from the mesh model.
  14421. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14422. * @param name defines the name of the new instance
  14423. * @returns a new InstancedMesh
  14424. */
  14425. createInstance(name: string): InstancedMesh;
  14426. /**
  14427. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14428. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14429. * @returns the current mesh
  14430. */
  14431. synchronizeInstances(): Mesh;
  14432. /**
  14433. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14434. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14435. * This should be used together with the simplification to avoid disappearing triangles.
  14436. * @param successCallback an optional success callback to be called after the optimization finished.
  14437. * @returns the current mesh
  14438. */
  14439. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14440. /**
  14441. * Serialize current mesh
  14442. * @param serializationObject defines the object which will receive the serialization data
  14443. */
  14444. serialize(serializationObject: any): void;
  14445. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  14446. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14447. /**
  14448. * Returns a new Mesh object parsed from the source provided.
  14449. * @param parsedMesh is the source
  14450. * @param scene defines the hosting scene
  14451. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14452. * @returns a new Mesh
  14453. */
  14454. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14455. /**
  14456. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14457. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14458. * @param name defines the name of the mesh to create
  14459. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14460. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14461. * @param closePath creates a seam between the first and the last points of each path of the path array
  14462. * @param offset is taken in account only if the `pathArray` is containing a single path
  14463. * @param scene defines the hosting scene
  14464. * @param updatable defines if the mesh must be flagged as updatable
  14465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14466. * @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)
  14467. * @returns a new Mesh
  14468. */
  14469. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14470. /**
  14471. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14472. * @param name defines the name of the mesh to create
  14473. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14474. * @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
  14475. * @param scene defines the hosting scene
  14476. * @param updatable defines if the mesh must be flagged as updatable
  14477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14478. * @returns a new Mesh
  14479. */
  14480. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14481. /**
  14482. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14483. * @param name defines the name of the mesh to create
  14484. * @param size sets the size (float) of each box side (default 1)
  14485. * @param scene defines the hosting scene
  14486. * @param updatable defines if the mesh must be flagged as updatable
  14487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14488. * @returns a new Mesh
  14489. */
  14490. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14491. /**
  14492. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14493. * @param name defines the name of the mesh to create
  14494. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14495. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14496. * @param scene defines the hosting scene
  14497. * @param updatable defines if the mesh must be flagged as updatable
  14498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14499. * @returns a new Mesh
  14500. */
  14501. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14502. /**
  14503. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14504. * @param name defines the name of the mesh to create
  14505. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14506. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14507. * @param scene defines the hosting scene
  14508. * @returns a new Mesh
  14509. */
  14510. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14511. /**
  14512. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14513. * @param name defines the name of the mesh to create
  14514. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14515. * @param diameterTop set the top cap diameter (floats, default 1)
  14516. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14517. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14518. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14519. * @param scene defines the hosting scene
  14520. * @param updatable defines if the mesh must be flagged as updatable
  14521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14522. * @returns a new Mesh
  14523. */
  14524. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14525. /**
  14526. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14527. * @param name defines the name of the mesh to create
  14528. * @param diameter sets the diameter size (float) of the torus (default 1)
  14529. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14530. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14531. * @param scene defines the hosting scene
  14532. * @param updatable defines if the mesh must be flagged as updatable
  14533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14534. * @returns a new Mesh
  14535. */
  14536. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14537. /**
  14538. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14539. * @param name defines the name of the mesh to create
  14540. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14541. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14542. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14543. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14544. * @param p the number of windings on X axis (positive integers, default 2)
  14545. * @param q the number of windings on Y axis (positive integers, default 3)
  14546. * @param scene defines the hosting scene
  14547. * @param updatable defines if the mesh must be flagged as updatable
  14548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14549. * @returns a new Mesh
  14550. */
  14551. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14552. /**
  14553. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14554. * @param name defines the name of the mesh to create
  14555. * @param points is an array successive Vector3
  14556. * @param scene defines the hosting scene
  14557. * @param updatable defines if the mesh must be flagged as updatable
  14558. * @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).
  14559. * @returns a new Mesh
  14560. */
  14561. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14562. /**
  14563. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14564. * @param name defines the name of the mesh to create
  14565. * @param points is an array successive Vector3
  14566. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14567. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14568. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14569. * @param scene defines the hosting scene
  14570. * @param updatable defines if the mesh must be flagged as updatable
  14571. * @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)
  14572. * @returns a new Mesh
  14573. */
  14574. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14575. /**
  14576. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14577. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14578. * 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.
  14579. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14580. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14581. * Remember you can only change the shape positions, not their number when updating a polygon.
  14582. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14583. * @param name defines the name of the mesh to create
  14584. * @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
  14585. * @param scene defines the hosting scene
  14586. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14587. * @param updatable defines if the mesh must be flagged as updatable
  14588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14589. * @param earcutInjection can be used to inject your own earcut reference
  14590. * @returns a new Mesh
  14591. */
  14592. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14593. /**
  14594. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14595. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14596. * @param name defines the name of the mesh to create
  14597. * @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
  14598. * @param depth defines the height of extrusion
  14599. * @param scene defines the hosting scene
  14600. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14601. * @param updatable defines if the mesh must be flagged as updatable
  14602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14603. * @param earcutInjection can be used to inject your own earcut reference
  14604. * @returns a new Mesh
  14605. */
  14606. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14607. /**
  14608. * Creates an extruded shape mesh.
  14609. * 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
  14610. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14611. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14612. * @param name defines the name of the mesh to create
  14613. * @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
  14614. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14615. * @param scale is the value to scale the shape
  14616. * @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
  14617. * @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
  14618. * @param scene defines the hosting scene
  14619. * @param updatable defines if the mesh must be flagged as updatable
  14620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14621. * @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)
  14622. * @returns a new Mesh
  14623. */
  14624. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14625. /**
  14626. * Creates an custom extruded shape mesh.
  14627. * The custom extrusion is a parametric shape.
  14628. * It has no predefined shape. Its final shape will depend on the input parameters.
  14629. * Please consider using the same method from the MeshBuilder class instead
  14630. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14631. * @param name defines the name of the mesh to create
  14632. * @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
  14633. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14634. * @param scaleFunction is a custom Javascript function called on each path point
  14635. * @param rotationFunction is a custom Javascript function called on each path point
  14636. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14637. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14638. * @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
  14639. * @param scene defines the hosting scene
  14640. * @param updatable defines if the mesh must be flagged as updatable
  14641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14642. * @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)
  14643. * @returns a new Mesh
  14644. */
  14645. 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;
  14646. /**
  14647. * Creates lathe mesh.
  14648. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14649. * Please consider using the same method from the MeshBuilder class instead
  14650. * @param name defines the name of the mesh to create
  14651. * @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
  14652. * @param radius is the radius value of the lathe
  14653. * @param tessellation is the side number of the lathe.
  14654. * @param scene defines the hosting scene
  14655. * @param updatable defines if the mesh must be flagged as updatable
  14656. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14657. * @returns a new Mesh
  14658. */
  14659. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14660. /**
  14661. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14662. * @param name defines the name of the mesh to create
  14663. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14664. * @param scene defines the hosting scene
  14665. * @param updatable defines if the mesh must be flagged as updatable
  14666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14667. * @returns a new Mesh
  14668. */
  14669. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14670. /**
  14671. * Creates a ground mesh.
  14672. * Please consider using the same method from the MeshBuilder class instead
  14673. * @param name defines the name of the mesh to create
  14674. * @param width set the width of the ground
  14675. * @param height set the height of the ground
  14676. * @param subdivisions sets the number of subdivisions per side
  14677. * @param scene defines the hosting scene
  14678. * @param updatable defines if the mesh must be flagged as updatable
  14679. * @returns a new Mesh
  14680. */
  14681. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14682. /**
  14683. * Creates a tiled ground mesh.
  14684. * Please consider using the same method from the MeshBuilder class instead
  14685. * @param name defines the name of the mesh to create
  14686. * @param xmin set the ground minimum X coordinate
  14687. * @param zmin set the ground minimum Y coordinate
  14688. * @param xmax set the ground maximum X coordinate
  14689. * @param zmax set the ground maximum Z coordinate
  14690. * @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
  14691. * @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
  14692. * @param scene defines the hosting scene
  14693. * @param updatable defines if the mesh must be flagged as updatable
  14694. * @returns a new Mesh
  14695. */
  14696. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14697. w: number;
  14698. h: number;
  14699. }, precision: {
  14700. w: number;
  14701. h: number;
  14702. }, scene: Scene, updatable?: boolean): Mesh;
  14703. /**
  14704. * Creates a ground mesh from a height map.
  14705. * Please consider using the same method from the MeshBuilder class instead
  14706. * @see http://doc.babylonjs.com/babylon101/height_map
  14707. * @param name defines the name of the mesh to create
  14708. * @param url sets the URL of the height map image resource
  14709. * @param width set the ground width size
  14710. * @param height set the ground height size
  14711. * @param subdivisions sets the number of subdivision per side
  14712. * @param minHeight is the minimum altitude on the ground
  14713. * @param maxHeight is the maximum altitude on the ground
  14714. * @param scene defines the hosting scene
  14715. * @param updatable defines if the mesh must be flagged as updatable
  14716. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14717. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14718. * @returns a new Mesh
  14719. */
  14720. 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;
  14721. /**
  14722. * Creates a tube mesh.
  14723. * The tube is a parametric shape.
  14724. * It has no predefined shape. Its final shape will depend on the input parameters.
  14725. * Please consider using the same method from the MeshBuilder class instead
  14726. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14727. * @param name defines the name of the mesh to create
  14728. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14729. * @param radius sets the tube radius size
  14730. * @param tessellation is the number of sides on the tubular surface
  14731. * @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
  14732. * @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
  14733. * @param scene defines the hosting scene
  14734. * @param updatable defines if the mesh must be flagged as updatable
  14735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14736. * @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)
  14737. * @returns a new Mesh
  14738. */
  14739. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14740. (i: number, distance: number): number;
  14741. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14742. /**
  14743. * Creates a polyhedron mesh.
  14744. * Please consider using the same method from the MeshBuilder class instead.
  14745. * * 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
  14746. * * The parameter `size` (positive float, default 1) sets the polygon size
  14747. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14748. * * 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`
  14749. * * 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
  14750. * * 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)`)
  14751. * * 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
  14752. * * 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
  14753. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14754. * * 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
  14755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14756. * @param name defines the name of the mesh to create
  14757. * @param options defines the options used to create the mesh
  14758. * @param scene defines the hosting scene
  14759. * @returns a new Mesh
  14760. */
  14761. static CreatePolyhedron(name: string, options: {
  14762. type?: number;
  14763. size?: number;
  14764. sizeX?: number;
  14765. sizeY?: number;
  14766. sizeZ?: number;
  14767. custom?: any;
  14768. faceUV?: Vector4[];
  14769. faceColors?: Color4[];
  14770. updatable?: boolean;
  14771. sideOrientation?: number;
  14772. }, scene: Scene): Mesh;
  14773. /**
  14774. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  14775. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  14776. * * 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`)
  14777. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  14778. * * 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
  14779. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14780. * * 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
  14781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14782. * @param name defines the name of the mesh
  14783. * @param options defines the options used to create the mesh
  14784. * @param scene defines the hosting scene
  14785. * @returns a new Mesh
  14786. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  14787. */
  14788. static CreateIcoSphere(name: string, options: {
  14789. radius?: number;
  14790. flat?: boolean;
  14791. subdivisions?: number;
  14792. sideOrientation?: number;
  14793. updatable?: boolean;
  14794. }, scene: Scene): Mesh;
  14795. /**
  14796. * Creates a decal mesh.
  14797. * Please consider using the same method from the MeshBuilder class instead.
  14798. * A decal is a mesh usually applied as a model onto the surface of another mesh
  14799. * @param name defines the name of the mesh
  14800. * @param sourceMesh defines the mesh receiving the decal
  14801. * @param position sets the position of the decal in world coordinates
  14802. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  14803. * @param size sets the decal scaling
  14804. * @param angle sets the angle to rotate the decal
  14805. * @returns a new Mesh
  14806. */
  14807. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  14808. /**
  14809. * Prepare internal position array for software CPU skinning
  14810. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  14811. */
  14812. setPositionsForCPUSkinning(): Float32Array;
  14813. /**
  14814. * Prepare internal normal array for software CPU skinning
  14815. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  14816. */
  14817. setNormalsForCPUSkinning(): Float32Array;
  14818. /**
  14819. * Updates the vertex buffer by applying transformation from the bones
  14820. * @param skeleton defines the skeleton to apply to current mesh
  14821. * @returns the current mesh
  14822. */
  14823. applySkeleton(skeleton: Skeleton): Mesh;
  14824. /**
  14825. * 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
  14826. * @param meshes defines the list of meshes to scan
  14827. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  14828. */
  14829. static MinMax(meshes: AbstractMesh[]): {
  14830. min: Vector3;
  14831. max: Vector3;
  14832. };
  14833. /**
  14834. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  14835. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  14836. * @returns a vector3
  14837. */
  14838. static Center(meshesOrMinMaxVector: {
  14839. min: Vector3;
  14840. max: Vector3;
  14841. } | AbstractMesh[]): Vector3;
  14842. /**
  14843. * Merge the array of meshes into a single mesh for performance reasons.
  14844. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  14845. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  14846. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  14847. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  14848. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  14849. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  14850. * @returns a new mesh
  14851. */
  14852. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  14853. /** @hidden */
  14854. addInstance(instance: InstancedMesh): void;
  14855. /** @hidden */
  14856. removeInstance(instance: InstancedMesh): void;
  14857. }
  14858. }
  14859. declare module BABYLON {
  14860. /**
  14861. * Interface used to define Action
  14862. */
  14863. export interface IAction {
  14864. /**
  14865. * Trigger for the action
  14866. */
  14867. trigger: number;
  14868. /** Options of the trigger */
  14869. triggerOptions: any;
  14870. /**
  14871. * Gets the trigger parameters
  14872. * @returns the trigger parameters
  14873. */
  14874. getTriggerParameter(): any;
  14875. /**
  14876. * Internal only - executes current action event
  14877. * @hidden
  14878. */ private _executeCurrent(evt?: ActionEvent): void;
  14879. /**
  14880. * Serialize placeholder for child classes
  14881. * @param parent of child
  14882. * @returns the serialized object
  14883. */
  14884. serialize(parent: any): any;
  14885. /**
  14886. * Internal only
  14887. * @hidden
  14888. */ private _prepare(): void;
  14889. /**
  14890. * Internal only - manager for action
  14891. * @hidden
  14892. */ private _actionManager: AbstractActionManager;
  14893. /**
  14894. * Adds action to chain of actions, may be a DoNothingAction
  14895. * @param action defines the next action to execute
  14896. * @returns The action passed in
  14897. * @see https://www.babylonjs-playground.com/#1T30HR#0
  14898. */
  14899. then(action: IAction): IAction;
  14900. }
  14901. /**
  14902. * The action to be carried out following a trigger
  14903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  14904. */
  14905. export class Action implements IAction {
  14906. /** the trigger, with or without parameters, for the action */
  14907. triggerOptions: any;
  14908. /**
  14909. * Trigger for the action
  14910. */
  14911. trigger: number;
  14912. /**
  14913. * Internal only - manager for action
  14914. * @hidden
  14915. */ private _actionManager: ActionManager;
  14916. private _nextActiveAction;
  14917. private _child;
  14918. private _condition?;
  14919. private _triggerParameter;
  14920. /**
  14921. * An event triggered prior to action being executed.
  14922. */
  14923. onBeforeExecuteObservable: Observable<Action>;
  14924. /**
  14925. * Creates a new Action
  14926. * @param triggerOptions the trigger, with or without parameters, for the action
  14927. * @param condition an optional determinant of action
  14928. */
  14929. constructor(
  14930. /** the trigger, with or without parameters, for the action */
  14931. triggerOptions: any, condition?: Condition);
  14932. /**
  14933. * Internal only
  14934. * @hidden
  14935. */ private _prepare(): void;
  14936. /**
  14937. * Gets the trigger parameters
  14938. * @returns the trigger parameters
  14939. */
  14940. getTriggerParameter(): any;
  14941. /**
  14942. * Internal only - executes current action event
  14943. * @hidden
  14944. */ private _executeCurrent(evt?: ActionEvent): void;
  14945. /**
  14946. * Execute placeholder for child classes
  14947. * @param evt optional action event
  14948. */
  14949. execute(evt?: ActionEvent): void;
  14950. /**
  14951. * Skips to next active action
  14952. */
  14953. skipToNextActiveAction(): void;
  14954. /**
  14955. * Adds action to chain of actions, may be a DoNothingAction
  14956. * @param action defines the next action to execute
  14957. * @returns The action passed in
  14958. * @see https://www.babylonjs-playground.com/#1T30HR#0
  14959. */
  14960. then(action: Action): Action;
  14961. /**
  14962. * Internal only
  14963. * @hidden
  14964. */ private _getProperty(propertyPath: string): string;
  14965. /**
  14966. * Internal only
  14967. * @hidden
  14968. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  14969. /**
  14970. * Serialize placeholder for child classes
  14971. * @param parent of child
  14972. * @returns the serialized object
  14973. */
  14974. serialize(parent: any): any;
  14975. /**
  14976. * Internal only called by serialize
  14977. * @hidden
  14978. */
  14979. protected _serialize(serializedAction: any, parent?: any): any;
  14980. /**
  14981. * Internal only
  14982. * @hidden
  14983. */ private static _SerializeValueAsString: (value: any) => string;
  14984. /**
  14985. * Internal only
  14986. * @hidden
  14987. */ private static _GetTargetProperty: (target: Scene | Node) => {
  14988. name: string;
  14989. targetType: string;
  14990. value: string;
  14991. };
  14992. }
  14993. }
  14994. declare module BABYLON {
  14995. /**
  14996. * A Condition applied to an Action
  14997. */
  14998. export class Condition {
  14999. /**
  15000. * Internal only - manager for action
  15001. * @hidden
  15002. */ private _actionManager: ActionManager;
  15003. /**
  15004. * Internal only
  15005. * @hidden
  15006. */ private _evaluationId: number;
  15007. /**
  15008. * Internal only
  15009. * @hidden
  15010. */ private _currentResult: boolean;
  15011. /**
  15012. * Creates a new Condition
  15013. * @param actionManager the manager of the action the condition is applied to
  15014. */
  15015. constructor(actionManager: ActionManager);
  15016. /**
  15017. * Check if the current condition is valid
  15018. * @returns a boolean
  15019. */
  15020. isValid(): boolean;
  15021. /**
  15022. * Internal only
  15023. * @hidden
  15024. */ private _getProperty(propertyPath: string): string;
  15025. /**
  15026. * Internal only
  15027. * @hidden
  15028. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  15029. /**
  15030. * Serialize placeholder for child classes
  15031. * @returns the serialized object
  15032. */
  15033. serialize(): any;
  15034. /**
  15035. * Internal only
  15036. * @hidden
  15037. */
  15038. protected _serialize(serializedCondition: any): any;
  15039. }
  15040. /**
  15041. * Defines specific conditional operators as extensions of Condition
  15042. */
  15043. export class ValueCondition extends Condition {
  15044. /** path to specify the property of the target the conditional operator uses */
  15045. propertyPath: string;
  15046. /** the value compared by the conditional operator against the current value of the property */
  15047. value: any;
  15048. /** the conditional operator, default ValueCondition.IsEqual */
  15049. operator: number;
  15050. /**
  15051. * Internal only
  15052. * @hidden
  15053. */
  15054. private static _IsEqual;
  15055. /**
  15056. * Internal only
  15057. * @hidden
  15058. */
  15059. private static _IsDifferent;
  15060. /**
  15061. * Internal only
  15062. * @hidden
  15063. */
  15064. private static _IsGreater;
  15065. /**
  15066. * Internal only
  15067. * @hidden
  15068. */
  15069. private static _IsLesser;
  15070. /**
  15071. * returns the number for IsEqual
  15072. */
  15073. static readonly IsEqual: number;
  15074. /**
  15075. * Returns the number for IsDifferent
  15076. */
  15077. static readonly IsDifferent: number;
  15078. /**
  15079. * Returns the number for IsGreater
  15080. */
  15081. static readonly IsGreater: number;
  15082. /**
  15083. * Returns the number for IsLesser
  15084. */
  15085. static readonly IsLesser: number;
  15086. /**
  15087. * Internal only The action manager for the condition
  15088. * @hidden
  15089. */ private _actionManager: ActionManager;
  15090. /**
  15091. * Internal only
  15092. * @hidden
  15093. */
  15094. private _target;
  15095. /**
  15096. * Internal only
  15097. * @hidden
  15098. */
  15099. private _effectiveTarget;
  15100. /**
  15101. * Internal only
  15102. * @hidden
  15103. */
  15104. private _property;
  15105. /**
  15106. * Creates a new ValueCondition
  15107. * @param actionManager manager for the action the condition applies to
  15108. * @param target for the action
  15109. * @param propertyPath path to specify the property of the target the conditional operator uses
  15110. * @param value the value compared by the conditional operator against the current value of the property
  15111. * @param operator the conditional operator, default ValueCondition.IsEqual
  15112. */
  15113. constructor(actionManager: ActionManager, target: any,
  15114. /** path to specify the property of the target the conditional operator uses */
  15115. propertyPath: string,
  15116. /** the value compared by the conditional operator against the current value of the property */
  15117. value: any,
  15118. /** the conditional operator, default ValueCondition.IsEqual */
  15119. operator?: number);
  15120. /**
  15121. * Compares the given value with the property value for the specified conditional operator
  15122. * @returns the result of the comparison
  15123. */
  15124. isValid(): boolean;
  15125. /**
  15126. * Serialize the ValueCondition into a JSON compatible object
  15127. * @returns serialization object
  15128. */
  15129. serialize(): any;
  15130. /**
  15131. * Gets the name of the conditional operator for the ValueCondition
  15132. * @param operator the conditional operator
  15133. * @returns the name
  15134. */
  15135. static GetOperatorName(operator: number): string;
  15136. }
  15137. /**
  15138. * Defines a predicate condition as an extension of Condition
  15139. */
  15140. export class PredicateCondition extends Condition {
  15141. /** defines the predicate function used to validate the condition */
  15142. predicate: () => boolean;
  15143. /**
  15144. * Internal only - manager for action
  15145. * @hidden
  15146. */ private _actionManager: ActionManager;
  15147. /**
  15148. * Creates a new PredicateCondition
  15149. * @param actionManager manager for the action the condition applies to
  15150. * @param predicate defines the predicate function used to validate the condition
  15151. */
  15152. constructor(actionManager: ActionManager,
  15153. /** defines the predicate function used to validate the condition */
  15154. predicate: () => boolean);
  15155. /**
  15156. * @returns the validity of the predicate condition
  15157. */
  15158. isValid(): boolean;
  15159. }
  15160. /**
  15161. * Defines a state condition as an extension of Condition
  15162. */
  15163. export class StateCondition extends Condition {
  15164. /** Value to compare with target state */
  15165. value: string;
  15166. /**
  15167. * Internal only - manager for action
  15168. * @hidden
  15169. */ private _actionManager: ActionManager;
  15170. /**
  15171. * Internal only
  15172. * @hidden
  15173. */
  15174. private _target;
  15175. /**
  15176. * Creates a new StateCondition
  15177. * @param actionManager manager for the action the condition applies to
  15178. * @param target of the condition
  15179. * @param value to compare with target state
  15180. */
  15181. constructor(actionManager: ActionManager, target: any,
  15182. /** Value to compare with target state */
  15183. value: string);
  15184. /**
  15185. * Gets a boolean indicating if the current condition is met
  15186. * @returns the validity of the state
  15187. */
  15188. isValid(): boolean;
  15189. /**
  15190. * Serialize the StateCondition into a JSON compatible object
  15191. * @returns serialization object
  15192. */
  15193. serialize(): any;
  15194. }
  15195. }
  15196. declare module BABYLON {
  15197. /**
  15198. * This defines an action responsible to toggle a boolean once triggered.
  15199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15200. */
  15201. export class SwitchBooleanAction extends Action {
  15202. /**
  15203. * The path to the boolean property in the target object
  15204. */
  15205. propertyPath: string;
  15206. private _target;
  15207. private _effectiveTarget;
  15208. private _property;
  15209. /**
  15210. * Instantiate the action
  15211. * @param triggerOptions defines the trigger options
  15212. * @param target defines the object containing the boolean
  15213. * @param propertyPath defines the path to the boolean property in the target object
  15214. * @param condition defines the trigger related conditions
  15215. */
  15216. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15217. /** @hidden */ private _prepare(): void;
  15218. /**
  15219. * Execute the action toggle the boolean value.
  15220. */
  15221. execute(): void;
  15222. /**
  15223. * Serializes the actions and its related information.
  15224. * @param parent defines the object to serialize in
  15225. * @returns the serialized object
  15226. */
  15227. serialize(parent: any): any;
  15228. }
  15229. /**
  15230. * This defines an action responsible to set a the state field of the target
  15231. * to a desired value once triggered.
  15232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15233. */
  15234. export class SetStateAction extends Action {
  15235. /**
  15236. * The value to store in the state field.
  15237. */
  15238. value: string;
  15239. private _target;
  15240. /**
  15241. * Instantiate the action
  15242. * @param triggerOptions defines the trigger options
  15243. * @param target defines the object containing the state property
  15244. * @param value defines the value to store in the state field
  15245. * @param condition defines the trigger related conditions
  15246. */
  15247. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15248. /**
  15249. * Execute the action and store the value on the target state property.
  15250. */
  15251. execute(): void;
  15252. /**
  15253. * Serializes the actions and its related information.
  15254. * @param parent defines the object to serialize in
  15255. * @returns the serialized object
  15256. */
  15257. serialize(parent: any): any;
  15258. }
  15259. /**
  15260. * This defines an action responsible to set a property of the target
  15261. * to a desired value once triggered.
  15262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15263. */
  15264. export class SetValueAction extends Action {
  15265. /**
  15266. * The path of the property to set in the target.
  15267. */
  15268. propertyPath: string;
  15269. /**
  15270. * The value to set in the property
  15271. */
  15272. value: any;
  15273. private _target;
  15274. private _effectiveTarget;
  15275. private _property;
  15276. /**
  15277. * Instantiate the action
  15278. * @param triggerOptions defines the trigger options
  15279. * @param target defines the object containing the property
  15280. * @param propertyPath defines the path of the property to set in the target
  15281. * @param value defines the value to set in the property
  15282. * @param condition defines the trigger related conditions
  15283. */
  15284. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15285. /** @hidden */ private _prepare(): void;
  15286. /**
  15287. * Execute the action and set the targetted property to the desired value.
  15288. */
  15289. execute(): void;
  15290. /**
  15291. * Serializes the actions and its related information.
  15292. * @param parent defines the object to serialize in
  15293. * @returns the serialized object
  15294. */
  15295. serialize(parent: any): any;
  15296. }
  15297. /**
  15298. * This defines an action responsible to increment the target value
  15299. * to a desired value once triggered.
  15300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15301. */
  15302. export class IncrementValueAction extends Action {
  15303. /**
  15304. * The path of the property to increment in the target.
  15305. */
  15306. propertyPath: string;
  15307. /**
  15308. * The value we should increment the property by.
  15309. */
  15310. value: any;
  15311. private _target;
  15312. private _effectiveTarget;
  15313. private _property;
  15314. /**
  15315. * Instantiate the action
  15316. * @param triggerOptions defines the trigger options
  15317. * @param target defines the object containing the property
  15318. * @param propertyPath defines the path of the property to increment in the target
  15319. * @param value defines the value value we should increment the property by
  15320. * @param condition defines the trigger related conditions
  15321. */
  15322. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15323. /** @hidden */ private _prepare(): void;
  15324. /**
  15325. * Execute the action and increment the target of the value amount.
  15326. */
  15327. execute(): void;
  15328. /**
  15329. * Serializes the actions and its related information.
  15330. * @param parent defines the object to serialize in
  15331. * @returns the serialized object
  15332. */
  15333. serialize(parent: any): any;
  15334. }
  15335. /**
  15336. * This defines an action responsible to start an animation once triggered.
  15337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15338. */
  15339. export class PlayAnimationAction extends Action {
  15340. /**
  15341. * Where the animation should start (animation frame)
  15342. */
  15343. from: number;
  15344. /**
  15345. * Where the animation should stop (animation frame)
  15346. */
  15347. to: number;
  15348. /**
  15349. * Define if the animation should loop or stop after the first play.
  15350. */
  15351. loop?: boolean;
  15352. private _target;
  15353. /**
  15354. * Instantiate the action
  15355. * @param triggerOptions defines the trigger options
  15356. * @param target defines the target animation or animation name
  15357. * @param from defines from where the animation should start (animation frame)
  15358. * @param end defines where the animation should stop (animation frame)
  15359. * @param loop defines if the animation should loop or stop after the first play
  15360. * @param condition defines the trigger related conditions
  15361. */
  15362. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15363. /** @hidden */ private _prepare(): void;
  15364. /**
  15365. * Execute the action and play the animation.
  15366. */
  15367. execute(): void;
  15368. /**
  15369. * Serializes the actions and its related information.
  15370. * @param parent defines the object to serialize in
  15371. * @returns the serialized object
  15372. */
  15373. serialize(parent: any): any;
  15374. }
  15375. /**
  15376. * This defines an action responsible to stop an animation once triggered.
  15377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15378. */
  15379. export class StopAnimationAction extends Action {
  15380. private _target;
  15381. /**
  15382. * Instantiate the action
  15383. * @param triggerOptions defines the trigger options
  15384. * @param target defines the target animation or animation name
  15385. * @param condition defines the trigger related conditions
  15386. */
  15387. constructor(triggerOptions: any, target: any, condition?: Condition);
  15388. /** @hidden */ private _prepare(): void;
  15389. /**
  15390. * Execute the action and stop the animation.
  15391. */
  15392. execute(): void;
  15393. /**
  15394. * Serializes the actions and its related information.
  15395. * @param parent defines the object to serialize in
  15396. * @returns the serialized object
  15397. */
  15398. serialize(parent: any): any;
  15399. }
  15400. /**
  15401. * This defines an action responsible that does nothing once triggered.
  15402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15403. */
  15404. export class DoNothingAction extends Action {
  15405. /**
  15406. * Instantiate the action
  15407. * @param triggerOptions defines the trigger options
  15408. * @param condition defines the trigger related conditions
  15409. */
  15410. constructor(triggerOptions?: any, condition?: Condition);
  15411. /**
  15412. * Execute the action and do nothing.
  15413. */
  15414. execute(): void;
  15415. /**
  15416. * Serializes the actions and its related information.
  15417. * @param parent defines the object to serialize in
  15418. * @returns the serialized object
  15419. */
  15420. serialize(parent: any): any;
  15421. }
  15422. /**
  15423. * This defines an action responsible to trigger several actions once triggered.
  15424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15425. */
  15426. export class CombineAction extends Action {
  15427. /**
  15428. * The list of aggregated animations to run.
  15429. */
  15430. children: Action[];
  15431. /**
  15432. * Instantiate the action
  15433. * @param triggerOptions defines the trigger options
  15434. * @param children defines the list of aggregated animations to run
  15435. * @param condition defines the trigger related conditions
  15436. */
  15437. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15438. /** @hidden */ private _prepare(): void;
  15439. /**
  15440. * Execute the action and executes all the aggregated actions.
  15441. */
  15442. execute(evt: ActionEvent): void;
  15443. /**
  15444. * Serializes the actions and its related information.
  15445. * @param parent defines the object to serialize in
  15446. * @returns the serialized object
  15447. */
  15448. serialize(parent: any): any;
  15449. }
  15450. /**
  15451. * This defines an action responsible to run code (external event) once triggered.
  15452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15453. */
  15454. export class ExecuteCodeAction extends Action {
  15455. /**
  15456. * The callback function to run.
  15457. */
  15458. func: (evt: ActionEvent) => void;
  15459. /**
  15460. * Instantiate the action
  15461. * @param triggerOptions defines the trigger options
  15462. * @param func defines the callback function to run
  15463. * @param condition defines the trigger related conditions
  15464. */
  15465. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15466. /**
  15467. * Execute the action and run the attached code.
  15468. */
  15469. execute(evt: ActionEvent): void;
  15470. }
  15471. /**
  15472. * This defines an action responsible to set the parent property of the target once triggered.
  15473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15474. */
  15475. export class SetParentAction extends Action {
  15476. private _parent;
  15477. private _target;
  15478. /**
  15479. * Instantiate the action
  15480. * @param triggerOptions defines the trigger options
  15481. * @param target defines the target containing the parent property
  15482. * @param parent defines from where the animation should start (animation frame)
  15483. * @param condition defines the trigger related conditions
  15484. */
  15485. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15486. /** @hidden */ private _prepare(): void;
  15487. /**
  15488. * Execute the action and set the parent property.
  15489. */
  15490. execute(): void;
  15491. /**
  15492. * Serializes the actions and its related information.
  15493. * @param parent defines the object to serialize in
  15494. * @returns the serialized object
  15495. */
  15496. serialize(parent: any): any;
  15497. }
  15498. }
  15499. declare module BABYLON {
  15500. /**
  15501. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15502. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15504. */
  15505. export class ActionManager extends AbstractActionManager {
  15506. /**
  15507. * Nothing
  15508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15509. */
  15510. static readonly NothingTrigger: number;
  15511. /**
  15512. * On pick
  15513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15514. */
  15515. static readonly OnPickTrigger: number;
  15516. /**
  15517. * On left pick
  15518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15519. */
  15520. static readonly OnLeftPickTrigger: number;
  15521. /**
  15522. * On right pick
  15523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15524. */
  15525. static readonly OnRightPickTrigger: number;
  15526. /**
  15527. * On center pick
  15528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15529. */
  15530. static readonly OnCenterPickTrigger: number;
  15531. /**
  15532. * On pick down
  15533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15534. */
  15535. static readonly OnPickDownTrigger: number;
  15536. /**
  15537. * On double pick
  15538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15539. */
  15540. static readonly OnDoublePickTrigger: number;
  15541. /**
  15542. * On pick up
  15543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15544. */
  15545. static readonly OnPickUpTrigger: number;
  15546. /**
  15547. * On pick out.
  15548. * This trigger will only be raised if you also declared a OnPickDown
  15549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15550. */
  15551. static readonly OnPickOutTrigger: number;
  15552. /**
  15553. * On long press
  15554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15555. */
  15556. static readonly OnLongPressTrigger: number;
  15557. /**
  15558. * On pointer over
  15559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15560. */
  15561. static readonly OnPointerOverTrigger: number;
  15562. /**
  15563. * On pointer out
  15564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15565. */
  15566. static readonly OnPointerOutTrigger: number;
  15567. /**
  15568. * On every frame
  15569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15570. */
  15571. static readonly OnEveryFrameTrigger: number;
  15572. /**
  15573. * On intersection enter
  15574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15575. */
  15576. static readonly OnIntersectionEnterTrigger: number;
  15577. /**
  15578. * On intersection exit
  15579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15580. */
  15581. static readonly OnIntersectionExitTrigger: number;
  15582. /**
  15583. * On key down
  15584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15585. */
  15586. static readonly OnKeyDownTrigger: number;
  15587. /**
  15588. * On key up
  15589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15590. */
  15591. static readonly OnKeyUpTrigger: number;
  15592. private _scene;
  15593. /**
  15594. * Creates a new action manager
  15595. * @param scene defines the hosting scene
  15596. */
  15597. constructor(scene: Scene);
  15598. /**
  15599. * Releases all associated resources
  15600. */
  15601. dispose(): void;
  15602. /**
  15603. * Gets hosting scene
  15604. * @returns the hosting scene
  15605. */
  15606. getScene(): Scene;
  15607. /**
  15608. * Does this action manager handles actions of any of the given triggers
  15609. * @param triggers defines the triggers to be tested
  15610. * @return a boolean indicating whether one (or more) of the triggers is handled
  15611. */
  15612. hasSpecificTriggers(triggers: number[]): boolean;
  15613. /**
  15614. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15615. * speed.
  15616. * @param triggerA defines the trigger to be tested
  15617. * @param triggerB defines the trigger to be tested
  15618. * @return a boolean indicating whether one (or more) of the triggers is handled
  15619. */
  15620. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15621. /**
  15622. * Does this action manager handles actions of a given trigger
  15623. * @param trigger defines the trigger to be tested
  15624. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15625. * @return whether the trigger is handled
  15626. */
  15627. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15628. /**
  15629. * Does this action manager has pointer triggers
  15630. */
  15631. readonly hasPointerTriggers: boolean;
  15632. /**
  15633. * Does this action manager has pick triggers
  15634. */
  15635. readonly hasPickTriggers: boolean;
  15636. /**
  15637. * Registers an action to this action manager
  15638. * @param action defines the action to be registered
  15639. * @return the action amended (prepared) after registration
  15640. */
  15641. registerAction(action: IAction): Nullable<IAction>;
  15642. /**
  15643. * Unregisters an action to this action manager
  15644. * @param action defines the action to be unregistered
  15645. * @return a boolean indicating whether the action has been unregistered
  15646. */
  15647. unregisterAction(action: IAction): Boolean;
  15648. /**
  15649. * Process a specific trigger
  15650. * @param trigger defines the trigger to process
  15651. * @param evt defines the event details to be processed
  15652. */
  15653. processTrigger(trigger: number, evt?: IActionEvent): void;
  15654. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  15655. /** @hidden */ private _getProperty(propertyPath: string): string;
  15656. /**
  15657. * Serialize this manager to a JSON object
  15658. * @param name defines the property name to store this manager
  15659. * @returns a JSON representation of this manager
  15660. */
  15661. serialize(name: string): any;
  15662. /**
  15663. * Creates a new ActionManager from a JSON data
  15664. * @param parsedActions defines the JSON data to read from
  15665. * @param object defines the hosting mesh
  15666. * @param scene defines the hosting scene
  15667. */
  15668. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15669. /**
  15670. * Get a trigger name by index
  15671. * @param trigger defines the trigger index
  15672. * @returns a trigger name
  15673. */
  15674. static GetTriggerName(trigger: number): string;
  15675. }
  15676. }
  15677. declare module BABYLON {
  15678. /**
  15679. * Class representing a ray with position and direction
  15680. */
  15681. export class Ray {
  15682. /** origin point */
  15683. origin: Vector3;
  15684. /** direction */
  15685. direction: Vector3;
  15686. /** length of the ray */
  15687. length: number;
  15688. private static readonly TmpVector3;
  15689. private _tmpRay;
  15690. /**
  15691. * Creates a new ray
  15692. * @param origin origin point
  15693. * @param direction direction
  15694. * @param length length of the ray
  15695. */
  15696. constructor(
  15697. /** origin point */
  15698. origin: Vector3,
  15699. /** direction */
  15700. direction: Vector3,
  15701. /** length of the ray */
  15702. length?: number);
  15703. /**
  15704. * Checks if the ray intersects a box
  15705. * @param minimum bound of the box
  15706. * @param maximum bound of the box
  15707. * @param intersectionTreshold extra extend to be added to the box in all direction
  15708. * @returns if the box was hit
  15709. */
  15710. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15711. /**
  15712. * Checks if the ray intersects a box
  15713. * @param box the bounding box to check
  15714. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15715. * @returns if the box was hit
  15716. */
  15717. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15718. /**
  15719. * If the ray hits a sphere
  15720. * @param sphere the bounding sphere to check
  15721. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15722. * @returns true if it hits the sphere
  15723. */
  15724. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15725. /**
  15726. * If the ray hits a triange
  15727. * @param vertex0 triangle vertex
  15728. * @param vertex1 triangle vertex
  15729. * @param vertex2 triangle vertex
  15730. * @returns intersection information if hit
  15731. */
  15732. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15733. /**
  15734. * Checks if ray intersects a plane
  15735. * @param plane the plane to check
  15736. * @returns the distance away it was hit
  15737. */
  15738. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15739. /**
  15740. * Checks if ray intersects a mesh
  15741. * @param mesh the mesh to check
  15742. * @param fastCheck if only the bounding box should checked
  15743. * @returns picking info of the intersecton
  15744. */
  15745. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  15746. /**
  15747. * Checks if ray intersects a mesh
  15748. * @param meshes the meshes to check
  15749. * @param fastCheck if only the bounding box should checked
  15750. * @param results array to store result in
  15751. * @returns Array of picking infos
  15752. */
  15753. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  15754. private _comparePickingInfo;
  15755. private static smallnum;
  15756. private static rayl;
  15757. /**
  15758. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  15759. * @param sega the first point of the segment to test the intersection against
  15760. * @param segb the second point of the segment to test the intersection against
  15761. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  15762. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  15763. */
  15764. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  15765. /**
  15766. * Update the ray from viewport position
  15767. * @param x position
  15768. * @param y y position
  15769. * @param viewportWidth viewport width
  15770. * @param viewportHeight viewport height
  15771. * @param world world matrix
  15772. * @param view view matrix
  15773. * @param projection projection matrix
  15774. * @returns this ray updated
  15775. */
  15776. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15777. /**
  15778. * Creates a ray with origin and direction of 0,0,0
  15779. * @returns the new ray
  15780. */
  15781. static Zero(): Ray;
  15782. /**
  15783. * Creates a new ray from screen space and viewport
  15784. * @param x position
  15785. * @param y y position
  15786. * @param viewportWidth viewport width
  15787. * @param viewportHeight viewport height
  15788. * @param world world matrix
  15789. * @param view view matrix
  15790. * @param projection projection matrix
  15791. * @returns new ray
  15792. */
  15793. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15794. /**
  15795. * 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
  15796. * transformed to the given world matrix.
  15797. * @param origin The origin point
  15798. * @param end The end point
  15799. * @param world a matrix to transform the ray to. Default is the identity matrix.
  15800. * @returns the new ray
  15801. */
  15802. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  15803. /**
  15804. * Transforms a ray by a matrix
  15805. * @param ray ray to transform
  15806. * @param matrix matrix to apply
  15807. * @returns the resulting new ray
  15808. */
  15809. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  15810. /**
  15811. * Transforms a ray by a matrix
  15812. * @param ray ray to transform
  15813. * @param matrix matrix to apply
  15814. * @param result ray to store result in
  15815. */
  15816. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  15817. /**
  15818. * Unproject a ray from screen space to object space
  15819. * @param sourceX defines the screen space x coordinate to use
  15820. * @param sourceY defines the screen space y coordinate to use
  15821. * @param viewportWidth defines the current width of the viewport
  15822. * @param viewportHeight defines the current height of the viewport
  15823. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15824. * @param view defines the view matrix to use
  15825. * @param projection defines the projection matrix to use
  15826. */
  15827. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  15828. }
  15829. /**
  15830. * Type used to define predicate used to select faces when a mesh intersection is detected
  15831. */
  15832. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  15833. interface Scene {
  15834. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  15835. /** @hidden */ private _cachedRayForTransform: Ray;
  15836. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  15837. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  15838. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  15839. }
  15840. }
  15841. declare module BABYLON {
  15842. interface Scene {
  15843. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  15844. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  15845. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  15846. /**
  15847. * All of the sprite managers added to this scene
  15848. * @see http://doc.babylonjs.com/babylon101/sprites
  15849. */
  15850. spriteManagers: Array<ISpriteManager>;
  15851. /**
  15852. * An event triggered when sprites rendering is about to start
  15853. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  15854. */
  15855. onBeforeSpritesRenderingObservable: Observable<Scene>;
  15856. /**
  15857. * An event triggered when sprites rendering is done
  15858. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  15859. */
  15860. onAfterSpritesRenderingObservable: Observable<Scene>;
  15861. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15862. /** Launch a ray to try to pick a sprite in the scene
  15863. * @param x position on screen
  15864. * @param y position on screen
  15865. * @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
  15866. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  15867. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  15868. * @returns a PickingInfo
  15869. */
  15870. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15871. /** Use the given ray to pick a sprite in the scene
  15872. * @param ray The ray (in world space) to use to pick meshes
  15873. * @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
  15874. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  15875. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  15876. * @returns a PickingInfo
  15877. */
  15878. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15879. /**
  15880. * Force the sprite under the pointer
  15881. * @param sprite defines the sprite to use
  15882. */
  15883. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  15884. /**
  15885. * Gets the sprite under the pointer
  15886. * @returns a Sprite or null if no sprite is under the pointer
  15887. */
  15888. getPointerOverSprite(): Nullable<Sprite>;
  15889. }
  15890. /**
  15891. * Defines the sprite scene component responsible to manage sprites
  15892. * in a given scene.
  15893. */
  15894. export class SpriteSceneComponent implements ISceneComponent {
  15895. /**
  15896. * The component name helpfull to identify the component in the list of scene components.
  15897. */
  15898. readonly name: string;
  15899. /**
  15900. * The scene the component belongs to.
  15901. */
  15902. scene: Scene;
  15903. /** @hidden */
  15904. private _spritePredicate;
  15905. /**
  15906. * Creates a new instance of the component for the given scene
  15907. * @param scene Defines the scene to register the component in
  15908. */
  15909. constructor(scene: Scene);
  15910. /**
  15911. * Registers the component in a given scene
  15912. */
  15913. register(): void;
  15914. /**
  15915. * Rebuilds the elements related to this component in case of
  15916. * context lost for instance.
  15917. */
  15918. rebuild(): void;
  15919. /**
  15920. * Disposes the component and the associated ressources.
  15921. */
  15922. dispose(): void;
  15923. private _pickSpriteButKeepRay;
  15924. private _pointerMove;
  15925. private _pointerDown;
  15926. private _pointerUp;
  15927. }
  15928. }
  15929. declare module BABYLON {
  15930. /** @hidden */
  15931. export var fogFragmentDeclaration: {
  15932. name: string;
  15933. shader: string;
  15934. };
  15935. }
  15936. declare module BABYLON {
  15937. /** @hidden */
  15938. export var fogFragment: {
  15939. name: string;
  15940. shader: string;
  15941. };
  15942. }
  15943. declare module BABYLON {
  15944. /** @hidden */
  15945. export var spritesPixelShader: {
  15946. name: string;
  15947. shader: string;
  15948. };
  15949. }
  15950. declare module BABYLON {
  15951. /** @hidden */
  15952. export var fogVertexDeclaration: {
  15953. name: string;
  15954. shader: string;
  15955. };
  15956. }
  15957. declare module BABYLON {
  15958. /** @hidden */
  15959. export var spritesVertexShader: {
  15960. name: string;
  15961. shader: string;
  15962. };
  15963. }
  15964. declare module BABYLON {
  15965. /**
  15966. * Defines the minimum interface to fullfil in order to be a sprite manager.
  15967. */
  15968. export interface ISpriteManager extends IDisposable {
  15969. /**
  15970. * Restricts the camera to viewing objects with the same layerMask.
  15971. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  15972. */
  15973. layerMask: number;
  15974. /**
  15975. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  15976. */
  15977. isPickable: boolean;
  15978. /**
  15979. * Specifies the rendering group id for this mesh (0 by default)
  15980. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  15981. */
  15982. renderingGroupId: number;
  15983. /**
  15984. * Defines the list of sprites managed by the manager.
  15985. */
  15986. sprites: Array<Sprite>;
  15987. /**
  15988. * Tests the intersection of a sprite with a specific ray.
  15989. * @param ray The ray we are sending to test the collision
  15990. * @param camera The camera space we are sending rays in
  15991. * @param predicate A predicate allowing excluding sprites from the list of object to test
  15992. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  15993. * @returns picking info or null.
  15994. */
  15995. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  15996. /**
  15997. * Renders the list of sprites on screen.
  15998. */
  15999. render(): void;
  16000. }
  16001. /**
  16002. * Class used to manage multiple sprites on the same spritesheet
  16003. * @see http://doc.babylonjs.com/babylon101/sprites
  16004. */
  16005. export class SpriteManager implements ISpriteManager {
  16006. /** defines the manager's name */
  16007. name: string;
  16008. /** Gets the list of sprites */
  16009. sprites: Sprite[];
  16010. /** Gets or sets the rendering group id (0 by default) */
  16011. renderingGroupId: number;
  16012. /** Gets or sets camera layer mask */
  16013. layerMask: number;
  16014. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16015. fogEnabled: boolean;
  16016. /** Gets or sets a boolean indicating if the sprites are pickable */
  16017. isPickable: boolean;
  16018. /** Defines the default width of a cell in the spritesheet */
  16019. cellWidth: number;
  16020. /** Defines the default height of a cell in the spritesheet */
  16021. cellHeight: number;
  16022. /**
  16023. * An event triggered when the manager is disposed.
  16024. */
  16025. onDisposeObservable: Observable<SpriteManager>;
  16026. private _onDisposeObserver;
  16027. /**
  16028. * Callback called when the manager is disposed
  16029. */
  16030. onDispose: () => void;
  16031. private _capacity;
  16032. private _spriteTexture;
  16033. private _epsilon;
  16034. private _scene;
  16035. private _vertexData;
  16036. private _buffer;
  16037. private _vertexBuffers;
  16038. private _indexBuffer;
  16039. private _effectBase;
  16040. private _effectFog;
  16041. /**
  16042. * Gets or sets the spritesheet texture
  16043. */
  16044. texture: Texture;
  16045. /**
  16046. * Creates a new sprite manager
  16047. * @param name defines the manager's name
  16048. * @param imgUrl defines the sprite sheet url
  16049. * @param capacity defines the maximum allowed number of sprites
  16050. * @param cellSize defines the size of a sprite cell
  16051. * @param scene defines the hosting scene
  16052. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16053. * @param samplingMode defines the smapling mode to use with spritesheet
  16054. */
  16055. constructor(
  16056. /** defines the manager's name */
  16057. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16058. private _appendSpriteVertex;
  16059. /**
  16060. * Intersects the sprites with a ray
  16061. * @param ray defines the ray to intersect with
  16062. * @param camera defines the current active camera
  16063. * @param predicate defines a predicate used to select candidate sprites
  16064. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16065. * @returns null if no hit or a PickingInfo
  16066. */
  16067. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16068. /**
  16069. * Render all child sprites
  16070. */
  16071. render(): void;
  16072. /**
  16073. * Release associated resources
  16074. */
  16075. dispose(): void;
  16076. }
  16077. }
  16078. declare module BABYLON {
  16079. /**
  16080. * Class used to represent a sprite
  16081. * @see http://doc.babylonjs.com/babylon101/sprites
  16082. */
  16083. export class Sprite {
  16084. /** defines the name */
  16085. name: string;
  16086. /** Gets or sets the current world position */
  16087. position: Vector3;
  16088. /** Gets or sets the main color */
  16089. color: Color4;
  16090. /** Gets or sets the width */
  16091. width: number;
  16092. /** Gets or sets the height */
  16093. height: number;
  16094. /** Gets or sets rotation angle */
  16095. angle: number;
  16096. /** Gets or sets the cell index in the sprite sheet */
  16097. cellIndex: number;
  16098. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16099. invertU: number;
  16100. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16101. invertV: number;
  16102. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16103. disposeWhenFinishedAnimating: boolean;
  16104. /** Gets the list of attached animations */
  16105. animations: Animation[];
  16106. /** Gets or sets a boolean indicating if the sprite can be picked */
  16107. isPickable: boolean;
  16108. /**
  16109. * Gets or sets the associated action manager
  16110. */
  16111. actionManager: Nullable<ActionManager>;
  16112. private _animationStarted;
  16113. private _loopAnimation;
  16114. private _fromIndex;
  16115. private _toIndex;
  16116. private _delay;
  16117. private _direction;
  16118. private _manager;
  16119. private _time;
  16120. private _onAnimationEnd;
  16121. /**
  16122. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16123. */
  16124. isVisible: boolean;
  16125. /**
  16126. * Gets or sets the sprite size
  16127. */
  16128. size: number;
  16129. /**
  16130. * Creates a new Sprite
  16131. * @param name defines the name
  16132. * @param manager defines the manager
  16133. */
  16134. constructor(
  16135. /** defines the name */
  16136. name: string, manager: ISpriteManager);
  16137. /**
  16138. * Starts an animation
  16139. * @param from defines the initial key
  16140. * @param to defines the end key
  16141. * @param loop defines if the animation must loop
  16142. * @param delay defines the start delay (in ms)
  16143. * @param onAnimationEnd defines a callback to call when animation ends
  16144. */
  16145. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16146. /** Stops current animation (if any) */
  16147. stopAnimation(): void;
  16148. /** @hidden */ private _animate(deltaTime: number): void;
  16149. /** Release associated resources */
  16150. dispose(): void;
  16151. }
  16152. }
  16153. declare module BABYLON {
  16154. /**
  16155. * Information about the result of picking within a scene
  16156. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16157. */
  16158. export class PickingInfo {
  16159. /** @hidden */ private _pickingUnavailable: boolean;
  16160. /**
  16161. * If the pick collided with an object
  16162. */
  16163. hit: boolean;
  16164. /**
  16165. * Distance away where the pick collided
  16166. */
  16167. distance: number;
  16168. /**
  16169. * The location of pick collision
  16170. */
  16171. pickedPoint: Nullable<Vector3>;
  16172. /**
  16173. * The mesh corresponding the the pick collision
  16174. */
  16175. pickedMesh: Nullable<AbstractMesh>;
  16176. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16177. bu: number;
  16178. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16179. bv: number;
  16180. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16181. faceId: number;
  16182. /** Id of the the submesh that was picked */
  16183. subMeshId: number;
  16184. /** If a sprite was picked, this will be the sprite the pick collided with */
  16185. pickedSprite: Nullable<Sprite>;
  16186. /**
  16187. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16188. */
  16189. originMesh: Nullable<AbstractMesh>;
  16190. /**
  16191. * The ray that was used to perform the picking.
  16192. */
  16193. ray: Nullable<Ray>;
  16194. /**
  16195. * Gets the normal correspodning to the face the pick collided with
  16196. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16197. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16198. * @returns The normal correspodning to the face the pick collided with
  16199. */
  16200. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16201. /**
  16202. * Gets the texture coordinates of where the pick occured
  16203. * @returns the vector containing the coordnates of the texture
  16204. */
  16205. getTextureCoordinates(): Nullable<Vector2>;
  16206. }
  16207. }
  16208. declare module BABYLON {
  16209. /**
  16210. * Gather the list of pointer event types as constants.
  16211. */
  16212. export class PointerEventTypes {
  16213. /**
  16214. * 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.
  16215. */
  16216. static readonly POINTERDOWN: number;
  16217. /**
  16218. * The pointerup event is fired when a pointer is no longer active.
  16219. */
  16220. static readonly POINTERUP: number;
  16221. /**
  16222. * The pointermove event is fired when a pointer changes coordinates.
  16223. */
  16224. static readonly POINTERMOVE: number;
  16225. /**
  16226. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16227. */
  16228. static readonly POINTERWHEEL: number;
  16229. /**
  16230. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16231. */
  16232. static readonly POINTERPICK: number;
  16233. /**
  16234. * The pointertap event is fired when a the object has been touched and released without drag.
  16235. */
  16236. static readonly POINTERTAP: number;
  16237. /**
  16238. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16239. */
  16240. static readonly POINTERDOUBLETAP: number;
  16241. }
  16242. /**
  16243. * Base class of pointer info types.
  16244. */
  16245. export class PointerInfoBase {
  16246. /**
  16247. * Defines the type of event (PointerEventTypes)
  16248. */
  16249. type: number;
  16250. /**
  16251. * Defines the related dom event
  16252. */
  16253. event: PointerEvent | MouseWheelEvent;
  16254. /**
  16255. * Instantiates the base class of pointers info.
  16256. * @param type Defines the type of event (PointerEventTypes)
  16257. * @param event Defines the related dom event
  16258. */
  16259. constructor(
  16260. /**
  16261. * Defines the type of event (PointerEventTypes)
  16262. */
  16263. type: number,
  16264. /**
  16265. * Defines the related dom event
  16266. */
  16267. event: PointerEvent | MouseWheelEvent);
  16268. }
  16269. /**
  16270. * This class is used to store pointer related info for the onPrePointerObservable event.
  16271. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16272. */
  16273. export class PointerInfoPre extends PointerInfoBase {
  16274. /**
  16275. * Ray from a pointer if availible (eg. 6dof controller)
  16276. */
  16277. ray: Nullable<Ray>;
  16278. /**
  16279. * Defines the local position of the pointer on the canvas.
  16280. */
  16281. localPosition: Vector2;
  16282. /**
  16283. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16284. */
  16285. skipOnPointerObservable: boolean;
  16286. /**
  16287. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16288. * @param type Defines the type of event (PointerEventTypes)
  16289. * @param event Defines the related dom event
  16290. * @param localX Defines the local x coordinates of the pointer when the event occured
  16291. * @param localY Defines the local y coordinates of the pointer when the event occured
  16292. */
  16293. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16294. }
  16295. /**
  16296. * This type contains all the data related to a pointer event in Babylon.js.
  16297. * 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.
  16298. */
  16299. export class PointerInfo extends PointerInfoBase {
  16300. /**
  16301. * Defines the picking info associated to the info (if any)\
  16302. */
  16303. pickInfo: Nullable<PickingInfo>;
  16304. /**
  16305. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16306. * @param type Defines the type of event (PointerEventTypes)
  16307. * @param event Defines the related dom event
  16308. * @param pickInfo Defines the picking info associated to the info (if any)\
  16309. */
  16310. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16311. /**
  16312. * Defines the picking info associated to the info (if any)\
  16313. */
  16314. pickInfo: Nullable<PickingInfo>);
  16315. }
  16316. /**
  16317. * Data relating to a touch event on the screen.
  16318. */
  16319. export interface PointerTouch {
  16320. /**
  16321. * X coordinate of touch.
  16322. */
  16323. x: number;
  16324. /**
  16325. * Y coordinate of touch.
  16326. */
  16327. y: number;
  16328. /**
  16329. * Id of touch. Unique for each finger.
  16330. */
  16331. pointerId: number;
  16332. /**
  16333. * Event type passed from DOM.
  16334. */
  16335. type: any;
  16336. }
  16337. }
  16338. declare module BABYLON {
  16339. /**
  16340. * Manage the mouse inputs to control the movement of a free camera.
  16341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16342. */
  16343. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16344. /**
  16345. * Define if touch is enabled in the mouse input
  16346. */
  16347. touchEnabled: boolean;
  16348. /**
  16349. * Defines the camera the input is attached to.
  16350. */
  16351. camera: FreeCamera;
  16352. /**
  16353. * Defines the buttons associated with the input to handle camera move.
  16354. */
  16355. buttons: number[];
  16356. /**
  16357. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16358. */
  16359. angularSensibility: number;
  16360. private _pointerInput;
  16361. private _onMouseMove;
  16362. private _observer;
  16363. private previousPosition;
  16364. /**
  16365. * Observable for when a pointer move event occurs containing the move offset
  16366. */
  16367. onPointerMovedObservable: Observable<{
  16368. offsetX: number;
  16369. offsetY: number;
  16370. }>;
  16371. /**
  16372. * @hidden
  16373. * If the camera should be rotated automatically based on pointer movement
  16374. */ private _allowCameraRotation: boolean;
  16375. /**
  16376. * Manage the mouse inputs to control the movement of a free camera.
  16377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16378. * @param touchEnabled Defines if touch is enabled or not
  16379. */
  16380. constructor(
  16381. /**
  16382. * Define if touch is enabled in the mouse input
  16383. */
  16384. touchEnabled?: boolean);
  16385. /**
  16386. * Attach the input controls to a specific dom element to get the input from.
  16387. * @param element Defines the element the controls should be listened from
  16388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16389. */
  16390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16391. /**
  16392. * Called on JS contextmenu event.
  16393. * Override this method to provide functionality.
  16394. */
  16395. protected onContextMenu(evt: PointerEvent): void;
  16396. /**
  16397. * Detach the current controls from the specified dom element.
  16398. * @param element Defines the element to stop listening the inputs from
  16399. */
  16400. detachControl(element: Nullable<HTMLElement>): void;
  16401. /**
  16402. * Gets the class name of the current intput.
  16403. * @returns the class name
  16404. */
  16405. getClassName(): string;
  16406. /**
  16407. * Get the friendly name associated with the input class.
  16408. * @returns the input friendly name
  16409. */
  16410. getSimpleName(): string;
  16411. }
  16412. }
  16413. declare module BABYLON {
  16414. /**
  16415. * Manage the touch inputs to control the movement of a free camera.
  16416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16417. */
  16418. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16419. /**
  16420. * Defines the camera the input is attached to.
  16421. */
  16422. camera: FreeCamera;
  16423. /**
  16424. * Defines the touch sensibility for rotation.
  16425. * The higher the faster.
  16426. */
  16427. touchAngularSensibility: number;
  16428. /**
  16429. * Defines the touch sensibility for move.
  16430. * The higher the faster.
  16431. */
  16432. touchMoveSensibility: number;
  16433. private _offsetX;
  16434. private _offsetY;
  16435. private _pointerPressed;
  16436. private _pointerInput;
  16437. private _observer;
  16438. private _onLostFocus;
  16439. /**
  16440. * Attach the input controls to a specific dom element to get the input from.
  16441. * @param element Defines the element the controls should be listened from
  16442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16443. */
  16444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16445. /**
  16446. * Detach the current controls from the specified dom element.
  16447. * @param element Defines the element to stop listening the inputs from
  16448. */
  16449. detachControl(element: Nullable<HTMLElement>): void;
  16450. /**
  16451. * Update the current camera state depending on the inputs that have been used this frame.
  16452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16453. */
  16454. checkInputs(): void;
  16455. /**
  16456. * Gets the class name of the current intput.
  16457. * @returns the class name
  16458. */
  16459. getClassName(): string;
  16460. /**
  16461. * Get the friendly name associated with the input class.
  16462. * @returns the input friendly name
  16463. */
  16464. getSimpleName(): string;
  16465. }
  16466. }
  16467. declare module BABYLON {
  16468. /**
  16469. * Default Inputs manager for the FreeCamera.
  16470. * It groups all the default supported inputs for ease of use.
  16471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16472. */
  16473. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16474. /**
  16475. * @hidden
  16476. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  16477. /**
  16478. * Instantiates a new FreeCameraInputsManager.
  16479. * @param camera Defines the camera the inputs belong to
  16480. */
  16481. constructor(camera: FreeCamera);
  16482. /**
  16483. * Add keyboard input support to the input manager.
  16484. * @returns the current input manager
  16485. */
  16486. addKeyboard(): FreeCameraInputsManager;
  16487. /**
  16488. * Add mouse input support to the input manager.
  16489. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16490. * @returns the current input manager
  16491. */
  16492. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16493. /**
  16494. * Removes the mouse input support from the manager
  16495. * @returns the current input manager
  16496. */
  16497. removeMouse(): FreeCameraInputsManager;
  16498. /**
  16499. * Add touch input support to the input manager.
  16500. * @returns the current input manager
  16501. */
  16502. addTouch(): FreeCameraInputsManager;
  16503. /**
  16504. * Remove all attached input methods from a camera
  16505. */
  16506. clear(): void;
  16507. }
  16508. }
  16509. declare module BABYLON {
  16510. /**
  16511. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16512. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16513. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16514. */
  16515. export class FreeCamera extends TargetCamera {
  16516. /**
  16517. * Define the collision ellipsoid of the camera.
  16518. * This is helpful to simulate a camera body like the player body around the camera
  16519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16520. */
  16521. ellipsoid: Vector3;
  16522. /**
  16523. * Define an offset for the position of the ellipsoid around the camera.
  16524. * This can be helpful to determine the center of the body near the gravity center of the body
  16525. * instead of its head.
  16526. */
  16527. ellipsoidOffset: Vector3;
  16528. /**
  16529. * Enable or disable collisions of the camera with the rest of the scene objects.
  16530. */
  16531. checkCollisions: boolean;
  16532. /**
  16533. * Enable or disable gravity on the camera.
  16534. */
  16535. applyGravity: boolean;
  16536. /**
  16537. * Define the input manager associated to the camera.
  16538. */
  16539. inputs: FreeCameraInputsManager;
  16540. /**
  16541. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16542. * Higher values reduce sensitivity.
  16543. */
  16544. /**
  16545. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16546. * Higher values reduce sensitivity.
  16547. */
  16548. angularSensibility: number;
  16549. /**
  16550. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16551. */
  16552. keysUp: number[];
  16553. /**
  16554. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16555. */
  16556. keysDown: number[];
  16557. /**
  16558. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16559. */
  16560. keysLeft: number[];
  16561. /**
  16562. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16563. */
  16564. keysRight: number[];
  16565. /**
  16566. * Event raised when the camera collide with a mesh in the scene.
  16567. */
  16568. onCollide: (collidedMesh: AbstractMesh) => void;
  16569. private _collider;
  16570. private _needMoveForGravity;
  16571. private _oldPosition;
  16572. private _diffPosition;
  16573. private _newPosition;
  16574. /** @hidden */ private _localDirection: Vector3;
  16575. /** @hidden */ private _transformedDirection: Vector3;
  16576. /**
  16577. * Instantiates a Free Camera.
  16578. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16579. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16580. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16581. * @param name Define the name of the camera in the scene
  16582. * @param position Define the start position of the camera in the scene
  16583. * @param scene Define the scene the camera belongs to
  16584. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16585. */
  16586. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16587. /**
  16588. * Attached controls to the current camera.
  16589. * @param element Defines the element the controls should be listened from
  16590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16591. */
  16592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16593. /**
  16594. * Detach the current controls from the camera.
  16595. * The camera will stop reacting to inputs.
  16596. * @param element Defines the element to stop listening the inputs from
  16597. */
  16598. detachControl(element: HTMLElement): void;
  16599. private _collisionMask;
  16600. /**
  16601. * Define a collision mask to limit the list of object the camera can collide with
  16602. */
  16603. collisionMask: number;
  16604. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  16605. private _onCollisionPositionChange;
  16606. /** @hidden */ private _checkInputs(): void;
  16607. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  16608. /** @hidden */ private _updatePosition(): void;
  16609. /**
  16610. * Destroy the camera and release the current resources hold by it.
  16611. */
  16612. dispose(): void;
  16613. /**
  16614. * Gets the current object class name.
  16615. * @return the class name
  16616. */
  16617. getClassName(): string;
  16618. }
  16619. }
  16620. declare module BABYLON {
  16621. /**
  16622. * Represents a gamepad control stick position
  16623. */
  16624. export class StickValues {
  16625. /**
  16626. * The x component of the control stick
  16627. */
  16628. x: number;
  16629. /**
  16630. * The y component of the control stick
  16631. */
  16632. y: number;
  16633. /**
  16634. * Initializes the gamepad x and y control stick values
  16635. * @param x The x component of the gamepad control stick value
  16636. * @param y The y component of the gamepad control stick value
  16637. */
  16638. constructor(
  16639. /**
  16640. * The x component of the control stick
  16641. */
  16642. x: number,
  16643. /**
  16644. * The y component of the control stick
  16645. */
  16646. y: number);
  16647. }
  16648. /**
  16649. * An interface which manages callbacks for gamepad button changes
  16650. */
  16651. export interface GamepadButtonChanges {
  16652. /**
  16653. * Called when a gamepad has been changed
  16654. */
  16655. changed: boolean;
  16656. /**
  16657. * Called when a gamepad press event has been triggered
  16658. */
  16659. pressChanged: boolean;
  16660. /**
  16661. * Called when a touch event has been triggered
  16662. */
  16663. touchChanged: boolean;
  16664. /**
  16665. * Called when a value has changed
  16666. */
  16667. valueChanged: boolean;
  16668. }
  16669. /**
  16670. * Represents a gamepad
  16671. */
  16672. export class Gamepad {
  16673. /**
  16674. * The id of the gamepad
  16675. */
  16676. id: string;
  16677. /**
  16678. * The index of the gamepad
  16679. */
  16680. index: number;
  16681. /**
  16682. * The browser gamepad
  16683. */
  16684. browserGamepad: any;
  16685. /**
  16686. * Specifies what type of gamepad this represents
  16687. */
  16688. type: number;
  16689. private _leftStick;
  16690. private _rightStick;
  16691. /** @hidden */ private _isConnected: boolean;
  16692. private _leftStickAxisX;
  16693. private _leftStickAxisY;
  16694. private _rightStickAxisX;
  16695. private _rightStickAxisY;
  16696. /**
  16697. * Triggered when the left control stick has been changed
  16698. */
  16699. private _onleftstickchanged;
  16700. /**
  16701. * Triggered when the right control stick has been changed
  16702. */
  16703. private _onrightstickchanged;
  16704. /**
  16705. * Represents a gamepad controller
  16706. */
  16707. static GAMEPAD: number;
  16708. /**
  16709. * Represents a generic controller
  16710. */
  16711. static GENERIC: number;
  16712. /**
  16713. * Represents an XBox controller
  16714. */
  16715. static XBOX: number;
  16716. /**
  16717. * Represents a pose-enabled controller
  16718. */
  16719. static POSE_ENABLED: number;
  16720. /**
  16721. * Specifies whether the left control stick should be Y-inverted
  16722. */
  16723. protected _invertLeftStickY: boolean;
  16724. /**
  16725. * Specifies if the gamepad has been connected
  16726. */
  16727. readonly isConnected: boolean;
  16728. /**
  16729. * Initializes the gamepad
  16730. * @param id The id of the gamepad
  16731. * @param index The index of the gamepad
  16732. * @param browserGamepad The browser gamepad
  16733. * @param leftStickX The x component of the left joystick
  16734. * @param leftStickY The y component of the left joystick
  16735. * @param rightStickX The x component of the right joystick
  16736. * @param rightStickY The y component of the right joystick
  16737. */
  16738. constructor(
  16739. /**
  16740. * The id of the gamepad
  16741. */
  16742. id: string,
  16743. /**
  16744. * The index of the gamepad
  16745. */
  16746. index: number,
  16747. /**
  16748. * The browser gamepad
  16749. */
  16750. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  16751. /**
  16752. * Callback triggered when the left joystick has changed
  16753. * @param callback
  16754. */
  16755. onleftstickchanged(callback: (values: StickValues) => void): void;
  16756. /**
  16757. * Callback triggered when the right joystick has changed
  16758. * @param callback
  16759. */
  16760. onrightstickchanged(callback: (values: StickValues) => void): void;
  16761. /**
  16762. * Gets the left joystick
  16763. */
  16764. /**
  16765. * Sets the left joystick values
  16766. */
  16767. leftStick: StickValues;
  16768. /**
  16769. * Gets the right joystick
  16770. */
  16771. /**
  16772. * Sets the right joystick value
  16773. */
  16774. rightStick: StickValues;
  16775. /**
  16776. * Updates the gamepad joystick positions
  16777. */
  16778. update(): void;
  16779. /**
  16780. * Disposes the gamepad
  16781. */
  16782. dispose(): void;
  16783. }
  16784. /**
  16785. * Represents a generic gamepad
  16786. */
  16787. export class GenericPad extends Gamepad {
  16788. private _buttons;
  16789. private _onbuttondown;
  16790. private _onbuttonup;
  16791. /**
  16792. * Observable triggered when a button has been pressed
  16793. */
  16794. onButtonDownObservable: Observable<number>;
  16795. /**
  16796. * Observable triggered when a button has been released
  16797. */
  16798. onButtonUpObservable: Observable<number>;
  16799. /**
  16800. * Callback triggered when a button has been pressed
  16801. * @param callback Called when a button has been pressed
  16802. */
  16803. onbuttondown(callback: (buttonPressed: number) => void): void;
  16804. /**
  16805. * Callback triggered when a button has been released
  16806. * @param callback Called when a button has been released
  16807. */
  16808. onbuttonup(callback: (buttonReleased: number) => void): void;
  16809. /**
  16810. * Initializes the generic gamepad
  16811. * @param id The id of the generic gamepad
  16812. * @param index The index of the generic gamepad
  16813. * @param browserGamepad The browser gamepad
  16814. */
  16815. constructor(id: string, index: number, browserGamepad: any);
  16816. private _setButtonValue;
  16817. /**
  16818. * Updates the generic gamepad
  16819. */
  16820. update(): void;
  16821. /**
  16822. * Disposes the generic gamepad
  16823. */
  16824. dispose(): void;
  16825. }
  16826. }
  16827. declare module BABYLON {
  16828. /**
  16829. * Defines the types of pose enabled controllers that are supported
  16830. */
  16831. export enum PoseEnabledControllerType {
  16832. /**
  16833. * HTC Vive
  16834. */
  16835. VIVE = 0,
  16836. /**
  16837. * Oculus Rift
  16838. */
  16839. OCULUS = 1,
  16840. /**
  16841. * Windows mixed reality
  16842. */
  16843. WINDOWS = 2,
  16844. /**
  16845. * Samsung gear VR
  16846. */
  16847. GEAR_VR = 3,
  16848. /**
  16849. * Google Daydream
  16850. */
  16851. DAYDREAM = 4,
  16852. /**
  16853. * Generic
  16854. */
  16855. GENERIC = 5
  16856. }
  16857. /**
  16858. * Defines the MutableGamepadButton interface for the state of a gamepad button
  16859. */
  16860. export interface MutableGamepadButton {
  16861. /**
  16862. * Value of the button/trigger
  16863. */
  16864. value: number;
  16865. /**
  16866. * If the button/trigger is currently touched
  16867. */
  16868. touched: boolean;
  16869. /**
  16870. * If the button/trigger is currently pressed
  16871. */
  16872. pressed: boolean;
  16873. }
  16874. /**
  16875. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  16876. * @hidden
  16877. */
  16878. export interface ExtendedGamepadButton extends GamepadButton {
  16879. /**
  16880. * If the button/trigger is currently pressed
  16881. */
  16882. readonly pressed: boolean;
  16883. /**
  16884. * If the button/trigger is currently touched
  16885. */
  16886. readonly touched: boolean;
  16887. /**
  16888. * Value of the button/trigger
  16889. */
  16890. readonly value: number;
  16891. }
  16892. /** @hidden */
  16893. export interface _GamePadFactory {
  16894. /**
  16895. * Returns wether or not the current gamepad can be created for this type of controller.
  16896. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  16897. * @returns true if it can be created, otherwise false
  16898. */
  16899. canCreate(gamepadInfo: any): boolean;
  16900. /**
  16901. * Creates a new instance of the Gamepad.
  16902. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  16903. * @returns the new gamepad instance
  16904. */
  16905. create(gamepadInfo: any): Gamepad;
  16906. }
  16907. /**
  16908. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  16909. */
  16910. export class PoseEnabledControllerHelper {
  16911. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  16912. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  16913. /**
  16914. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  16915. * @param vrGamepad the gamepad to initialized
  16916. * @returns a vr controller of the type the gamepad identified as
  16917. */
  16918. static InitiateController(vrGamepad: any): Gamepad;
  16919. }
  16920. /**
  16921. * Defines the PoseEnabledController object that contains state of a vr capable controller
  16922. */
  16923. export class PoseEnabledController extends Gamepad implements PoseControlled {
  16924. private _deviceRoomPosition;
  16925. private _deviceRoomRotationQuaternion;
  16926. /**
  16927. * The device position in babylon space
  16928. */
  16929. devicePosition: Vector3;
  16930. /**
  16931. * The device rotation in babylon space
  16932. */
  16933. deviceRotationQuaternion: Quaternion;
  16934. /**
  16935. * The scale factor of the device in babylon space
  16936. */
  16937. deviceScaleFactor: number;
  16938. /**
  16939. * (Likely devicePosition should be used instead) The device position in its room space
  16940. */
  16941. position: Vector3;
  16942. /**
  16943. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  16944. */
  16945. rotationQuaternion: Quaternion;
  16946. /**
  16947. * The type of controller (Eg. Windows mixed reality)
  16948. */
  16949. controllerType: PoseEnabledControllerType;
  16950. protected _calculatedPosition: Vector3;
  16951. private _calculatedRotation;
  16952. /**
  16953. * The raw pose from the device
  16954. */
  16955. rawPose: DevicePose;
  16956. private _trackPosition;
  16957. private _maxRotationDistFromHeadset;
  16958. private _draggedRoomRotation;
  16959. /**
  16960. * @hidden
  16961. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  16962. /**
  16963. * Internal, the mesh attached to the controller
  16964. * @hidden
  16965. */ private _mesh: Nullable<AbstractMesh>;
  16966. private _poseControlledCamera;
  16967. private _leftHandSystemQuaternion;
  16968. /**
  16969. * Internal, matrix used to convert room space to babylon space
  16970. * @hidden
  16971. */ private _deviceToWorld: Matrix;
  16972. /**
  16973. * Node to be used when casting a ray from the controller
  16974. * @hidden
  16975. */ private _pointingPoseNode: Nullable<TransformNode>;
  16976. /**
  16977. * Name of the child mesh that can be used to cast a ray from the controller
  16978. */
  16979. static readonly POINTING_POSE: string;
  16980. /**
  16981. * Creates a new PoseEnabledController from a gamepad
  16982. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  16983. */
  16984. constructor(browserGamepad: any);
  16985. private _workingMatrix;
  16986. /**
  16987. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  16988. */
  16989. update(): void;
  16990. /**
  16991. * Updates only the pose device and mesh without doing any button event checking
  16992. */
  16993. protected _updatePoseAndMesh(): void;
  16994. /**
  16995. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  16996. * @param poseData raw pose fromthe device
  16997. */
  16998. updateFromDevice(poseData: DevicePose): void;
  16999. /**
  17000. * @hidden
  17001. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  17002. /**
  17003. * Attaches a mesh to the controller
  17004. * @param mesh the mesh to be attached
  17005. */
  17006. attachToMesh(mesh: AbstractMesh): void;
  17007. /**
  17008. * Attaches the controllers mesh to a camera
  17009. * @param camera the camera the mesh should be attached to
  17010. */
  17011. attachToPoseControlledCamera(camera: TargetCamera): void;
  17012. /**
  17013. * Disposes of the controller
  17014. */
  17015. dispose(): void;
  17016. /**
  17017. * The mesh that is attached to the controller
  17018. */
  17019. readonly mesh: Nullable<AbstractMesh>;
  17020. /**
  17021. * Gets the ray of the controller in the direction the controller is pointing
  17022. * @param length the length the resulting ray should be
  17023. * @returns a ray in the direction the controller is pointing
  17024. */
  17025. getForwardRay(length?: number): Ray;
  17026. }
  17027. }
  17028. declare module BABYLON {
  17029. /**
  17030. * Defines the WebVRController object that represents controllers tracked in 3D space
  17031. */
  17032. export abstract class WebVRController extends PoseEnabledController {
  17033. /**
  17034. * Internal, the default controller model for the controller
  17035. */
  17036. protected _defaultModel: AbstractMesh;
  17037. /**
  17038. * Fired when the trigger state has changed
  17039. */
  17040. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17041. /**
  17042. * Fired when the main button state has changed
  17043. */
  17044. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17045. /**
  17046. * Fired when the secondary button state has changed
  17047. */
  17048. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17049. /**
  17050. * Fired when the pad state has changed
  17051. */
  17052. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17053. /**
  17054. * Fired when controllers stick values have changed
  17055. */
  17056. onPadValuesChangedObservable: Observable<StickValues>;
  17057. /**
  17058. * Array of button availible on the controller
  17059. */
  17060. protected _buttons: Array<MutableGamepadButton>;
  17061. private _onButtonStateChange;
  17062. /**
  17063. * Fired when a controller button's state has changed
  17064. * @param callback the callback containing the button that was modified
  17065. */
  17066. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17067. /**
  17068. * X and Y axis corresponding to the controllers joystick
  17069. */
  17070. pad: StickValues;
  17071. /**
  17072. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17073. */
  17074. hand: string;
  17075. /**
  17076. * The default controller model for the controller
  17077. */
  17078. readonly defaultModel: AbstractMesh;
  17079. /**
  17080. * Creates a new WebVRController from a gamepad
  17081. * @param vrGamepad the gamepad that the WebVRController should be created from
  17082. */
  17083. constructor(vrGamepad: any);
  17084. /**
  17085. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17086. */
  17087. update(): void;
  17088. /**
  17089. * Function to be called when a button is modified
  17090. */
  17091. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17092. /**
  17093. * Loads a mesh and attaches it to the controller
  17094. * @param scene the scene the mesh should be added to
  17095. * @param meshLoaded callback for when the mesh has been loaded
  17096. */
  17097. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17098. private _setButtonValue;
  17099. private _changes;
  17100. private _checkChanges;
  17101. /**
  17102. * Disposes of th webVRCOntroller
  17103. */
  17104. dispose(): void;
  17105. }
  17106. }
  17107. declare module BABYLON {
  17108. /**
  17109. * The HemisphericLight simulates the ambient environment light,
  17110. * so the passed direction is the light reflection direction, not the incoming direction.
  17111. */
  17112. export class HemisphericLight extends Light {
  17113. /**
  17114. * The groundColor is the light in the opposite direction to the one specified during creation.
  17115. * 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.
  17116. */
  17117. groundColor: Color3;
  17118. /**
  17119. * The light reflection direction, not the incoming direction.
  17120. */
  17121. direction: Vector3;
  17122. /**
  17123. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17124. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17125. * The HemisphericLight can't cast shadows.
  17126. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17127. * @param name The friendly name of the light
  17128. * @param direction The direction of the light reflection
  17129. * @param scene The scene the light belongs to
  17130. */
  17131. constructor(name: string, direction: Vector3, scene: Scene);
  17132. protected _buildUniformLayout(): void;
  17133. /**
  17134. * Returns the string "HemisphericLight".
  17135. * @return The class name
  17136. */
  17137. getClassName(): string;
  17138. /**
  17139. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17140. * Returns the updated direction.
  17141. * @param target The target the direction should point to
  17142. * @return The computed direction
  17143. */
  17144. setDirectionToTarget(target: Vector3): Vector3;
  17145. /**
  17146. * Returns the shadow generator associated to the light.
  17147. * @returns Always null for hemispheric lights because it does not support shadows.
  17148. */
  17149. getShadowGenerator(): Nullable<IShadowGenerator>;
  17150. /**
  17151. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17152. * @param effect The effect to update
  17153. * @param lightIndex The index of the light in the effect to update
  17154. * @returns The hemispheric light
  17155. */
  17156. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17157. /**
  17158. * Computes the world matrix of the node
  17159. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17160. * @param useWasUpdatedFlag defines a reserved property
  17161. * @returns the world matrix
  17162. */
  17163. computeWorldMatrix(): Matrix;
  17164. /**
  17165. * Returns the integer 3.
  17166. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17167. */
  17168. getTypeID(): number;
  17169. /**
  17170. * Prepares the list of defines specific to the light type.
  17171. * @param defines the list of defines
  17172. * @param lightIndex defines the index of the light for the effect
  17173. */
  17174. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17175. }
  17176. }
  17177. declare module BABYLON {
  17178. /** @hidden */
  17179. export var vrMultiviewToSingleviewPixelShader: {
  17180. name: string;
  17181. shader: string;
  17182. };
  17183. }
  17184. declare module BABYLON {
  17185. /**
  17186. * Renders to multiple views with a single draw call
  17187. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17188. */
  17189. export class MultiviewRenderTarget extends RenderTargetTexture {
  17190. /**
  17191. * Creates a multiview render target
  17192. * @param scene scene used with the render target
  17193. * @param size the size of the render target (used for each view)
  17194. */
  17195. constructor(scene: Scene, size?: number | {
  17196. width: number;
  17197. height: number;
  17198. } | {
  17199. ratio: number;
  17200. });
  17201. /**
  17202. * @hidden
  17203. * @param faceIndex the face index, if its a cube texture
  17204. */ private _bindFrameBuffer(faceIndex?: number): void;
  17205. /**
  17206. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17207. * @returns the view count
  17208. */
  17209. getViewCount(): number;
  17210. }
  17211. }
  17212. declare module BABYLON {
  17213. interface Engine {
  17214. /**
  17215. * Creates a new multiview render target
  17216. * @param width defines the width of the texture
  17217. * @param height defines the height of the texture
  17218. * @returns the created multiview texture
  17219. */
  17220. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17221. /**
  17222. * Binds a multiview framebuffer to be drawn to
  17223. * @param multiviewTexture texture to bind
  17224. */
  17225. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17226. }
  17227. interface Camera {
  17228. /**
  17229. * @hidden
  17230. * 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)
  17231. */ private _useMultiviewToSingleView: boolean;
  17232. /**
  17233. * @hidden
  17234. * 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)
  17235. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  17236. /**
  17237. * @hidden
  17238. * ensures the multiview texture of the camera exists and has the specified width/height
  17239. * @param width height to set on the multiview texture
  17240. * @param height width to set on the multiview texture
  17241. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17242. }
  17243. interface Scene {
  17244. /** @hidden */ private _transformMatrixR: Matrix;
  17245. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  17246. /** @hidden */ private _createMultiviewUbo(): void;
  17247. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17248. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  17249. }
  17250. }
  17251. declare module BABYLON {
  17252. /**
  17253. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17254. * This will not be used for webXR as it supports displaying texture arrays directly
  17255. */
  17256. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17257. /**
  17258. * Initializes a VRMultiviewToSingleview
  17259. * @param name name of the post process
  17260. * @param camera camera to be applied to
  17261. * @param scaleFactor scaling factor to the size of the output texture
  17262. */
  17263. constructor(name: string, camera: Camera, scaleFactor: number);
  17264. }
  17265. }
  17266. declare module BABYLON {
  17267. interface Engine {
  17268. /** @hidden */ private _vrDisplay: any;
  17269. /** @hidden */ private _vrSupported: boolean;
  17270. /** @hidden */ private _oldSize: Size;
  17271. /** @hidden */ private _oldHardwareScaleFactor: number;
  17272. /** @hidden */ private _vrExclusivePointerMode: boolean;
  17273. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17274. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  17275. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  17276. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  17277. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  17278. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  17279. /**
  17280. * Observable signaled when VR display mode changes
  17281. */
  17282. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17283. /**
  17284. * Observable signaled when VR request present is complete
  17285. */
  17286. onVRRequestPresentComplete: Observable<boolean>;
  17287. /**
  17288. * Observable signaled when VR request present starts
  17289. */
  17290. onVRRequestPresentStart: Observable<Engine>;
  17291. /**
  17292. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17293. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17294. */
  17295. isInVRExclusivePointerMode: boolean;
  17296. /**
  17297. * Gets a boolean indicating if a webVR device was detected
  17298. * @returns true if a webVR device was detected
  17299. */
  17300. isVRDevicePresent(): boolean;
  17301. /**
  17302. * Gets the current webVR device
  17303. * @returns the current webVR device (or null)
  17304. */
  17305. getVRDevice(): any;
  17306. /**
  17307. * Initializes a webVR display and starts listening to display change events
  17308. * The onVRDisplayChangedObservable will be notified upon these changes
  17309. * @returns A promise containing a VRDisplay and if vr is supported
  17310. */
  17311. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17312. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17313. /**
  17314. * Call this function to switch to webVR mode
  17315. * Will do nothing if webVR is not supported or if there is no webVR device
  17316. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17317. */
  17318. enableVR(): void;
  17319. /** @hidden */ private _onVRFullScreenTriggered(): void;
  17320. }
  17321. }
  17322. declare module BABYLON {
  17323. /**
  17324. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17325. * IMPORTANT!! The data is right-hand data.
  17326. * @export
  17327. * @interface DevicePose
  17328. */
  17329. export interface DevicePose {
  17330. /**
  17331. * The position of the device, values in array are [x,y,z].
  17332. */
  17333. readonly position: Nullable<Float32Array>;
  17334. /**
  17335. * The linearVelocity of the device, values in array are [x,y,z].
  17336. */
  17337. readonly linearVelocity: Nullable<Float32Array>;
  17338. /**
  17339. * The linearAcceleration of the device, values in array are [x,y,z].
  17340. */
  17341. readonly linearAcceleration: Nullable<Float32Array>;
  17342. /**
  17343. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17344. */
  17345. readonly orientation: Nullable<Float32Array>;
  17346. /**
  17347. * The angularVelocity of the device, values in array are [x,y,z].
  17348. */
  17349. readonly angularVelocity: Nullable<Float32Array>;
  17350. /**
  17351. * The angularAcceleration of the device, values in array are [x,y,z].
  17352. */
  17353. readonly angularAcceleration: Nullable<Float32Array>;
  17354. }
  17355. /**
  17356. * Interface representing a pose controlled object in Babylon.
  17357. * A pose controlled object has both regular pose values as well as pose values
  17358. * from an external device such as a VR head mounted display
  17359. */
  17360. export interface PoseControlled {
  17361. /**
  17362. * The position of the object in babylon space.
  17363. */
  17364. position: Vector3;
  17365. /**
  17366. * The rotation quaternion of the object in babylon space.
  17367. */
  17368. rotationQuaternion: Quaternion;
  17369. /**
  17370. * The position of the device in babylon space.
  17371. */
  17372. devicePosition?: Vector3;
  17373. /**
  17374. * The rotation quaternion of the device in babylon space.
  17375. */
  17376. deviceRotationQuaternion: Quaternion;
  17377. /**
  17378. * The raw pose coming from the device.
  17379. */
  17380. rawPose: Nullable<DevicePose>;
  17381. /**
  17382. * The scale of the device to be used when translating from device space to babylon space.
  17383. */
  17384. deviceScaleFactor: number;
  17385. /**
  17386. * Updates the poseControlled values based on the input device pose.
  17387. * @param poseData the pose data to update the object with
  17388. */
  17389. updateFromDevice(poseData: DevicePose): void;
  17390. }
  17391. /**
  17392. * Set of options to customize the webVRCamera
  17393. */
  17394. export interface WebVROptions {
  17395. /**
  17396. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17397. */
  17398. trackPosition?: boolean;
  17399. /**
  17400. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17401. */
  17402. positionScale?: number;
  17403. /**
  17404. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17405. */
  17406. displayName?: string;
  17407. /**
  17408. * Should the native controller meshes be initialized. (default: true)
  17409. */
  17410. controllerMeshes?: boolean;
  17411. /**
  17412. * Creating a default HemiLight only on controllers. (default: true)
  17413. */
  17414. defaultLightingOnControllers?: boolean;
  17415. /**
  17416. * If you don't want to use the default VR button of the helper. (default: false)
  17417. */
  17418. useCustomVRButton?: boolean;
  17419. /**
  17420. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17421. */
  17422. customVRButton?: HTMLButtonElement;
  17423. /**
  17424. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17425. */
  17426. rayLength?: number;
  17427. /**
  17428. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17429. */
  17430. defaultHeight?: number;
  17431. /**
  17432. * If multiview should be used if availible (default: false)
  17433. */
  17434. useMultiview?: boolean;
  17435. }
  17436. /**
  17437. * This represents a WebVR camera.
  17438. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17439. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17440. */
  17441. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17442. private webVROptions;
  17443. /**
  17444. * @hidden
  17445. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17446. */ private _vrDevice: any;
  17447. /**
  17448. * The rawPose of the vrDevice.
  17449. */
  17450. rawPose: Nullable<DevicePose>;
  17451. private _onVREnabled;
  17452. private _specsVersion;
  17453. private _attached;
  17454. private _frameData;
  17455. protected _descendants: Array<Node>;
  17456. private _deviceRoomPosition;
  17457. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  17458. private _standingMatrix;
  17459. /**
  17460. * Represents device position in babylon space.
  17461. */
  17462. devicePosition: Vector3;
  17463. /**
  17464. * Represents device rotation in babylon space.
  17465. */
  17466. deviceRotationQuaternion: Quaternion;
  17467. /**
  17468. * The scale of the device to be used when translating from device space to babylon space.
  17469. */
  17470. deviceScaleFactor: number;
  17471. private _deviceToWorld;
  17472. private _worldToDevice;
  17473. /**
  17474. * References to the webVR controllers for the vrDevice.
  17475. */
  17476. controllers: Array<WebVRController>;
  17477. /**
  17478. * Emits an event when a controller is attached.
  17479. */
  17480. onControllersAttachedObservable: Observable<WebVRController[]>;
  17481. /**
  17482. * Emits an event when a controller's mesh has been loaded;
  17483. */
  17484. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17485. /**
  17486. * Emits an event when the HMD's pose has been updated.
  17487. */
  17488. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17489. private _poseSet;
  17490. /**
  17491. * If the rig cameras be used as parent instead of this camera.
  17492. */
  17493. rigParenting: boolean;
  17494. private _lightOnControllers;
  17495. private _defaultHeight?;
  17496. /**
  17497. * Instantiates a WebVRFreeCamera.
  17498. * @param name The name of the WebVRFreeCamera
  17499. * @param position The starting anchor position for the camera
  17500. * @param scene The scene the camera belongs to
  17501. * @param webVROptions a set of customizable options for the webVRCamera
  17502. */
  17503. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17504. /**
  17505. * Gets the device distance from the ground in meters.
  17506. * @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.
  17507. */
  17508. deviceDistanceToRoomGround(): number;
  17509. /**
  17510. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17511. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17512. */
  17513. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17514. /**
  17515. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17516. * @returns A promise with a boolean set to if the standing matrix is supported.
  17517. */
  17518. useStandingMatrixAsync(): Promise<boolean>;
  17519. /**
  17520. * Disposes the camera
  17521. */
  17522. dispose(): void;
  17523. /**
  17524. * Gets a vrController by name.
  17525. * @param name The name of the controller to retreive
  17526. * @returns the controller matching the name specified or null if not found
  17527. */
  17528. getControllerByName(name: string): Nullable<WebVRController>;
  17529. private _leftController;
  17530. /**
  17531. * The controller corresponding to the users left hand.
  17532. */
  17533. readonly leftController: Nullable<WebVRController>;
  17534. private _rightController;
  17535. /**
  17536. * The controller corresponding to the users right hand.
  17537. */
  17538. readonly rightController: Nullable<WebVRController>;
  17539. /**
  17540. * Casts a ray forward from the vrCamera's gaze.
  17541. * @param length Length of the ray (default: 100)
  17542. * @returns the ray corresponding to the gaze
  17543. */
  17544. getForwardRay(length?: number): Ray;
  17545. /**
  17546. * @hidden
  17547. * Updates the camera based on device's frame data
  17548. */ private _checkInputs(): void;
  17549. /**
  17550. * Updates the poseControlled values based on the input device pose.
  17551. * @param poseData Pose coming from the device
  17552. */
  17553. updateFromDevice(poseData: DevicePose): void;
  17554. private _htmlElementAttached;
  17555. private _detachIfAttached;
  17556. /**
  17557. * WebVR's attach control will start broadcasting frames to the device.
  17558. * Note that in certain browsers (chrome for example) this function must be called
  17559. * within a user-interaction callback. Example:
  17560. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17561. *
  17562. * @param element html element to attach the vrDevice to
  17563. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17564. */
  17565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17566. /**
  17567. * Detaches the camera from the html element and disables VR
  17568. *
  17569. * @param element html element to detach from
  17570. */
  17571. detachControl(element: HTMLElement): void;
  17572. /**
  17573. * @returns the name of this class
  17574. */
  17575. getClassName(): string;
  17576. /**
  17577. * Calls resetPose on the vrDisplay
  17578. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17579. */
  17580. resetToCurrentRotation(): void;
  17581. /**
  17582. * @hidden
  17583. * Updates the rig cameras (left and right eye)
  17584. */ private _updateRigCameras(): void;
  17585. private _workingVector;
  17586. private _oneVector;
  17587. private _workingMatrix;
  17588. private updateCacheCalled;
  17589. private _correctPositionIfNotTrackPosition;
  17590. /**
  17591. * @hidden
  17592. * Updates the cached values of the camera
  17593. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17594. */ private _updateCache(ignoreParentClass?: boolean): void;
  17595. /**
  17596. * @hidden
  17597. * Get current device position in babylon world
  17598. */ private _computeDevicePosition(): void;
  17599. /**
  17600. * Updates the current device position and rotation in the babylon world
  17601. */
  17602. update(): void;
  17603. /**
  17604. * @hidden
  17605. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17606. * @returns an identity matrix
  17607. */ private _getViewMatrix(): Matrix;
  17608. private _tmpMatrix;
  17609. /**
  17610. * This function is called by the two RIG cameras.
  17611. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17612. * @hidden
  17613. */ private _getWebVRViewMatrix(): Matrix;
  17614. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  17615. private _onGamepadConnectedObserver;
  17616. private _onGamepadDisconnectedObserver;
  17617. private _updateCacheWhenTrackingDisabledObserver;
  17618. /**
  17619. * Initializes the controllers and their meshes
  17620. */
  17621. initControllers(): void;
  17622. }
  17623. }
  17624. declare module BABYLON {
  17625. /**
  17626. * Size options for a post process
  17627. */
  17628. export type PostProcessOptions = {
  17629. width: number;
  17630. height: number;
  17631. };
  17632. /**
  17633. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17634. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17635. */
  17636. export class PostProcess {
  17637. /** Name of the PostProcess. */
  17638. name: string;
  17639. /**
  17640. * Gets or sets the unique id of the post process
  17641. */
  17642. uniqueId: number;
  17643. /**
  17644. * Width of the texture to apply the post process on
  17645. */
  17646. width: number;
  17647. /**
  17648. * Height of the texture to apply the post process on
  17649. */
  17650. height: number;
  17651. /**
  17652. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17653. * @hidden
  17654. */ private _outputTexture: Nullable<InternalTexture>;
  17655. /**
  17656. * Sampling mode used by the shader
  17657. * See https://doc.babylonjs.com/classes/3.1/texture
  17658. */
  17659. renderTargetSamplingMode: number;
  17660. /**
  17661. * Clear color to use when screen clearing
  17662. */
  17663. clearColor: Color4;
  17664. /**
  17665. * If the buffer needs to be cleared before applying the post process. (default: true)
  17666. * Should be set to false if shader will overwrite all previous pixels.
  17667. */
  17668. autoClear: boolean;
  17669. /**
  17670. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17671. */
  17672. alphaMode: number;
  17673. /**
  17674. * Sets the setAlphaBlendConstants of the babylon engine
  17675. */
  17676. alphaConstants: Color4;
  17677. /**
  17678. * Animations to be used for the post processing
  17679. */
  17680. animations: Animation[];
  17681. /**
  17682. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17683. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  17684. */
  17685. enablePixelPerfectMode: boolean;
  17686. /**
  17687. * Force the postprocess to be applied without taking in account viewport
  17688. */
  17689. forceFullscreenViewport: boolean;
  17690. /**
  17691. * List of inspectable custom properties (used by the Inspector)
  17692. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17693. */
  17694. inspectableCustomProperties: IInspectable[];
  17695. /**
  17696. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  17697. *
  17698. * | Value | Type | Description |
  17699. * | ----- | ----------------------------------- | ----------- |
  17700. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  17701. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  17702. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  17703. *
  17704. */
  17705. scaleMode: number;
  17706. /**
  17707. * Force textures to be a power of two (default: false)
  17708. */
  17709. alwaysForcePOT: boolean;
  17710. private _samples;
  17711. /**
  17712. * Number of sample textures (default: 1)
  17713. */
  17714. samples: number;
  17715. /**
  17716. * Modify the scale of the post process to be the same as the viewport (default: false)
  17717. */
  17718. adaptScaleToCurrentViewport: boolean;
  17719. private _camera;
  17720. private _scene;
  17721. private _engine;
  17722. private _options;
  17723. private _reusable;
  17724. private _textureType;
  17725. /**
  17726. * Smart array of input and output textures for the post process.
  17727. * @hidden
  17728. */ private _textures: SmartArray<InternalTexture>;
  17729. /**
  17730. * The index in _textures that corresponds to the output texture.
  17731. * @hidden
  17732. */ private _currentRenderTextureInd: number;
  17733. private _effect;
  17734. private _samplers;
  17735. private _fragmentUrl;
  17736. private _vertexUrl;
  17737. private _parameters;
  17738. private _scaleRatio;
  17739. protected _indexParameters: any;
  17740. private _shareOutputWithPostProcess;
  17741. private _texelSize;
  17742. private _forcedOutputTexture;
  17743. /**
  17744. * Returns the fragment url or shader name used in the post process.
  17745. * @returns the fragment url or name in the shader store.
  17746. */
  17747. getEffectName(): string;
  17748. /**
  17749. * An event triggered when the postprocess is activated.
  17750. */
  17751. onActivateObservable: Observable<Camera>;
  17752. private _onActivateObserver;
  17753. /**
  17754. * A function that is added to the onActivateObservable
  17755. */
  17756. onActivate: Nullable<(camera: Camera) => void>;
  17757. /**
  17758. * An event triggered when the postprocess changes its size.
  17759. */
  17760. onSizeChangedObservable: Observable<PostProcess>;
  17761. private _onSizeChangedObserver;
  17762. /**
  17763. * A function that is added to the onSizeChangedObservable
  17764. */
  17765. onSizeChanged: (postProcess: PostProcess) => void;
  17766. /**
  17767. * An event triggered when the postprocess applies its effect.
  17768. */
  17769. onApplyObservable: Observable<Effect>;
  17770. private _onApplyObserver;
  17771. /**
  17772. * A function that is added to the onApplyObservable
  17773. */
  17774. onApply: (effect: Effect) => void;
  17775. /**
  17776. * An event triggered before rendering the postprocess
  17777. */
  17778. onBeforeRenderObservable: Observable<Effect>;
  17779. private _onBeforeRenderObserver;
  17780. /**
  17781. * A function that is added to the onBeforeRenderObservable
  17782. */
  17783. onBeforeRender: (effect: Effect) => void;
  17784. /**
  17785. * An event triggered after rendering the postprocess
  17786. */
  17787. onAfterRenderObservable: Observable<Effect>;
  17788. private _onAfterRenderObserver;
  17789. /**
  17790. * A function that is added to the onAfterRenderObservable
  17791. */
  17792. onAfterRender: (efect: Effect) => void;
  17793. /**
  17794. * 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
  17795. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  17796. */
  17797. inputTexture: InternalTexture;
  17798. /**
  17799. * Gets the camera which post process is applied to.
  17800. * @returns The camera the post process is applied to.
  17801. */
  17802. getCamera(): Camera;
  17803. /**
  17804. * Gets the texel size of the postprocess.
  17805. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  17806. */
  17807. readonly texelSize: Vector2;
  17808. /**
  17809. * Creates a new instance PostProcess
  17810. * @param name The name of the PostProcess.
  17811. * @param fragmentUrl The url of the fragment shader to be used.
  17812. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  17813. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  17814. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17815. * @param camera The camera to apply the render pass to.
  17816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17817. * @param engine The engine which the post process will be applied. (default: current engine)
  17818. * @param reusable If the post process can be reused on the same frame. (default: false)
  17819. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  17820. * @param textureType Type of textures used when performing the post process. (default: 0)
  17821. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  17822. * @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
  17823. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  17824. */
  17825. constructor(
  17826. /** Name of the PostProcess. */
  17827. 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);
  17828. /**
  17829. * Gets a string idenfifying the name of the class
  17830. * @returns "PostProcess" string
  17831. */
  17832. getClassName(): string;
  17833. /**
  17834. * Gets the engine which this post process belongs to.
  17835. * @returns The engine the post process was enabled with.
  17836. */
  17837. getEngine(): Engine;
  17838. /**
  17839. * The effect that is created when initializing the post process.
  17840. * @returns The created effect corresponding the the postprocess.
  17841. */
  17842. getEffect(): Effect;
  17843. /**
  17844. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  17845. * @param postProcess The post process to share the output with.
  17846. * @returns This post process.
  17847. */
  17848. shareOutputWith(postProcess: PostProcess): PostProcess;
  17849. /**
  17850. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  17851. * This should be called if the post process that shares output with this post process is disabled/disposed.
  17852. */
  17853. useOwnOutput(): void;
  17854. /**
  17855. * Updates the effect with the current post process compile time values and recompiles the shader.
  17856. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  17857. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  17858. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  17859. * @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
  17860. * @param onCompiled Called when the shader has been compiled.
  17861. * @param onError Called if there is an error when compiling a shader.
  17862. */
  17863. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17864. /**
  17865. * The post process is reusable if it can be used multiple times within one frame.
  17866. * @returns If the post process is reusable
  17867. */
  17868. isReusable(): boolean;
  17869. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  17870. markTextureDirty(): void;
  17871. /**
  17872. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  17873. * 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.
  17874. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  17875. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  17876. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  17877. * @returns The target texture that was bound to be written to.
  17878. */
  17879. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  17880. /**
  17881. * If the post process is supported.
  17882. */
  17883. readonly isSupported: boolean;
  17884. /**
  17885. * The aspect ratio of the output texture.
  17886. */
  17887. readonly aspectRatio: number;
  17888. /**
  17889. * Get a value indicating if the post-process is ready to be used
  17890. * @returns true if the post-process is ready (shader is compiled)
  17891. */
  17892. isReady(): boolean;
  17893. /**
  17894. * Binds all textures and uniforms to the shader, this will be run on every pass.
  17895. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  17896. */
  17897. apply(): Nullable<Effect>;
  17898. private _disposeTextures;
  17899. /**
  17900. * Disposes the post process.
  17901. * @param camera The camera to dispose the post process on.
  17902. */
  17903. dispose(camera?: Camera): void;
  17904. }
  17905. }
  17906. declare module BABYLON {
  17907. /** @hidden */
  17908. export var kernelBlurVaryingDeclaration: {
  17909. name: string;
  17910. shader: string;
  17911. };
  17912. }
  17913. declare module BABYLON {
  17914. /** @hidden */
  17915. export var kernelBlurFragment: {
  17916. name: string;
  17917. shader: string;
  17918. };
  17919. }
  17920. declare module BABYLON {
  17921. /** @hidden */
  17922. export var kernelBlurFragment2: {
  17923. name: string;
  17924. shader: string;
  17925. };
  17926. }
  17927. declare module BABYLON {
  17928. /** @hidden */
  17929. export var kernelBlurPixelShader: {
  17930. name: string;
  17931. shader: string;
  17932. };
  17933. }
  17934. declare module BABYLON {
  17935. /** @hidden */
  17936. export var kernelBlurVertex: {
  17937. name: string;
  17938. shader: string;
  17939. };
  17940. }
  17941. declare module BABYLON {
  17942. /** @hidden */
  17943. export var kernelBlurVertexShader: {
  17944. name: string;
  17945. shader: string;
  17946. };
  17947. }
  17948. declare module BABYLON {
  17949. /**
  17950. * The Blur Post Process which blurs an image based on a kernel and direction.
  17951. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  17952. */
  17953. export class BlurPostProcess extends PostProcess {
  17954. /** The direction in which to blur the image. */
  17955. direction: Vector2;
  17956. private blockCompilation;
  17957. protected _kernel: number;
  17958. protected _idealKernel: number;
  17959. protected _packedFloat: boolean;
  17960. private _staticDefines;
  17961. /**
  17962. * Sets the length in pixels of the blur sample region
  17963. */
  17964. /**
  17965. * Gets the length in pixels of the blur sample region
  17966. */
  17967. kernel: number;
  17968. /**
  17969. * Sets wether or not the blur needs to unpack/repack floats
  17970. */
  17971. /**
  17972. * Gets wether or not the blur is unpacking/repacking floats
  17973. */
  17974. packedFloat: boolean;
  17975. /**
  17976. * Creates a new instance BlurPostProcess
  17977. * @param name The name of the effect.
  17978. * @param direction The direction in which to blur the image.
  17979. * @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.
  17980. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17981. * @param camera The camera to apply the render pass to.
  17982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17983. * @param engine The engine which the post process will be applied. (default: current engine)
  17984. * @param reusable If the post process can be reused on the same frame. (default: false)
  17985. * @param textureType Type of textures used when performing the post process. (default: 0)
  17986. * @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)
  17987. */
  17988. constructor(name: string,
  17989. /** The direction in which to blur the image. */
  17990. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  17991. /**
  17992. * Updates the effect with the current post process compile time values and recompiles the shader.
  17993. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  17994. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  17995. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  17996. * @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
  17997. * @param onCompiled Called when the shader has been compiled.
  17998. * @param onError Called if there is an error when compiling a shader.
  17999. */
  18000. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18001. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18002. /**
  18003. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18004. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18005. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18006. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18007. * The gaps between physical kernels are compensated for in the weighting of the samples
  18008. * @param idealKernel Ideal blur kernel.
  18009. * @return Nearest best kernel.
  18010. */
  18011. protected _nearestBestKernel(idealKernel: number): number;
  18012. /**
  18013. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18014. * @param x The point on the Gaussian distribution to sample.
  18015. * @return the value of the Gaussian function at x.
  18016. */
  18017. protected _gaussianWeight(x: number): number;
  18018. /**
  18019. * Generates a string that can be used as a floating point number in GLSL.
  18020. * @param x Value to print.
  18021. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18022. * @return GLSL float string.
  18023. */
  18024. protected _glslFloat(x: number, decimalFigures?: number): string;
  18025. }
  18026. }
  18027. declare module BABYLON {
  18028. /**
  18029. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18030. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18031. * You can then easily use it as a reflectionTexture on a flat surface.
  18032. * In case the surface is not a plane, please consider relying on reflection probes.
  18033. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18034. */
  18035. export class MirrorTexture extends RenderTargetTexture {
  18036. private scene;
  18037. /**
  18038. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18039. * 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.
  18040. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18041. */
  18042. mirrorPlane: Plane;
  18043. /**
  18044. * Define the blur ratio used to blur the reflection if needed.
  18045. */
  18046. blurRatio: number;
  18047. /**
  18048. * Define the adaptive blur kernel used to blur the reflection if needed.
  18049. * This will autocompute the closest best match for the `blurKernel`
  18050. */
  18051. adaptiveBlurKernel: number;
  18052. /**
  18053. * Define the blur kernel used to blur the reflection if needed.
  18054. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18055. */
  18056. blurKernel: number;
  18057. /**
  18058. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18059. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18060. */
  18061. blurKernelX: number;
  18062. /**
  18063. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18064. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18065. */
  18066. blurKernelY: number;
  18067. private _autoComputeBlurKernel;
  18068. protected _onRatioRescale(): void;
  18069. private _updateGammaSpace;
  18070. private _imageProcessingConfigChangeObserver;
  18071. private _transformMatrix;
  18072. private _mirrorMatrix;
  18073. private _savedViewMatrix;
  18074. private _blurX;
  18075. private _blurY;
  18076. private _adaptiveBlurKernel;
  18077. private _blurKernelX;
  18078. private _blurKernelY;
  18079. private _blurRatio;
  18080. /**
  18081. * Instantiates a Mirror Texture.
  18082. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18083. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18084. * You can then easily use it as a reflectionTexture on a flat surface.
  18085. * In case the surface is not a plane, please consider relying on reflection probes.
  18086. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18087. * @param name
  18088. * @param size
  18089. * @param scene
  18090. * @param generateMipMaps
  18091. * @param type
  18092. * @param samplingMode
  18093. * @param generateDepthBuffer
  18094. */
  18095. constructor(name: string, size: number | {
  18096. width: number;
  18097. height: number;
  18098. } | {
  18099. ratio: number;
  18100. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18101. private _preparePostProcesses;
  18102. /**
  18103. * Clone the mirror texture.
  18104. * @returns the cloned texture
  18105. */
  18106. clone(): MirrorTexture;
  18107. /**
  18108. * Serialize the texture to a JSON representation you could use in Parse later on
  18109. * @returns the serialized JSON representation
  18110. */
  18111. serialize(): any;
  18112. /**
  18113. * Dispose the texture and release its associated resources.
  18114. */
  18115. dispose(): void;
  18116. }
  18117. }
  18118. declare module BABYLON {
  18119. /**
  18120. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18121. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18122. */
  18123. export class Texture extends BaseTexture {
  18124. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18125. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18126. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18127. /** nearest is mag = nearest and min = nearest and mip = linear */
  18128. static readonly NEAREST_SAMPLINGMODE: number;
  18129. /** nearest is mag = nearest and min = nearest and mip = linear */
  18130. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18131. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18132. static readonly BILINEAR_SAMPLINGMODE: number;
  18133. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18134. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18135. /** Trilinear is mag = linear and min = linear and mip = linear */
  18136. static readonly TRILINEAR_SAMPLINGMODE: number;
  18137. /** Trilinear is mag = linear and min = linear and mip = linear */
  18138. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18139. /** mag = nearest and min = nearest and mip = nearest */
  18140. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18141. /** mag = nearest and min = linear and mip = nearest */
  18142. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18143. /** mag = nearest and min = linear and mip = linear */
  18144. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18145. /** mag = nearest and min = linear and mip = none */
  18146. static readonly NEAREST_LINEAR: number;
  18147. /** mag = nearest and min = nearest and mip = none */
  18148. static readonly NEAREST_NEAREST: number;
  18149. /** mag = linear and min = nearest and mip = nearest */
  18150. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18151. /** mag = linear and min = nearest and mip = linear */
  18152. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18153. /** mag = linear and min = linear and mip = none */
  18154. static readonly LINEAR_LINEAR: number;
  18155. /** mag = linear and min = nearest and mip = none */
  18156. static readonly LINEAR_NEAREST: number;
  18157. /** Explicit coordinates mode */
  18158. static readonly EXPLICIT_MODE: number;
  18159. /** Spherical coordinates mode */
  18160. static readonly SPHERICAL_MODE: number;
  18161. /** Planar coordinates mode */
  18162. static readonly PLANAR_MODE: number;
  18163. /** Cubic coordinates mode */
  18164. static readonly CUBIC_MODE: number;
  18165. /** Projection coordinates mode */
  18166. static readonly PROJECTION_MODE: number;
  18167. /** Inverse Cubic coordinates mode */
  18168. static readonly SKYBOX_MODE: number;
  18169. /** Inverse Cubic coordinates mode */
  18170. static readonly INVCUBIC_MODE: number;
  18171. /** Equirectangular coordinates mode */
  18172. static readonly EQUIRECTANGULAR_MODE: number;
  18173. /** Equirectangular Fixed coordinates mode */
  18174. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18175. /** Equirectangular Fixed Mirrored coordinates mode */
  18176. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18177. /** Texture is not repeating outside of 0..1 UVs */
  18178. static readonly CLAMP_ADDRESSMODE: number;
  18179. /** Texture is repeating outside of 0..1 UVs */
  18180. static readonly WRAP_ADDRESSMODE: number;
  18181. /** Texture is repeating and mirrored */
  18182. static readonly MIRROR_ADDRESSMODE: number;
  18183. /**
  18184. * 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
  18185. */
  18186. static UseSerializedUrlIfAny: boolean;
  18187. /**
  18188. * Define the url of the texture.
  18189. */
  18190. url: Nullable<string>;
  18191. /**
  18192. * Define an offset on the texture to offset the u coordinates of the UVs
  18193. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18194. */
  18195. uOffset: number;
  18196. /**
  18197. * Define an offset on the texture to offset the v coordinates of the UVs
  18198. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18199. */
  18200. vOffset: number;
  18201. /**
  18202. * Define an offset on the texture to scale the u coordinates of the UVs
  18203. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18204. */
  18205. uScale: number;
  18206. /**
  18207. * Define an offset on the texture to scale the v coordinates of the UVs
  18208. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18209. */
  18210. vScale: number;
  18211. /**
  18212. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18213. * @see http://doc.babylonjs.com/how_to/more_materials
  18214. */
  18215. uAng: number;
  18216. /**
  18217. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18218. * @see http://doc.babylonjs.com/how_to/more_materials
  18219. */
  18220. vAng: number;
  18221. /**
  18222. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18223. * @see http://doc.babylonjs.com/how_to/more_materials
  18224. */
  18225. wAng: number;
  18226. /**
  18227. * Defines the center of rotation (U)
  18228. */
  18229. uRotationCenter: number;
  18230. /**
  18231. * Defines the center of rotation (V)
  18232. */
  18233. vRotationCenter: number;
  18234. /**
  18235. * Defines the center of rotation (W)
  18236. */
  18237. wRotationCenter: number;
  18238. /**
  18239. * Are mip maps generated for this texture or not.
  18240. */
  18241. readonly noMipmap: boolean;
  18242. /**
  18243. * List of inspectable custom properties (used by the Inspector)
  18244. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18245. */
  18246. inspectableCustomProperties: Nullable<IInspectable[]>;
  18247. private _noMipmap;
  18248. /** @hidden */ private _invertY: boolean;
  18249. private _rowGenerationMatrix;
  18250. private _cachedTextureMatrix;
  18251. private _projectionModeMatrix;
  18252. private _t0;
  18253. private _t1;
  18254. private _t2;
  18255. private _cachedUOffset;
  18256. private _cachedVOffset;
  18257. private _cachedUScale;
  18258. private _cachedVScale;
  18259. private _cachedUAng;
  18260. private _cachedVAng;
  18261. private _cachedWAng;
  18262. private _cachedProjectionMatrixId;
  18263. private _cachedCoordinatesMode;
  18264. /** @hidden */
  18265. protected _initialSamplingMode: number;
  18266. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18267. private _deleteBuffer;
  18268. protected _format: Nullable<number>;
  18269. private _delayedOnLoad;
  18270. private _delayedOnError;
  18271. /**
  18272. * Observable triggered once the texture has been loaded.
  18273. */
  18274. onLoadObservable: Observable<Texture>;
  18275. protected _isBlocking: boolean;
  18276. /**
  18277. * Is the texture preventing material to render while loading.
  18278. * If false, a default texture will be used instead of the loading one during the preparation step.
  18279. */
  18280. isBlocking: boolean;
  18281. /**
  18282. * Get the current sampling mode associated with the texture.
  18283. */
  18284. readonly samplingMode: number;
  18285. /**
  18286. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18287. */
  18288. readonly invertY: boolean;
  18289. /**
  18290. * Instantiates a new texture.
  18291. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18292. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18293. * @param url define the url of the picture to load as a texture
  18294. * @param scene define the scene the texture will belong to
  18295. * @param noMipmap define if the texture will require mip maps or not
  18296. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18297. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18298. * @param onLoad define a callback triggered when the texture has been loaded
  18299. * @param onError define a callback triggered when an error occurred during the loading session
  18300. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18301. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18302. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18303. */
  18304. 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);
  18305. /**
  18306. * Update the url (and optional buffer) of this texture if url was null during construction.
  18307. * @param url the url of the texture
  18308. * @param buffer the buffer of the texture (defaults to null)
  18309. * @param onLoad callback called when the texture is loaded (defaults to null)
  18310. */
  18311. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18312. /**
  18313. * Finish the loading sequence of a texture flagged as delayed load.
  18314. * @hidden
  18315. */
  18316. delayLoad(): void;
  18317. private _prepareRowForTextureGeneration;
  18318. /**
  18319. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18320. * @returns the transform matrix of the texture.
  18321. */
  18322. getTextureMatrix(): Matrix;
  18323. /**
  18324. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18325. * @returns The reflection texture transform
  18326. */
  18327. getReflectionTextureMatrix(): Matrix;
  18328. /**
  18329. * Clones the texture.
  18330. * @returns the cloned texture
  18331. */
  18332. clone(): Texture;
  18333. /**
  18334. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18335. * @returns The JSON representation of the texture
  18336. */
  18337. serialize(): any;
  18338. /**
  18339. * Get the current class name of the texture useful for serialization or dynamic coding.
  18340. * @returns "Texture"
  18341. */
  18342. getClassName(): string;
  18343. /**
  18344. * Dispose the texture and release its associated resources.
  18345. */
  18346. dispose(): void;
  18347. /**
  18348. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18349. * @param parsedTexture Define the JSON representation of the texture
  18350. * @param scene Define the scene the parsed texture should be instantiated in
  18351. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18352. * @returns The parsed texture if successful
  18353. */
  18354. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18355. /**
  18356. * Creates a texture from its base 64 representation.
  18357. * @param data Define the base64 payload without the data: prefix
  18358. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18359. * @param scene Define the scene the texture should belong to
  18360. * @param noMipmap Forces the texture to not create mip map information if true
  18361. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18362. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18363. * @param onLoad define a callback triggered when the texture has been loaded
  18364. * @param onError define a callback triggered when an error occurred during the loading session
  18365. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18366. * @returns the created texture
  18367. */
  18368. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18369. /**
  18370. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18371. * @param data Define the base64 payload without the data: prefix
  18372. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18373. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18374. * @param scene Define the scene the texture should belong to
  18375. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18376. * @param noMipmap Forces the texture to not create mip map information if true
  18377. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18378. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18379. * @param onLoad define a callback triggered when the texture has been loaded
  18380. * @param onError define a callback triggered when an error occurred during the loading session
  18381. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18382. * @returns the created texture
  18383. */
  18384. 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;
  18385. }
  18386. }
  18387. declare module BABYLON {
  18388. /**
  18389. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18390. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18391. */
  18392. export class PostProcessManager {
  18393. private _scene;
  18394. private _indexBuffer;
  18395. private _vertexBuffers;
  18396. /**
  18397. * Creates a new instance PostProcess
  18398. * @param scene The scene that the post process is associated with.
  18399. */
  18400. constructor(scene: Scene);
  18401. private _prepareBuffers;
  18402. private _buildIndexBuffer;
  18403. /**
  18404. * Rebuilds the vertex buffers of the manager.
  18405. * @hidden
  18406. */ private _rebuild(): void;
  18407. /**
  18408. * Prepares a frame to be run through a post process.
  18409. * @param sourceTexture The input texture to the post procesess. (default: null)
  18410. * @param postProcesses An array of post processes to be run. (default: null)
  18411. * @returns True if the post processes were able to be run.
  18412. * @hidden
  18413. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18414. /**
  18415. * Manually render a set of post processes to a texture.
  18416. * @param postProcesses An array of post processes to be run.
  18417. * @param targetTexture The target texture to render to.
  18418. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18419. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18420. * @param lodLevel defines which lod of the texture to render to
  18421. */
  18422. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18423. /**
  18424. * Finalize the result of the output of the postprocesses.
  18425. * @param doNotPresent If true the result will not be displayed to the screen.
  18426. * @param targetTexture The target texture to render to.
  18427. * @param faceIndex The index of the face to bind the target texture to.
  18428. * @param postProcesses The array of post processes to render.
  18429. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18430. * @hidden
  18431. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18432. /**
  18433. * Disposes of the post process manager.
  18434. */
  18435. dispose(): void;
  18436. }
  18437. }
  18438. declare module BABYLON {
  18439. interface AbstractScene {
  18440. /**
  18441. * The list of procedural textures added to the scene
  18442. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18443. */
  18444. proceduralTextures: Array<ProceduralTexture>;
  18445. }
  18446. /**
  18447. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18448. * in a given scene.
  18449. */
  18450. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18451. /**
  18452. * The component name helpfull to identify the component in the list of scene components.
  18453. */
  18454. readonly name: string;
  18455. /**
  18456. * The scene the component belongs to.
  18457. */
  18458. scene: Scene;
  18459. /**
  18460. * Creates a new instance of the component for the given scene
  18461. * @param scene Defines the scene to register the component in
  18462. */
  18463. constructor(scene: Scene);
  18464. /**
  18465. * Registers the component in a given scene
  18466. */
  18467. register(): void;
  18468. /**
  18469. * Rebuilds the elements related to this component in case of
  18470. * context lost for instance.
  18471. */
  18472. rebuild(): void;
  18473. /**
  18474. * Disposes the component and the associated ressources.
  18475. */
  18476. dispose(): void;
  18477. private _beforeClear;
  18478. }
  18479. }
  18480. declare module BABYLON {
  18481. interface Engine {
  18482. /**
  18483. * Creates a new render target cube texture
  18484. * @param size defines the size of the texture
  18485. * @param options defines the options used to create the texture
  18486. * @returns a new render target cube texture stored in an InternalTexture
  18487. */
  18488. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18489. }
  18490. }
  18491. declare module BABYLON {
  18492. /** @hidden */
  18493. export var proceduralVertexShader: {
  18494. name: string;
  18495. shader: string;
  18496. };
  18497. }
  18498. declare module BABYLON {
  18499. /**
  18500. * 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.
  18501. * This is the base class of any Procedural texture and contains most of the shareable code.
  18502. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18503. */
  18504. export class ProceduralTexture extends Texture {
  18505. isCube: boolean;
  18506. /**
  18507. * Define if the texture is enabled or not (disabled texture will not render)
  18508. */
  18509. isEnabled: boolean;
  18510. /**
  18511. * Define if the texture must be cleared before rendering (default is true)
  18512. */
  18513. autoClear: boolean;
  18514. /**
  18515. * Callback called when the texture is generated
  18516. */
  18517. onGenerated: () => void;
  18518. /**
  18519. * Event raised when the texture is generated
  18520. */
  18521. onGeneratedObservable: Observable<ProceduralTexture>;
  18522. /** @hidden */ private _generateMipMaps: boolean;
  18523. /** @hidden **/ private _effect: Effect;
  18524. /** @hidden */ private _textures: {
  18525. [key: string]: Texture;
  18526. };
  18527. private _size;
  18528. private _currentRefreshId;
  18529. private _refreshRate;
  18530. private _vertexBuffers;
  18531. private _indexBuffer;
  18532. private _uniforms;
  18533. private _samplers;
  18534. private _fragment;
  18535. private _floats;
  18536. private _ints;
  18537. private _floatsArrays;
  18538. private _colors3;
  18539. private _colors4;
  18540. private _vectors2;
  18541. private _vectors3;
  18542. private _matrices;
  18543. private _fallbackTexture;
  18544. private _fallbackTextureUsed;
  18545. private _engine;
  18546. private _cachedDefines;
  18547. private _contentUpdateId;
  18548. private _contentData;
  18549. /**
  18550. * Instantiates a new procedural texture.
  18551. * 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.
  18552. * This is the base class of any Procedural texture and contains most of the shareable code.
  18553. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18554. * @param name Define the name of the texture
  18555. * @param size Define the size of the texture to create
  18556. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18557. * @param scene Define the scene the texture belongs to
  18558. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18559. * @param generateMipMaps Define if the texture should creates mip maps or not
  18560. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18561. */
  18562. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18563. /**
  18564. * The effect that is created when initializing the post process.
  18565. * @returns The created effect corresponding the the postprocess.
  18566. */
  18567. getEffect(): Effect;
  18568. /**
  18569. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18570. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18571. */
  18572. getContent(): Nullable<ArrayBufferView>;
  18573. private _createIndexBuffer;
  18574. /** @hidden */ private _rebuild(): void;
  18575. /**
  18576. * Resets the texture in order to recreate its associated resources.
  18577. * This can be called in case of context loss
  18578. */
  18579. reset(): void;
  18580. protected _getDefines(): string;
  18581. /**
  18582. * Is the texture ready to be used ? (rendered at least once)
  18583. * @returns true if ready, otherwise, false.
  18584. */
  18585. isReady(): boolean;
  18586. /**
  18587. * Resets the refresh counter of the texture and start bak from scratch.
  18588. * Could be useful to regenerate the texture if it is setup to render only once.
  18589. */
  18590. resetRefreshCounter(): void;
  18591. /**
  18592. * Set the fragment shader to use in order to render the texture.
  18593. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18594. */
  18595. setFragment(fragment: any): void;
  18596. /**
  18597. * Define the refresh rate of the texture or the rendering frequency.
  18598. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18599. */
  18600. refreshRate: number;
  18601. /** @hidden */ private _shouldRender(): boolean;
  18602. /**
  18603. * Get the size the texture is rendering at.
  18604. * @returns the size (texture is always squared)
  18605. */
  18606. getRenderSize(): number;
  18607. /**
  18608. * Resize the texture to new value.
  18609. * @param size Define the new size the texture should have
  18610. * @param generateMipMaps Define whether the new texture should create mip maps
  18611. */
  18612. resize(size: number, generateMipMaps: boolean): void;
  18613. private _checkUniform;
  18614. /**
  18615. * Set a texture in the shader program used to render.
  18616. * @param name Define the name of the uniform samplers as defined in the shader
  18617. * @param texture Define the texture to bind to this sampler
  18618. * @return the texture itself allowing "fluent" like uniform updates
  18619. */
  18620. setTexture(name: string, texture: Texture): ProceduralTexture;
  18621. /**
  18622. * Set a float in the shader.
  18623. * @param name Define the name of the uniform as defined in the shader
  18624. * @param value Define the value to give to the uniform
  18625. * @return the texture itself allowing "fluent" like uniform updates
  18626. */
  18627. setFloat(name: string, value: number): ProceduralTexture;
  18628. /**
  18629. * Set a int in the shader.
  18630. * @param name Define the name of the uniform as defined in the shader
  18631. * @param value Define the value to give to the uniform
  18632. * @return the texture itself allowing "fluent" like uniform updates
  18633. */
  18634. setInt(name: string, value: number): ProceduralTexture;
  18635. /**
  18636. * Set an array of floats in the shader.
  18637. * @param name Define the name of the uniform as defined in the shader
  18638. * @param value Define the value to give to the uniform
  18639. * @return the texture itself allowing "fluent" like uniform updates
  18640. */
  18641. setFloats(name: string, value: number[]): ProceduralTexture;
  18642. /**
  18643. * Set a vec3 in the shader from a Color3.
  18644. * @param name Define the name of the uniform as defined in the shader
  18645. * @param value Define the value to give to the uniform
  18646. * @return the texture itself allowing "fluent" like uniform updates
  18647. */
  18648. setColor3(name: string, value: Color3): ProceduralTexture;
  18649. /**
  18650. * Set a vec4 in the shader from a Color4.
  18651. * @param name Define the name of the uniform as defined in the shader
  18652. * @param value Define the value to give to the uniform
  18653. * @return the texture itself allowing "fluent" like uniform updates
  18654. */
  18655. setColor4(name: string, value: Color4): ProceduralTexture;
  18656. /**
  18657. * Set a vec2 in the shader from a Vector2.
  18658. * @param name Define the name of the uniform as defined in the shader
  18659. * @param value Define the value to give to the uniform
  18660. * @return the texture itself allowing "fluent" like uniform updates
  18661. */
  18662. setVector2(name: string, value: Vector2): ProceduralTexture;
  18663. /**
  18664. * Set a vec3 in the shader from a Vector3.
  18665. * @param name Define the name of the uniform as defined in the shader
  18666. * @param value Define the value to give to the uniform
  18667. * @return the texture itself allowing "fluent" like uniform updates
  18668. */
  18669. setVector3(name: string, value: Vector3): ProceduralTexture;
  18670. /**
  18671. * Set a mat4 in the shader from a MAtrix.
  18672. * @param name Define the name of the uniform as defined in the shader
  18673. * @param value Define the value to give to the uniform
  18674. * @return the texture itself allowing "fluent" like uniform updates
  18675. */
  18676. setMatrix(name: string, value: Matrix): ProceduralTexture;
  18677. /**
  18678. * Render the texture to its associated render target.
  18679. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  18680. */
  18681. render(useCameraPostProcess?: boolean): void;
  18682. /**
  18683. * Clone the texture.
  18684. * @returns the cloned texture
  18685. */
  18686. clone(): ProceduralTexture;
  18687. /**
  18688. * Dispose the texture and release its asoociated resources.
  18689. */
  18690. dispose(): void;
  18691. }
  18692. }
  18693. declare module BABYLON {
  18694. /**
  18695. * This represents the base class for particle system in Babylon.
  18696. * 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.
  18697. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18698. * @example https://doc.babylonjs.com/babylon101/particles
  18699. */
  18700. export class BaseParticleSystem {
  18701. /**
  18702. * Source color is added to the destination color without alpha affecting the result
  18703. */
  18704. static BLENDMODE_ONEONE: number;
  18705. /**
  18706. * Blend current color and particle color using particle’s alpha
  18707. */
  18708. static BLENDMODE_STANDARD: number;
  18709. /**
  18710. * Add current color and particle color multiplied by particle’s alpha
  18711. */
  18712. static BLENDMODE_ADD: number;
  18713. /**
  18714. * Multiply current color with particle color
  18715. */
  18716. static BLENDMODE_MULTIPLY: number;
  18717. /**
  18718. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  18719. */
  18720. static BLENDMODE_MULTIPLYADD: number;
  18721. /**
  18722. * List of animations used by the particle system.
  18723. */
  18724. animations: Animation[];
  18725. /**
  18726. * The id of the Particle system.
  18727. */
  18728. id: string;
  18729. /**
  18730. * The friendly name of the Particle system.
  18731. */
  18732. name: string;
  18733. /**
  18734. * The rendering group used by the Particle system to chose when to render.
  18735. */
  18736. renderingGroupId: number;
  18737. /**
  18738. * The emitter represents the Mesh or position we are attaching the particle system to.
  18739. */
  18740. emitter: Nullable<AbstractMesh | Vector3>;
  18741. /**
  18742. * The maximum number of particles to emit per frame
  18743. */
  18744. emitRate: number;
  18745. /**
  18746. * If you want to launch only a few particles at once, that can be done, as well.
  18747. */
  18748. manualEmitCount: number;
  18749. /**
  18750. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18751. */
  18752. updateSpeed: number;
  18753. /**
  18754. * The amount of time the particle system is running (depends of the overall update speed).
  18755. */
  18756. targetStopDuration: number;
  18757. /**
  18758. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18759. */
  18760. disposeOnStop: boolean;
  18761. /**
  18762. * Minimum power of emitting particles.
  18763. */
  18764. minEmitPower: number;
  18765. /**
  18766. * Maximum power of emitting particles.
  18767. */
  18768. maxEmitPower: number;
  18769. /**
  18770. * Minimum life time of emitting particles.
  18771. */
  18772. minLifeTime: number;
  18773. /**
  18774. * Maximum life time of emitting particles.
  18775. */
  18776. maxLifeTime: number;
  18777. /**
  18778. * Minimum Size of emitting particles.
  18779. */
  18780. minSize: number;
  18781. /**
  18782. * Maximum Size of emitting particles.
  18783. */
  18784. maxSize: number;
  18785. /**
  18786. * Minimum scale of emitting particles on X axis.
  18787. */
  18788. minScaleX: number;
  18789. /**
  18790. * Maximum scale of emitting particles on X axis.
  18791. */
  18792. maxScaleX: number;
  18793. /**
  18794. * Minimum scale of emitting particles on Y axis.
  18795. */
  18796. minScaleY: number;
  18797. /**
  18798. * Maximum scale of emitting particles on Y axis.
  18799. */
  18800. maxScaleY: number;
  18801. /**
  18802. * Gets or sets the minimal initial rotation in radians.
  18803. */
  18804. minInitialRotation: number;
  18805. /**
  18806. * Gets or sets the maximal initial rotation in radians.
  18807. */
  18808. maxInitialRotation: number;
  18809. /**
  18810. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18811. */
  18812. minAngularSpeed: number;
  18813. /**
  18814. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18815. */
  18816. maxAngularSpeed: number;
  18817. /**
  18818. * The texture used to render each particle. (this can be a spritesheet)
  18819. */
  18820. particleTexture: Nullable<Texture>;
  18821. /**
  18822. * The layer mask we are rendering the particles through.
  18823. */
  18824. layerMask: number;
  18825. /**
  18826. * This can help using your own shader to render the particle system.
  18827. * The according effect will be created
  18828. */
  18829. customShader: any;
  18830. /**
  18831. * By default particle system starts as soon as they are created. This prevents the
  18832. * automatic start to happen and let you decide when to start emitting particles.
  18833. */
  18834. preventAutoStart: boolean;
  18835. private _noiseTexture;
  18836. /**
  18837. * Gets or sets a texture used to add random noise to particle positions
  18838. */
  18839. noiseTexture: Nullable<ProceduralTexture>;
  18840. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18841. noiseStrength: Vector3;
  18842. /**
  18843. * Callback triggered when the particle animation is ending.
  18844. */
  18845. onAnimationEnd: Nullable<() => void>;
  18846. /**
  18847. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18848. */
  18849. blendMode: number;
  18850. /**
  18851. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18852. * to override the particles.
  18853. */
  18854. forceDepthWrite: boolean;
  18855. /** 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 */
  18856. preWarmCycles: number;
  18857. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  18858. preWarmStepOffset: number;
  18859. /**
  18860. * 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)
  18861. */
  18862. spriteCellChangeSpeed: number;
  18863. /**
  18864. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18865. */
  18866. startSpriteCellID: number;
  18867. /**
  18868. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18869. */
  18870. endSpriteCellID: number;
  18871. /**
  18872. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18873. */
  18874. spriteCellWidth: number;
  18875. /**
  18876. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18877. */
  18878. spriteCellHeight: number;
  18879. /**
  18880. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18881. */
  18882. spriteRandomStartCell: boolean;
  18883. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18884. translationPivot: Vector2;
  18885. /** @hidden */
  18886. protected _isAnimationSheetEnabled: boolean;
  18887. /**
  18888. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18889. */
  18890. beginAnimationOnStart: boolean;
  18891. /**
  18892. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18893. */
  18894. beginAnimationFrom: number;
  18895. /**
  18896. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18897. */
  18898. beginAnimationTo: number;
  18899. /**
  18900. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18901. */
  18902. beginAnimationLoop: boolean;
  18903. /**
  18904. * Gets or sets a world offset applied to all particles
  18905. */
  18906. worldOffset: Vector3;
  18907. /**
  18908. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  18909. */
  18910. isAnimationSheetEnabled: boolean;
  18911. /**
  18912. * Get hosting scene
  18913. * @returns the scene
  18914. */
  18915. getScene(): Scene;
  18916. /**
  18917. * You can use gravity if you want to give an orientation to your particles.
  18918. */
  18919. gravity: Vector3;
  18920. protected _colorGradients: Nullable<Array<ColorGradient>>;
  18921. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  18922. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  18923. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  18924. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  18925. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  18926. protected _dragGradients: Nullable<Array<FactorGradient>>;
  18927. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  18928. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  18929. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  18930. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  18931. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  18932. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  18933. /**
  18934. * Defines the delay in milliseconds before starting the system (0 by default)
  18935. */
  18936. startDelay: number;
  18937. /**
  18938. * Gets the current list of drag gradients.
  18939. * You must use addDragGradient and removeDragGradient to udpate this list
  18940. * @returns the list of drag gradients
  18941. */
  18942. getDragGradients(): Nullable<Array<FactorGradient>>;
  18943. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18944. limitVelocityDamping: number;
  18945. /**
  18946. * Gets the current list of limit velocity gradients.
  18947. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18948. * @returns the list of limit velocity gradients
  18949. */
  18950. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18951. /**
  18952. * Gets the current list of color gradients.
  18953. * You must use addColorGradient and removeColorGradient to udpate this list
  18954. * @returns the list of color gradients
  18955. */
  18956. getColorGradients(): Nullable<Array<ColorGradient>>;
  18957. /**
  18958. * Gets the current list of size gradients.
  18959. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18960. * @returns the list of size gradients
  18961. */
  18962. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18963. /**
  18964. * Gets the current list of color remap gradients.
  18965. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18966. * @returns the list of color remap gradients
  18967. */
  18968. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18969. /**
  18970. * Gets the current list of alpha remap gradients.
  18971. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18972. * @returns the list of alpha remap gradients
  18973. */
  18974. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Gets the current list of life time gradients.
  18977. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18978. * @returns the list of life time gradients
  18979. */
  18980. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18981. /**
  18982. * Gets the current list of angular speed gradients.
  18983. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18984. * @returns the list of angular speed gradients
  18985. */
  18986. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18987. /**
  18988. * Gets the current list of velocity gradients.
  18989. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18990. * @returns the list of velocity gradients
  18991. */
  18992. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18993. /**
  18994. * Gets the current list of start size gradients.
  18995. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18996. * @returns the list of start size gradients
  18997. */
  18998. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18999. /**
  19000. * Gets the current list of emit rate gradients.
  19001. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19002. * @returns the list of emit rate gradients
  19003. */
  19004. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19007. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19008. */
  19009. direction1: Vector3;
  19010. /**
  19011. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19012. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19013. */
  19014. direction2: Vector3;
  19015. /**
  19016. * 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.
  19017. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19018. */
  19019. minEmitBox: Vector3;
  19020. /**
  19021. * 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.
  19022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19023. */
  19024. maxEmitBox: Vector3;
  19025. /**
  19026. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19027. */
  19028. color1: Color4;
  19029. /**
  19030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19031. */
  19032. color2: Color4;
  19033. /**
  19034. * Color the particle will have at the end of its lifetime
  19035. */
  19036. colorDead: Color4;
  19037. /**
  19038. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19039. */
  19040. textureMask: Color4;
  19041. /**
  19042. * The particle emitter type defines the emitter used by the particle system.
  19043. * It can be for example box, sphere, or cone...
  19044. */
  19045. particleEmitterType: IParticleEmitterType;
  19046. /** @hidden */ private _isSubEmitter: boolean;
  19047. /**
  19048. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19049. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19050. */
  19051. billboardMode: number;
  19052. protected _isBillboardBased: boolean;
  19053. /**
  19054. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19055. */
  19056. isBillboardBased: boolean;
  19057. /**
  19058. * The scene the particle system belongs to.
  19059. */
  19060. protected _scene: Scene;
  19061. /**
  19062. * Local cache of defines for image processing.
  19063. */
  19064. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19065. /**
  19066. * Default configuration related to image processing available in the standard Material.
  19067. */
  19068. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19069. /**
  19070. * Gets the image processing configuration used either in this material.
  19071. */
  19072. /**
  19073. * Sets the Default image processing configuration used either in the this material.
  19074. *
  19075. * If sets to null, the scene one is in use.
  19076. */
  19077. imageProcessingConfiguration: ImageProcessingConfiguration;
  19078. /**
  19079. * Attaches a new image processing configuration to the Standard Material.
  19080. * @param configuration
  19081. */
  19082. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19083. /** @hidden */
  19084. protected _reset(): void;
  19085. /** @hidden */
  19086. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19087. /**
  19088. * Instantiates a particle system.
  19089. * 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.
  19090. * @param name The name of the particle system
  19091. */
  19092. constructor(name: string);
  19093. /**
  19094. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19095. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19096. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19097. * @returns the emitter
  19098. */
  19099. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19100. /**
  19101. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19102. * @param radius The radius of the hemisphere to emit from
  19103. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19104. * @returns the emitter
  19105. */
  19106. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19107. /**
  19108. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19109. * @param radius The radius of the sphere to emit from
  19110. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19111. * @returns the emitter
  19112. */
  19113. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19114. /**
  19115. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19116. * @param radius The radius of the sphere to emit from
  19117. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19118. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19119. * @returns the emitter
  19120. */
  19121. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19122. /**
  19123. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19124. * @param radius The radius of the emission cylinder
  19125. * @param height The height of the emission cylinder
  19126. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19127. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19128. * @returns the emitter
  19129. */
  19130. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19131. /**
  19132. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19133. * @param radius The radius of the cylinder to emit from
  19134. * @param height The height of the emission cylinder
  19135. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19136. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19137. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19138. * @returns the emitter
  19139. */
  19140. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19141. /**
  19142. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19143. * @param radius The radius of the cone to emit from
  19144. * @param angle The base angle of the cone
  19145. * @returns the emitter
  19146. */
  19147. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19148. /**
  19149. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19150. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19151. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19152. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19153. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19154. * @returns the emitter
  19155. */
  19156. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19157. }
  19158. }
  19159. declare module BABYLON {
  19160. /**
  19161. * Type of sub emitter
  19162. */
  19163. export enum SubEmitterType {
  19164. /**
  19165. * Attached to the particle over it's lifetime
  19166. */
  19167. ATTACHED = 0,
  19168. /**
  19169. * Created when the particle dies
  19170. */
  19171. END = 1
  19172. }
  19173. /**
  19174. * Sub emitter class used to emit particles from an existing particle
  19175. */
  19176. export class SubEmitter {
  19177. /**
  19178. * the particle system to be used by the sub emitter
  19179. */
  19180. particleSystem: ParticleSystem;
  19181. /**
  19182. * Type of the submitter (Default: END)
  19183. */
  19184. type: SubEmitterType;
  19185. /**
  19186. * 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)
  19187. * Note: This only is supported when using an emitter of type Mesh
  19188. */
  19189. inheritDirection: boolean;
  19190. /**
  19191. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19192. */
  19193. inheritedVelocityAmount: number;
  19194. /**
  19195. * Creates a sub emitter
  19196. * @param particleSystem the particle system to be used by the sub emitter
  19197. */
  19198. constructor(
  19199. /**
  19200. * the particle system to be used by the sub emitter
  19201. */
  19202. particleSystem: ParticleSystem);
  19203. /**
  19204. * Clones the sub emitter
  19205. * @returns the cloned sub emitter
  19206. */
  19207. clone(): SubEmitter;
  19208. /**
  19209. * Serialize current object to a JSON object
  19210. * @returns the serialized object
  19211. */
  19212. serialize(): any;
  19213. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19214. /**
  19215. * Creates a new SubEmitter from a serialized JSON version
  19216. * @param serializationObject defines the JSON object to read from
  19217. * @param scene defines the hosting scene
  19218. * @param rootUrl defines the rootUrl for data loading
  19219. * @returns a new SubEmitter
  19220. */
  19221. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19222. /** Release associated resources */
  19223. dispose(): void;
  19224. }
  19225. }
  19226. declare module BABYLON {
  19227. /** @hidden */
  19228. export var imageProcessingDeclaration: {
  19229. name: string;
  19230. shader: string;
  19231. };
  19232. }
  19233. declare module BABYLON {
  19234. /** @hidden */
  19235. export var imageProcessingFunctions: {
  19236. name: string;
  19237. shader: string;
  19238. };
  19239. }
  19240. declare module BABYLON {
  19241. /** @hidden */
  19242. export var particlesPixelShader: {
  19243. name: string;
  19244. shader: string;
  19245. };
  19246. }
  19247. declare module BABYLON {
  19248. /** @hidden */
  19249. export var particlesVertexShader: {
  19250. name: string;
  19251. shader: string;
  19252. };
  19253. }
  19254. declare module BABYLON {
  19255. /**
  19256. * This represents a particle system in Babylon.
  19257. * 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.
  19258. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19259. * @example https://doc.babylonjs.com/babylon101/particles
  19260. */
  19261. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19262. /**
  19263. * Billboard mode will only apply to Y axis
  19264. */
  19265. static readonly BILLBOARDMODE_Y: number;
  19266. /**
  19267. * Billboard mode will apply to all axes
  19268. */
  19269. static readonly BILLBOARDMODE_ALL: number;
  19270. /**
  19271. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19272. */
  19273. static readonly BILLBOARDMODE_STRETCHED: number;
  19274. /**
  19275. * This function can be defined to provide custom update for active particles.
  19276. * This function will be called instead of regular update (age, position, color, etc.).
  19277. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19278. */
  19279. updateFunction: (particles: Particle[]) => void;
  19280. private _emitterWorldMatrix;
  19281. /**
  19282. * This function can be defined to specify initial direction for every new particle.
  19283. * It by default use the emitterType defined function
  19284. */
  19285. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19286. /**
  19287. * This function can be defined to specify initial position for every new particle.
  19288. * It by default use the emitterType defined function
  19289. */
  19290. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19291. /**
  19292. * @hidden
  19293. */ private _inheritedVelocityOffset: Vector3;
  19294. /**
  19295. * An event triggered when the system is disposed
  19296. */
  19297. onDisposeObservable: Observable<ParticleSystem>;
  19298. private _onDisposeObserver;
  19299. /**
  19300. * Sets a callback that will be triggered when the system is disposed
  19301. */
  19302. onDispose: () => void;
  19303. private _particles;
  19304. private _epsilon;
  19305. private _capacity;
  19306. private _stockParticles;
  19307. private _newPartsExcess;
  19308. private _vertexData;
  19309. private _vertexBuffer;
  19310. private _vertexBuffers;
  19311. private _spriteBuffer;
  19312. private _indexBuffer;
  19313. private _effect;
  19314. private _customEffect;
  19315. private _cachedDefines;
  19316. private _scaledColorStep;
  19317. private _colorDiff;
  19318. private _scaledDirection;
  19319. private _scaledGravity;
  19320. private _currentRenderId;
  19321. private _alive;
  19322. private _useInstancing;
  19323. private _started;
  19324. private _stopped;
  19325. private _actualFrame;
  19326. private _scaledUpdateSpeed;
  19327. private _vertexBufferSize;
  19328. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  19329. /** @hidden */ private _currentEmitRate1: number;
  19330. /** @hidden */ private _currentEmitRate2: number;
  19331. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  19332. /** @hidden */ private _currentStartSize1: number;
  19333. /** @hidden */ private _currentStartSize2: number;
  19334. private readonly _rawTextureWidth;
  19335. private _rampGradientsTexture;
  19336. private _useRampGradients;
  19337. /** Gets or sets a boolean indicating that ramp gradients must be used
  19338. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19339. */
  19340. useRampGradients: boolean;
  19341. /**
  19342. * 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.
  19343. * 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: [])
  19344. */
  19345. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19346. private _subEmitters;
  19347. /**
  19348. * @hidden
  19349. * If the particle systems emitter should be disposed when the particle system is disposed
  19350. */ private _disposeEmitterOnDispose: boolean;
  19351. /**
  19352. * The current active Sub-systems, this property is used by the root particle system only.
  19353. */
  19354. activeSubSystems: Array<ParticleSystem>;
  19355. private _rootParticleSystem;
  19356. /**
  19357. * Gets the current list of active particles
  19358. */
  19359. readonly particles: Particle[];
  19360. /**
  19361. * Returns the string "ParticleSystem"
  19362. * @returns a string containing the class name
  19363. */
  19364. getClassName(): string;
  19365. /**
  19366. * Instantiates a particle system.
  19367. * 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.
  19368. * @param name The name of the particle system
  19369. * @param capacity The max number of particles alive at the same time
  19370. * @param scene The scene the particle system belongs to
  19371. * @param customEffect a custom effect used to change the way particles are rendered by default
  19372. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19373. * @param epsilon Offset used to render the particles
  19374. */
  19375. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19376. private _addFactorGradient;
  19377. private _removeFactorGradient;
  19378. /**
  19379. * Adds a new life time gradient
  19380. * @param gradient defines the gradient to use (between 0 and 1)
  19381. * @param factor defines the life time factor to affect to the specified gradient
  19382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19383. * @returns the current particle system
  19384. */
  19385. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19386. /**
  19387. * Remove a specific life time gradient
  19388. * @param gradient defines the gradient to remove
  19389. * @returns the current particle system
  19390. */
  19391. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19392. /**
  19393. * Adds a new size gradient
  19394. * @param gradient defines the gradient to use (between 0 and 1)
  19395. * @param factor defines the size factor to affect to the specified gradient
  19396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19397. * @returns the current particle system
  19398. */
  19399. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19400. /**
  19401. * Remove a specific size gradient
  19402. * @param gradient defines the gradient to remove
  19403. * @returns the current particle system
  19404. */
  19405. removeSizeGradient(gradient: number): IParticleSystem;
  19406. /**
  19407. * Adds a new color remap gradient
  19408. * @param gradient defines the gradient to use (between 0 and 1)
  19409. * @param min defines the color remap minimal range
  19410. * @param max defines the color remap maximal range
  19411. * @returns the current particle system
  19412. */
  19413. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19414. /**
  19415. * Remove a specific color remap gradient
  19416. * @param gradient defines the gradient to remove
  19417. * @returns the current particle system
  19418. */
  19419. removeColorRemapGradient(gradient: number): IParticleSystem;
  19420. /**
  19421. * Adds a new alpha remap gradient
  19422. * @param gradient defines the gradient to use (between 0 and 1)
  19423. * @param min defines the alpha remap minimal range
  19424. * @param max defines the alpha remap maximal range
  19425. * @returns the current particle system
  19426. */
  19427. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19428. /**
  19429. * Remove a specific alpha remap gradient
  19430. * @param gradient defines the gradient to remove
  19431. * @returns the current particle system
  19432. */
  19433. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19434. /**
  19435. * Adds a new angular speed gradient
  19436. * @param gradient defines the gradient to use (between 0 and 1)
  19437. * @param factor defines the angular speed to affect to the specified gradient
  19438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19439. * @returns the current particle system
  19440. */
  19441. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19442. /**
  19443. * Remove a specific angular speed gradient
  19444. * @param gradient defines the gradient to remove
  19445. * @returns the current particle system
  19446. */
  19447. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19448. /**
  19449. * Adds a new velocity gradient
  19450. * @param gradient defines the gradient to use (between 0 and 1)
  19451. * @param factor defines the velocity to affect to the specified gradient
  19452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19453. * @returns the current particle system
  19454. */
  19455. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19456. /**
  19457. * Remove a specific velocity gradient
  19458. * @param gradient defines the gradient to remove
  19459. * @returns the current particle system
  19460. */
  19461. removeVelocityGradient(gradient: number): IParticleSystem;
  19462. /**
  19463. * Adds a new limit velocity gradient
  19464. * @param gradient defines the gradient to use (between 0 and 1)
  19465. * @param factor defines the limit velocity value to affect to the specified gradient
  19466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19467. * @returns the current particle system
  19468. */
  19469. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19470. /**
  19471. * Remove a specific limit velocity gradient
  19472. * @param gradient defines the gradient to remove
  19473. * @returns the current particle system
  19474. */
  19475. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19476. /**
  19477. * Adds a new drag gradient
  19478. * @param gradient defines the gradient to use (between 0 and 1)
  19479. * @param factor defines the drag value to affect to the specified gradient
  19480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19481. * @returns the current particle system
  19482. */
  19483. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19484. /**
  19485. * Remove a specific drag gradient
  19486. * @param gradient defines the gradient to remove
  19487. * @returns the current particle system
  19488. */
  19489. removeDragGradient(gradient: number): IParticleSystem;
  19490. /**
  19491. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19492. * @param gradient defines the gradient to use (between 0 and 1)
  19493. * @param factor defines the emit rate value to affect to the specified gradient
  19494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19495. * @returns the current particle system
  19496. */
  19497. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19498. /**
  19499. * Remove a specific emit rate gradient
  19500. * @param gradient defines the gradient to remove
  19501. * @returns the current particle system
  19502. */
  19503. removeEmitRateGradient(gradient: number): IParticleSystem;
  19504. /**
  19505. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19506. * @param gradient defines the gradient to use (between 0 and 1)
  19507. * @param factor defines the start size value to affect to the specified gradient
  19508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19509. * @returns the current particle system
  19510. */
  19511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19512. /**
  19513. * Remove a specific start size gradient
  19514. * @param gradient defines the gradient to remove
  19515. * @returns the current particle system
  19516. */
  19517. removeStartSizeGradient(gradient: number): IParticleSystem;
  19518. private _createRampGradientTexture;
  19519. /**
  19520. * Gets the current list of ramp gradients.
  19521. * You must use addRampGradient and removeRampGradient to udpate this list
  19522. * @returns the list of ramp gradients
  19523. */
  19524. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19525. /**
  19526. * Adds a new ramp gradient used to remap particle colors
  19527. * @param gradient defines the gradient to use (between 0 and 1)
  19528. * @param color defines the color to affect to the specified gradient
  19529. * @returns the current particle system
  19530. */
  19531. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19532. /**
  19533. * Remove a specific ramp gradient
  19534. * @param gradient defines the gradient to remove
  19535. * @returns the current particle system
  19536. */
  19537. removeRampGradient(gradient: number): ParticleSystem;
  19538. /**
  19539. * Adds a new color gradient
  19540. * @param gradient defines the gradient to use (between 0 and 1)
  19541. * @param color1 defines the color to affect to the specified gradient
  19542. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19543. * @returns this particle system
  19544. */
  19545. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19546. /**
  19547. * Remove a specific color gradient
  19548. * @param gradient defines the gradient to remove
  19549. * @returns this particle system
  19550. */
  19551. removeColorGradient(gradient: number): IParticleSystem;
  19552. private _fetchR;
  19553. protected _reset(): void;
  19554. private _resetEffect;
  19555. private _createVertexBuffers;
  19556. private _createIndexBuffer;
  19557. /**
  19558. * Gets the maximum number of particles active at the same time.
  19559. * @returns The max number of active particles.
  19560. */
  19561. getCapacity(): number;
  19562. /**
  19563. * Gets whether there are still active particles in the system.
  19564. * @returns True if it is alive, otherwise false.
  19565. */
  19566. isAlive(): boolean;
  19567. /**
  19568. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19569. * @returns True if it has been started, otherwise false.
  19570. */
  19571. isStarted(): boolean;
  19572. private _prepareSubEmitterInternalArray;
  19573. /**
  19574. * Starts the particle system and begins to emit
  19575. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19576. */
  19577. start(delay?: number): void;
  19578. /**
  19579. * Stops the particle system.
  19580. * @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.
  19581. */
  19582. stop(stopSubEmitters?: boolean): void;
  19583. /**
  19584. * Remove all active particles
  19585. */
  19586. reset(): void;
  19587. /**
  19588. * @hidden (for internal use only)
  19589. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19590. /**
  19591. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19592. * Its lifetime will start back at 0.
  19593. */
  19594. recycleParticle: (particle: Particle) => void;
  19595. private _stopSubEmitters;
  19596. private _createParticle;
  19597. private _removeFromRoot;
  19598. private _emitFromParticle;
  19599. private _update;
  19600. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19601. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19602. /** @hidden */
  19603. private _getEffect;
  19604. /**
  19605. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19606. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19607. */
  19608. animate(preWarmOnly?: boolean): void;
  19609. private _appendParticleVertices;
  19610. /**
  19611. * Rebuilds the particle system.
  19612. */
  19613. rebuild(): void;
  19614. /**
  19615. * Is this system ready to be used/rendered
  19616. * @return true if the system is ready
  19617. */
  19618. isReady(): boolean;
  19619. private _render;
  19620. /**
  19621. * Renders the particle system in its current state.
  19622. * @returns the current number of particles
  19623. */
  19624. render(): number;
  19625. /**
  19626. * Disposes the particle system and free the associated resources
  19627. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19628. */
  19629. dispose(disposeTexture?: boolean): void;
  19630. /**
  19631. * Clones the particle system.
  19632. * @param name The name of the cloned object
  19633. * @param newEmitter The new emitter to use
  19634. * @returns the cloned particle system
  19635. */
  19636. clone(name: string, newEmitter: any): ParticleSystem;
  19637. /**
  19638. * Serializes the particle system to a JSON object.
  19639. * @returns the JSON object
  19640. */
  19641. serialize(): any;
  19642. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19643. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19644. /**
  19645. * Parses a JSON object to create a particle system.
  19646. * @param parsedParticleSystem The JSON object to parse
  19647. * @param scene The scene to create the particle system in
  19648. * @param rootUrl The root url to use to load external dependencies like texture
  19649. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19650. * @returns the Parsed particle system
  19651. */
  19652. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19653. }
  19654. }
  19655. declare module BABYLON {
  19656. /**
  19657. * A particle represents one of the element emitted by a particle system.
  19658. * This is mainly define by its coordinates, direction, velocity and age.
  19659. */
  19660. export class Particle {
  19661. /**
  19662. * The particle system the particle belongs to.
  19663. */
  19664. particleSystem: ParticleSystem;
  19665. private static _Count;
  19666. /**
  19667. * Unique ID of the particle
  19668. */
  19669. id: number;
  19670. /**
  19671. * The world position of the particle in the scene.
  19672. */
  19673. position: Vector3;
  19674. /**
  19675. * The world direction of the particle in the scene.
  19676. */
  19677. direction: Vector3;
  19678. /**
  19679. * The color of the particle.
  19680. */
  19681. color: Color4;
  19682. /**
  19683. * The color change of the particle per step.
  19684. */
  19685. colorStep: Color4;
  19686. /**
  19687. * Defines how long will the life of the particle be.
  19688. */
  19689. lifeTime: number;
  19690. /**
  19691. * The current age of the particle.
  19692. */
  19693. age: number;
  19694. /**
  19695. * The current size of the particle.
  19696. */
  19697. size: number;
  19698. /**
  19699. * The current scale of the particle.
  19700. */
  19701. scale: Vector2;
  19702. /**
  19703. * The current angle of the particle.
  19704. */
  19705. angle: number;
  19706. /**
  19707. * Defines how fast is the angle changing.
  19708. */
  19709. angularSpeed: number;
  19710. /**
  19711. * Defines the cell index used by the particle to be rendered from a sprite.
  19712. */
  19713. cellIndex: number;
  19714. /**
  19715. * The information required to support color remapping
  19716. */
  19717. remapData: Vector4;
  19718. /** @hidden */ private _randomCellOffset?: number;
  19719. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  19720. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  19721. /** @hidden */ private _initialStartSpriteCellID: number;
  19722. /** @hidden */ private _initialEndSpriteCellID: number;
  19723. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  19724. /** @hidden */ private _currentColor1: Color4;
  19725. /** @hidden */ private _currentColor2: Color4;
  19726. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  19727. /** @hidden */ private _currentSize1: number;
  19728. /** @hidden */ private _currentSize2: number;
  19729. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  19730. /** @hidden */ private _currentAngularSpeed1: number;
  19731. /** @hidden */ private _currentAngularSpeed2: number;
  19732. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  19733. /** @hidden */ private _currentVelocity1: number;
  19734. /** @hidden */ private _currentVelocity2: number;
  19735. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  19736. /** @hidden */ private _currentLimitVelocity1: number;
  19737. /** @hidden */ private _currentLimitVelocity2: number;
  19738. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  19739. /** @hidden */ private _currentDrag1: number;
  19740. /** @hidden */ private _currentDrag2: number;
  19741. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  19742. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  19743. /**
  19744. * Creates a new instance Particle
  19745. * @param particleSystem the particle system the particle belongs to
  19746. */
  19747. constructor(
  19748. /**
  19749. * The particle system the particle belongs to.
  19750. */
  19751. particleSystem: ParticleSystem);
  19752. private updateCellInfoFromSystem;
  19753. /**
  19754. * Defines how the sprite cell index is updated for the particle
  19755. */
  19756. updateCellIndex(): void;
  19757. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  19758. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  19759. /** @hidden */ private _reset(): void;
  19760. /**
  19761. * Copy the properties of particle to another one.
  19762. * @param other the particle to copy the information to.
  19763. */
  19764. copyTo(other: Particle): void;
  19765. }
  19766. }
  19767. declare module BABYLON {
  19768. /**
  19769. * Particle emitter represents a volume emitting particles.
  19770. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  19771. */
  19772. export interface IParticleEmitterType {
  19773. /**
  19774. * Called by the particle System when the direction is computed for the created particle.
  19775. * @param worldMatrix is the world matrix of the particle system
  19776. * @param directionToUpdate is the direction vector to update with the result
  19777. * @param particle is the particle we are computed the direction for
  19778. */
  19779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19780. /**
  19781. * Called by the particle System when the position is computed for the created particle.
  19782. * @param worldMatrix is the world matrix of the particle system
  19783. * @param positionToUpdate is the position vector to update with the result
  19784. * @param particle is the particle we are computed the position for
  19785. */
  19786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19787. /**
  19788. * Clones the current emitter and returns a copy of it
  19789. * @returns the new emitter
  19790. */
  19791. clone(): IParticleEmitterType;
  19792. /**
  19793. * Called by the GPUParticleSystem to setup the update shader
  19794. * @param effect defines the update shader
  19795. */
  19796. applyToShader(effect: Effect): void;
  19797. /**
  19798. * Returns a string to use to update the GPU particles update shader
  19799. * @returns the effect defines string
  19800. */
  19801. getEffectDefines(): string;
  19802. /**
  19803. * Returns a string representing the class name
  19804. * @returns a string containing the class name
  19805. */
  19806. getClassName(): string;
  19807. /**
  19808. * Serializes the particle system to a JSON object.
  19809. * @returns the JSON object
  19810. */
  19811. serialize(): any;
  19812. /**
  19813. * Parse properties from a JSON object
  19814. * @param serializationObject defines the JSON object
  19815. */
  19816. parse(serializationObject: any): void;
  19817. }
  19818. }
  19819. declare module BABYLON {
  19820. /**
  19821. * Particle emitter emitting particles from the inside of a box.
  19822. * It emits the particles randomly between 2 given directions.
  19823. */
  19824. export class BoxParticleEmitter implements IParticleEmitterType {
  19825. /**
  19826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19827. */
  19828. direction1: Vector3;
  19829. /**
  19830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19831. */
  19832. direction2: Vector3;
  19833. /**
  19834. * 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.
  19835. */
  19836. minEmitBox: Vector3;
  19837. /**
  19838. * 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.
  19839. */
  19840. maxEmitBox: Vector3;
  19841. /**
  19842. * Creates a new instance BoxParticleEmitter
  19843. */
  19844. constructor();
  19845. /**
  19846. * Called by the particle System when the direction is computed for the created particle.
  19847. * @param worldMatrix is the world matrix of the particle system
  19848. * @param directionToUpdate is the direction vector to update with the result
  19849. * @param particle is the particle we are computed the direction for
  19850. */
  19851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19852. /**
  19853. * Called by the particle System when the position is computed for the created particle.
  19854. * @param worldMatrix is the world matrix of the particle system
  19855. * @param positionToUpdate is the position vector to update with the result
  19856. * @param particle is the particle we are computed the position for
  19857. */
  19858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19859. /**
  19860. * Clones the current emitter and returns a copy of it
  19861. * @returns the new emitter
  19862. */
  19863. clone(): BoxParticleEmitter;
  19864. /**
  19865. * Called by the GPUParticleSystem to setup the update shader
  19866. * @param effect defines the update shader
  19867. */
  19868. applyToShader(effect: Effect): void;
  19869. /**
  19870. * Returns a string to use to update the GPU particles update shader
  19871. * @returns a string containng the defines string
  19872. */
  19873. getEffectDefines(): string;
  19874. /**
  19875. * Returns the string "BoxParticleEmitter"
  19876. * @returns a string containing the class name
  19877. */
  19878. getClassName(): string;
  19879. /**
  19880. * Serializes the particle system to a JSON object.
  19881. * @returns the JSON object
  19882. */
  19883. serialize(): any;
  19884. /**
  19885. * Parse properties from a JSON object
  19886. * @param serializationObject defines the JSON object
  19887. */
  19888. parse(serializationObject: any): void;
  19889. }
  19890. }
  19891. declare module BABYLON {
  19892. /**
  19893. * Particle emitter emitting particles from the inside of a cone.
  19894. * It emits the particles alongside the cone volume from the base to the particle.
  19895. * The emission direction might be randomized.
  19896. */
  19897. export class ConeParticleEmitter implements IParticleEmitterType {
  19898. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  19899. directionRandomizer: number;
  19900. private _radius;
  19901. private _angle;
  19902. private _height;
  19903. /**
  19904. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  19905. */
  19906. radiusRange: number;
  19907. /**
  19908. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  19909. */
  19910. heightRange: number;
  19911. /**
  19912. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  19913. */
  19914. emitFromSpawnPointOnly: boolean;
  19915. /**
  19916. * Gets or sets the radius of the emission cone
  19917. */
  19918. radius: number;
  19919. /**
  19920. * Gets or sets the angle of the emission cone
  19921. */
  19922. angle: number;
  19923. private _buildHeight;
  19924. /**
  19925. * Creates a new instance ConeParticleEmitter
  19926. * @param radius the radius of the emission cone (1 by default)
  19927. * @param angle the cone base angle (PI by default)
  19928. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  19929. */
  19930. constructor(radius?: number, angle?: number,
  19931. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  19932. directionRandomizer?: number);
  19933. /**
  19934. * Called by the particle System when the direction is computed for the created particle.
  19935. * @param worldMatrix is the world matrix of the particle system
  19936. * @param directionToUpdate is the direction vector to update with the result
  19937. * @param particle is the particle we are computed the direction for
  19938. */
  19939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19940. /**
  19941. * Called by the particle System when the position is computed for the created particle.
  19942. * @param worldMatrix is the world matrix of the particle system
  19943. * @param positionToUpdate is the position vector to update with the result
  19944. * @param particle is the particle we are computed the position for
  19945. */
  19946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19947. /**
  19948. * Clones the current emitter and returns a copy of it
  19949. * @returns the new emitter
  19950. */
  19951. clone(): ConeParticleEmitter;
  19952. /**
  19953. * Called by the GPUParticleSystem to setup the update shader
  19954. * @param effect defines the update shader
  19955. */
  19956. applyToShader(effect: Effect): void;
  19957. /**
  19958. * Returns a string to use to update the GPU particles update shader
  19959. * @returns a string containng the defines string
  19960. */
  19961. getEffectDefines(): string;
  19962. /**
  19963. * Returns the string "ConeParticleEmitter"
  19964. * @returns a string containing the class name
  19965. */
  19966. getClassName(): string;
  19967. /**
  19968. * Serializes the particle system to a JSON object.
  19969. * @returns the JSON object
  19970. */
  19971. serialize(): any;
  19972. /**
  19973. * Parse properties from a JSON object
  19974. * @param serializationObject defines the JSON object
  19975. */
  19976. parse(serializationObject: any): void;
  19977. }
  19978. }
  19979. declare module BABYLON {
  19980. /**
  19981. * Particle emitter emitting particles from the inside of a cylinder.
  19982. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  19983. */
  19984. export class CylinderParticleEmitter implements IParticleEmitterType {
  19985. /**
  19986. * The radius of the emission cylinder.
  19987. */
  19988. radius: number;
  19989. /**
  19990. * The height of the emission cylinder.
  19991. */
  19992. height: number;
  19993. /**
  19994. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  19995. */
  19996. radiusRange: number;
  19997. /**
  19998. * How much to randomize the particle direction [0-1].
  19999. */
  20000. directionRandomizer: number;
  20001. /**
  20002. * Creates a new instance CylinderParticleEmitter
  20003. * @param radius the radius of the emission cylinder (1 by default)
  20004. * @param height the height of the emission cylinder (1 by default)
  20005. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20006. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20007. */
  20008. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  20027. * @param worldMatrix is the world matrix of the particle system
  20028. * @param directionToUpdate is the direction vector to update with the result
  20029. * @param particle is the particle we are computed the direction for
  20030. */
  20031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20032. /**
  20033. * Called by the particle System when the position is computed for the created particle.
  20034. * @param worldMatrix is the world matrix of the particle system
  20035. * @param positionToUpdate is the position vector to update with the result
  20036. * @param particle is the particle we are computed the position for
  20037. */
  20038. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20039. /**
  20040. * Clones the current emitter and returns a copy of it
  20041. * @returns the new emitter
  20042. */
  20043. clone(): CylinderParticleEmitter;
  20044. /**
  20045. * Called by the GPUParticleSystem to setup the update shader
  20046. * @param effect defines the update shader
  20047. */
  20048. applyToShader(effect: Effect): void;
  20049. /**
  20050. * Returns a string to use to update the GPU particles update shader
  20051. * @returns a string containng the defines string
  20052. */
  20053. getEffectDefines(): string;
  20054. /**
  20055. * Returns the string "CylinderParticleEmitter"
  20056. * @returns a string containing the class name
  20057. */
  20058. getClassName(): string;
  20059. /**
  20060. * Serializes the particle system to a JSON object.
  20061. * @returns the JSON object
  20062. */
  20063. serialize(): any;
  20064. /**
  20065. * Parse properties from a JSON object
  20066. * @param serializationObject defines the JSON object
  20067. */
  20068. parse(serializationObject: any): void;
  20069. }
  20070. /**
  20071. * Particle emitter emitting particles from the inside of a cylinder.
  20072. * It emits the particles randomly between two vectors.
  20073. */
  20074. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20075. /**
  20076. * The min limit of the emission direction.
  20077. */
  20078. direction1: Vector3;
  20079. /**
  20080. * The max limit of the emission direction.
  20081. */
  20082. direction2: Vector3;
  20083. /**
  20084. * Creates a new instance CylinderDirectedParticleEmitter
  20085. * @param radius the radius of the emission cylinder (1 by default)
  20086. * @param height the height of the emission cylinder (1 by default)
  20087. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20088. * @param direction1 the min limit of the emission direction (up vector by default)
  20089. * @param direction2 the max limit of the emission direction (up vector by default)
  20090. */
  20091. constructor(radius?: number, height?: number, radiusRange?: number,
  20092. /**
  20093. * The min limit of the emission direction.
  20094. */
  20095. direction1?: Vector3,
  20096. /**
  20097. * The max limit of the emission direction.
  20098. */
  20099. direction2?: Vector3);
  20100. /**
  20101. * Called by the particle System when the direction is computed for the created particle.
  20102. * @param worldMatrix is the world matrix of the particle system
  20103. * @param directionToUpdate is the direction vector to update with the result
  20104. * @param particle is the particle we are computed the direction for
  20105. */
  20106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20107. /**
  20108. * Clones the current emitter and returns a copy of it
  20109. * @returns the new emitter
  20110. */
  20111. clone(): CylinderDirectedParticleEmitter;
  20112. /**
  20113. * Called by the GPUParticleSystem to setup the update shader
  20114. * @param effect defines the update shader
  20115. */
  20116. applyToShader(effect: Effect): void;
  20117. /**
  20118. * Returns a string to use to update the GPU particles update shader
  20119. * @returns a string containng the defines string
  20120. */
  20121. getEffectDefines(): string;
  20122. /**
  20123. * Returns the string "CylinderDirectedParticleEmitter"
  20124. * @returns a string containing the class name
  20125. */
  20126. getClassName(): string;
  20127. /**
  20128. * Serializes the particle system to a JSON object.
  20129. * @returns the JSON object
  20130. */
  20131. serialize(): any;
  20132. /**
  20133. * Parse properties from a JSON object
  20134. * @param serializationObject defines the JSON object
  20135. */
  20136. parse(serializationObject: any): void;
  20137. }
  20138. }
  20139. declare module BABYLON {
  20140. /**
  20141. * Particle emitter emitting particles from the inside of a hemisphere.
  20142. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20143. */
  20144. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20145. /**
  20146. * The radius of the emission hemisphere.
  20147. */
  20148. radius: number;
  20149. /**
  20150. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20151. */
  20152. radiusRange: number;
  20153. /**
  20154. * How much to randomize the particle direction [0-1].
  20155. */
  20156. directionRandomizer: number;
  20157. /**
  20158. * Creates a new instance HemisphericParticleEmitter
  20159. * @param radius the radius of the emission hemisphere (1 by default)
  20160. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20161. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20162. */
  20163. constructor(
  20164. /**
  20165. * The radius of the emission hemisphere.
  20166. */
  20167. radius?: number,
  20168. /**
  20169. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20170. */
  20171. radiusRange?: number,
  20172. /**
  20173. * How much to randomize the particle direction [0-1].
  20174. */
  20175. directionRandomizer?: number);
  20176. /**
  20177. * Called by the particle System when the direction is computed for the created particle.
  20178. * @param worldMatrix is the world matrix of the particle system
  20179. * @param directionToUpdate is the direction vector to update with the result
  20180. * @param particle is the particle we are computed the direction for
  20181. */
  20182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20183. /**
  20184. * Called by the particle System when the position is computed for the created particle.
  20185. * @param worldMatrix is the world matrix of the particle system
  20186. * @param positionToUpdate is the position vector to update with the result
  20187. * @param particle is the particle we are computed the position for
  20188. */
  20189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20190. /**
  20191. * Clones the current emitter and returns a copy of it
  20192. * @returns the new emitter
  20193. */
  20194. clone(): HemisphericParticleEmitter;
  20195. /**
  20196. * Called by the GPUParticleSystem to setup the update shader
  20197. * @param effect defines the update shader
  20198. */
  20199. applyToShader(effect: Effect): void;
  20200. /**
  20201. * Returns a string to use to update the GPU particles update shader
  20202. * @returns a string containng the defines string
  20203. */
  20204. getEffectDefines(): string;
  20205. /**
  20206. * Returns the string "HemisphericParticleEmitter"
  20207. * @returns a string containing the class name
  20208. */
  20209. getClassName(): string;
  20210. /**
  20211. * Serializes the particle system to a JSON object.
  20212. * @returns the JSON object
  20213. */
  20214. serialize(): any;
  20215. /**
  20216. * Parse properties from a JSON object
  20217. * @param serializationObject defines the JSON object
  20218. */
  20219. parse(serializationObject: any): void;
  20220. }
  20221. }
  20222. declare module BABYLON {
  20223. /**
  20224. * Particle emitter emitting particles from a point.
  20225. * It emits the particles randomly between 2 given directions.
  20226. */
  20227. export class PointParticleEmitter implements IParticleEmitterType {
  20228. /**
  20229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20230. */
  20231. direction1: Vector3;
  20232. /**
  20233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20234. */
  20235. direction2: Vector3;
  20236. /**
  20237. * Creates a new instance PointParticleEmitter
  20238. */
  20239. constructor();
  20240. /**
  20241. * Called by the particle System when the direction is computed for the created particle.
  20242. * @param worldMatrix is the world matrix of the particle system
  20243. * @param directionToUpdate is the direction vector to update with the result
  20244. * @param particle is the particle we are computed the direction for
  20245. */
  20246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20247. /**
  20248. * Called by the particle System when the position is computed for the created particle.
  20249. * @param worldMatrix is the world matrix of the particle system
  20250. * @param positionToUpdate is the position vector to update with the result
  20251. * @param particle is the particle we are computed the position for
  20252. */
  20253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20254. /**
  20255. * Clones the current emitter and returns a copy of it
  20256. * @returns the new emitter
  20257. */
  20258. clone(): PointParticleEmitter;
  20259. /**
  20260. * Called by the GPUParticleSystem to setup the update shader
  20261. * @param effect defines the update shader
  20262. */
  20263. applyToShader(effect: Effect): void;
  20264. /**
  20265. * Returns a string to use to update the GPU particles update shader
  20266. * @returns a string containng the defines string
  20267. */
  20268. getEffectDefines(): string;
  20269. /**
  20270. * Returns the string "PointParticleEmitter"
  20271. * @returns a string containing the class name
  20272. */
  20273. getClassName(): string;
  20274. /**
  20275. * Serializes the particle system to a JSON object.
  20276. * @returns the JSON object
  20277. */
  20278. serialize(): any;
  20279. /**
  20280. * Parse properties from a JSON object
  20281. * @param serializationObject defines the JSON object
  20282. */
  20283. parse(serializationObject: any): void;
  20284. }
  20285. }
  20286. declare module BABYLON {
  20287. /**
  20288. * Particle emitter emitting particles from the inside of a sphere.
  20289. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20290. */
  20291. export class SphereParticleEmitter implements IParticleEmitterType {
  20292. /**
  20293. * The radius of the emission sphere.
  20294. */
  20295. radius: number;
  20296. /**
  20297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20298. */
  20299. radiusRange: number;
  20300. /**
  20301. * How much to randomize the particle direction [0-1].
  20302. */
  20303. directionRandomizer: number;
  20304. /**
  20305. * Creates a new instance SphereParticleEmitter
  20306. * @param radius the radius of the emission sphere (1 by default)
  20307. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20308. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20309. */
  20310. constructor(
  20311. /**
  20312. * The radius of the emission sphere.
  20313. */
  20314. radius?: number,
  20315. /**
  20316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20317. */
  20318. radiusRange?: number,
  20319. /**
  20320. * How much to randomize the particle direction [0-1].
  20321. */
  20322. directionRandomizer?: number);
  20323. /**
  20324. * Called by the particle System when the direction is computed for the created particle.
  20325. * @param worldMatrix is the world matrix of the particle system
  20326. * @param directionToUpdate is the direction vector to update with the result
  20327. * @param particle is the particle we are computed the direction for
  20328. */
  20329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20330. /**
  20331. * Called by the particle System when the position is computed for the created particle.
  20332. * @param worldMatrix is the world matrix of the particle system
  20333. * @param positionToUpdate is the position vector to update with the result
  20334. * @param particle is the particle we are computed the position for
  20335. */
  20336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20337. /**
  20338. * Clones the current emitter and returns a copy of it
  20339. * @returns the new emitter
  20340. */
  20341. clone(): SphereParticleEmitter;
  20342. /**
  20343. * Called by the GPUParticleSystem to setup the update shader
  20344. * @param effect defines the update shader
  20345. */
  20346. applyToShader(effect: Effect): void;
  20347. /**
  20348. * Returns a string to use to update the GPU particles update shader
  20349. * @returns a string containng the defines string
  20350. */
  20351. getEffectDefines(): string;
  20352. /**
  20353. * Returns the string "SphereParticleEmitter"
  20354. * @returns a string containing the class name
  20355. */
  20356. getClassName(): string;
  20357. /**
  20358. * Serializes the particle system to a JSON object.
  20359. * @returns the JSON object
  20360. */
  20361. serialize(): any;
  20362. /**
  20363. * Parse properties from a JSON object
  20364. * @param serializationObject defines the JSON object
  20365. */
  20366. parse(serializationObject: any): void;
  20367. }
  20368. /**
  20369. * Particle emitter emitting particles from the inside of a sphere.
  20370. * It emits the particles randomly between two vectors.
  20371. */
  20372. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20373. /**
  20374. * The min limit of the emission direction.
  20375. */
  20376. direction1: Vector3;
  20377. /**
  20378. * The max limit of the emission direction.
  20379. */
  20380. direction2: Vector3;
  20381. /**
  20382. * Creates a new instance SphereDirectedParticleEmitter
  20383. * @param radius the radius of the emission sphere (1 by default)
  20384. * @param direction1 the min limit of the emission direction (up vector by default)
  20385. * @param direction2 the max limit of the emission direction (up vector by default)
  20386. */
  20387. constructor(radius?: number,
  20388. /**
  20389. * The min limit of the emission direction.
  20390. */
  20391. direction1?: Vector3,
  20392. /**
  20393. * The max limit of the emission direction.
  20394. */
  20395. direction2?: Vector3);
  20396. /**
  20397. * Called by the particle System when the direction is computed for the created particle.
  20398. * @param worldMatrix is the world matrix of the particle system
  20399. * @param directionToUpdate is the direction vector to update with the result
  20400. * @param particle is the particle we are computed the direction for
  20401. */
  20402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20403. /**
  20404. * Clones the current emitter and returns a copy of it
  20405. * @returns the new emitter
  20406. */
  20407. clone(): SphereDirectedParticleEmitter;
  20408. /**
  20409. * Called by the GPUParticleSystem to setup the update shader
  20410. * @param effect defines the update shader
  20411. */
  20412. applyToShader(effect: Effect): void;
  20413. /**
  20414. * Returns a string to use to update the GPU particles update shader
  20415. * @returns a string containng the defines string
  20416. */
  20417. getEffectDefines(): string;
  20418. /**
  20419. * Returns the string "SphereDirectedParticleEmitter"
  20420. * @returns a string containing the class name
  20421. */
  20422. getClassName(): string;
  20423. /**
  20424. * Serializes the particle system to a JSON object.
  20425. * @returns the JSON object
  20426. */
  20427. serialize(): any;
  20428. /**
  20429. * Parse properties from a JSON object
  20430. * @param serializationObject defines the JSON object
  20431. */
  20432. parse(serializationObject: any): void;
  20433. }
  20434. }
  20435. declare module BABYLON {
  20436. /**
  20437. * Interface representing a particle system in Babylon.js.
  20438. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20439. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20440. */
  20441. export interface IParticleSystem {
  20442. /**
  20443. * List of animations used by the particle system.
  20444. */
  20445. animations: Animation[];
  20446. /**
  20447. * The id of the Particle system.
  20448. */
  20449. id: string;
  20450. /**
  20451. * The name of the Particle system.
  20452. */
  20453. name: string;
  20454. /**
  20455. * The emitter represents the Mesh or position we are attaching the particle system to.
  20456. */
  20457. emitter: Nullable<AbstractMesh | Vector3>;
  20458. /**
  20459. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20460. */
  20461. isBillboardBased: boolean;
  20462. /**
  20463. * The rendering group used by the Particle system to chose when to render.
  20464. */
  20465. renderingGroupId: number;
  20466. /**
  20467. * The layer mask we are rendering the particles through.
  20468. */
  20469. layerMask: number;
  20470. /**
  20471. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20472. */
  20473. updateSpeed: number;
  20474. /**
  20475. * The amount of time the particle system is running (depends of the overall update speed).
  20476. */
  20477. targetStopDuration: number;
  20478. /**
  20479. * The texture used to render each particle. (this can be a spritesheet)
  20480. */
  20481. particleTexture: Nullable<Texture>;
  20482. /**
  20483. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20484. */
  20485. blendMode: number;
  20486. /**
  20487. * Minimum life time of emitting particles.
  20488. */
  20489. minLifeTime: number;
  20490. /**
  20491. * Maximum life time of emitting particles.
  20492. */
  20493. maxLifeTime: number;
  20494. /**
  20495. * Minimum Size of emitting particles.
  20496. */
  20497. minSize: number;
  20498. /**
  20499. * Maximum Size of emitting particles.
  20500. */
  20501. maxSize: number;
  20502. /**
  20503. * Minimum scale of emitting particles on X axis.
  20504. */
  20505. minScaleX: number;
  20506. /**
  20507. * Maximum scale of emitting particles on X axis.
  20508. */
  20509. maxScaleX: number;
  20510. /**
  20511. * Minimum scale of emitting particles on Y axis.
  20512. */
  20513. minScaleY: number;
  20514. /**
  20515. * Maximum scale of emitting particles on Y axis.
  20516. */
  20517. maxScaleY: number;
  20518. /**
  20519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20520. */
  20521. color1: Color4;
  20522. /**
  20523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20524. */
  20525. color2: Color4;
  20526. /**
  20527. * Color the particle will have at the end of its lifetime.
  20528. */
  20529. colorDead: Color4;
  20530. /**
  20531. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20532. */
  20533. emitRate: number;
  20534. /**
  20535. * You can use gravity if you want to give an orientation to your particles.
  20536. */
  20537. gravity: Vector3;
  20538. /**
  20539. * Minimum power of emitting particles.
  20540. */
  20541. minEmitPower: number;
  20542. /**
  20543. * Maximum power of emitting particles.
  20544. */
  20545. maxEmitPower: number;
  20546. /**
  20547. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20548. */
  20549. minAngularSpeed: number;
  20550. /**
  20551. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20552. */
  20553. maxAngularSpeed: number;
  20554. /**
  20555. * Gets or sets the minimal initial rotation in radians.
  20556. */
  20557. minInitialRotation: number;
  20558. /**
  20559. * Gets or sets the maximal initial rotation in radians.
  20560. */
  20561. maxInitialRotation: number;
  20562. /**
  20563. * The particle emitter type defines the emitter used by the particle system.
  20564. * It can be for example box, sphere, or cone...
  20565. */
  20566. particleEmitterType: Nullable<IParticleEmitterType>;
  20567. /**
  20568. * Defines the delay in milliseconds before starting the system (0 by default)
  20569. */
  20570. startDelay: number;
  20571. /**
  20572. * 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
  20573. */
  20574. preWarmCycles: number;
  20575. /**
  20576. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20577. */
  20578. preWarmStepOffset: number;
  20579. /**
  20580. * 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)
  20581. */
  20582. spriteCellChangeSpeed: number;
  20583. /**
  20584. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20585. */
  20586. startSpriteCellID: number;
  20587. /**
  20588. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20589. */
  20590. endSpriteCellID: number;
  20591. /**
  20592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20593. */
  20594. spriteCellWidth: number;
  20595. /**
  20596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20597. */
  20598. spriteCellHeight: number;
  20599. /**
  20600. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20601. */
  20602. spriteRandomStartCell: boolean;
  20603. /**
  20604. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20605. */
  20606. isAnimationSheetEnabled: boolean;
  20607. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20608. translationPivot: Vector2;
  20609. /**
  20610. * Gets or sets a texture used to add random noise to particle positions
  20611. */
  20612. noiseTexture: Nullable<BaseTexture>;
  20613. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20614. noiseStrength: Vector3;
  20615. /**
  20616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20618. */
  20619. billboardMode: number;
  20620. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20621. limitVelocityDamping: number;
  20622. /**
  20623. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20624. */
  20625. beginAnimationOnStart: boolean;
  20626. /**
  20627. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  20628. */
  20629. beginAnimationFrom: number;
  20630. /**
  20631. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  20632. */
  20633. beginAnimationTo: number;
  20634. /**
  20635. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  20636. */
  20637. beginAnimationLoop: boolean;
  20638. /**
  20639. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20640. */
  20641. disposeOnStop: boolean;
  20642. /**
  20643. * Gets the maximum number of particles active at the same time.
  20644. * @returns The max number of active particles.
  20645. */
  20646. getCapacity(): number;
  20647. /**
  20648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20649. * @returns True if it has been started, otherwise false.
  20650. */
  20651. isStarted(): boolean;
  20652. /**
  20653. * Animates the particle system for this frame.
  20654. */
  20655. animate(): void;
  20656. /**
  20657. * Renders the particle system in its current state.
  20658. * @returns the current number of particles
  20659. */
  20660. render(): number;
  20661. /**
  20662. * Dispose the particle system and frees its associated resources.
  20663. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20664. */
  20665. dispose(disposeTexture?: boolean): void;
  20666. /**
  20667. * Clones the particle system.
  20668. * @param name The name of the cloned object
  20669. * @param newEmitter The new emitter to use
  20670. * @returns the cloned particle system
  20671. */
  20672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  20673. /**
  20674. * Serializes the particle system to a JSON object.
  20675. * @returns the JSON object
  20676. */
  20677. serialize(): any;
  20678. /**
  20679. * Rebuild the particle system
  20680. */
  20681. rebuild(): void;
  20682. /**
  20683. * Starts the particle system and begins to emit
  20684. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  20685. */
  20686. start(delay?: number): void;
  20687. /**
  20688. * Stops the particle system.
  20689. */
  20690. stop(): void;
  20691. /**
  20692. * Remove all active particles
  20693. */
  20694. reset(): void;
  20695. /**
  20696. * Is this system ready to be used/rendered
  20697. * @return true if the system is ready
  20698. */
  20699. isReady(): boolean;
  20700. /**
  20701. * Adds a new color gradient
  20702. * @param gradient defines the gradient to use (between 0 and 1)
  20703. * @param color1 defines the color to affect to the specified gradient
  20704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20705. * @returns the current particle system
  20706. */
  20707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20708. /**
  20709. * Remove a specific color gradient
  20710. * @param gradient defines the gradient to remove
  20711. * @returns the current particle system
  20712. */
  20713. removeColorGradient(gradient: number): IParticleSystem;
  20714. /**
  20715. * Adds a new size gradient
  20716. * @param gradient defines the gradient to use (between 0 and 1)
  20717. * @param factor defines the size factor to affect to the specified gradient
  20718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20719. * @returns the current particle system
  20720. */
  20721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20722. /**
  20723. * Remove a specific size gradient
  20724. * @param gradient defines the gradient to remove
  20725. * @returns the current particle system
  20726. */
  20727. removeSizeGradient(gradient: number): IParticleSystem;
  20728. /**
  20729. * Gets the current list of color gradients.
  20730. * You must use addColorGradient and removeColorGradient to udpate this list
  20731. * @returns the list of color gradients
  20732. */
  20733. getColorGradients(): Nullable<Array<ColorGradient>>;
  20734. /**
  20735. * Gets the current list of size gradients.
  20736. * You must use addSizeGradient and removeSizeGradient to udpate this list
  20737. * @returns the list of size gradients
  20738. */
  20739. getSizeGradients(): Nullable<Array<FactorGradient>>;
  20740. /**
  20741. * Gets the current list of angular speed gradients.
  20742. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  20743. * @returns the list of angular speed gradients
  20744. */
  20745. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  20746. /**
  20747. * Adds a new angular speed gradient
  20748. * @param gradient defines the gradient to use (between 0 and 1)
  20749. * @param factor defines the angular speed to affect to the specified gradient
  20750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20751. * @returns the current particle system
  20752. */
  20753. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20754. /**
  20755. * Remove a specific angular speed gradient
  20756. * @param gradient defines the gradient to remove
  20757. * @returns the current particle system
  20758. */
  20759. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20760. /**
  20761. * Gets the current list of velocity gradients.
  20762. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  20763. * @returns the list of velocity gradients
  20764. */
  20765. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  20766. /**
  20767. * Adds a new velocity gradient
  20768. * @param gradient defines the gradient to use (between 0 and 1)
  20769. * @param factor defines the velocity to affect to the specified gradient
  20770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20771. * @returns the current particle system
  20772. */
  20773. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20774. /**
  20775. * Remove a specific velocity gradient
  20776. * @param gradient defines the gradient to remove
  20777. * @returns the current particle system
  20778. */
  20779. removeVelocityGradient(gradient: number): IParticleSystem;
  20780. /**
  20781. * Gets the current list of limit velocity gradients.
  20782. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  20783. * @returns the list of limit velocity gradients
  20784. */
  20785. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  20786. /**
  20787. * Adds a new limit velocity gradient
  20788. * @param gradient defines the gradient to use (between 0 and 1)
  20789. * @param factor defines the limit velocity to affect to the specified gradient
  20790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20791. * @returns the current particle system
  20792. */
  20793. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20794. /**
  20795. * Remove a specific limit velocity gradient
  20796. * @param gradient defines the gradient to remove
  20797. * @returns the current particle system
  20798. */
  20799. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20800. /**
  20801. * Adds a new drag gradient
  20802. * @param gradient defines the gradient to use (between 0 and 1)
  20803. * @param factor defines the drag to affect to the specified gradient
  20804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20805. * @returns the current particle system
  20806. */
  20807. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20808. /**
  20809. * Remove a specific drag gradient
  20810. * @param gradient defines the gradient to remove
  20811. * @returns the current particle system
  20812. */
  20813. removeDragGradient(gradient: number): IParticleSystem;
  20814. /**
  20815. * Gets the current list of drag gradients.
  20816. * You must use addDragGradient and removeDragGradient to udpate this list
  20817. * @returns the list of drag gradients
  20818. */
  20819. getDragGradients(): Nullable<Array<FactorGradient>>;
  20820. /**
  20821. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20822. * @param gradient defines the gradient to use (between 0 and 1)
  20823. * @param factor defines the emit rate to affect to the specified gradient
  20824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20825. * @returns the current particle system
  20826. */
  20827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20828. /**
  20829. * Remove a specific emit rate gradient
  20830. * @param gradient defines the gradient to remove
  20831. * @returns the current particle system
  20832. */
  20833. removeEmitRateGradient(gradient: number): IParticleSystem;
  20834. /**
  20835. * Gets the current list of emit rate gradients.
  20836. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  20837. * @returns the list of emit rate gradients
  20838. */
  20839. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  20840. /**
  20841. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20842. * @param gradient defines the gradient to use (between 0 and 1)
  20843. * @param factor defines the start size to affect to the specified gradient
  20844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20845. * @returns the current particle system
  20846. */
  20847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20848. /**
  20849. * Remove a specific start size gradient
  20850. * @param gradient defines the gradient to remove
  20851. * @returns the current particle system
  20852. */
  20853. removeStartSizeGradient(gradient: number): IParticleSystem;
  20854. /**
  20855. * Gets the current list of start size gradients.
  20856. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  20857. * @returns the list of start size gradients
  20858. */
  20859. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  20860. /**
  20861. * Adds a new life time gradient
  20862. * @param gradient defines the gradient to use (between 0 and 1)
  20863. * @param factor defines the life time factor to affect to the specified gradient
  20864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20865. * @returns the current particle system
  20866. */
  20867. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20868. /**
  20869. * Remove a specific life time gradient
  20870. * @param gradient defines the gradient to remove
  20871. * @returns the current particle system
  20872. */
  20873. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20874. /**
  20875. * Gets the current list of life time gradients.
  20876. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  20877. * @returns the list of life time gradients
  20878. */
  20879. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  20880. /**
  20881. * Gets the current list of color gradients.
  20882. * You must use addColorGradient and removeColorGradient to udpate this list
  20883. * @returns the list of color gradients
  20884. */
  20885. getColorGradients(): Nullable<Array<ColorGradient>>;
  20886. /**
  20887. * Adds a new ramp gradient used to remap particle colors
  20888. * @param gradient defines the gradient to use (between 0 and 1)
  20889. * @param color defines the color to affect to the specified gradient
  20890. * @returns the current particle system
  20891. */
  20892. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  20893. /**
  20894. * Gets the current list of ramp gradients.
  20895. * You must use addRampGradient and removeRampGradient to udpate this list
  20896. * @returns the list of ramp gradients
  20897. */
  20898. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20899. /** Gets or sets a boolean indicating that ramp gradients must be used
  20900. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20901. */
  20902. useRampGradients: boolean;
  20903. /**
  20904. * Adds a new color remap gradient
  20905. * @param gradient defines the gradient to use (between 0 and 1)
  20906. * @param min defines the color remap minimal range
  20907. * @param max defines the color remap maximal range
  20908. * @returns the current particle system
  20909. */
  20910. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20911. /**
  20912. * Gets the current list of color remap gradients.
  20913. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  20914. * @returns the list of color remap gradients
  20915. */
  20916. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  20917. /**
  20918. * Adds a new alpha remap gradient
  20919. * @param gradient defines the gradient to use (between 0 and 1)
  20920. * @param min defines the alpha remap minimal range
  20921. * @param max defines the alpha remap maximal range
  20922. * @returns the current particle system
  20923. */
  20924. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20925. /**
  20926. * Gets the current list of alpha remap gradients.
  20927. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  20928. * @returns the list of alpha remap gradients
  20929. */
  20930. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  20931. /**
  20932. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  20933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  20934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  20935. * @returns the emitter
  20936. */
  20937. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  20938. /**
  20939. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  20940. * @param radius The radius of the hemisphere to emit from
  20941. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  20942. * @returns the emitter
  20943. */
  20944. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  20945. /**
  20946. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  20947. * @param radius The radius of the sphere to emit from
  20948. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  20949. * @returns the emitter
  20950. */
  20951. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  20952. /**
  20953. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  20954. * @param radius The radius of the sphere to emit from
  20955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  20956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  20957. * @returns the emitter
  20958. */
  20959. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  20960. /**
  20961. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  20962. * @param radius The radius of the emission cylinder
  20963. * @param height The height of the emission cylinder
  20964. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  20965. * @param directionRandomizer How much to randomize the particle direction [0-1]
  20966. * @returns the emitter
  20967. */
  20968. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  20969. /**
  20970. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  20971. * @param radius The radius of the cylinder to emit from
  20972. * @param height The height of the emission cylinder
  20973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20974. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  20975. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  20976. * @returns the emitter
  20977. */
  20978. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  20979. /**
  20980. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  20981. * @param radius The radius of the cone to emit from
  20982. * @param angle The base angle of the cone
  20983. * @returns the emitter
  20984. */
  20985. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  20986. /**
  20987. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  20988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  20989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  20990. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  20991. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  20992. * @returns the emitter
  20993. */
  20994. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  20995. /**
  20996. * Get hosting scene
  20997. * @returns the scene
  20998. */
  20999. getScene(): Scene;
  21000. }
  21001. }
  21002. declare module BABYLON {
  21003. /** @hidden */
  21004. export var linePixelShader: {
  21005. name: string;
  21006. shader: string;
  21007. };
  21008. }
  21009. declare module BABYLON {
  21010. /** @hidden */
  21011. export var lineVertexShader: {
  21012. name: string;
  21013. shader: string;
  21014. };
  21015. }
  21016. declare module BABYLON {
  21017. interface AbstractMesh {
  21018. /**
  21019. * Gets the edgesRenderer associated with the mesh
  21020. */
  21021. edgesRenderer: Nullable<EdgesRenderer>;
  21022. }
  21023. interface LinesMesh {
  21024. /**
  21025. * Enables the edge rendering mode on the mesh.
  21026. * This mode makes the mesh edges visible
  21027. * @param epsilon defines the maximal distance between two angles to detect a face
  21028. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21029. * @returns the currentAbstractMesh
  21030. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21031. */
  21032. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21033. }
  21034. interface InstancedLinesMesh {
  21035. /**
  21036. * Enables the edge rendering mode on the mesh.
  21037. * This mode makes the mesh edges visible
  21038. * @param epsilon defines the maximal distance between two angles to detect a face
  21039. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21040. * @returns the current InstancedLinesMesh
  21041. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21042. */
  21043. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21044. }
  21045. /**
  21046. * Defines the minimum contract an Edges renderer should follow.
  21047. */
  21048. export interface IEdgesRenderer extends IDisposable {
  21049. /**
  21050. * Gets or sets a boolean indicating if the edgesRenderer is active
  21051. */
  21052. isEnabled: boolean;
  21053. /**
  21054. * Renders the edges of the attached mesh,
  21055. */
  21056. render(): void;
  21057. /**
  21058. * Checks wether or not the edges renderer is ready to render.
  21059. * @return true if ready, otherwise false.
  21060. */
  21061. isReady(): boolean;
  21062. }
  21063. /**
  21064. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21065. */
  21066. export class EdgesRenderer implements IEdgesRenderer {
  21067. /**
  21068. * Define the size of the edges with an orthographic camera
  21069. */
  21070. edgesWidthScalerForOrthographic: number;
  21071. /**
  21072. * Define the size of the edges with a perspective camera
  21073. */
  21074. edgesWidthScalerForPerspective: number;
  21075. protected _source: AbstractMesh;
  21076. protected _linesPositions: number[];
  21077. protected _linesNormals: number[];
  21078. protected _linesIndices: number[];
  21079. protected _epsilon: number;
  21080. protected _indicesCount: number;
  21081. protected _lineShader: ShaderMaterial;
  21082. protected _ib: DataBuffer;
  21083. protected _buffers: {
  21084. [key: string]: Nullable<VertexBuffer>;
  21085. };
  21086. protected _checkVerticesInsteadOfIndices: boolean;
  21087. private _meshRebuildObserver;
  21088. private _meshDisposeObserver;
  21089. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21090. isEnabled: boolean;
  21091. /**
  21092. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21093. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21094. * @param source Mesh used to create edges
  21095. * @param epsilon sum of angles in adjacency to check for edge
  21096. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21097. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21098. */
  21099. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21100. protected _prepareRessources(): void;
  21101. /** @hidden */ private _rebuild(): void;
  21102. /**
  21103. * Releases the required resources for the edges renderer
  21104. */
  21105. dispose(): void;
  21106. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21107. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21108. /**
  21109. * Checks if the pair of p0 and p1 is en edge
  21110. * @param faceIndex
  21111. * @param edge
  21112. * @param faceNormals
  21113. * @param p0
  21114. * @param p1
  21115. * @private
  21116. */
  21117. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21118. /**
  21119. * push line into the position, normal and index buffer
  21120. * @protected
  21121. */
  21122. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21123. /**
  21124. * Generates lines edges from adjacencjes
  21125. * @private
  21126. */ private _generateEdgesLines(): void;
  21127. /**
  21128. * Checks wether or not the edges renderer is ready to render.
  21129. * @return true if ready, otherwise false.
  21130. */
  21131. isReady(): boolean;
  21132. /**
  21133. * Renders the edges of the attached mesh,
  21134. */
  21135. render(): void;
  21136. }
  21137. /**
  21138. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21139. */
  21140. export class LineEdgesRenderer extends EdgesRenderer {
  21141. /**
  21142. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21143. * @param source LineMesh used to generate edges
  21144. * @param epsilon not important (specified angle for edge detection)
  21145. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21146. */
  21147. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21148. /**
  21149. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21150. */ private _generateEdgesLines(): void;
  21151. }
  21152. }
  21153. declare module BABYLON {
  21154. /**
  21155. * This represents the object necessary to create a rendering group.
  21156. * This is exclusively used and created by the rendering manager.
  21157. * To modify the behavior, you use the available helpers in your scene or meshes.
  21158. * @hidden
  21159. */
  21160. export class RenderingGroup {
  21161. index: number;
  21162. private static _zeroVector;
  21163. private _scene;
  21164. private _opaqueSubMeshes;
  21165. private _transparentSubMeshes;
  21166. private _alphaTestSubMeshes;
  21167. private _depthOnlySubMeshes;
  21168. private _particleSystems;
  21169. private _spriteManagers;
  21170. private _opaqueSortCompareFn;
  21171. private _alphaTestSortCompareFn;
  21172. private _transparentSortCompareFn;
  21173. private _renderOpaque;
  21174. private _renderAlphaTest;
  21175. private _renderTransparent;
  21176. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  21177. onBeforeTransparentRendering: () => void;
  21178. /**
  21179. * Set the opaque sort comparison function.
  21180. * If null the sub meshes will be render in the order they were created
  21181. */
  21182. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21183. /**
  21184. * Set the alpha test sort comparison function.
  21185. * If null the sub meshes will be render in the order they were created
  21186. */
  21187. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21188. /**
  21189. * Set the transparent sort comparison function.
  21190. * If null the sub meshes will be render in the order they were created
  21191. */
  21192. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21193. /**
  21194. * Creates a new rendering group.
  21195. * @param index The rendering group index
  21196. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21197. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21198. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21199. */
  21200. 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>);
  21201. /**
  21202. * Render all the sub meshes contained in the group.
  21203. * @param customRenderFunction Used to override the default render behaviour of the group.
  21204. * @returns true if rendered some submeshes.
  21205. */
  21206. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21207. /**
  21208. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21209. * @param subMeshes The submeshes to render
  21210. */
  21211. private renderOpaqueSorted;
  21212. /**
  21213. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21214. * @param subMeshes The submeshes to render
  21215. */
  21216. private renderAlphaTestSorted;
  21217. /**
  21218. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21219. * @param subMeshes The submeshes to render
  21220. */
  21221. private renderTransparentSorted;
  21222. /**
  21223. * Renders the submeshes in a specified order.
  21224. * @param subMeshes The submeshes to sort before render
  21225. * @param sortCompareFn The comparison function use to sort
  21226. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21227. * @param transparent Specifies to activate blending if true
  21228. */
  21229. private static renderSorted;
  21230. /**
  21231. * Renders the submeshes in the order they were dispatched (no sort applied).
  21232. * @param subMeshes The submeshes to render
  21233. */
  21234. private static renderUnsorted;
  21235. /**
  21236. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21237. * are rendered back to front if in the same alpha index.
  21238. *
  21239. * @param a The first submesh
  21240. * @param b The second submesh
  21241. * @returns The result of the comparison
  21242. */
  21243. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21244. /**
  21245. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21246. * are rendered back to front.
  21247. *
  21248. * @param a The first submesh
  21249. * @param b The second submesh
  21250. * @returns The result of the comparison
  21251. */
  21252. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21253. /**
  21254. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21255. * are rendered front to back (prevent overdraw).
  21256. *
  21257. * @param a The first submesh
  21258. * @param b The second submesh
  21259. * @returns The result of the comparison
  21260. */
  21261. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21262. /**
  21263. * Resets the different lists of submeshes to prepare a new frame.
  21264. */
  21265. prepare(): void;
  21266. dispose(): void;
  21267. /**
  21268. * Inserts the submesh in its correct queue depending on its material.
  21269. * @param subMesh The submesh to dispatch
  21270. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21271. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21272. */
  21273. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21274. dispatchSprites(spriteManager: ISpriteManager): void;
  21275. dispatchParticles(particleSystem: IParticleSystem): void;
  21276. private _renderParticles;
  21277. private _renderSprites;
  21278. }
  21279. }
  21280. declare module BABYLON {
  21281. /**
  21282. * Interface describing the different options available in the rendering manager
  21283. * regarding Auto Clear between groups.
  21284. */
  21285. export interface IRenderingManagerAutoClearSetup {
  21286. /**
  21287. * Defines whether or not autoclear is enable.
  21288. */
  21289. autoClear: boolean;
  21290. /**
  21291. * Defines whether or not to autoclear the depth buffer.
  21292. */
  21293. depth: boolean;
  21294. /**
  21295. * Defines whether or not to autoclear the stencil buffer.
  21296. */
  21297. stencil: boolean;
  21298. }
  21299. /**
  21300. * This class is used by the onRenderingGroupObservable
  21301. */
  21302. export class RenderingGroupInfo {
  21303. /**
  21304. * The Scene that being rendered
  21305. */
  21306. scene: Scene;
  21307. /**
  21308. * The camera currently used for the rendering pass
  21309. */
  21310. camera: Nullable<Camera>;
  21311. /**
  21312. * The ID of the renderingGroup being processed
  21313. */
  21314. renderingGroupId: number;
  21315. }
  21316. /**
  21317. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21318. * It is enable to manage the different groups as well as the different necessary sort functions.
  21319. * This should not be used directly aside of the few static configurations
  21320. */
  21321. export class RenderingManager {
  21322. /**
  21323. * The max id used for rendering groups (not included)
  21324. */
  21325. static MAX_RENDERINGGROUPS: number;
  21326. /**
  21327. * The min id used for rendering groups (included)
  21328. */
  21329. static MIN_RENDERINGGROUPS: number;
  21330. /**
  21331. * Used to globally prevent autoclearing scenes.
  21332. */
  21333. static AUTOCLEAR: boolean;
  21334. /**
  21335. * @hidden
  21336. */ private _useSceneAutoClearSetup: boolean;
  21337. private _scene;
  21338. private _renderingGroups;
  21339. private _depthStencilBufferAlreadyCleaned;
  21340. private _autoClearDepthStencil;
  21341. private _customOpaqueSortCompareFn;
  21342. private _customAlphaTestSortCompareFn;
  21343. private _customTransparentSortCompareFn;
  21344. private _renderingGroupInfo;
  21345. /**
  21346. * Instantiates a new rendering group for a particular scene
  21347. * @param scene Defines the scene the groups belongs to
  21348. */
  21349. constructor(scene: Scene);
  21350. private _clearDepthStencilBuffer;
  21351. /**
  21352. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21353. * @hidden
  21354. */
  21355. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21356. /**
  21357. * Resets the different information of the group to prepare a new frame
  21358. * @hidden
  21359. */
  21360. reset(): void;
  21361. /**
  21362. * Dispose and release the group and its associated resources.
  21363. * @hidden
  21364. */
  21365. dispose(): void;
  21366. /**
  21367. * Clear the info related to rendering groups preventing retention points during dispose.
  21368. */
  21369. freeRenderingGroups(): void;
  21370. private _prepareRenderingGroup;
  21371. /**
  21372. * Add a sprite manager to the rendering manager in order to render it this frame.
  21373. * @param spriteManager Define the sprite manager to render
  21374. */
  21375. dispatchSprites(spriteManager: ISpriteManager): void;
  21376. /**
  21377. * Add a particle system to the rendering manager in order to render it this frame.
  21378. * @param particleSystem Define the particle system to render
  21379. */
  21380. dispatchParticles(particleSystem: IParticleSystem): void;
  21381. /**
  21382. * Add a submesh to the manager in order to render it this frame
  21383. * @param subMesh The submesh to dispatch
  21384. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21385. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21386. */
  21387. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21388. /**
  21389. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21390. * This allowed control for front to back rendering or reversly depending of the special needs.
  21391. *
  21392. * @param renderingGroupId The rendering group id corresponding to its index
  21393. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21394. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21395. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21396. */
  21397. 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;
  21398. /**
  21399. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21400. *
  21401. * @param renderingGroupId The rendering group id corresponding to its index
  21402. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21403. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21404. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21405. */
  21406. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21407. /**
  21408. * Gets the current auto clear configuration for one rendering group of the rendering
  21409. * manager.
  21410. * @param index the rendering group index to get the information for
  21411. * @returns The auto clear setup for the requested rendering group
  21412. */
  21413. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21414. }
  21415. }
  21416. declare module BABYLON {
  21417. /**
  21418. * This Helps creating a texture that will be created from a camera in your scene.
  21419. * It is basically a dynamic texture that could be used to create special effects for instance.
  21420. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21421. */
  21422. export class RenderTargetTexture extends Texture {
  21423. isCube: boolean;
  21424. /**
  21425. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21426. */
  21427. static readonly REFRESHRATE_RENDER_ONCE: number;
  21428. /**
  21429. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21430. */
  21431. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21432. /**
  21433. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21434. * the central point of your effect and can save a lot of performances.
  21435. */
  21436. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21437. /**
  21438. * Use this predicate to dynamically define the list of mesh you want to render.
  21439. * If set, the renderList property will be overwritten.
  21440. */
  21441. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21442. private _renderList;
  21443. /**
  21444. * Use this list to define the list of mesh you want to render.
  21445. */
  21446. renderList: Nullable<Array<AbstractMesh>>;
  21447. private _hookArray;
  21448. /**
  21449. * Define if particles should be rendered in your texture.
  21450. */
  21451. renderParticles: boolean;
  21452. /**
  21453. * Define if sprites should be rendered in your texture.
  21454. */
  21455. renderSprites: boolean;
  21456. /**
  21457. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21458. */
  21459. coordinatesMode: number;
  21460. /**
  21461. * Define the camera used to render the texture.
  21462. */
  21463. activeCamera: Nullable<Camera>;
  21464. /**
  21465. * Override the render function of the texture with your own one.
  21466. */
  21467. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21468. /**
  21469. * Define if camera post processes should be use while rendering the texture.
  21470. */
  21471. useCameraPostProcesses: boolean;
  21472. /**
  21473. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21474. */
  21475. ignoreCameraViewport: boolean;
  21476. private _postProcessManager;
  21477. private _postProcesses;
  21478. private _resizeObserver;
  21479. /**
  21480. * An event triggered when the texture is unbind.
  21481. */
  21482. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21483. /**
  21484. * An event triggered when the texture is unbind.
  21485. */
  21486. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21487. private _onAfterUnbindObserver;
  21488. /**
  21489. * Set a after unbind callback in the texture.
  21490. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21491. */
  21492. onAfterUnbind: () => void;
  21493. /**
  21494. * An event triggered before rendering the texture
  21495. */
  21496. onBeforeRenderObservable: Observable<number>;
  21497. private _onBeforeRenderObserver;
  21498. /**
  21499. * Set a before render callback in the texture.
  21500. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21501. */
  21502. onBeforeRender: (faceIndex: number) => void;
  21503. /**
  21504. * An event triggered after rendering the texture
  21505. */
  21506. onAfterRenderObservable: Observable<number>;
  21507. private _onAfterRenderObserver;
  21508. /**
  21509. * Set a after render callback in the texture.
  21510. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21511. */
  21512. onAfterRender: (faceIndex: number) => void;
  21513. /**
  21514. * An event triggered after the texture clear
  21515. */
  21516. onClearObservable: Observable<Engine>;
  21517. private _onClearObserver;
  21518. /**
  21519. * Set a clear callback in the texture.
  21520. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21521. */
  21522. onClear: (Engine: Engine) => void;
  21523. /**
  21524. * Define the clear color of the Render Target if it should be different from the scene.
  21525. */
  21526. clearColor: Color4;
  21527. protected _size: number | {
  21528. width: number;
  21529. height: number;
  21530. };
  21531. protected _initialSizeParameter: number | {
  21532. width: number;
  21533. height: number;
  21534. } | {
  21535. ratio: number;
  21536. };
  21537. protected _sizeRatio: Nullable<number>;
  21538. /** @hidden */ private _generateMipMaps: boolean;
  21539. protected _renderingManager: RenderingManager;
  21540. /** @hidden */ private _waitingRenderList: string[];
  21541. protected _doNotChangeAspectRatio: boolean;
  21542. protected _currentRefreshId: number;
  21543. protected _refreshRate: number;
  21544. protected _textureMatrix: Matrix;
  21545. protected _samples: number;
  21546. protected _renderTargetOptions: RenderTargetCreationOptions;
  21547. /**
  21548. * Gets render target creation options that were used.
  21549. */
  21550. readonly renderTargetOptions: RenderTargetCreationOptions;
  21551. protected _engine: Engine;
  21552. protected _onRatioRescale(): void;
  21553. /**
  21554. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21555. * It must define where the camera used to render the texture is set
  21556. */
  21557. boundingBoxPosition: Vector3;
  21558. private _boundingBoxSize;
  21559. /**
  21560. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21561. * When defined, the cubemap will switch to local mode
  21562. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21563. * @example https://www.babylonjs-playground.com/#RNASML
  21564. */
  21565. boundingBoxSize: Vector3;
  21566. /**
  21567. * In case the RTT has been created with a depth texture, get the associated
  21568. * depth texture.
  21569. * Otherwise, return null.
  21570. */
  21571. depthStencilTexture: Nullable<InternalTexture>;
  21572. /**
  21573. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21574. * or used a shadow, depth texture...
  21575. * @param name The friendly name of the texture
  21576. * @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)
  21577. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21578. * @param generateMipMaps True if mip maps need to be generated after render.
  21579. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21580. * @param type The type of the buffer in the RTT (int, half float, float...)
  21581. * @param isCube True if a cube texture needs to be created
  21582. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21583. * @param generateDepthBuffer True to generate a depth buffer
  21584. * @param generateStencilBuffer True to generate a stencil buffer
  21585. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21586. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21587. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21588. */
  21589. constructor(name: string, size: number | {
  21590. width: number;
  21591. height: number;
  21592. } | {
  21593. ratio: number;
  21594. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21595. /**
  21596. * Creates a depth stencil texture.
  21597. * This is only available in WebGL 2 or with the depth texture extension available.
  21598. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21599. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21600. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21601. */
  21602. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21603. private _processSizeParameter;
  21604. /**
  21605. * Define the number of samples to use in case of MSAA.
  21606. * It defaults to one meaning no MSAA has been enabled.
  21607. */
  21608. samples: number;
  21609. /**
  21610. * Resets the refresh counter of the texture and start bak from scratch.
  21611. * Could be useful to regenerate the texture if it is setup to render only once.
  21612. */
  21613. resetRefreshCounter(): void;
  21614. /**
  21615. * Define the refresh rate of the texture or the rendering frequency.
  21616. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21617. */
  21618. refreshRate: number;
  21619. /**
  21620. * Adds a post process to the render target rendering passes.
  21621. * @param postProcess define the post process to add
  21622. */
  21623. addPostProcess(postProcess: PostProcess): void;
  21624. /**
  21625. * Clear all the post processes attached to the render target
  21626. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21627. */
  21628. clearPostProcesses(dispose?: boolean): void;
  21629. /**
  21630. * Remove one of the post process from the list of attached post processes to the texture
  21631. * @param postProcess define the post process to remove from the list
  21632. */
  21633. removePostProcess(postProcess: PostProcess): void;
  21634. /** @hidden */ private _shouldRender(): boolean;
  21635. /**
  21636. * Gets the actual render size of the texture.
  21637. * @returns the width of the render size
  21638. */
  21639. getRenderSize(): number;
  21640. /**
  21641. * Gets the actual render width of the texture.
  21642. * @returns the width of the render size
  21643. */
  21644. getRenderWidth(): number;
  21645. /**
  21646. * Gets the actual render height of the texture.
  21647. * @returns the height of the render size
  21648. */
  21649. getRenderHeight(): number;
  21650. /**
  21651. * Get if the texture can be rescaled or not.
  21652. */
  21653. readonly canRescale: boolean;
  21654. /**
  21655. * Resize the texture using a ratio.
  21656. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21657. */
  21658. scale(ratio: number): void;
  21659. /**
  21660. * Get the texture reflection matrix used to rotate/transform the reflection.
  21661. * @returns the reflection matrix
  21662. */
  21663. getReflectionTextureMatrix(): Matrix;
  21664. /**
  21665. * Resize the texture to a new desired size.
  21666. * Be carrefull as it will recreate all the data in the new texture.
  21667. * @param size Define the new size. It can be:
  21668. * - a number for squared texture,
  21669. * - an object containing { width: number, height: number }
  21670. * - or an object containing a ratio { ratio: number }
  21671. */
  21672. resize(size: number | {
  21673. width: number;
  21674. height: number;
  21675. } | {
  21676. ratio: number;
  21677. }): void;
  21678. /**
  21679. * Renders all the objects from the render list into the texture.
  21680. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21681. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21682. */
  21683. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21684. private _bestReflectionRenderTargetDimension;
  21685. /**
  21686. * @hidden
  21687. * @param faceIndex face index to bind to if this is a cubetexture
  21688. */ private _bindFrameBuffer(faceIndex?: number): void;
  21689. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21690. private renderToTarget;
  21691. /**
  21692. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21693. * This allowed control for front to back rendering or reversly depending of the special needs.
  21694. *
  21695. * @param renderingGroupId The rendering group id corresponding to its index
  21696. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21697. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21698. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21699. */
  21700. 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;
  21701. /**
  21702. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21703. *
  21704. * @param renderingGroupId The rendering group id corresponding to its index
  21705. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21706. */
  21707. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21708. /**
  21709. * Clones the texture.
  21710. * @returns the cloned texture
  21711. */
  21712. clone(): RenderTargetTexture;
  21713. /**
  21714. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21715. * @returns The JSON representation of the texture
  21716. */
  21717. serialize(): any;
  21718. /**
  21719. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21720. */
  21721. disposeFramebufferObjects(): void;
  21722. /**
  21723. * Dispose the texture and release its associated resources.
  21724. */
  21725. dispose(): void;
  21726. /** @hidden */ private _rebuild(): void;
  21727. /**
  21728. * Clear the info related to rendering groups preventing retention point in material dispose.
  21729. */
  21730. freeRenderingGroups(): void;
  21731. /**
  21732. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21733. * @returns the view count
  21734. */
  21735. getViewCount(): number;
  21736. }
  21737. }
  21738. declare module BABYLON {
  21739. /**
  21740. * Base class for the main features of a material in Babylon.js
  21741. */
  21742. export class Material implements IAnimatable {
  21743. /**
  21744. * Returns the triangle fill mode
  21745. */
  21746. static readonly TriangleFillMode: number;
  21747. /**
  21748. * Returns the wireframe mode
  21749. */
  21750. static readonly WireFrameFillMode: number;
  21751. /**
  21752. * Returns the point fill mode
  21753. */
  21754. static readonly PointFillMode: number;
  21755. /**
  21756. * Returns the point list draw mode
  21757. */
  21758. static readonly PointListDrawMode: number;
  21759. /**
  21760. * Returns the line list draw mode
  21761. */
  21762. static readonly LineListDrawMode: number;
  21763. /**
  21764. * Returns the line loop draw mode
  21765. */
  21766. static readonly LineLoopDrawMode: number;
  21767. /**
  21768. * Returns the line strip draw mode
  21769. */
  21770. static readonly LineStripDrawMode: number;
  21771. /**
  21772. * Returns the triangle strip draw mode
  21773. */
  21774. static readonly TriangleStripDrawMode: number;
  21775. /**
  21776. * Returns the triangle fan draw mode
  21777. */
  21778. static readonly TriangleFanDrawMode: number;
  21779. /**
  21780. * Stores the clock-wise side orientation
  21781. */
  21782. static readonly ClockWiseSideOrientation: number;
  21783. /**
  21784. * Stores the counter clock-wise side orientation
  21785. */
  21786. static readonly CounterClockWiseSideOrientation: number;
  21787. /**
  21788. * The dirty texture flag value
  21789. */
  21790. static readonly TextureDirtyFlag: number;
  21791. /**
  21792. * The dirty light flag value
  21793. */
  21794. static readonly LightDirtyFlag: number;
  21795. /**
  21796. * The dirty fresnel flag value
  21797. */
  21798. static readonly FresnelDirtyFlag: number;
  21799. /**
  21800. * The dirty attribute flag value
  21801. */
  21802. static readonly AttributesDirtyFlag: number;
  21803. /**
  21804. * The dirty misc flag value
  21805. */
  21806. static readonly MiscDirtyFlag: number;
  21807. /**
  21808. * The all dirty flag value
  21809. */
  21810. static readonly AllDirtyFlag: number;
  21811. /**
  21812. * The ID of the material
  21813. */
  21814. id: string;
  21815. /**
  21816. * Gets or sets the unique id of the material
  21817. */
  21818. uniqueId: number;
  21819. /**
  21820. * The name of the material
  21821. */
  21822. name: string;
  21823. /**
  21824. * Gets or sets user defined metadata
  21825. */
  21826. metadata: any;
  21827. /**
  21828. * For internal use only. Please do not use.
  21829. */
  21830. reservedDataStore: any;
  21831. /**
  21832. * Specifies if the ready state should be checked on each call
  21833. */
  21834. checkReadyOnEveryCall: boolean;
  21835. /**
  21836. * Specifies if the ready state should be checked once
  21837. */
  21838. checkReadyOnlyOnce: boolean;
  21839. /**
  21840. * The state of the material
  21841. */
  21842. state: string;
  21843. /**
  21844. * The alpha value of the material
  21845. */
  21846. protected _alpha: number;
  21847. /**
  21848. * List of inspectable custom properties (used by the Inspector)
  21849. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21850. */
  21851. inspectableCustomProperties: IInspectable[];
  21852. /**
  21853. * Sets the alpha value of the material
  21854. */
  21855. /**
  21856. * Gets the alpha value of the material
  21857. */
  21858. alpha: number;
  21859. /**
  21860. * Specifies if back face culling is enabled
  21861. */
  21862. protected _backFaceCulling: boolean;
  21863. /**
  21864. * Sets the back-face culling state
  21865. */
  21866. /**
  21867. * Gets the back-face culling state
  21868. */
  21869. backFaceCulling: boolean;
  21870. /**
  21871. * Stores the value for side orientation
  21872. */
  21873. sideOrientation: number;
  21874. /**
  21875. * Callback triggered when the material is compiled
  21876. */
  21877. onCompiled: Nullable<(effect: Effect) => void>;
  21878. /**
  21879. * Callback triggered when an error occurs
  21880. */
  21881. onError: Nullable<(effect: Effect, errors: string) => void>;
  21882. /**
  21883. * Callback triggered to get the render target textures
  21884. */
  21885. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21886. /**
  21887. * Gets a boolean indicating that current material needs to register RTT
  21888. */
  21889. readonly hasRenderTargetTextures: boolean;
  21890. /**
  21891. * Specifies if the material should be serialized
  21892. */
  21893. doNotSerialize: boolean;
  21894. /**
  21895. * @hidden
  21896. */ private _storeEffectOnSubMeshes: boolean;
  21897. /**
  21898. * Stores the animations for the material
  21899. */
  21900. animations: Nullable<Array<Animation>>;
  21901. /**
  21902. * An event triggered when the material is disposed
  21903. */
  21904. onDisposeObservable: Observable<Material>;
  21905. /**
  21906. * An observer which watches for dispose events
  21907. */
  21908. private _onDisposeObserver;
  21909. private _onUnBindObservable;
  21910. /**
  21911. * Called during a dispose event
  21912. */
  21913. onDispose: () => void;
  21914. private _onBindObservable;
  21915. /**
  21916. * An event triggered when the material is bound
  21917. */
  21918. readonly onBindObservable: Observable<AbstractMesh>;
  21919. /**
  21920. * An observer which watches for bind events
  21921. */
  21922. private _onBindObserver;
  21923. /**
  21924. * Called during a bind event
  21925. */
  21926. onBind: (Mesh: AbstractMesh) => void;
  21927. /**
  21928. * An event triggered when the material is unbound
  21929. */
  21930. readonly onUnBindObservable: Observable<Material>;
  21931. /**
  21932. * Stores the value of the alpha mode
  21933. */
  21934. private _alphaMode;
  21935. /**
  21936. * Sets the value of the alpha mode.
  21937. *
  21938. * | Value | Type | Description |
  21939. * | --- | --- | --- |
  21940. * | 0 | ALPHA_DISABLE | |
  21941. * | 1 | ALPHA_ADD | |
  21942. * | 2 | ALPHA_COMBINE | |
  21943. * | 3 | ALPHA_SUBTRACT | |
  21944. * | 4 | ALPHA_MULTIPLY | |
  21945. * | 5 | ALPHA_MAXIMIZED | |
  21946. * | 6 | ALPHA_ONEONE | |
  21947. * | 7 | ALPHA_PREMULTIPLIED | |
  21948. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21949. * | 9 | ALPHA_INTERPOLATE | |
  21950. * | 10 | ALPHA_SCREENMODE | |
  21951. *
  21952. */
  21953. /**
  21954. * Gets the value of the alpha mode
  21955. */
  21956. alphaMode: number;
  21957. /**
  21958. * Stores the state of the need depth pre-pass value
  21959. */
  21960. private _needDepthPrePass;
  21961. /**
  21962. * Sets the need depth pre-pass value
  21963. */
  21964. /**
  21965. * Gets the depth pre-pass value
  21966. */
  21967. needDepthPrePass: boolean;
  21968. /**
  21969. * Specifies if depth writing should be disabled
  21970. */
  21971. disableDepthWrite: boolean;
  21972. /**
  21973. * Specifies if depth writing should be forced
  21974. */
  21975. forceDepthWrite: boolean;
  21976. /**
  21977. * Specifies if there should be a separate pass for culling
  21978. */
  21979. separateCullingPass: boolean;
  21980. /**
  21981. * Stores the state specifing if fog should be enabled
  21982. */
  21983. private _fogEnabled;
  21984. /**
  21985. * Sets the state for enabling fog
  21986. */
  21987. /**
  21988. * Gets the value of the fog enabled state
  21989. */
  21990. fogEnabled: boolean;
  21991. /**
  21992. * Stores the size of points
  21993. */
  21994. pointSize: number;
  21995. /**
  21996. * Stores the z offset value
  21997. */
  21998. zOffset: number;
  21999. /**
  22000. * Gets a value specifying if wireframe mode is enabled
  22001. */
  22002. /**
  22003. * Sets the state of wireframe mode
  22004. */
  22005. wireframe: boolean;
  22006. /**
  22007. * Gets the value specifying if point clouds are enabled
  22008. */
  22009. /**
  22010. * Sets the state of point cloud mode
  22011. */
  22012. pointsCloud: boolean;
  22013. /**
  22014. * Gets the material fill mode
  22015. */
  22016. /**
  22017. * Sets the material fill mode
  22018. */
  22019. fillMode: number;
  22020. /**
  22021. * @hidden
  22022. * Stores the effects for the material
  22023. */ private _effect: Nullable<Effect>;
  22024. /**
  22025. * @hidden
  22026. * Specifies if the material was previously ready
  22027. */ private _wasPreviouslyReady: boolean;
  22028. /**
  22029. * Specifies if uniform buffers should be used
  22030. */
  22031. private _useUBO;
  22032. /**
  22033. * Stores a reference to the scene
  22034. */
  22035. private _scene;
  22036. /**
  22037. * Stores the fill mode state
  22038. */
  22039. private _fillMode;
  22040. /**
  22041. * Specifies if the depth write state should be cached
  22042. */
  22043. private _cachedDepthWriteState;
  22044. /**
  22045. * Stores the uniform buffer
  22046. */
  22047. protected _uniformBuffer: UniformBuffer;
  22048. /** @hidden */ private _indexInSceneMaterialArray: number;
  22049. /** @hidden */
  22050. meshMap: Nullable<{
  22051. [id: string]: AbstractMesh | undefined;
  22052. }>;
  22053. /**
  22054. * Creates a material instance
  22055. * @param name defines the name of the material
  22056. * @param scene defines the scene to reference
  22057. * @param doNotAdd specifies if the material should be added to the scene
  22058. */
  22059. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22060. /**
  22061. * Returns a string representation of the current material
  22062. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22063. * @returns a string with material information
  22064. */
  22065. toString(fullDetails?: boolean): string;
  22066. /**
  22067. * Gets the class name of the material
  22068. * @returns a string with the class name of the material
  22069. */
  22070. getClassName(): string;
  22071. /**
  22072. * Specifies if updates for the material been locked
  22073. */
  22074. readonly isFrozen: boolean;
  22075. /**
  22076. * Locks updates for the material
  22077. */
  22078. freeze(): void;
  22079. /**
  22080. * Unlocks updates for the material
  22081. */
  22082. unfreeze(): void;
  22083. /**
  22084. * Specifies if the material is ready to be used
  22085. * @param mesh defines the mesh to check
  22086. * @param useInstances specifies if instances should be used
  22087. * @returns a boolean indicating if the material is ready to be used
  22088. */
  22089. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22090. /**
  22091. * Specifies that the submesh is ready to be used
  22092. * @param mesh defines the mesh to check
  22093. * @param subMesh defines which submesh to check
  22094. * @param useInstances specifies that instances should be used
  22095. * @returns a boolean indicating that the submesh is ready or not
  22096. */
  22097. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22098. /**
  22099. * Returns the material effect
  22100. * @returns the effect associated with the material
  22101. */
  22102. getEffect(): Nullable<Effect>;
  22103. /**
  22104. * Returns the current scene
  22105. * @returns a Scene
  22106. */
  22107. getScene(): Scene;
  22108. /**
  22109. * Specifies if the material will require alpha blending
  22110. * @returns a boolean specifying if alpha blending is needed
  22111. */
  22112. needAlphaBlending(): boolean;
  22113. /**
  22114. * Specifies if the mesh will require alpha blending
  22115. * @param mesh defines the mesh to check
  22116. * @returns a boolean specifying if alpha blending is needed for the mesh
  22117. */
  22118. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22119. /**
  22120. * Specifies if this material should be rendered in alpha test mode
  22121. * @returns a boolean specifying if an alpha test is needed.
  22122. */
  22123. needAlphaTesting(): boolean;
  22124. /**
  22125. * Gets the texture used for the alpha test
  22126. * @returns the texture to use for alpha testing
  22127. */
  22128. getAlphaTestTexture(): Nullable<BaseTexture>;
  22129. /**
  22130. * Marks the material to indicate that it needs to be re-calculated
  22131. */
  22132. markDirty(): void;
  22133. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22134. /**
  22135. * Binds the material to the mesh
  22136. * @param world defines the world transformation matrix
  22137. * @param mesh defines the mesh to bind the material to
  22138. */
  22139. bind(world: Matrix, mesh?: Mesh): void;
  22140. /**
  22141. * Binds the submesh to the material
  22142. * @param world defines the world transformation matrix
  22143. * @param mesh defines the mesh containing the submesh
  22144. * @param subMesh defines the submesh to bind the material to
  22145. */
  22146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22147. /**
  22148. * Binds the world matrix to the material
  22149. * @param world defines the world transformation matrix
  22150. */
  22151. bindOnlyWorldMatrix(world: Matrix): void;
  22152. /**
  22153. * Binds the scene's uniform buffer to the effect.
  22154. * @param effect defines the effect to bind to the scene uniform buffer
  22155. * @param sceneUbo defines the uniform buffer storing scene data
  22156. */
  22157. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22158. /**
  22159. * Binds the view matrix to the effect
  22160. * @param effect defines the effect to bind the view matrix to
  22161. */
  22162. bindView(effect: Effect): void;
  22163. /**
  22164. * Binds the view projection matrix to the effect
  22165. * @param effect defines the effect to bind the view projection matrix to
  22166. */
  22167. bindViewProjection(effect: Effect): void;
  22168. /**
  22169. * Specifies if material alpha testing should be turned on for the mesh
  22170. * @param mesh defines the mesh to check
  22171. */
  22172. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22173. /**
  22174. * Processes to execute after binding the material to a mesh
  22175. * @param mesh defines the rendered mesh
  22176. */
  22177. protected _afterBind(mesh?: Mesh): void;
  22178. /**
  22179. * Unbinds the material from the mesh
  22180. */
  22181. unbind(): void;
  22182. /**
  22183. * Gets the active textures from the material
  22184. * @returns an array of textures
  22185. */
  22186. getActiveTextures(): BaseTexture[];
  22187. /**
  22188. * Specifies if the material uses a texture
  22189. * @param texture defines the texture to check against the material
  22190. * @returns a boolean specifying if the material uses the texture
  22191. */
  22192. hasTexture(texture: BaseTexture): boolean;
  22193. /**
  22194. * Makes a duplicate of the material, and gives it a new name
  22195. * @param name defines the new name for the duplicated material
  22196. * @returns the cloned material
  22197. */
  22198. clone(name: string): Nullable<Material>;
  22199. /**
  22200. * Gets the meshes bound to the material
  22201. * @returns an array of meshes bound to the material
  22202. */
  22203. getBindedMeshes(): AbstractMesh[];
  22204. /**
  22205. * Force shader compilation
  22206. * @param mesh defines the mesh associated with this material
  22207. * @param onCompiled defines a function to execute once the material is compiled
  22208. * @param options defines the options to configure the compilation
  22209. */
  22210. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22211. clipPlane: boolean;
  22212. }>): void;
  22213. /**
  22214. * Force shader compilation
  22215. * @param mesh defines the mesh that will use this material
  22216. * @param options defines additional options for compiling the shaders
  22217. * @returns a promise that resolves when the compilation completes
  22218. */
  22219. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22220. clipPlane: boolean;
  22221. }>): Promise<void>;
  22222. private static readonly _AllDirtyCallBack;
  22223. private static readonly _ImageProcessingDirtyCallBack;
  22224. private static readonly _TextureDirtyCallBack;
  22225. private static readonly _FresnelDirtyCallBack;
  22226. private static readonly _MiscDirtyCallBack;
  22227. private static readonly _LightsDirtyCallBack;
  22228. private static readonly _AttributeDirtyCallBack;
  22229. private static _FresnelAndMiscDirtyCallBack;
  22230. private static _TextureAndMiscDirtyCallBack;
  22231. private static readonly _DirtyCallbackArray;
  22232. private static readonly _RunDirtyCallBacks;
  22233. /**
  22234. * Marks a define in the material to indicate that it needs to be re-computed
  22235. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22236. */
  22237. markAsDirty(flag: number): void;
  22238. /**
  22239. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22240. * @param func defines a function which checks material defines against the submeshes
  22241. */
  22242. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22243. /**
  22244. * Indicates that we need to re-calculated for all submeshes
  22245. */
  22246. protected _markAllSubMeshesAsAllDirty(): void;
  22247. /**
  22248. * Indicates that image processing needs to be re-calculated for all submeshes
  22249. */
  22250. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22251. /**
  22252. * Indicates that textures need to be re-calculated for all submeshes
  22253. */
  22254. protected _markAllSubMeshesAsTexturesDirty(): void;
  22255. /**
  22256. * Indicates that fresnel needs to be re-calculated for all submeshes
  22257. */
  22258. protected _markAllSubMeshesAsFresnelDirty(): void;
  22259. /**
  22260. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22261. */
  22262. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22263. /**
  22264. * Indicates that lights need to be re-calculated for all submeshes
  22265. */
  22266. protected _markAllSubMeshesAsLightsDirty(): void;
  22267. /**
  22268. * Indicates that attributes need to be re-calculated for all submeshes
  22269. */
  22270. protected _markAllSubMeshesAsAttributesDirty(): void;
  22271. /**
  22272. * Indicates that misc needs to be re-calculated for all submeshes
  22273. */
  22274. protected _markAllSubMeshesAsMiscDirty(): void;
  22275. /**
  22276. * Indicates that textures and misc need to be re-calculated for all submeshes
  22277. */
  22278. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22279. /**
  22280. * Disposes the material
  22281. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22282. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22283. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22284. */
  22285. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22286. /** @hidden */
  22287. private releaseVertexArrayObject;
  22288. /**
  22289. * Serializes this material
  22290. * @returns the serialized material object
  22291. */
  22292. serialize(): any;
  22293. /**
  22294. * Creates a material from parsed material data
  22295. * @param parsedMaterial defines parsed material data
  22296. * @param scene defines the hosting scene
  22297. * @param rootUrl defines the root URL to use to load textures
  22298. * @returns a new material
  22299. */
  22300. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22301. }
  22302. }
  22303. declare module BABYLON {
  22304. /**
  22305. * Base class for submeshes
  22306. */
  22307. export class BaseSubMesh {
  22308. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  22309. /** @hidden */ private _materialEffect: Nullable<Effect>;
  22310. /**
  22311. * Gets associated effect
  22312. */
  22313. readonly effect: Nullable<Effect>;
  22314. /**
  22315. * Sets associated effect (effect used to render this submesh)
  22316. * @param effect defines the effect to associate with
  22317. * @param defines defines the set of defines used to compile this effect
  22318. */
  22319. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22320. }
  22321. /**
  22322. * Defines a subdivision inside a mesh
  22323. */
  22324. export class SubMesh extends BaseSubMesh implements ICullable {
  22325. /** the material index to use */
  22326. materialIndex: number;
  22327. /** vertex index start */
  22328. verticesStart: number;
  22329. /** vertices count */
  22330. verticesCount: number;
  22331. /** index start */
  22332. indexStart: number;
  22333. /** indices count */
  22334. indexCount: number;
  22335. /** @hidden */ private _linesIndexCount: number;
  22336. private _mesh;
  22337. private _renderingMesh;
  22338. private _boundingInfo;
  22339. private _linesIndexBuffer;
  22340. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  22341. /** @hidden */ private _trianglePlanes: Plane[];
  22342. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  22343. /** @hidden */ private _renderId: number;
  22344. /** @hidden */ private _alphaIndex: number;
  22345. /** @hidden */ private _distanceToCamera: number;
  22346. /** @hidden */ private _id: number;
  22347. private _currentMaterial;
  22348. /**
  22349. * Add a new submesh to a mesh
  22350. * @param materialIndex defines the material index to use
  22351. * @param verticesStart defines vertex index start
  22352. * @param verticesCount defines vertices count
  22353. * @param indexStart defines index start
  22354. * @param indexCount defines indices count
  22355. * @param mesh defines the parent mesh
  22356. * @param renderingMesh defines an optional rendering mesh
  22357. * @param createBoundingBox defines if bounding box should be created for this submesh
  22358. * @returns the new submesh
  22359. */
  22360. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22361. /**
  22362. * Creates a new submesh
  22363. * @param materialIndex defines the material index to use
  22364. * @param verticesStart defines vertex index start
  22365. * @param verticesCount defines vertices count
  22366. * @param indexStart defines index start
  22367. * @param indexCount defines indices count
  22368. * @param mesh defines the parent mesh
  22369. * @param renderingMesh defines an optional rendering mesh
  22370. * @param createBoundingBox defines if bounding box should be created for this submesh
  22371. */
  22372. constructor(
  22373. /** the material index to use */
  22374. materialIndex: number,
  22375. /** vertex index start */
  22376. verticesStart: number,
  22377. /** vertices count */
  22378. verticesCount: number,
  22379. /** index start */
  22380. indexStart: number,
  22381. /** indices count */
  22382. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22383. /**
  22384. * Returns true if this submesh covers the entire parent mesh
  22385. * @ignorenaming
  22386. */
  22387. readonly IsGlobal: boolean;
  22388. /**
  22389. * Returns the submesh BoudingInfo object
  22390. * @returns current bounding info (or mesh's one if the submesh is global)
  22391. */
  22392. getBoundingInfo(): BoundingInfo;
  22393. /**
  22394. * Sets the submesh BoundingInfo
  22395. * @param boundingInfo defines the new bounding info to use
  22396. * @returns the SubMesh
  22397. */
  22398. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22399. /**
  22400. * Returns the mesh of the current submesh
  22401. * @return the parent mesh
  22402. */
  22403. getMesh(): AbstractMesh;
  22404. /**
  22405. * Returns the rendering mesh of the submesh
  22406. * @returns the rendering mesh (could be different from parent mesh)
  22407. */
  22408. getRenderingMesh(): Mesh;
  22409. /**
  22410. * Returns the submesh material
  22411. * @returns null or the current material
  22412. */
  22413. getMaterial(): Nullable<Material>;
  22414. /**
  22415. * Sets a new updated BoundingInfo object to the submesh
  22416. * @param data defines an optional position array to use to determine the bounding info
  22417. * @returns the SubMesh
  22418. */
  22419. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22420. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  22421. /**
  22422. * Updates the submesh BoundingInfo
  22423. * @param world defines the world matrix to use to update the bounding info
  22424. * @returns the submesh
  22425. */
  22426. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22427. /**
  22428. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22429. * @param frustumPlanes defines the frustum planes
  22430. * @returns true if the submesh is intersecting with the frustum
  22431. */
  22432. isInFrustum(frustumPlanes: Plane[]): boolean;
  22433. /**
  22434. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22435. * @param frustumPlanes defines the frustum planes
  22436. * @returns true if the submesh is inside the frustum
  22437. */
  22438. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22439. /**
  22440. * Renders the submesh
  22441. * @param enableAlphaMode defines if alpha needs to be used
  22442. * @returns the submesh
  22443. */
  22444. render(enableAlphaMode: boolean): SubMesh;
  22445. /**
  22446. * @hidden
  22447. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22448. /**
  22449. * Checks if the submesh intersects with a ray
  22450. * @param ray defines the ray to test
  22451. * @returns true is the passed ray intersects the submesh bounding box
  22452. */
  22453. canIntersects(ray: Ray): boolean;
  22454. /**
  22455. * Intersects current submesh with a ray
  22456. * @param ray defines the ray to test
  22457. * @param positions defines mesh's positions array
  22458. * @param indices defines mesh's indices array
  22459. * @param fastCheck defines if only bounding info should be used
  22460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22461. * @returns intersection info or null if no intersection
  22462. */
  22463. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22464. /** @hidden */
  22465. private _intersectLines;
  22466. /** @hidden */
  22467. private _intersectUnIndexedLines;
  22468. /** @hidden */
  22469. private _intersectTriangles;
  22470. /** @hidden */
  22471. private _intersectUnIndexedTriangles;
  22472. /** @hidden */ private _rebuild(): void;
  22473. /**
  22474. * Creates a new submesh from the passed mesh
  22475. * @param newMesh defines the new hosting mesh
  22476. * @param newRenderingMesh defines an optional rendering mesh
  22477. * @returns the new submesh
  22478. */
  22479. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22480. /**
  22481. * Release associated resources
  22482. */
  22483. dispose(): void;
  22484. /**
  22485. * Gets the class name
  22486. * @returns the string "SubMesh".
  22487. */
  22488. getClassName(): string;
  22489. /**
  22490. * Creates a new submesh from indices data
  22491. * @param materialIndex the index of the main mesh material
  22492. * @param startIndex the index where to start the copy in the mesh indices array
  22493. * @param indexCount the number of indices to copy then from the startIndex
  22494. * @param mesh the main mesh to create the submesh from
  22495. * @param renderingMesh the optional rendering mesh
  22496. * @returns a new submesh
  22497. */
  22498. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22499. }
  22500. }
  22501. declare module BABYLON {
  22502. /**
  22503. * Class used to store geometry data (vertex buffers + index buffer)
  22504. */
  22505. export class Geometry implements IGetSetVerticesData {
  22506. /**
  22507. * Gets or sets the ID of the geometry
  22508. */
  22509. id: string;
  22510. /**
  22511. * Gets or sets the unique ID of the geometry
  22512. */
  22513. uniqueId: number;
  22514. /**
  22515. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22516. */
  22517. delayLoadState: number;
  22518. /**
  22519. * Gets the file containing the data to load when running in delay load state
  22520. */
  22521. delayLoadingFile: Nullable<string>;
  22522. /**
  22523. * Callback called when the geometry is updated
  22524. */
  22525. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22526. private _scene;
  22527. private _engine;
  22528. private _meshes;
  22529. private _totalVertices;
  22530. /** @hidden */ private _indices: IndicesArray;
  22531. /** @hidden */ private _vertexBuffers: {
  22532. [key: string]: VertexBuffer;
  22533. };
  22534. private _isDisposed;
  22535. private _extend;
  22536. private _boundingBias;
  22537. /** @hidden */ private _delayInfo: Array<string>;
  22538. private _indexBuffer;
  22539. private _indexBufferIsUpdatable;
  22540. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  22541. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22542. /** @hidden */ private _softwareSkinningFrameId: number;
  22543. private _vertexArrayObjects;
  22544. private _updatable;
  22545. /** @hidden */ private _positions: Nullable<Vector3[]>;
  22546. /**
  22547. * 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
  22548. */
  22549. /**
  22550. * 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
  22551. */
  22552. boundingBias: Vector2;
  22553. /**
  22554. * Static function used to attach a new empty geometry to a mesh
  22555. * @param mesh defines the mesh to attach the geometry to
  22556. * @returns the new Geometry
  22557. */
  22558. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22559. /**
  22560. * Creates a new geometry
  22561. * @param id defines the unique ID
  22562. * @param scene defines the hosting scene
  22563. * @param vertexData defines the VertexData used to get geometry data
  22564. * @param updatable defines if geometry must be updatable (false by default)
  22565. * @param mesh defines the mesh that will be associated with the geometry
  22566. */
  22567. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22568. /**
  22569. * Gets the current extend of the geometry
  22570. */
  22571. readonly extend: {
  22572. minimum: Vector3;
  22573. maximum: Vector3;
  22574. };
  22575. /**
  22576. * Gets the hosting scene
  22577. * @returns the hosting Scene
  22578. */
  22579. getScene(): Scene;
  22580. /**
  22581. * Gets the hosting engine
  22582. * @returns the hosting Engine
  22583. */
  22584. getEngine(): Engine;
  22585. /**
  22586. * Defines if the geometry is ready to use
  22587. * @returns true if the geometry is ready to be used
  22588. */
  22589. isReady(): boolean;
  22590. /**
  22591. * Gets a value indicating that the geometry should not be serialized
  22592. */
  22593. readonly doNotSerialize: boolean;
  22594. /** @hidden */ private _rebuild(): void;
  22595. /**
  22596. * Affects all geometry data in one call
  22597. * @param vertexData defines the geometry data
  22598. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22599. */
  22600. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22601. /**
  22602. * Set specific vertex data
  22603. * @param kind defines the data kind (Position, normal, etc...)
  22604. * @param data defines the vertex data to use
  22605. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22606. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22607. */
  22608. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22609. /**
  22610. * Removes a specific vertex data
  22611. * @param kind defines the data kind (Position, normal, etc...)
  22612. */
  22613. removeVerticesData(kind: string): void;
  22614. /**
  22615. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22616. * @param buffer defines the vertex buffer to use
  22617. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22618. */
  22619. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22620. /**
  22621. * Update a specific vertex buffer
  22622. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22623. * It will do nothing if the buffer is not updatable
  22624. * @param kind defines the data kind (Position, normal, etc...)
  22625. * @param data defines the data to use
  22626. * @param offset defines the offset in the target buffer where to store the data
  22627. * @param useBytes set to true if the offset is in bytes
  22628. */
  22629. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22630. /**
  22631. * Update a specific vertex buffer
  22632. * This function will create a new buffer if the current one is not updatable
  22633. * @param kind defines the data kind (Position, normal, etc...)
  22634. * @param data defines the data to use
  22635. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22636. */
  22637. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22638. private _updateBoundingInfo;
  22639. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22640. /**
  22641. * Gets total number of vertices
  22642. * @returns the total number of vertices
  22643. */
  22644. getTotalVertices(): number;
  22645. /**
  22646. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22647. * @param kind defines the data kind (Position, normal, etc...)
  22648. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22649. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22650. * @returns a float array containing vertex data
  22651. */
  22652. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22653. /**
  22654. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22655. * @param kind defines the data kind (Position, normal, etc...)
  22656. * @returns true if the vertex buffer with the specified kind is updatable
  22657. */
  22658. isVertexBufferUpdatable(kind: string): boolean;
  22659. /**
  22660. * Gets a specific vertex buffer
  22661. * @param kind defines the data kind (Position, normal, etc...)
  22662. * @returns a VertexBuffer
  22663. */
  22664. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22665. /**
  22666. * Returns all vertex buffers
  22667. * @return an object holding all vertex buffers indexed by kind
  22668. */
  22669. getVertexBuffers(): Nullable<{
  22670. [key: string]: VertexBuffer;
  22671. }>;
  22672. /**
  22673. * Gets a boolean indicating if specific vertex buffer is present
  22674. * @param kind defines the data kind (Position, normal, etc...)
  22675. * @returns true if data is present
  22676. */
  22677. isVerticesDataPresent(kind: string): boolean;
  22678. /**
  22679. * Gets a list of all attached data kinds (Position, normal, etc...)
  22680. * @returns a list of string containing all kinds
  22681. */
  22682. getVerticesDataKinds(): string[];
  22683. /**
  22684. * Update index buffer
  22685. * @param indices defines the indices to store in the index buffer
  22686. * @param offset defines the offset in the target buffer where to store the data
  22687. * @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)
  22688. */
  22689. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22690. /**
  22691. * Creates a new index buffer
  22692. * @param indices defines the indices to store in the index buffer
  22693. * @param totalVertices defines the total number of vertices (could be null)
  22694. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22695. */
  22696. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22697. /**
  22698. * Return the total number of indices
  22699. * @returns the total number of indices
  22700. */
  22701. getTotalIndices(): number;
  22702. /**
  22703. * Gets the index buffer array
  22704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22706. * @returns the index buffer array
  22707. */
  22708. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22709. /**
  22710. * Gets the index buffer
  22711. * @return the index buffer
  22712. */
  22713. getIndexBuffer(): Nullable<DataBuffer>;
  22714. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22715. /**
  22716. * Release the associated resources for a specific mesh
  22717. * @param mesh defines the source mesh
  22718. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22719. */
  22720. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22721. /**
  22722. * Apply current geometry to a given mesh
  22723. * @param mesh defines the mesh to apply geometry to
  22724. */
  22725. applyToMesh(mesh: Mesh): void;
  22726. private _updateExtend;
  22727. private _applyToMesh;
  22728. private notifyUpdate;
  22729. /**
  22730. * Load the geometry if it was flagged as delay loaded
  22731. * @param scene defines the hosting scene
  22732. * @param onLoaded defines a callback called when the geometry is loaded
  22733. */
  22734. load(scene: Scene, onLoaded?: () => void): void;
  22735. private _queueLoad;
  22736. /**
  22737. * Invert the geometry to move from a right handed system to a left handed one.
  22738. */
  22739. toLeftHanded(): void;
  22740. /** @hidden */ private _resetPointsArrayCache(): void;
  22741. /** @hidden */ private _generatePointsArray(): boolean;
  22742. /**
  22743. * Gets a value indicating if the geometry is disposed
  22744. * @returns true if the geometry was disposed
  22745. */
  22746. isDisposed(): boolean;
  22747. private _disposeVertexArrayObjects;
  22748. /**
  22749. * Free all associated resources
  22750. */
  22751. dispose(): void;
  22752. /**
  22753. * Clone the current geometry into a new geometry
  22754. * @param id defines the unique ID of the new geometry
  22755. * @returns a new geometry object
  22756. */
  22757. copy(id: string): Geometry;
  22758. /**
  22759. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22760. * @return a JSON representation of the current geometry data (without the vertices data)
  22761. */
  22762. serialize(): any;
  22763. private toNumberArray;
  22764. /**
  22765. * Serialize all vertices data into a JSON oject
  22766. * @returns a JSON representation of the current geometry data
  22767. */
  22768. serializeVerticeData(): any;
  22769. /**
  22770. * Extracts a clone of a mesh geometry
  22771. * @param mesh defines the source mesh
  22772. * @param id defines the unique ID of the new geometry object
  22773. * @returns the new geometry object
  22774. */
  22775. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22776. /**
  22777. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22778. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22779. * Be aware Math.random() could cause collisions, but:
  22780. * "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"
  22781. * @returns a string containing a new GUID
  22782. */
  22783. static RandomId(): string;
  22784. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22785. private static _CleanMatricesWeights;
  22786. /**
  22787. * Create a new geometry from persisted data (Using .babylon file format)
  22788. * @param parsedVertexData defines the persisted data
  22789. * @param scene defines the hosting scene
  22790. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22791. * @returns the new geometry object
  22792. */
  22793. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22794. }
  22795. }
  22796. declare module BABYLON {
  22797. /**
  22798. * Define an interface for all classes that will get and set the data on vertices
  22799. */
  22800. export interface IGetSetVerticesData {
  22801. /**
  22802. * Gets a boolean indicating if specific vertex data is present
  22803. * @param kind defines the vertex data kind to use
  22804. * @returns true is data kind is present
  22805. */
  22806. isVerticesDataPresent(kind: string): boolean;
  22807. /**
  22808. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22809. * @param kind defines the data kind (Position, normal, etc...)
  22810. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22811. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22812. * @returns a float array containing vertex data
  22813. */
  22814. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22815. /**
  22816. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22817. * @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.
  22818. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22819. * @returns the indices array or an empty array if the mesh has no geometry
  22820. */
  22821. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22822. /**
  22823. * Set specific vertex data
  22824. * @param kind defines the data kind (Position, normal, etc...)
  22825. * @param data defines the vertex data to use
  22826. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22827. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22828. */
  22829. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22830. /**
  22831. * Update a specific associated vertex buffer
  22832. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22833. * - VertexBuffer.PositionKind
  22834. * - VertexBuffer.UVKind
  22835. * - VertexBuffer.UV2Kind
  22836. * - VertexBuffer.UV3Kind
  22837. * - VertexBuffer.UV4Kind
  22838. * - VertexBuffer.UV5Kind
  22839. * - VertexBuffer.UV6Kind
  22840. * - VertexBuffer.ColorKind
  22841. * - VertexBuffer.MatricesIndicesKind
  22842. * - VertexBuffer.MatricesIndicesExtraKind
  22843. * - VertexBuffer.MatricesWeightsKind
  22844. * - VertexBuffer.MatricesWeightsExtraKind
  22845. * @param data defines the data source
  22846. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22847. * @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)
  22848. */
  22849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22850. /**
  22851. * Creates a new index buffer
  22852. * @param indices defines the indices to store in the index buffer
  22853. * @param totalVertices defines the total number of vertices (could be null)
  22854. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22855. */
  22856. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22857. }
  22858. /**
  22859. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22860. */
  22861. export class VertexData {
  22862. /**
  22863. * Mesh side orientation : usually the external or front surface
  22864. */
  22865. static readonly FRONTSIDE: number;
  22866. /**
  22867. * Mesh side orientation : usually the internal or back surface
  22868. */
  22869. static readonly BACKSIDE: number;
  22870. /**
  22871. * Mesh side orientation : both internal and external or front and back surfaces
  22872. */
  22873. static readonly DOUBLESIDE: number;
  22874. /**
  22875. * Mesh side orientation : by default, `FRONTSIDE`
  22876. */
  22877. static readonly DEFAULTSIDE: number;
  22878. /**
  22879. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22880. */
  22881. positions: Nullable<FloatArray>;
  22882. /**
  22883. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22884. */
  22885. normals: Nullable<FloatArray>;
  22886. /**
  22887. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22888. */
  22889. tangents: Nullable<FloatArray>;
  22890. /**
  22891. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22892. */
  22893. uvs: Nullable<FloatArray>;
  22894. /**
  22895. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22896. */
  22897. uvs2: Nullable<FloatArray>;
  22898. /**
  22899. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22900. */
  22901. uvs3: Nullable<FloatArray>;
  22902. /**
  22903. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22904. */
  22905. uvs4: Nullable<FloatArray>;
  22906. /**
  22907. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22908. */
  22909. uvs5: Nullable<FloatArray>;
  22910. /**
  22911. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22912. */
  22913. uvs6: Nullable<FloatArray>;
  22914. /**
  22915. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22916. */
  22917. colors: Nullable<FloatArray>;
  22918. /**
  22919. * 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).
  22920. */
  22921. matricesIndices: Nullable<FloatArray>;
  22922. /**
  22923. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22924. */
  22925. matricesWeights: Nullable<FloatArray>;
  22926. /**
  22927. * An array extending the number of possible indices
  22928. */
  22929. matricesIndicesExtra: Nullable<FloatArray>;
  22930. /**
  22931. * An array extending the number of possible weights when the number of indices is extended
  22932. */
  22933. matricesWeightsExtra: Nullable<FloatArray>;
  22934. /**
  22935. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22936. */
  22937. indices: Nullable<IndicesArray>;
  22938. /**
  22939. * Uses the passed data array to set the set the values for the specified kind of data
  22940. * @param data a linear array of floating numbers
  22941. * @param kind the type of data that is being set, eg positions, colors etc
  22942. */
  22943. set(data: FloatArray, kind: string): void;
  22944. /**
  22945. * Associates the vertexData to the passed Mesh.
  22946. * Sets it as updatable or not (default `false`)
  22947. * @param mesh the mesh the vertexData is applied to
  22948. * @param updatable when used and having the value true allows new data to update the vertexData
  22949. * @returns the VertexData
  22950. */
  22951. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22952. /**
  22953. * Associates the vertexData to the passed Geometry.
  22954. * Sets it as updatable or not (default `false`)
  22955. * @param geometry the geometry the vertexData is applied to
  22956. * @param updatable when used and having the value true allows new data to update the vertexData
  22957. * @returns VertexData
  22958. */
  22959. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22960. /**
  22961. * Updates the associated mesh
  22962. * @param mesh the mesh to be updated
  22963. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22964. * @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
  22965. * @returns VertexData
  22966. */
  22967. updateMesh(mesh: Mesh): VertexData;
  22968. /**
  22969. * Updates the associated geometry
  22970. * @param geometry the geometry to be updated
  22971. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22972. * @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
  22973. * @returns VertexData.
  22974. */
  22975. updateGeometry(geometry: Geometry): VertexData;
  22976. private _applyTo;
  22977. private _update;
  22978. /**
  22979. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22980. * @param matrix the transforming matrix
  22981. * @returns the VertexData
  22982. */
  22983. transform(matrix: Matrix): VertexData;
  22984. /**
  22985. * Merges the passed VertexData into the current one
  22986. * @param other the VertexData to be merged into the current one
  22987. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22988. * @returns the modified VertexData
  22989. */
  22990. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22991. private _mergeElement;
  22992. private _validate;
  22993. /**
  22994. * Serializes the VertexData
  22995. * @returns a serialized object
  22996. */
  22997. serialize(): any;
  22998. /**
  22999. * Extracts the vertexData from a mesh
  23000. * @param mesh the mesh from which to extract the VertexData
  23001. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23002. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23003. * @returns the object VertexData associated to the passed mesh
  23004. */
  23005. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23006. /**
  23007. * Extracts the vertexData from the geometry
  23008. * @param geometry the geometry from which to extract the VertexData
  23009. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23010. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23011. * @returns the object VertexData associated to the passed mesh
  23012. */
  23013. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23014. private static _ExtractFrom;
  23015. /**
  23016. * Creates the VertexData for a Ribbon
  23017. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23018. * * pathArray array of paths, each of which an array of successive Vector3
  23019. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23020. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23021. * * 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
  23022. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23023. * * 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)
  23024. * * 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)
  23025. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23026. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23027. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23028. * @returns the VertexData of the ribbon
  23029. */
  23030. static CreateRibbon(options: {
  23031. pathArray: Vector3[][];
  23032. closeArray?: boolean;
  23033. closePath?: boolean;
  23034. offset?: number;
  23035. sideOrientation?: number;
  23036. frontUVs?: Vector4;
  23037. backUVs?: Vector4;
  23038. invertUV?: boolean;
  23039. uvs?: Vector2[];
  23040. colors?: Color4[];
  23041. }): VertexData;
  23042. /**
  23043. * Creates the VertexData for a box
  23044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23045. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23046. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23047. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23048. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23049. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23050. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23052. * * 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)
  23053. * * 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)
  23054. * @returns the VertexData of the box
  23055. */
  23056. static CreateBox(options: {
  23057. size?: number;
  23058. width?: number;
  23059. height?: number;
  23060. depth?: number;
  23061. faceUV?: Vector4[];
  23062. faceColors?: Color4[];
  23063. sideOrientation?: number;
  23064. frontUVs?: Vector4;
  23065. backUVs?: Vector4;
  23066. }): VertexData;
  23067. /**
  23068. * Creates the VertexData for a tiled box
  23069. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23070. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23071. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23072. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * @returns the VertexData of the box
  23075. */
  23076. static CreateTiledBox(options: {
  23077. pattern?: number;
  23078. width?: number;
  23079. height?: number;
  23080. depth?: number;
  23081. tileSize?: number;
  23082. tileWidth?: number;
  23083. tileHeight?: number;
  23084. alignHorizontal?: number;
  23085. alignVertical?: number;
  23086. faceUV?: Vector4[];
  23087. faceColors?: Color4[];
  23088. sideOrientation?: number;
  23089. }): VertexData;
  23090. /**
  23091. * Creates the VertexData for a tiled plane
  23092. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23093. * * pattern a limited pattern arrangement depending on the number
  23094. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23095. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23096. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23098. * * 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)
  23099. * * 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)
  23100. * @returns the VertexData of the tiled plane
  23101. */
  23102. static CreateTiledPlane(options: {
  23103. pattern?: number;
  23104. tileSize?: number;
  23105. tileWidth?: number;
  23106. tileHeight?: number;
  23107. size?: number;
  23108. width?: number;
  23109. height?: number;
  23110. alignHorizontal?: number;
  23111. alignVertical?: number;
  23112. sideOrientation?: number;
  23113. frontUVs?: Vector4;
  23114. backUVs?: Vector4;
  23115. }): VertexData;
  23116. /**
  23117. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23119. * * segments sets the number of horizontal strips optional, default 32
  23120. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23121. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23122. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23123. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23124. * * 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
  23125. * * 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
  23126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23127. * * 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)
  23128. * * 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)
  23129. * @returns the VertexData of the ellipsoid
  23130. */
  23131. static CreateSphere(options: {
  23132. segments?: number;
  23133. diameter?: number;
  23134. diameterX?: number;
  23135. diameterY?: number;
  23136. diameterZ?: number;
  23137. arc?: number;
  23138. slice?: number;
  23139. sideOrientation?: number;
  23140. frontUVs?: Vector4;
  23141. backUVs?: Vector4;
  23142. }): VertexData;
  23143. /**
  23144. * Creates the VertexData for a cylinder, cone or prism
  23145. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23146. * * height sets the height (y direction) of the cylinder, optional, default 2
  23147. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23148. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23149. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23150. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23151. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23152. * * 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
  23153. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23154. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23155. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23156. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23158. * * 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)
  23159. * * 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)
  23160. * @returns the VertexData of the cylinder, cone or prism
  23161. */
  23162. static CreateCylinder(options: {
  23163. height?: number;
  23164. diameterTop?: number;
  23165. diameterBottom?: number;
  23166. diameter?: number;
  23167. tessellation?: number;
  23168. subdivisions?: number;
  23169. arc?: number;
  23170. faceColors?: Color4[];
  23171. faceUV?: Vector4[];
  23172. hasRings?: boolean;
  23173. enclose?: boolean;
  23174. sideOrientation?: number;
  23175. frontUVs?: Vector4;
  23176. backUVs?: Vector4;
  23177. }): VertexData;
  23178. /**
  23179. * Creates the VertexData for a torus
  23180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23181. * * diameter the diameter of the torus, optional default 1
  23182. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23183. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23185. * * 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)
  23186. * * 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)
  23187. * @returns the VertexData of the torus
  23188. */
  23189. static CreateTorus(options: {
  23190. diameter?: number;
  23191. thickness?: number;
  23192. tessellation?: number;
  23193. sideOrientation?: number;
  23194. frontUVs?: Vector4;
  23195. backUVs?: Vector4;
  23196. }): VertexData;
  23197. /**
  23198. * Creates the VertexData of the LineSystem
  23199. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23200. * - lines an array of lines, each line being an array of successive Vector3
  23201. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23202. * @returns the VertexData of the LineSystem
  23203. */
  23204. static CreateLineSystem(options: {
  23205. lines: Vector3[][];
  23206. colors?: Nullable<Color4[][]>;
  23207. }): VertexData;
  23208. /**
  23209. * Create the VertexData for a DashedLines
  23210. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23211. * - points an array successive Vector3
  23212. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23213. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23214. * - dashNb the intended total number of dashes, optional, default 200
  23215. * @returns the VertexData for the DashedLines
  23216. */
  23217. static CreateDashedLines(options: {
  23218. points: Vector3[];
  23219. dashSize?: number;
  23220. gapSize?: number;
  23221. dashNb?: number;
  23222. }): VertexData;
  23223. /**
  23224. * Creates the VertexData for a Ground
  23225. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23226. * - width the width (x direction) of the ground, optional, default 1
  23227. * - height the height (z direction) of the ground, optional, default 1
  23228. * - subdivisions the number of subdivisions per side, optional, default 1
  23229. * @returns the VertexData of the Ground
  23230. */
  23231. static CreateGround(options: {
  23232. width?: number;
  23233. height?: number;
  23234. subdivisions?: number;
  23235. subdivisionsX?: number;
  23236. subdivisionsY?: number;
  23237. }): VertexData;
  23238. /**
  23239. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23240. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23241. * * xmin the ground minimum X coordinate, optional, default -1
  23242. * * zmin the ground minimum Z coordinate, optional, default -1
  23243. * * xmax the ground maximum X coordinate, optional, default 1
  23244. * * zmax the ground maximum Z coordinate, optional, default 1
  23245. * * 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}
  23246. * * 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}
  23247. * @returns the VertexData of the TiledGround
  23248. */
  23249. static CreateTiledGround(options: {
  23250. xmin: number;
  23251. zmin: number;
  23252. xmax: number;
  23253. zmax: number;
  23254. subdivisions?: {
  23255. w: number;
  23256. h: number;
  23257. };
  23258. precision?: {
  23259. w: number;
  23260. h: number;
  23261. };
  23262. }): VertexData;
  23263. /**
  23264. * Creates the VertexData of the Ground designed from a heightmap
  23265. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23266. * * width the width (x direction) of the ground
  23267. * * height the height (z direction) of the ground
  23268. * * subdivisions the number of subdivisions per side
  23269. * * minHeight the minimum altitude on the ground, optional, default 0
  23270. * * maxHeight the maximum altitude on the ground, optional default 1
  23271. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23272. * * buffer the array holding the image color data
  23273. * * bufferWidth the width of image
  23274. * * bufferHeight the height of image
  23275. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23276. * @returns the VertexData of the Ground designed from a heightmap
  23277. */
  23278. static CreateGroundFromHeightMap(options: {
  23279. width: number;
  23280. height: number;
  23281. subdivisions: number;
  23282. minHeight: number;
  23283. maxHeight: number;
  23284. colorFilter: Color3;
  23285. buffer: Uint8Array;
  23286. bufferWidth: number;
  23287. bufferHeight: number;
  23288. alphaFilter: number;
  23289. }): VertexData;
  23290. /**
  23291. * Creates the VertexData for a Plane
  23292. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23293. * * size sets the width and height of the plane to the value of size, optional default 1
  23294. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23295. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23297. * * 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)
  23298. * * 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)
  23299. * @returns the VertexData of the box
  23300. */
  23301. static CreatePlane(options: {
  23302. size?: number;
  23303. width?: number;
  23304. height?: number;
  23305. sideOrientation?: number;
  23306. frontUVs?: Vector4;
  23307. backUVs?: Vector4;
  23308. }): VertexData;
  23309. /**
  23310. * Creates the VertexData of the Disc or regular Polygon
  23311. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23312. * * radius the radius of the disc, optional default 0.5
  23313. * * tessellation the number of polygon sides, optional, default 64
  23314. * * 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
  23315. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23316. * * 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)
  23317. * * 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)
  23318. * @returns the VertexData of the box
  23319. */
  23320. static CreateDisc(options: {
  23321. radius?: number;
  23322. tessellation?: number;
  23323. arc?: number;
  23324. sideOrientation?: number;
  23325. frontUVs?: Vector4;
  23326. backUVs?: Vector4;
  23327. }): VertexData;
  23328. /**
  23329. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23330. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23331. * @param polygon a mesh built from polygonTriangulation.build()
  23332. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23333. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23334. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23335. * @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)
  23336. * @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)
  23337. * @returns the VertexData of the Polygon
  23338. */
  23339. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23340. /**
  23341. * Creates the VertexData of the IcoSphere
  23342. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23343. * * radius the radius of the IcoSphere, optional default 1
  23344. * * radiusX allows stretching in the x direction, optional, default radius
  23345. * * radiusY allows stretching in the y direction, optional, default radius
  23346. * * radiusZ allows stretching in the z direction, optional, default radius
  23347. * * flat when true creates a flat shaded mesh, optional, default true
  23348. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23350. * * 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)
  23351. * * 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)
  23352. * @returns the VertexData of the IcoSphere
  23353. */
  23354. static CreateIcoSphere(options: {
  23355. radius?: number;
  23356. radiusX?: number;
  23357. radiusY?: number;
  23358. radiusZ?: number;
  23359. flat?: boolean;
  23360. subdivisions?: number;
  23361. sideOrientation?: number;
  23362. frontUVs?: Vector4;
  23363. backUVs?: Vector4;
  23364. }): VertexData;
  23365. /**
  23366. * Creates the VertexData for a Polyhedron
  23367. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23368. * * type provided types are:
  23369. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23370. * * 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)
  23371. * * size the size of the IcoSphere, optional default 1
  23372. * * sizeX allows stretching in the x direction, optional, default size
  23373. * * sizeY allows stretching in the y direction, optional, default size
  23374. * * sizeZ allows stretching in the z direction, optional, default size
  23375. * * 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
  23376. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23377. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23378. * * flat when true creates a flat shaded mesh, optional, default true
  23379. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23381. * * 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)
  23382. * * 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)
  23383. * @returns the VertexData of the Polyhedron
  23384. */
  23385. static CreatePolyhedron(options: {
  23386. type?: number;
  23387. size?: number;
  23388. sizeX?: number;
  23389. sizeY?: number;
  23390. sizeZ?: number;
  23391. custom?: any;
  23392. faceUV?: Vector4[];
  23393. faceColors?: Color4[];
  23394. flat?: boolean;
  23395. sideOrientation?: number;
  23396. frontUVs?: Vector4;
  23397. backUVs?: Vector4;
  23398. }): VertexData;
  23399. /**
  23400. * Creates the VertexData for a TorusKnot
  23401. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23402. * * radius the radius of the torus knot, optional, default 2
  23403. * * tube the thickness of the tube, optional, default 0.5
  23404. * * radialSegments the number of sides on each tube segments, optional, default 32
  23405. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23406. * * p the number of windings around the z axis, optional, default 2
  23407. * * q the number of windings around the x axis, optional, default 3
  23408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23409. * * 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)
  23410. * * 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)
  23411. * @returns the VertexData of the Torus Knot
  23412. */
  23413. static CreateTorusKnot(options: {
  23414. radius?: number;
  23415. tube?: number;
  23416. radialSegments?: number;
  23417. tubularSegments?: number;
  23418. p?: number;
  23419. q?: number;
  23420. sideOrientation?: number;
  23421. frontUVs?: Vector4;
  23422. backUVs?: Vector4;
  23423. }): VertexData;
  23424. /**
  23425. * Compute normals for given positions and indices
  23426. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23427. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23428. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23429. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23430. * * facetNormals : optional array of facet normals (vector3)
  23431. * * facetPositions : optional array of facet positions (vector3)
  23432. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23433. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23434. * * bInfo : optional bounding info, required for facetPartitioning computation
  23435. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23436. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23437. * * useRightHandedSystem: optional boolean to for right handed system computation
  23438. * * depthSort : optional boolean to enable the facet depth sort computation
  23439. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23440. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23441. */
  23442. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23443. facetNormals?: any;
  23444. facetPositions?: any;
  23445. facetPartitioning?: any;
  23446. ratio?: number;
  23447. bInfo?: any;
  23448. bbSize?: Vector3;
  23449. subDiv?: any;
  23450. useRightHandedSystem?: boolean;
  23451. depthSort?: boolean;
  23452. distanceTo?: Vector3;
  23453. depthSortedFacets?: any;
  23454. }): void;
  23455. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23456. /**
  23457. * Applies VertexData created from the imported parameters to the geometry
  23458. * @param parsedVertexData the parsed data from an imported file
  23459. * @param geometry the geometry to apply the VertexData to
  23460. */
  23461. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23462. }
  23463. }
  23464. declare module BABYLON {
  23465. /**
  23466. * Class containing static functions to help procedurally build meshes
  23467. */
  23468. export class DiscBuilder {
  23469. /**
  23470. * Creates a plane polygonal mesh. By default, this is a disc
  23471. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23472. * * 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
  23473. * * 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
  23474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23475. * * 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
  23476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23477. * @param name defines the name of the mesh
  23478. * @param options defines the options used to create the mesh
  23479. * @param scene defines the hosting scene
  23480. * @returns the plane polygonal mesh
  23481. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23482. */
  23483. static CreateDisc(name: string, options: {
  23484. radius?: number;
  23485. tessellation?: number;
  23486. arc?: number;
  23487. updatable?: boolean;
  23488. sideOrientation?: number;
  23489. frontUVs?: Vector4;
  23490. backUVs?: Vector4;
  23491. }, scene?: Nullable<Scene>): Mesh;
  23492. }
  23493. }
  23494. declare module BABYLON {
  23495. /**
  23496. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23497. *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.
  23498. * The SPS is also a particle system. It provides some methods to manage the particles.
  23499. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23500. *
  23501. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23502. */
  23503. export class SolidParticleSystem implements IDisposable {
  23504. /**
  23505. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23506. * Example : var p = SPS.particles[i];
  23507. */
  23508. particles: SolidParticle[];
  23509. /**
  23510. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23511. */
  23512. nbParticles: number;
  23513. /**
  23514. * If the particles must ever face the camera (default false). Useful for planar particles.
  23515. */
  23516. billboard: boolean;
  23517. /**
  23518. * Recompute normals when adding a shape
  23519. */
  23520. recomputeNormals: boolean;
  23521. /**
  23522. * This a counter ofr your own usage. It's not set by any SPS functions.
  23523. */
  23524. counter: number;
  23525. /**
  23526. * The SPS name. This name is also given to the underlying mesh.
  23527. */
  23528. name: string;
  23529. /**
  23530. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23531. */
  23532. mesh: Mesh;
  23533. /**
  23534. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23535. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23536. */
  23537. vars: any;
  23538. /**
  23539. * This array is populated when the SPS is set as 'pickable'.
  23540. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23541. * Each element of this array is an object `{idx: int, faceId: int}`.
  23542. * `idx` is the picked particle index in the `SPS.particles` array
  23543. * `faceId` is the picked face index counted within this particle.
  23544. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23545. */
  23546. pickedParticles: {
  23547. idx: number;
  23548. faceId: number;
  23549. }[];
  23550. /**
  23551. * This array is populated when `enableDepthSort` is set to true.
  23552. * Each element of this array is an instance of the class DepthSortedParticle.
  23553. */
  23554. depthSortedParticles: DepthSortedParticle[];
  23555. /**
  23556. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23557. * @hidden
  23558. */ private _bSphereOnly: boolean;
  23559. /**
  23560. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23561. * @hidden
  23562. */ private _bSphereRadiusFactor: number;
  23563. private _scene;
  23564. private _positions;
  23565. private _indices;
  23566. private _normals;
  23567. private _colors;
  23568. private _uvs;
  23569. private _indices32;
  23570. private _positions32;
  23571. private _normals32;
  23572. private _fixedNormal32;
  23573. private _colors32;
  23574. private _uvs32;
  23575. private _index;
  23576. private _updatable;
  23577. private _pickable;
  23578. private _isVisibilityBoxLocked;
  23579. private _alwaysVisible;
  23580. private _depthSort;
  23581. private _shapeCounter;
  23582. private _copy;
  23583. private _color;
  23584. private _computeParticleColor;
  23585. private _computeParticleTexture;
  23586. private _computeParticleRotation;
  23587. private _computeParticleVertex;
  23588. private _computeBoundingBox;
  23589. private _depthSortParticles;
  23590. private _camera;
  23591. private _mustUnrotateFixedNormals;
  23592. private _particlesIntersect;
  23593. private _needs32Bits;
  23594. /**
  23595. * Creates a SPS (Solid Particle System) object.
  23596. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23597. * @param scene (Scene) is the scene in which the SPS is added.
  23598. * @param options defines the options of the sps e.g.
  23599. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23600. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23601. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23602. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23603. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23604. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23605. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23606. */
  23607. constructor(name: string, scene: Scene, options?: {
  23608. updatable?: boolean;
  23609. isPickable?: boolean;
  23610. enableDepthSort?: boolean;
  23611. particleIntersection?: boolean;
  23612. boundingSphereOnly?: boolean;
  23613. bSphereRadiusFactor?: number;
  23614. });
  23615. /**
  23616. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23617. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23618. * @returns the created mesh
  23619. */
  23620. buildMesh(): Mesh;
  23621. /**
  23622. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23623. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23624. * Thus the particles generated from `digest()` have their property `position` set yet.
  23625. * @param mesh ( Mesh ) is the mesh to be digested
  23626. * @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
  23627. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23628. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23629. * @returns the current SPS
  23630. */
  23631. digest(mesh: Mesh, options?: {
  23632. facetNb?: number;
  23633. number?: number;
  23634. delta?: number;
  23635. }): SolidParticleSystem;
  23636. private _unrotateFixedNormals;
  23637. private _resetCopy;
  23638. private _meshBuilder;
  23639. private _posToShape;
  23640. private _uvsToShapeUV;
  23641. private _addParticle;
  23642. /**
  23643. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23644. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23645. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23646. * @param nb (positive integer) the number of particles to be created from this model
  23647. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23648. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23649. * @returns the number of shapes in the system
  23650. */
  23651. addShape(mesh: Mesh, nb: number, options?: {
  23652. positionFunction?: any;
  23653. vertexFunction?: any;
  23654. }): number;
  23655. private _rebuildParticle;
  23656. /**
  23657. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23658. * @returns the SPS.
  23659. */
  23660. rebuildMesh(): SolidParticleSystem;
  23661. /**
  23662. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23663. * This method calls `updateParticle()` for each particle of the SPS.
  23664. * For an animated SPS, it is usually called within the render loop.
  23665. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23666. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23667. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23668. * @returns the SPS.
  23669. */
  23670. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23671. /**
  23672. * Disposes the SPS.
  23673. */
  23674. dispose(): void;
  23675. /**
  23676. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23677. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23678. * @returns the SPS.
  23679. */
  23680. refreshVisibleSize(): SolidParticleSystem;
  23681. /**
  23682. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23683. * @param size the size (float) of the visibility box
  23684. * note : this doesn't lock the SPS mesh bounding box.
  23685. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23686. */
  23687. setVisibilityBox(size: number): void;
  23688. /**
  23689. * Gets whether the SPS as always visible or not
  23690. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23691. */
  23692. /**
  23693. * Sets the SPS as always visible or not
  23694. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23695. */
  23696. isAlwaysVisible: boolean;
  23697. /**
  23698. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23699. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23700. */
  23701. /**
  23702. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23703. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23704. */
  23705. isVisibilityBoxLocked: boolean;
  23706. /**
  23707. * Tells to `setParticles()` to compute the particle rotations or not.
  23708. * Default value : true. The SPS is faster when it's set to false.
  23709. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23710. */
  23711. /**
  23712. * Gets if `setParticles()` computes the particle rotations or not.
  23713. * Default value : true. The SPS is faster when it's set to false.
  23714. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23715. */
  23716. computeParticleRotation: boolean;
  23717. /**
  23718. * Tells to `setParticles()` to compute the particle colors or not.
  23719. * Default value : true. The SPS is faster when it's set to false.
  23720. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23721. */
  23722. /**
  23723. * Gets if `setParticles()` computes the particle colors or not.
  23724. * Default value : true. The SPS is faster when it's set to false.
  23725. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23726. */
  23727. computeParticleColor: boolean;
  23728. /**
  23729. * Gets if `setParticles()` computes the particle textures or not.
  23730. * Default value : true. The SPS is faster when it's set to false.
  23731. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23732. */
  23733. computeParticleTexture: boolean;
  23734. /**
  23735. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23736. * Default value : false. The SPS is faster when it's set to false.
  23737. * Note : the particle custom vertex positions aren't stored values.
  23738. */
  23739. /**
  23740. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23741. * Default value : false. The SPS is faster when it's set to false.
  23742. * Note : the particle custom vertex positions aren't stored values.
  23743. */
  23744. computeParticleVertex: boolean;
  23745. /**
  23746. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23747. */
  23748. /**
  23749. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23750. */
  23751. computeBoundingBox: boolean;
  23752. /**
  23753. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23754. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23755. * Default : `true`
  23756. */
  23757. /**
  23758. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23759. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23760. * Default : `true`
  23761. */
  23762. depthSortParticles: boolean;
  23763. /**
  23764. * This function does nothing. It may be overwritten to set all the particle first values.
  23765. * The SPS doesn't call this function, you may have to call it by your own.
  23766. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23767. */
  23768. initParticles(): void;
  23769. /**
  23770. * This function does nothing. It may be overwritten to recycle a particle.
  23771. * The SPS doesn't call this function, you may have to call it by your own.
  23772. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23773. * @param particle The particle to recycle
  23774. * @returns the recycled particle
  23775. */
  23776. recycleParticle(particle: SolidParticle): SolidParticle;
  23777. /**
  23778. * Updates a particle : this function should be overwritten by the user.
  23779. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23780. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23781. * @example : just set a particle position or velocity and recycle conditions
  23782. * @param particle The particle to update
  23783. * @returns the updated particle
  23784. */
  23785. updateParticle(particle: SolidParticle): SolidParticle;
  23786. /**
  23787. * Updates a vertex of a particle : it can be overwritten by the user.
  23788. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23789. * @param particle the current particle
  23790. * @param vertex the current index of the current particle
  23791. * @param pt the index of the current vertex in the particle shape
  23792. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23793. * @example : just set a vertex particle position
  23794. * @returns the updated vertex
  23795. */
  23796. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23797. /**
  23798. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23799. * This does nothing and may be overwritten by the user.
  23800. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23801. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23802. * @param update the boolean update value actually passed to setParticles()
  23803. */
  23804. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23805. /**
  23806. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23807. * This will be passed three parameters.
  23808. * This does nothing and may be overwritten by the user.
  23809. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23810. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23811. * @param update the boolean update value actually passed to setParticles()
  23812. */
  23813. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23814. }
  23815. }
  23816. declare module BABYLON {
  23817. /**
  23818. * Represents one particle of a solid particle system.
  23819. */
  23820. export class SolidParticle {
  23821. /**
  23822. * particle global index
  23823. */
  23824. idx: number;
  23825. /**
  23826. * The color of the particle
  23827. */
  23828. color: Nullable<Color4>;
  23829. /**
  23830. * The world space position of the particle.
  23831. */
  23832. position: Vector3;
  23833. /**
  23834. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23835. */
  23836. rotation: Vector3;
  23837. /**
  23838. * The world space rotation quaternion of the particle.
  23839. */
  23840. rotationQuaternion: Nullable<Quaternion>;
  23841. /**
  23842. * The scaling of the particle.
  23843. */
  23844. scaling: Vector3;
  23845. /**
  23846. * The uvs of the particle.
  23847. */
  23848. uvs: Vector4;
  23849. /**
  23850. * The current speed of the particle.
  23851. */
  23852. velocity: Vector3;
  23853. /**
  23854. * The pivot point in the particle local space.
  23855. */
  23856. pivot: Vector3;
  23857. /**
  23858. * Must the particle be translated from its pivot point in its local space ?
  23859. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23860. * Default : false
  23861. */
  23862. translateFromPivot: boolean;
  23863. /**
  23864. * Is the particle active or not ?
  23865. */
  23866. alive: boolean;
  23867. /**
  23868. * Is the particle visible or not ?
  23869. */
  23870. isVisible: boolean;
  23871. /**
  23872. * Index of this particle in the global "positions" array (Internal use)
  23873. * @hidden
  23874. */ private _pos: number;
  23875. /**
  23876. * @hidden Index of this particle in the global "indices" array (Internal use)
  23877. */ private _ind: number;
  23878. /**
  23879. * @hidden ModelShape of this particle (Internal use)
  23880. */ private _model: ModelShape;
  23881. /**
  23882. * ModelShape id of this particle
  23883. */
  23884. shapeId: number;
  23885. /**
  23886. * Index of the particle in its shape id (Internal use)
  23887. */
  23888. idxInShape: number;
  23889. /**
  23890. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23891. */ private _modelBoundingInfo: BoundingInfo;
  23892. /**
  23893. * @hidden Particle BoundingInfo object (Internal use)
  23894. */ private _boundingInfo: BoundingInfo;
  23895. /**
  23896. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23897. */ private _sps: SolidParticleSystem;
  23898. /**
  23899. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23900. */ private _stillInvisible: boolean;
  23901. /**
  23902. * @hidden Last computed particle rotation matrix
  23903. */ private _rotationMatrix: number[];
  23904. /**
  23905. * Parent particle Id, if any.
  23906. * Default null.
  23907. */
  23908. parentId: Nullable<number>;
  23909. /**
  23910. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23911. * The possible values are :
  23912. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23913. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23914. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23915. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23916. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23917. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23918. * */
  23919. cullingStrategy: number;
  23920. /**
  23921. * @hidden Internal global position in the SPS.
  23922. */ private _globalPosition: Vector3;
  23923. /**
  23924. * Creates a Solid Particle object.
  23925. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23926. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23927. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23928. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23929. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23930. * @param shapeId (integer) is the model shape identifier in the SPS.
  23931. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23932. * @param sps defines the sps it is associated to
  23933. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23934. */
  23935. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23936. /**
  23937. * Legacy support, changed scale to scaling
  23938. */
  23939. /**
  23940. * Legacy support, changed scale to scaling
  23941. */
  23942. scale: Vector3;
  23943. /**
  23944. * Legacy support, changed quaternion to rotationQuaternion
  23945. */
  23946. /**
  23947. * Legacy support, changed quaternion to rotationQuaternion
  23948. */
  23949. quaternion: Nullable<Quaternion>;
  23950. /**
  23951. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23952. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23953. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23954. * @returns true if it intersects
  23955. */
  23956. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23957. /**
  23958. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23959. * A particle is in the frustum if its bounding box intersects the frustum
  23960. * @param frustumPlanes defines the frustum to test
  23961. * @returns true if the particle is in the frustum planes
  23962. */
  23963. isInFrustum(frustumPlanes: Plane[]): boolean;
  23964. /**
  23965. * get the rotation matrix of the particle
  23966. * @hidden
  23967. */
  23968. getRotationMatrix(m: Matrix): void;
  23969. }
  23970. /**
  23971. * Represents the shape of the model used by one particle of a solid particle system.
  23972. * SPS internal tool, don't use it manually.
  23973. */
  23974. export class ModelShape {
  23975. /**
  23976. * The shape id
  23977. * @hidden
  23978. */
  23979. shapeID: number;
  23980. /**
  23981. * flat array of model positions (internal use)
  23982. * @hidden
  23983. */ private _shape: Vector3[];
  23984. /**
  23985. * flat array of model UVs (internal use)
  23986. * @hidden
  23987. */ private _shapeUV: number[];
  23988. /**
  23989. * length of the shape in the model indices array (internal use)
  23990. * @hidden
  23991. */ private _indicesLength: number;
  23992. /**
  23993. * Custom position function (internal use)
  23994. * @hidden
  23995. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23996. /**
  23997. * Custom vertex function (internal use)
  23998. * @hidden
  23999. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24000. /**
  24001. * 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.
  24002. * SPS internal tool, don't use it manually.
  24003. * @hidden
  24004. */
  24005. 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>);
  24006. }
  24007. /**
  24008. * Represents a Depth Sorted Particle in the solid particle system.
  24009. */
  24010. export class DepthSortedParticle {
  24011. /**
  24012. * Index of the particle in the "indices" array
  24013. */
  24014. ind: number;
  24015. /**
  24016. * Length of the particle shape in the "indices" array
  24017. */
  24018. indicesLength: number;
  24019. /**
  24020. * Squared distance from the particle to the camera
  24021. */
  24022. sqDistance: number;
  24023. }
  24024. }
  24025. declare module BABYLON {
  24026. /**
  24027. * @hidden
  24028. */
  24029. 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>>;
  24030. }
  24031. }
  24032. declare module BABYLON {
  24033. /** @hidden */ private class _FacetDataStorage {
  24034. facetPositions: Vector3[];
  24035. facetNormals: Vector3[];
  24036. facetPartitioning: number[][];
  24037. facetNb: number;
  24038. partitioningSubdivisions: number;
  24039. partitioningBBoxRatio: number;
  24040. facetDataEnabled: boolean;
  24041. facetParameters: any;
  24042. bbSize: Vector3;
  24043. subDiv: {
  24044. max: number;
  24045. X: number;
  24046. Y: number;
  24047. Z: number;
  24048. };
  24049. facetDepthSort: boolean;
  24050. facetDepthSortEnabled: boolean;
  24051. depthSortedIndices: IndicesArray;
  24052. depthSortedFacets: {
  24053. ind: number;
  24054. sqDistance: number;
  24055. }[];
  24056. facetDepthSortFunction: (f1: {
  24057. ind: number;
  24058. sqDistance: number;
  24059. }, f2: {
  24060. ind: number;
  24061. sqDistance: number;
  24062. }) => number;
  24063. facetDepthSortFrom: Vector3;
  24064. facetDepthSortOrigin: Vector3;
  24065. invertedMatrix: Matrix;
  24066. }
  24067. /**
  24068. * @hidden
  24069. **/ 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;
  24070. }
  24071. /**
  24072. * Class used to store all common mesh properties
  24073. */
  24074. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24075. /** No occlusion */
  24076. static OCCLUSION_TYPE_NONE: number;
  24077. /** Occlusion set to optimisitic */
  24078. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24079. /** Occlusion set to strict */
  24080. static OCCLUSION_TYPE_STRICT: number;
  24081. /** Use an accurante occlusion algorithm */
  24082. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24083. /** Use a conservative occlusion algorithm */
  24084. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24085. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24086. * Test order :
  24087. * Is the bounding sphere outside the frustum ?
  24088. * If not, are the bounding box vertices outside the frustum ?
  24089. * It not, then the cullable object is in the frustum.
  24090. */
  24091. static readonly CULLINGSTRATEGY_STANDARD: number;
  24092. /** Culling strategy : Bounding Sphere Only.
  24093. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24094. * It's also less accurate than the standard because some not visible objects can still be selected.
  24095. * Test : is the bounding sphere outside the frustum ?
  24096. * If not, then the cullable object is in the frustum.
  24097. */
  24098. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24099. /** Culling strategy : Optimistic Inclusion.
  24100. * This in an inclusion test first, then the standard exclusion test.
  24101. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24102. * 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.
  24103. * Anyway, it's as accurate as the standard strategy.
  24104. * Test :
  24105. * Is the cullable object bounding sphere center in the frustum ?
  24106. * If not, apply the default culling strategy.
  24107. */
  24108. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24109. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24110. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24111. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24112. * 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.
  24113. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24114. * Test :
  24115. * Is the cullable object bounding sphere center in the frustum ?
  24116. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24117. */
  24118. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24119. /**
  24120. * No billboard
  24121. */
  24122. static readonly BILLBOARDMODE_NONE: number;
  24123. /** Billboard on X axis */
  24124. static readonly BILLBOARDMODE_X: number;
  24125. /** Billboard on Y axis */
  24126. static readonly BILLBOARDMODE_Y: number;
  24127. /** Billboard on Z axis */
  24128. static readonly BILLBOARDMODE_Z: number;
  24129. /** Billboard on all axes */
  24130. static readonly BILLBOARDMODE_ALL: number;
  24131. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24132. /**
  24133. * The culling strategy to use to check whether the mesh must be rendered or not.
  24134. * This value can be changed at any time and will be used on the next render mesh selection.
  24135. * The possible values are :
  24136. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24137. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24139. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24140. * Please read each static variable documentation to get details about the culling process.
  24141. * */
  24142. cullingStrategy: number;
  24143. /**
  24144. * Gets the number of facets in the mesh
  24145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24146. */
  24147. readonly facetNb: number;
  24148. /**
  24149. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24151. */
  24152. partitioningSubdivisions: number;
  24153. /**
  24154. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24155. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24157. */
  24158. partitioningBBoxRatio: number;
  24159. /**
  24160. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24161. * Works only for updatable meshes.
  24162. * Doesn't work with multi-materials
  24163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24164. */
  24165. mustDepthSortFacets: boolean;
  24166. /**
  24167. * The location (Vector3) where the facet depth sort must be computed from.
  24168. * By default, the active camera position.
  24169. * Used only when facet depth sort is enabled
  24170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24171. */
  24172. facetDepthSortFrom: Vector3;
  24173. /**
  24174. * gets a boolean indicating if facetData is enabled
  24175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24176. */
  24177. readonly isFacetDataEnabled: boolean;
  24178. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  24179. /**
  24180. * An event triggered when this mesh collides with another one
  24181. */
  24182. onCollideObservable: Observable<AbstractMesh>;
  24183. /** Set a function to call when this mesh collides with another one */
  24184. onCollide: () => void;
  24185. /**
  24186. * An event triggered when the collision's position changes
  24187. */
  24188. onCollisionPositionChangeObservable: Observable<Vector3>;
  24189. /** Set a function to call when the collision's position changes */
  24190. onCollisionPositionChange: () => void;
  24191. /**
  24192. * An event triggered when material is changed
  24193. */
  24194. onMaterialChangedObservable: Observable<AbstractMesh>;
  24195. /**
  24196. * Gets or sets the orientation for POV movement & rotation
  24197. */
  24198. definedFacingForward: boolean;
  24199. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  24200. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  24201. /**
  24202. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24203. */
  24204. /**
  24205. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24206. */
  24207. visibility: number;
  24208. /** Gets or sets the alpha index used to sort transparent meshes
  24209. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24210. */
  24211. alphaIndex: number;
  24212. /**
  24213. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24214. */
  24215. isVisible: boolean;
  24216. /**
  24217. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24218. */
  24219. isPickable: boolean;
  24220. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24221. showSubMeshesBoundingBox: boolean;
  24222. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24223. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24224. */
  24225. isBlocker: boolean;
  24226. /**
  24227. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24228. */
  24229. enablePointerMoveEvents: boolean;
  24230. /**
  24231. * Specifies the rendering group id for this mesh (0 by default)
  24232. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24233. */
  24234. renderingGroupId: number;
  24235. private _material;
  24236. /** Gets or sets current material */
  24237. material: Nullable<Material>;
  24238. /**
  24239. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24240. * @see http://doc.babylonjs.com/babylon101/shadows
  24241. */
  24242. receiveShadows: boolean;
  24243. /** Defines color to use when rendering outline */
  24244. outlineColor: Color3;
  24245. /** Define width to use when rendering outline */
  24246. outlineWidth: number;
  24247. /** Defines color to use when rendering overlay */
  24248. overlayColor: Color3;
  24249. /** Defines alpha to use when rendering overlay */
  24250. overlayAlpha: number;
  24251. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24252. hasVertexAlpha: boolean;
  24253. /** 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) */
  24254. useVertexColors: boolean;
  24255. /**
  24256. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24257. */
  24258. computeBonesUsingShaders: boolean;
  24259. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24260. numBoneInfluencers: number;
  24261. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24262. applyFog: boolean;
  24263. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24264. useOctreeForRenderingSelection: boolean;
  24265. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24266. useOctreeForPicking: boolean;
  24267. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24268. useOctreeForCollisions: boolean;
  24269. /**
  24270. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24271. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24272. */
  24273. layerMask: number;
  24274. /**
  24275. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24276. */
  24277. alwaysSelectAsActiveMesh: boolean;
  24278. /**
  24279. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24280. */
  24281. doNotSyncBoundingInfo: boolean;
  24282. /**
  24283. * Gets or sets the current action manager
  24284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24285. */
  24286. actionManager: Nullable<AbstractActionManager>;
  24287. private _meshCollisionData;
  24288. /**
  24289. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24291. */
  24292. ellipsoid: Vector3;
  24293. /**
  24294. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24296. */
  24297. ellipsoidOffset: Vector3;
  24298. /**
  24299. * Gets or sets a collision mask used to mask collisions (default is -1).
  24300. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24301. */
  24302. collisionMask: number;
  24303. /**
  24304. * Gets or sets the current collision group mask (-1 by default).
  24305. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24306. */
  24307. collisionGroup: number;
  24308. /**
  24309. * Defines edge width used when edgesRenderer is enabled
  24310. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24311. */
  24312. edgesWidth: number;
  24313. /**
  24314. * Defines edge color used when edgesRenderer is enabled
  24315. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24316. */
  24317. edgesColor: Color4;
  24318. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  24319. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  24320. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  24321. /** @hidden */ private _renderId: number;
  24322. /**
  24323. * Gets or sets the list of subMeshes
  24324. * @see http://doc.babylonjs.com/how_to/multi_materials
  24325. */
  24326. subMeshes: SubMesh[];
  24327. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  24328. /** @hidden */ private _unIndexed: boolean;
  24329. /** @hidden */ private _lightSources: Light[];
  24330. /** Gets the list of lights affecting that mesh */
  24331. readonly lightSources: Light[];
  24332. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24333. /** @hidden */ private _waitingData: {
  24334. lods: Nullable<any>;
  24335. actions: Nullable<any>;
  24336. freezeWorldMatrix: Nullable<boolean>;
  24337. };
  24338. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  24339. /**
  24340. * Gets or sets a skeleton to apply skining transformations
  24341. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24342. */
  24343. skeleton: Nullable<Skeleton>;
  24344. /**
  24345. * An event triggered when the mesh is rebuilt.
  24346. */
  24347. onRebuildObservable: Observable<AbstractMesh>;
  24348. /**
  24349. * Creates a new AbstractMesh
  24350. * @param name defines the name of the mesh
  24351. * @param scene defines the hosting scene
  24352. */
  24353. constructor(name: string, scene?: Nullable<Scene>);
  24354. /**
  24355. * Returns the string "AbstractMesh"
  24356. * @returns "AbstractMesh"
  24357. */
  24358. getClassName(): string;
  24359. /**
  24360. * Gets a string representation of the current mesh
  24361. * @param fullDetails defines a boolean indicating if full details must be included
  24362. * @returns a string representation of the current mesh
  24363. */
  24364. toString(fullDetails?: boolean): string;
  24365. /**
  24366. * @hidden
  24367. */
  24368. protected _getEffectiveParent(): Nullable<Node>;
  24369. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24370. /** @hidden */ private _rebuild(): void;
  24371. /** @hidden */ private _resyncLightSources(): void;
  24372. /** @hidden */ private _resyncLighSource(light: Light): void;
  24373. /** @hidden */ private _unBindEffect(): void;
  24374. /** @hidden */ private _removeLightSource(light: Light): void;
  24375. private _markSubMeshesAsDirty;
  24376. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  24377. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  24378. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  24379. /**
  24380. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24381. */
  24382. scaling: Vector3;
  24383. /**
  24384. * Returns true if the mesh is blocked. Implemented by child classes
  24385. */
  24386. readonly isBlocked: boolean;
  24387. /**
  24388. * Returns the mesh itself by default. Implemented by child classes
  24389. * @param camera defines the camera to use to pick the right LOD level
  24390. * @returns the currentAbstractMesh
  24391. */
  24392. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24393. /**
  24394. * Returns 0 by default. Implemented by child classes
  24395. * @returns an integer
  24396. */
  24397. getTotalVertices(): number;
  24398. /**
  24399. * Returns a positive integer : the total number of indices in this mesh geometry.
  24400. * @returns the numner of indices or zero if the mesh has no geometry.
  24401. */
  24402. getTotalIndices(): number;
  24403. /**
  24404. * Returns null by default. Implemented by child classes
  24405. * @returns null
  24406. */
  24407. getIndices(): Nullable<IndicesArray>;
  24408. /**
  24409. * Returns the array of the requested vertex data kind. Implemented by child classes
  24410. * @param kind defines the vertex data kind to use
  24411. * @returns null
  24412. */
  24413. getVerticesData(kind: string): Nullable<FloatArray>;
  24414. /**
  24415. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24416. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24417. * Note that a new underlying VertexBuffer object is created each call.
  24418. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24419. * @param kind defines vertex data kind:
  24420. * * VertexBuffer.PositionKind
  24421. * * VertexBuffer.UVKind
  24422. * * VertexBuffer.UV2Kind
  24423. * * VertexBuffer.UV3Kind
  24424. * * VertexBuffer.UV4Kind
  24425. * * VertexBuffer.UV5Kind
  24426. * * VertexBuffer.UV6Kind
  24427. * * VertexBuffer.ColorKind
  24428. * * VertexBuffer.MatricesIndicesKind
  24429. * * VertexBuffer.MatricesIndicesExtraKind
  24430. * * VertexBuffer.MatricesWeightsKind
  24431. * * VertexBuffer.MatricesWeightsExtraKind
  24432. * @param data defines the data source
  24433. * @param updatable defines if the data must be flagged as updatable (or static)
  24434. * @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
  24435. * @returns the current mesh
  24436. */
  24437. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24438. /**
  24439. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24440. * If the mesh has no geometry, it is simply returned as it is.
  24441. * @param kind defines vertex data kind:
  24442. * * VertexBuffer.PositionKind
  24443. * * VertexBuffer.UVKind
  24444. * * VertexBuffer.UV2Kind
  24445. * * VertexBuffer.UV3Kind
  24446. * * VertexBuffer.UV4Kind
  24447. * * VertexBuffer.UV5Kind
  24448. * * VertexBuffer.UV6Kind
  24449. * * VertexBuffer.ColorKind
  24450. * * VertexBuffer.MatricesIndicesKind
  24451. * * VertexBuffer.MatricesIndicesExtraKind
  24452. * * VertexBuffer.MatricesWeightsKind
  24453. * * VertexBuffer.MatricesWeightsExtraKind
  24454. * @param data defines the data source
  24455. * @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
  24456. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24457. * @returns the current mesh
  24458. */
  24459. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24460. /**
  24461. * Sets the mesh indices,
  24462. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24463. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24464. * @param totalVertices Defines the total number of vertices
  24465. * @returns the current mesh
  24466. */
  24467. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24468. /**
  24469. * Gets a boolean indicating if specific vertex data is present
  24470. * @param kind defines the vertex data kind to use
  24471. * @returns true is data kind is present
  24472. */
  24473. isVerticesDataPresent(kind: string): boolean;
  24474. /**
  24475. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24476. * @returns a BoundingInfo
  24477. */
  24478. getBoundingInfo(): BoundingInfo;
  24479. /**
  24480. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24481. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24482. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24483. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24484. * @returns the current mesh
  24485. */
  24486. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24487. /**
  24488. * Overwrite the current bounding info
  24489. * @param boundingInfo defines the new bounding info
  24490. * @returns the current mesh
  24491. */
  24492. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24493. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24494. readonly useBones: boolean;
  24495. /** @hidden */ private _preActivate(): void;
  24496. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  24497. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  24498. /** @hidden */ private _postActivate(): void;
  24499. /** @hidden */ private _freeze(): void;
  24500. /** @hidden */ private _unFreeze(): void;
  24501. /**
  24502. * Gets the current world matrix
  24503. * @returns a Matrix
  24504. */
  24505. getWorldMatrix(): Matrix;
  24506. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  24507. /**
  24508. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24509. */
  24510. readonly isAnInstance: boolean;
  24511. /**
  24512. * Perform relative position change from the point of view of behind the front of the mesh.
  24513. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24514. * Supports definition of mesh facing forward or backward
  24515. * @param amountRight defines the distance on the right axis
  24516. * @param amountUp defines the distance on the up axis
  24517. * @param amountForward defines the distance on the forward axis
  24518. * @returns the current mesh
  24519. */
  24520. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24521. /**
  24522. * Calculate relative position change from the point of view of behind the front of the mesh.
  24523. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24524. * Supports definition of mesh facing forward or backward
  24525. * @param amountRight defines the distance on the right axis
  24526. * @param amountUp defines the distance on the up axis
  24527. * @param amountForward defines the distance on the forward axis
  24528. * @returns the new displacement vector
  24529. */
  24530. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24531. /**
  24532. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24533. * Supports definition of mesh facing forward or backward
  24534. * @param flipBack defines the flip
  24535. * @param twirlClockwise defines the twirl
  24536. * @param tiltRight defines the tilt
  24537. * @returns the current mesh
  24538. */
  24539. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24540. /**
  24541. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24542. * Supports definition of mesh facing forward or backward.
  24543. * @param flipBack defines the flip
  24544. * @param twirlClockwise defines the twirl
  24545. * @param tiltRight defines the tilt
  24546. * @returns the new rotation vector
  24547. */
  24548. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24549. /**
  24550. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24551. * This means the mesh underlying bounding box and sphere are recomputed.
  24552. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24553. * @returns the current mesh
  24554. */
  24555. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24556. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24557. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24558. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  24559. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24560. /** @hidden */
  24561. protected _afterComputeWorldMatrix(): void;
  24562. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24563. /**
  24564. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24565. * A mesh is in the frustum if its bounding box intersects the frustum
  24566. * @param frustumPlanes defines the frustum to test
  24567. * @returns true if the mesh is in the frustum planes
  24568. */
  24569. isInFrustum(frustumPlanes: Plane[]): boolean;
  24570. /**
  24571. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24572. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24573. * @param frustumPlanes defines the frustum to test
  24574. * @returns true if the mesh is completely in the frustum planes
  24575. */
  24576. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24577. /**
  24578. * True if the mesh intersects another mesh or a SolidParticle object
  24579. * @param mesh defines a target mesh or SolidParticle to test
  24580. * @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)
  24581. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24582. * @returns true if there is an intersection
  24583. */
  24584. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24585. /**
  24586. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24587. * @param point defines the point to test
  24588. * @returns true if there is an intersection
  24589. */
  24590. intersectsPoint(point: Vector3): boolean;
  24591. /**
  24592. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24594. */
  24595. checkCollisions: boolean;
  24596. /**
  24597. * Gets Collider object used to compute collisions (not physics)
  24598. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24599. */
  24600. readonly collider: Nullable<Collider>;
  24601. /**
  24602. * Move the mesh using collision engine
  24603. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24604. * @param displacement defines the requested displacement vector
  24605. * @returns the current mesh
  24606. */
  24607. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24608. private _onCollisionPositionChange;
  24609. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24610. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24611. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  24612. /** @hidden */ private _generatePointsArray(): boolean;
  24613. /**
  24614. * Checks if the passed Ray intersects with the mesh
  24615. * @param ray defines the ray to use
  24616. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24617. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24618. * @returns the picking info
  24619. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24620. */
  24621. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24622. /**
  24623. * Clones the current mesh
  24624. * @param name defines the mesh name
  24625. * @param newParent defines the new mesh parent
  24626. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24627. * @returns the new mesh
  24628. */
  24629. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24630. /**
  24631. * Disposes all the submeshes of the current meshnp
  24632. * @returns the current mesh
  24633. */
  24634. releaseSubMeshes(): AbstractMesh;
  24635. /**
  24636. * Releases resources associated with this abstract mesh.
  24637. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24638. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24639. */
  24640. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24641. /**
  24642. * Adds the passed mesh as a child to the current mesh
  24643. * @param mesh defines the child mesh
  24644. * @returns the current mesh
  24645. */
  24646. addChild(mesh: AbstractMesh): AbstractMesh;
  24647. /**
  24648. * Removes the passed mesh from the current mesh children list
  24649. * @param mesh defines the child mesh
  24650. * @returns the current mesh
  24651. */
  24652. removeChild(mesh: AbstractMesh): AbstractMesh;
  24653. /** @hidden */
  24654. private _initFacetData;
  24655. /**
  24656. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24657. * This method can be called within the render loop.
  24658. * 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
  24659. * @returns the current mesh
  24660. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24661. */
  24662. updateFacetData(): AbstractMesh;
  24663. /**
  24664. * Returns the facetLocalNormals array.
  24665. * The normals are expressed in the mesh local spac
  24666. * @returns an array of Vector3
  24667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24668. */
  24669. getFacetLocalNormals(): Vector3[];
  24670. /**
  24671. * Returns the facetLocalPositions array.
  24672. * The facet positions are expressed in the mesh local space
  24673. * @returns an array of Vector3
  24674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24675. */
  24676. getFacetLocalPositions(): Vector3[];
  24677. /**
  24678. * Returns the facetLocalPartioning array
  24679. * @returns an array of array of numbers
  24680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24681. */
  24682. getFacetLocalPartitioning(): number[][];
  24683. /**
  24684. * Returns the i-th facet position in the world system.
  24685. * This method allocates a new Vector3 per call
  24686. * @param i defines the facet index
  24687. * @returns a new Vector3
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24689. */
  24690. getFacetPosition(i: number): Vector3;
  24691. /**
  24692. * Sets the reference Vector3 with the i-th facet position in the world system
  24693. * @param i defines the facet index
  24694. * @param ref defines the target vector
  24695. * @returns the current mesh
  24696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24697. */
  24698. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24699. /**
  24700. * Returns the i-th facet normal in the world system.
  24701. * This method allocates a new Vector3 per call
  24702. * @param i defines the facet index
  24703. * @returns a new Vector3
  24704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24705. */
  24706. getFacetNormal(i: number): Vector3;
  24707. /**
  24708. * Sets the reference Vector3 with the i-th facet normal in the world system
  24709. * @param i defines the facet index
  24710. * @param ref defines the target vector
  24711. * @returns the current mesh
  24712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24713. */
  24714. getFacetNormalToRef(i: number, ref: Vector3): this;
  24715. /**
  24716. * 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)
  24717. * @param x defines x coordinate
  24718. * @param y defines y coordinate
  24719. * @param z defines z coordinate
  24720. * @returns the array of facet indexes
  24721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24722. */
  24723. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24724. /**
  24725. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24726. * @param projected sets as the (x,y,z) world projection on the facet
  24727. * @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
  24728. * @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
  24729. * @param x defines x coordinate
  24730. * @param y defines y coordinate
  24731. * @param z defines z coordinate
  24732. * @returns the face index if found (or null instead)
  24733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24734. */
  24735. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24736. /**
  24737. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24738. * @param projected sets as the (x,y,z) local projection on the facet
  24739. * @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
  24740. * @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
  24741. * @param x defines x coordinate
  24742. * @param y defines y coordinate
  24743. * @param z defines z coordinate
  24744. * @returns the face index if found (or null instead)
  24745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24746. */
  24747. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24748. /**
  24749. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24750. * @returns the parameters
  24751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24752. */
  24753. getFacetDataParameters(): any;
  24754. /**
  24755. * Disables the feature FacetData and frees the related memory
  24756. * @returns the current mesh
  24757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24758. */
  24759. disableFacetData(): AbstractMesh;
  24760. /**
  24761. * Updates the AbstractMesh indices array
  24762. * @param indices defines the data source
  24763. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24764. * @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)
  24765. * @returns the current mesh
  24766. */
  24767. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24768. /**
  24769. * Creates new normals data for the mesh
  24770. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24771. * @returns the current mesh
  24772. */
  24773. createNormals(updatable: boolean): AbstractMesh;
  24774. /**
  24775. * Align the mesh with a normal
  24776. * @param normal defines the normal to use
  24777. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24778. * @returns the current mesh
  24779. */
  24780. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24781. /** @hidden */ private _checkOcclusionQuery(): boolean;
  24782. /**
  24783. * Disables the mesh edge rendering mode
  24784. * @returns the currentAbstractMesh
  24785. */
  24786. disableEdgesRendering(): AbstractMesh;
  24787. /**
  24788. * Enables the edge rendering mode on the mesh.
  24789. * This mode makes the mesh edges visible
  24790. * @param epsilon defines the maximal distance between two angles to detect a face
  24791. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  24792. * @returns the currentAbstractMesh
  24793. * @see https://www.babylonjs-playground.com/#19O9TU#0
  24794. */
  24795. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  24796. }
  24797. }
  24798. declare module BABYLON {
  24799. /**
  24800. * Interface used to define ActionEvent
  24801. */
  24802. export interface IActionEvent {
  24803. /** The mesh or sprite that triggered the action */
  24804. source: any;
  24805. /** The X mouse cursor position at the time of the event */
  24806. pointerX: number;
  24807. /** The Y mouse cursor position at the time of the event */
  24808. pointerY: number;
  24809. /** The mesh that is currently pointed at (can be null) */
  24810. meshUnderPointer: Nullable<AbstractMesh>;
  24811. /** the original (browser) event that triggered the ActionEvent */
  24812. sourceEvent?: any;
  24813. /** additional data for the event */
  24814. additionalData?: any;
  24815. }
  24816. /**
  24817. * ActionEvent is the event being sent when an action is triggered.
  24818. */
  24819. export class ActionEvent implements IActionEvent {
  24820. /** The mesh or sprite that triggered the action */
  24821. source: any;
  24822. /** The X mouse cursor position at the time of the event */
  24823. pointerX: number;
  24824. /** The Y mouse cursor position at the time of the event */
  24825. pointerY: number;
  24826. /** The mesh that is currently pointed at (can be null) */
  24827. meshUnderPointer: Nullable<AbstractMesh>;
  24828. /** the original (browser) event that triggered the ActionEvent */
  24829. sourceEvent?: any;
  24830. /** additional data for the event */
  24831. additionalData?: any;
  24832. /**
  24833. * Creates a new ActionEvent
  24834. * @param source The mesh or sprite that triggered the action
  24835. * @param pointerX The X mouse cursor position at the time of the event
  24836. * @param pointerY The Y mouse cursor position at the time of the event
  24837. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24838. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24839. * @param additionalData additional data for the event
  24840. */
  24841. constructor(
  24842. /** The mesh or sprite that triggered the action */
  24843. source: any,
  24844. /** The X mouse cursor position at the time of the event */
  24845. pointerX: number,
  24846. /** The Y mouse cursor position at the time of the event */
  24847. pointerY: number,
  24848. /** The mesh that is currently pointed at (can be null) */
  24849. meshUnderPointer: Nullable<AbstractMesh>,
  24850. /** the original (browser) event that triggered the ActionEvent */
  24851. sourceEvent?: any,
  24852. /** additional data for the event */
  24853. additionalData?: any);
  24854. /**
  24855. * Helper function to auto-create an ActionEvent from a source mesh.
  24856. * @param source The source mesh that triggered the event
  24857. * @param evt The original (browser) event
  24858. * @param additionalData additional data for the event
  24859. * @returns the new ActionEvent
  24860. */
  24861. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24862. /**
  24863. * Helper function to auto-create an ActionEvent from a source sprite
  24864. * @param source The source sprite that triggered the event
  24865. * @param scene Scene associated with the sprite
  24866. * @param evt The original (browser) event
  24867. * @param additionalData additional data for the event
  24868. * @returns the new ActionEvent
  24869. */
  24870. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24871. /**
  24872. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24873. * @param scene the scene where the event occurred
  24874. * @param evt The original (browser) event
  24875. * @returns the new ActionEvent
  24876. */
  24877. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24878. /**
  24879. * Helper function to auto-create an ActionEvent from a primitive
  24880. * @param prim defines the target primitive
  24881. * @param pointerPos defines the pointer position
  24882. * @param evt The original (browser) event
  24883. * @param additionalData additional data for the event
  24884. * @returns the new ActionEvent
  24885. */
  24886. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24887. }
  24888. }
  24889. declare module BABYLON {
  24890. /**
  24891. * Abstract class used to decouple action Manager from scene and meshes.
  24892. * Do not instantiate.
  24893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24894. */
  24895. export abstract class AbstractActionManager implements IDisposable {
  24896. /** Gets the list of active triggers */
  24897. static Triggers: {
  24898. [key: string]: number;
  24899. };
  24900. /** Gets the cursor to use when hovering items */
  24901. hoverCursor: string;
  24902. /** Gets the list of actions */
  24903. actions: IAction[];
  24904. /**
  24905. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24906. */
  24907. isRecursive: boolean;
  24908. /**
  24909. * Releases all associated resources
  24910. */
  24911. abstract dispose(): void;
  24912. /**
  24913. * Does this action manager has pointer triggers
  24914. */
  24915. abstract readonly hasPointerTriggers: boolean;
  24916. /**
  24917. * Does this action manager has pick triggers
  24918. */
  24919. abstract readonly hasPickTriggers: boolean;
  24920. /**
  24921. * Process a specific trigger
  24922. * @param trigger defines the trigger to process
  24923. * @param evt defines the event details to be processed
  24924. */
  24925. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24926. /**
  24927. * Does this action manager handles actions of any of the given triggers
  24928. * @param triggers defines the triggers to be tested
  24929. * @return a boolean indicating whether one (or more) of the triggers is handled
  24930. */
  24931. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24932. /**
  24933. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24934. * speed.
  24935. * @param triggerA defines the trigger to be tested
  24936. * @param triggerB defines the trigger to be tested
  24937. * @return a boolean indicating whether one (or more) of the triggers is handled
  24938. */
  24939. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24940. /**
  24941. * Does this action manager handles actions of a given trigger
  24942. * @param trigger defines the trigger to be tested
  24943. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24944. * @return whether the trigger is handled
  24945. */
  24946. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24947. /**
  24948. * Serialize this manager to a JSON object
  24949. * @param name defines the property name to store this manager
  24950. * @returns a JSON representation of this manager
  24951. */
  24952. abstract serialize(name: string): any;
  24953. /**
  24954. * Registers an action to this action manager
  24955. * @param action defines the action to be registered
  24956. * @return the action amended (prepared) after registration
  24957. */
  24958. abstract registerAction(action: IAction): Nullable<IAction>;
  24959. /**
  24960. * Unregisters an action to this action manager
  24961. * @param action defines the action to be unregistered
  24962. * @return a boolean indicating whether the action has been unregistered
  24963. */
  24964. abstract unregisterAction(action: IAction): Boolean;
  24965. /**
  24966. * Does exist one action manager with at least one trigger
  24967. **/
  24968. static readonly HasTriggers: boolean;
  24969. /**
  24970. * Does exist one action manager with at least one pick trigger
  24971. **/
  24972. static readonly HasPickTriggers: boolean;
  24973. /**
  24974. * Does exist one action manager that handles actions of a given trigger
  24975. * @param trigger defines the trigger to be tested
  24976. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24977. **/
  24978. static HasSpecificTrigger(trigger: number): boolean;
  24979. }
  24980. }
  24981. declare module BABYLON {
  24982. /**
  24983. * Defines how a node can be built from a string name.
  24984. */
  24985. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24986. /**
  24987. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24988. */
  24989. export class Node implements IBehaviorAware<Node> {
  24990. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24991. private static _NodeConstructors;
  24992. /**
  24993. * Add a new node constructor
  24994. * @param type defines the type name of the node to construct
  24995. * @param constructorFunc defines the constructor function
  24996. */
  24997. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24998. /**
  24999. * Returns a node constructor based on type name
  25000. * @param type defines the type name
  25001. * @param name defines the new node name
  25002. * @param scene defines the hosting scene
  25003. * @param options defines optional options to transmit to constructors
  25004. * @returns the new constructor or null
  25005. */
  25006. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25007. /**
  25008. * Gets or sets the name of the node
  25009. */
  25010. name: string;
  25011. /**
  25012. * Gets or sets the id of the node
  25013. */
  25014. id: string;
  25015. /**
  25016. * Gets or sets the unique id of the node
  25017. */
  25018. uniqueId: number;
  25019. /**
  25020. * Gets or sets a string used to store user defined state for the node
  25021. */
  25022. state: string;
  25023. /**
  25024. * Gets or sets an object used to store user defined information for the node
  25025. */
  25026. metadata: any;
  25027. /**
  25028. * For internal use only. Please do not use.
  25029. */
  25030. reservedDataStore: any;
  25031. /**
  25032. * List of inspectable custom properties (used by the Inspector)
  25033. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25034. */
  25035. inspectableCustomProperties: IInspectable[];
  25036. /**
  25037. * Gets or sets a boolean used to define if the node must be serialized
  25038. */
  25039. doNotSerialize: boolean;
  25040. /** @hidden */ private _isDisposed: boolean;
  25041. /**
  25042. * Gets a list of Animations associated with the node
  25043. */
  25044. animations: Animation[];
  25045. protected _ranges: {
  25046. [name: string]: Nullable<AnimationRange>;
  25047. };
  25048. /**
  25049. * Callback raised when the node is ready to be used
  25050. */
  25051. onReady: Nullable<(node: Node) => void>;
  25052. private _isEnabled;
  25053. private _isParentEnabled;
  25054. private _isReady;
  25055. /** @hidden */ private _currentRenderId: number;
  25056. private _parentUpdateId;
  25057. /** @hidden */ private _childUpdateId: number;
  25058. /** @hidden */ private _waitingParentId: Nullable<string>;
  25059. /** @hidden */ private _scene: Scene;
  25060. /** @hidden */ private _cache: any;
  25061. private _parentNode;
  25062. private _children;
  25063. /** @hidden */ private _worldMatrix: Matrix;
  25064. /** @hidden */ private _worldMatrixDeterminant: number;
  25065. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  25066. /** @hidden */
  25067. private _sceneRootNodesIndex;
  25068. /**
  25069. * Gets a boolean indicating if the node has been disposed
  25070. * @returns true if the node was disposed
  25071. */
  25072. isDisposed(): boolean;
  25073. /**
  25074. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25075. * @see https://doc.babylonjs.com/how_to/parenting
  25076. */
  25077. parent: Nullable<Node>;
  25078. private addToSceneRootNodes;
  25079. private removeFromSceneRootNodes;
  25080. private _animationPropertiesOverride;
  25081. /**
  25082. * Gets or sets the animation properties override
  25083. */
  25084. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25085. /**
  25086. * Gets a string idenfifying the name of the class
  25087. * @returns "Node" string
  25088. */
  25089. getClassName(): string;
  25090. /** @hidden */ protected readonly _isNode: boolean;
  25091. /**
  25092. * An event triggered when the mesh is disposed
  25093. */
  25094. onDisposeObservable: Observable<Node>;
  25095. private _onDisposeObserver;
  25096. /**
  25097. * Sets a callback that will be raised when the node will be disposed
  25098. */
  25099. onDispose: () => void;
  25100. /**
  25101. * Creates a new Node
  25102. * @param name the name and id to be given to this node
  25103. * @param scene the scene this node will be added to
  25104. * @param addToRootNodes the node will be added to scene.rootNodes
  25105. */
  25106. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25107. /**
  25108. * Gets the scene of the node
  25109. * @returns a scene
  25110. */
  25111. getScene(): Scene;
  25112. /**
  25113. * Gets the engine of the node
  25114. * @returns a Engine
  25115. */
  25116. getEngine(): Engine;
  25117. private _behaviors;
  25118. /**
  25119. * Attach a behavior to the node
  25120. * @see http://doc.babylonjs.com/features/behaviour
  25121. * @param behavior defines the behavior to attach
  25122. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25123. * @returns the current Node
  25124. */
  25125. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25126. /**
  25127. * Remove an attached behavior
  25128. * @see http://doc.babylonjs.com/features/behaviour
  25129. * @param behavior defines the behavior to attach
  25130. * @returns the current Node
  25131. */
  25132. removeBehavior(behavior: Behavior<Node>): Node;
  25133. /**
  25134. * Gets the list of attached behaviors
  25135. * @see http://doc.babylonjs.com/features/behaviour
  25136. */
  25137. readonly behaviors: Behavior<Node>[];
  25138. /**
  25139. * Gets an attached behavior by name
  25140. * @param name defines the name of the behavior to look for
  25141. * @see http://doc.babylonjs.com/features/behaviour
  25142. * @returns null if behavior was not found else the requested behavior
  25143. */
  25144. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25145. /**
  25146. * Returns the latest update of the World matrix
  25147. * @returns a Matrix
  25148. */
  25149. getWorldMatrix(): Matrix;
  25150. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25151. /**
  25152. * Returns directly the latest state of the mesh World matrix.
  25153. * A Matrix is returned.
  25154. */
  25155. readonly worldMatrixFromCache: Matrix;
  25156. /** @hidden */ private _initCache(): void;
  25157. /** @hidden */
  25158. updateCache(force?: boolean): void;
  25159. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25160. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  25161. /** @hidden */ private _isSynchronized(): boolean;
  25162. /** @hidden */ private _markSyncedWithParent(): void;
  25163. /** @hidden */
  25164. isSynchronizedWithParent(): boolean;
  25165. /** @hidden */
  25166. isSynchronized(): boolean;
  25167. /**
  25168. * Is this node ready to be used/rendered
  25169. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25170. * @return true if the node is ready
  25171. */
  25172. isReady(completeCheck?: boolean): boolean;
  25173. /**
  25174. * Is this node enabled?
  25175. * 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
  25176. * @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
  25177. * @return whether this node (and its parent) is enabled
  25178. */
  25179. isEnabled(checkAncestors?: boolean): boolean;
  25180. /** @hidden */
  25181. protected _syncParentEnabledState(): void;
  25182. /**
  25183. * Set the enabled state of this node
  25184. * @param value defines the new enabled state
  25185. */
  25186. setEnabled(value: boolean): void;
  25187. /**
  25188. * Is this node a descendant of the given node?
  25189. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25190. * @param ancestor defines the parent node to inspect
  25191. * @returns a boolean indicating if this node is a descendant of the given node
  25192. */
  25193. isDescendantOf(ancestor: Node): boolean;
  25194. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25195. /**
  25196. * Will return all nodes that have this node as ascendant
  25197. * @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
  25198. * @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
  25199. * @return all children nodes of all types
  25200. */
  25201. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25202. /**
  25203. * Get all child-meshes of this node
  25204. * @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)
  25205. * @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
  25206. * @returns an array of AbstractMesh
  25207. */
  25208. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25209. /**
  25210. * Get all direct children of this node
  25211. * @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
  25212. * @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)
  25213. * @returns an array of Node
  25214. */
  25215. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25216. /** @hidden */ private _setReady(state: boolean): void;
  25217. /**
  25218. * Get an animation by name
  25219. * @param name defines the name of the animation to look for
  25220. * @returns null if not found else the requested animation
  25221. */
  25222. getAnimationByName(name: string): Nullable<Animation>;
  25223. /**
  25224. * Creates an animation range for this node
  25225. * @param name defines the name of the range
  25226. * @param from defines the starting key
  25227. * @param to defines the end key
  25228. */
  25229. createAnimationRange(name: string, from: number, to: number): void;
  25230. /**
  25231. * Delete a specific animation range
  25232. * @param name defines the name of the range to delete
  25233. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25234. */
  25235. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25236. /**
  25237. * Get an animation range by name
  25238. * @param name defines the name of the animation range to look for
  25239. * @returns null if not found else the requested animation range
  25240. */
  25241. getAnimationRange(name: string): Nullable<AnimationRange>;
  25242. /**
  25243. * Gets the list of all animation ranges defined on this node
  25244. * @returns an array
  25245. */
  25246. getAnimationRanges(): Nullable<AnimationRange>[];
  25247. /**
  25248. * Will start the animation sequence
  25249. * @param name defines the range frames for animation sequence
  25250. * @param loop defines if the animation should loop (false by default)
  25251. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25252. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25253. * @returns the object created for this animation. If range does not exist, it will return null
  25254. */
  25255. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25256. /**
  25257. * Serialize animation ranges into a JSON compatible object
  25258. * @returns serialization object
  25259. */
  25260. serializeAnimationRanges(): any;
  25261. /**
  25262. * Computes the world matrix of the node
  25263. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25264. * @returns the world matrix
  25265. */
  25266. computeWorldMatrix(force?: boolean): Matrix;
  25267. /**
  25268. * Releases resources associated with this node.
  25269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25271. */
  25272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25273. /**
  25274. * Parse animation range data from a serialization object and store them into a given node
  25275. * @param node defines where to store the animation ranges
  25276. * @param parsedNode defines the serialization object to read data from
  25277. * @param scene defines the hosting scene
  25278. */
  25279. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25280. /**
  25281. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25282. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25283. * @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
  25284. * @returns the new bounding vectors
  25285. */
  25286. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25287. min: Vector3;
  25288. max: Vector3;
  25289. };
  25290. }
  25291. }
  25292. declare module BABYLON {
  25293. /**
  25294. * @hidden
  25295. */
  25296. export class _IAnimationState {
  25297. key: number;
  25298. repeatCount: number;
  25299. workValue?: any;
  25300. loopMode?: number;
  25301. offsetValue?: any;
  25302. highLimitValue?: any;
  25303. }
  25304. /**
  25305. * Class used to store any kind of animation
  25306. */
  25307. export class Animation {
  25308. /**Name of the animation */
  25309. name: string;
  25310. /**Property to animate */
  25311. targetProperty: string;
  25312. /**The frames per second of the animation */
  25313. framePerSecond: number;
  25314. /**The data type of the animation */
  25315. dataType: number;
  25316. /**The loop mode of the animation */
  25317. loopMode?: number | undefined;
  25318. /**Specifies if blending should be enabled */
  25319. enableBlending?: boolean | undefined;
  25320. /**
  25321. * Use matrix interpolation instead of using direct key value when animating matrices
  25322. */
  25323. static AllowMatricesInterpolation: boolean;
  25324. /**
  25325. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25326. */
  25327. static AllowMatrixDecomposeForInterpolation: boolean;
  25328. /**
  25329. * Stores the key frames of the animation
  25330. */
  25331. private _keys;
  25332. /**
  25333. * Stores the easing function of the animation
  25334. */
  25335. private _easingFunction;
  25336. /**
  25337. * @hidden Internal use only
  25338. */ private _runtimeAnimations: RuntimeAnimation[];
  25339. /**
  25340. * The set of event that will be linked to this animation
  25341. */
  25342. private _events;
  25343. /**
  25344. * Stores an array of target property paths
  25345. */
  25346. targetPropertyPath: string[];
  25347. /**
  25348. * Stores the blending speed of the animation
  25349. */
  25350. blendingSpeed: number;
  25351. /**
  25352. * Stores the animation ranges for the animation
  25353. */
  25354. private _ranges;
  25355. /**
  25356. * @hidden Internal use
  25357. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25358. /**
  25359. * Sets up an animation
  25360. * @param property The property to animate
  25361. * @param animationType The animation type to apply
  25362. * @param framePerSecond The frames per second of the animation
  25363. * @param easingFunction The easing function used in the animation
  25364. * @returns The created animation
  25365. */
  25366. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25367. /**
  25368. * Create and start an animation on a node
  25369. * @param name defines the name of the global animation that will be run on all nodes
  25370. * @param node defines the root node where the animation will take place
  25371. * @param targetProperty defines property to animate
  25372. * @param framePerSecond defines the number of frame per second yo use
  25373. * @param totalFrame defines the number of frames in total
  25374. * @param from defines the initial value
  25375. * @param to defines the final value
  25376. * @param loopMode defines which loop mode you want to use (off by default)
  25377. * @param easingFunction defines the easing function to use (linear by default)
  25378. * @param onAnimationEnd defines the callback to call when animation end
  25379. * @returns the animatable created for this animation
  25380. */
  25381. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25382. /**
  25383. * Create and start an animation on a node and its descendants
  25384. * @param name defines the name of the global animation that will be run on all nodes
  25385. * @param node defines the root node where the animation will take place
  25386. * @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
  25387. * @param targetProperty defines property to animate
  25388. * @param framePerSecond defines the number of frame per second to use
  25389. * @param totalFrame defines the number of frames in total
  25390. * @param from defines the initial value
  25391. * @param to defines the final value
  25392. * @param loopMode defines which loop mode you want to use (off by default)
  25393. * @param easingFunction defines the easing function to use (linear by default)
  25394. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25395. * @returns the list of animatables created for all nodes
  25396. * @example https://www.babylonjs-playground.com/#MH0VLI
  25397. */
  25398. 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[]>;
  25399. /**
  25400. * Creates a new animation, merges it with the existing animations and starts it
  25401. * @param name Name of the animation
  25402. * @param node Node which contains the scene that begins the animations
  25403. * @param targetProperty Specifies which property to animate
  25404. * @param framePerSecond The frames per second of the animation
  25405. * @param totalFrame The total number of frames
  25406. * @param from The frame at the beginning of the animation
  25407. * @param to The frame at the end of the animation
  25408. * @param loopMode Specifies the loop mode of the animation
  25409. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25410. * @param onAnimationEnd Callback to run once the animation is complete
  25411. * @returns Nullable animation
  25412. */
  25413. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25414. /**
  25415. * Transition property of an host to the target Value
  25416. * @param property The property to transition
  25417. * @param targetValue The target Value of the property
  25418. * @param host The object where the property to animate belongs
  25419. * @param scene Scene used to run the animation
  25420. * @param frameRate Framerate (in frame/s) to use
  25421. * @param transition The transition type we want to use
  25422. * @param duration The duration of the animation, in milliseconds
  25423. * @param onAnimationEnd Callback trigger at the end of the animation
  25424. * @returns Nullable animation
  25425. */
  25426. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25427. /**
  25428. * Return the array of runtime animations currently using this animation
  25429. */
  25430. readonly runtimeAnimations: RuntimeAnimation[];
  25431. /**
  25432. * Specifies if any of the runtime animations are currently running
  25433. */
  25434. readonly hasRunningRuntimeAnimations: boolean;
  25435. /**
  25436. * Initializes the animation
  25437. * @param name Name of the animation
  25438. * @param targetProperty Property to animate
  25439. * @param framePerSecond The frames per second of the animation
  25440. * @param dataType The data type of the animation
  25441. * @param loopMode The loop mode of the animation
  25442. * @param enableBlending Specifies if blending should be enabled
  25443. */
  25444. constructor(
  25445. /**Name of the animation */
  25446. name: string,
  25447. /**Property to animate */
  25448. targetProperty: string,
  25449. /**The frames per second of the animation */
  25450. framePerSecond: number,
  25451. /**The data type of the animation */
  25452. dataType: number,
  25453. /**The loop mode of the animation */
  25454. loopMode?: number | undefined,
  25455. /**Specifies if blending should be enabled */
  25456. enableBlending?: boolean | undefined);
  25457. /**
  25458. * Converts the animation to a string
  25459. * @param fullDetails support for multiple levels of logging within scene loading
  25460. * @returns String form of the animation
  25461. */
  25462. toString(fullDetails?: boolean): string;
  25463. /**
  25464. * Add an event to this animation
  25465. * @param event Event to add
  25466. */
  25467. addEvent(event: AnimationEvent): void;
  25468. /**
  25469. * Remove all events found at the given frame
  25470. * @param frame The frame to remove events from
  25471. */
  25472. removeEvents(frame: number): void;
  25473. /**
  25474. * Retrieves all the events from the animation
  25475. * @returns Events from the animation
  25476. */
  25477. getEvents(): AnimationEvent[];
  25478. /**
  25479. * Creates an animation range
  25480. * @param name Name of the animation range
  25481. * @param from Starting frame of the animation range
  25482. * @param to Ending frame of the animation
  25483. */
  25484. createRange(name: string, from: number, to: number): void;
  25485. /**
  25486. * Deletes an animation range by name
  25487. * @param name Name of the animation range to delete
  25488. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25489. */
  25490. deleteRange(name: string, deleteFrames?: boolean): void;
  25491. /**
  25492. * Gets the animation range by name, or null if not defined
  25493. * @param name Name of the animation range
  25494. * @returns Nullable animation range
  25495. */
  25496. getRange(name: string): Nullable<AnimationRange>;
  25497. /**
  25498. * Gets the key frames from the animation
  25499. * @returns The key frames of the animation
  25500. */
  25501. getKeys(): Array<IAnimationKey>;
  25502. /**
  25503. * Gets the highest frame rate of the animation
  25504. * @returns Highest frame rate of the animation
  25505. */
  25506. getHighestFrame(): number;
  25507. /**
  25508. * Gets the easing function of the animation
  25509. * @returns Easing function of the animation
  25510. */
  25511. getEasingFunction(): IEasingFunction;
  25512. /**
  25513. * Sets the easing function of the animation
  25514. * @param easingFunction A custom mathematical formula for animation
  25515. */
  25516. setEasingFunction(easingFunction: EasingFunction): void;
  25517. /**
  25518. * Interpolates a scalar linearly
  25519. * @param startValue Start value of the animation curve
  25520. * @param endValue End value of the animation curve
  25521. * @param gradient Scalar amount to interpolate
  25522. * @returns Interpolated scalar value
  25523. */
  25524. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25525. /**
  25526. * Interpolates a scalar cubically
  25527. * @param startValue Start value of the animation curve
  25528. * @param outTangent End tangent of the animation
  25529. * @param endValue End value of the animation curve
  25530. * @param inTangent Start tangent of the animation curve
  25531. * @param gradient Scalar amount to interpolate
  25532. * @returns Interpolated scalar value
  25533. */
  25534. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25535. /**
  25536. * Interpolates a quaternion using a spherical linear interpolation
  25537. * @param startValue Start value of the animation curve
  25538. * @param endValue End value of the animation curve
  25539. * @param gradient Scalar amount to interpolate
  25540. * @returns Interpolated quaternion value
  25541. */
  25542. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25543. /**
  25544. * Interpolates a quaternion cubically
  25545. * @param startValue Start value of the animation curve
  25546. * @param outTangent End tangent of the animation curve
  25547. * @param endValue End value of the animation curve
  25548. * @param inTangent Start tangent of the animation curve
  25549. * @param gradient Scalar amount to interpolate
  25550. * @returns Interpolated quaternion value
  25551. */
  25552. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25553. /**
  25554. * Interpolates a Vector3 linearl
  25555. * @param startValue Start value of the animation curve
  25556. * @param endValue End value of the animation curve
  25557. * @param gradient Scalar amount to interpolate
  25558. * @returns Interpolated scalar value
  25559. */
  25560. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25561. /**
  25562. * Interpolates a Vector3 cubically
  25563. * @param startValue Start value of the animation curve
  25564. * @param outTangent End tangent of the animation
  25565. * @param endValue End value of the animation curve
  25566. * @param inTangent Start tangent of the animation curve
  25567. * @param gradient Scalar amount to interpolate
  25568. * @returns InterpolatedVector3 value
  25569. */
  25570. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25571. /**
  25572. * Interpolates a Vector2 linearly
  25573. * @param startValue Start value of the animation curve
  25574. * @param endValue End value of the animation curve
  25575. * @param gradient Scalar amount to interpolate
  25576. * @returns Interpolated Vector2 value
  25577. */
  25578. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25579. /**
  25580. * Interpolates a Vector2 cubically
  25581. * @param startValue Start value of the animation curve
  25582. * @param outTangent End tangent of the animation
  25583. * @param endValue End value of the animation curve
  25584. * @param inTangent Start tangent of the animation curve
  25585. * @param gradient Scalar amount to interpolate
  25586. * @returns Interpolated Vector2 value
  25587. */
  25588. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25589. /**
  25590. * Interpolates a size linearly
  25591. * @param startValue Start value of the animation curve
  25592. * @param endValue End value of the animation curve
  25593. * @param gradient Scalar amount to interpolate
  25594. * @returns Interpolated Size value
  25595. */
  25596. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25597. /**
  25598. * Interpolates a Color3 linearly
  25599. * @param startValue Start value of the animation curve
  25600. * @param endValue End value of the animation curve
  25601. * @param gradient Scalar amount to interpolate
  25602. * @returns Interpolated Color3 value
  25603. */
  25604. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25605. /**
  25606. * @hidden Internal use only
  25607. */ private _getKeyValue(value: any): any;
  25608. /**
  25609. * @hidden Internal use only
  25610. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  25611. /**
  25612. * Defines the function to use to interpolate matrices
  25613. * @param startValue defines the start matrix
  25614. * @param endValue defines the end matrix
  25615. * @param gradient defines the gradient between both matrices
  25616. * @param result defines an optional target matrix where to store the interpolation
  25617. * @returns the interpolated matrix
  25618. */
  25619. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25620. /**
  25621. * Makes a copy of the animation
  25622. * @returns Cloned animation
  25623. */
  25624. clone(): Animation;
  25625. /**
  25626. * Sets the key frames of the animation
  25627. * @param values The animation key frames to set
  25628. */
  25629. setKeys(values: Array<IAnimationKey>): void;
  25630. /**
  25631. * Serializes the animation to an object
  25632. * @returns Serialized object
  25633. */
  25634. serialize(): any;
  25635. /**
  25636. * Float animation type
  25637. */
  25638. private static _ANIMATIONTYPE_FLOAT;
  25639. /**
  25640. * Vector3 animation type
  25641. */
  25642. private static _ANIMATIONTYPE_VECTOR3;
  25643. /**
  25644. * Quaternion animation type
  25645. */
  25646. private static _ANIMATIONTYPE_QUATERNION;
  25647. /**
  25648. * Matrix animation type
  25649. */
  25650. private static _ANIMATIONTYPE_MATRIX;
  25651. /**
  25652. * Color3 animation type
  25653. */
  25654. private static _ANIMATIONTYPE_COLOR3;
  25655. /**
  25656. * Vector2 animation type
  25657. */
  25658. private static _ANIMATIONTYPE_VECTOR2;
  25659. /**
  25660. * Size animation type
  25661. */
  25662. private static _ANIMATIONTYPE_SIZE;
  25663. /**
  25664. * Relative Loop Mode
  25665. */
  25666. private static _ANIMATIONLOOPMODE_RELATIVE;
  25667. /**
  25668. * Cycle Loop Mode
  25669. */
  25670. private static _ANIMATIONLOOPMODE_CYCLE;
  25671. /**
  25672. * Constant Loop Mode
  25673. */
  25674. private static _ANIMATIONLOOPMODE_CONSTANT;
  25675. /**
  25676. * Get the float animation type
  25677. */
  25678. static readonly ANIMATIONTYPE_FLOAT: number;
  25679. /**
  25680. * Get the Vector3 animation type
  25681. */
  25682. static readonly ANIMATIONTYPE_VECTOR3: number;
  25683. /**
  25684. * Get the Vector2 animation type
  25685. */
  25686. static readonly ANIMATIONTYPE_VECTOR2: number;
  25687. /**
  25688. * Get the Size animation type
  25689. */
  25690. static readonly ANIMATIONTYPE_SIZE: number;
  25691. /**
  25692. * Get the Quaternion animation type
  25693. */
  25694. static readonly ANIMATIONTYPE_QUATERNION: number;
  25695. /**
  25696. * Get the Matrix animation type
  25697. */
  25698. static readonly ANIMATIONTYPE_MATRIX: number;
  25699. /**
  25700. * Get the Color3 animation type
  25701. */
  25702. static readonly ANIMATIONTYPE_COLOR3: number;
  25703. /**
  25704. * Get the Relative Loop Mode
  25705. */
  25706. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25707. /**
  25708. * Get the Cycle Loop Mode
  25709. */
  25710. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25711. /**
  25712. * Get the Constant Loop Mode
  25713. */
  25714. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25715. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25716. /**
  25717. * Parses an animation object and creates an animation
  25718. * @param parsedAnimation Parsed animation object
  25719. * @returns Animation object
  25720. */
  25721. static Parse(parsedAnimation: any): Animation;
  25722. /**
  25723. * Appends the serialized animations from the source animations
  25724. * @param source Source containing the animations
  25725. * @param destination Target to store the animations
  25726. */
  25727. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25728. }
  25729. }
  25730. declare module BABYLON {
  25731. /**
  25732. * Base class of all the textures in babylon.
  25733. * It groups all the common properties the materials, post process, lights... might need
  25734. * in order to make a correct use of the texture.
  25735. */
  25736. export class BaseTexture implements IAnimatable {
  25737. /**
  25738. * Default anisotropic filtering level for the application.
  25739. * It is set to 4 as a good tradeoff between perf and quality.
  25740. */
  25741. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25742. /**
  25743. * Gets or sets the unique id of the texture
  25744. */
  25745. uniqueId: number;
  25746. /**
  25747. * Define the name of the texture.
  25748. */
  25749. name: string;
  25750. /**
  25751. * Gets or sets an object used to store user defined information.
  25752. */
  25753. metadata: any;
  25754. /**
  25755. * For internal use only. Please do not use.
  25756. */
  25757. reservedDataStore: any;
  25758. private _hasAlpha;
  25759. /**
  25760. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25761. */
  25762. hasAlpha: boolean;
  25763. /**
  25764. * Defines if the alpha value should be determined via the rgb values.
  25765. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25766. */
  25767. getAlphaFromRGB: boolean;
  25768. /**
  25769. * Intensity or strength of the texture.
  25770. * It is commonly used by materials to fine tune the intensity of the texture
  25771. */
  25772. level: number;
  25773. /**
  25774. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25775. * This is part of the texture as textures usually maps to one uv set.
  25776. */
  25777. coordinatesIndex: number;
  25778. private _coordinatesMode;
  25779. /**
  25780. * How a texture is mapped.
  25781. *
  25782. * | Value | Type | Description |
  25783. * | ----- | ----------------------------------- | ----------- |
  25784. * | 0 | EXPLICIT_MODE | |
  25785. * | 1 | SPHERICAL_MODE | |
  25786. * | 2 | PLANAR_MODE | |
  25787. * | 3 | CUBIC_MODE | |
  25788. * | 4 | PROJECTION_MODE | |
  25789. * | 5 | SKYBOX_MODE | |
  25790. * | 6 | INVCUBIC_MODE | |
  25791. * | 7 | EQUIRECTANGULAR_MODE | |
  25792. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25793. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25794. */
  25795. coordinatesMode: number;
  25796. /**
  25797. * | Value | Type | Description |
  25798. * | ----- | ------------------ | ----------- |
  25799. * | 0 | CLAMP_ADDRESSMODE | |
  25800. * | 1 | WRAP_ADDRESSMODE | |
  25801. * | 2 | MIRROR_ADDRESSMODE | |
  25802. */
  25803. wrapU: number;
  25804. /**
  25805. * | Value | Type | Description |
  25806. * | ----- | ------------------ | ----------- |
  25807. * | 0 | CLAMP_ADDRESSMODE | |
  25808. * | 1 | WRAP_ADDRESSMODE | |
  25809. * | 2 | MIRROR_ADDRESSMODE | |
  25810. */
  25811. wrapV: number;
  25812. /**
  25813. * | Value | Type | Description |
  25814. * | ----- | ------------------ | ----------- |
  25815. * | 0 | CLAMP_ADDRESSMODE | |
  25816. * | 1 | WRAP_ADDRESSMODE | |
  25817. * | 2 | MIRROR_ADDRESSMODE | |
  25818. */
  25819. wrapR: number;
  25820. /**
  25821. * With compliant hardware and browser (supporting anisotropic filtering)
  25822. * this defines the level of anisotropic filtering in the texture.
  25823. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25824. */
  25825. anisotropicFilteringLevel: number;
  25826. /**
  25827. * Define if the texture is a cube texture or if false a 2d texture.
  25828. */
  25829. isCube: boolean;
  25830. /**
  25831. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25832. */
  25833. is3D: boolean;
  25834. /**
  25835. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25836. * HDR texture are usually stored in linear space.
  25837. * This only impacts the PBR and Background materials
  25838. */
  25839. gammaSpace: boolean;
  25840. /**
  25841. * Gets whether or not the texture contains RGBD data.
  25842. */
  25843. readonly isRGBD: boolean;
  25844. /**
  25845. * Is Z inverted in the texture (useful in a cube texture).
  25846. */
  25847. invertZ: boolean;
  25848. /**
  25849. * Are mip maps generated for this texture or not.
  25850. */
  25851. readonly noMipmap: boolean;
  25852. /**
  25853. * @hidden
  25854. */
  25855. lodLevelInAlpha: boolean;
  25856. /**
  25857. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25858. */
  25859. lodGenerationOffset: number;
  25860. /**
  25861. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25862. */
  25863. lodGenerationScale: number;
  25864. /**
  25865. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  25866. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  25867. * average roughness values.
  25868. */
  25869. linearSpecularLOD: boolean;
  25870. /**
  25871. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  25872. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  25873. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  25874. */
  25875. irradianceTexture: Nullable<BaseTexture>;
  25876. /**
  25877. * Define if the texture is a render target.
  25878. */
  25879. isRenderTarget: boolean;
  25880. /**
  25881. * Define the unique id of the texture in the scene.
  25882. */
  25883. readonly uid: string;
  25884. /**
  25885. * Return a string representation of the texture.
  25886. * @returns the texture as a string
  25887. */
  25888. toString(): string;
  25889. /**
  25890. * Get the class name of the texture.
  25891. * @returns "BaseTexture"
  25892. */
  25893. getClassName(): string;
  25894. /**
  25895. * Define the list of animation attached to the texture.
  25896. */
  25897. animations: Animation[];
  25898. /**
  25899. * An event triggered when the texture is disposed.
  25900. */
  25901. onDisposeObservable: Observable<BaseTexture>;
  25902. private _onDisposeObserver;
  25903. /**
  25904. * Callback triggered when the texture has been disposed.
  25905. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25906. */
  25907. onDispose: () => void;
  25908. /**
  25909. * Define the current state of the loading sequence when in delayed load mode.
  25910. */
  25911. delayLoadState: number;
  25912. private _scene;
  25913. /** @hidden */ private _texture: Nullable<InternalTexture>;
  25914. private _uid;
  25915. /**
  25916. * Define if the texture is preventinga material to render or not.
  25917. * If not and the texture is not ready, the engine will use a default black texture instead.
  25918. */
  25919. readonly isBlocking: boolean;
  25920. /**
  25921. * Instantiates a new BaseTexture.
  25922. * Base class of all the textures in babylon.
  25923. * It groups all the common properties the materials, post process, lights... might need
  25924. * in order to make a correct use of the texture.
  25925. * @param scene Define the scene the texture blongs to
  25926. */
  25927. constructor(scene: Nullable<Scene>);
  25928. /**
  25929. * Get the scene the texture belongs to.
  25930. * @returns the scene or null if undefined
  25931. */
  25932. getScene(): Nullable<Scene>;
  25933. /**
  25934. * Get the texture transform matrix used to offset tile the texture for istance.
  25935. * @returns the transformation matrix
  25936. */
  25937. getTextureMatrix(): Matrix;
  25938. /**
  25939. * Get the texture reflection matrix used to rotate/transform the reflection.
  25940. * @returns the reflection matrix
  25941. */
  25942. getReflectionTextureMatrix(): Matrix;
  25943. /**
  25944. * Get the underlying lower level texture from Babylon.
  25945. * @returns the insternal texture
  25946. */
  25947. getInternalTexture(): Nullable<InternalTexture>;
  25948. /**
  25949. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25950. * @returns true if ready or not blocking
  25951. */
  25952. isReadyOrNotBlocking(): boolean;
  25953. /**
  25954. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25955. * @returns true if fully ready
  25956. */
  25957. isReady(): boolean;
  25958. private _cachedSize;
  25959. /**
  25960. * Get the size of the texture.
  25961. * @returns the texture size.
  25962. */
  25963. getSize(): ISize;
  25964. /**
  25965. * Get the base size of the texture.
  25966. * It can be different from the size if the texture has been resized for POT for instance
  25967. * @returns the base size
  25968. */
  25969. getBaseSize(): ISize;
  25970. /**
  25971. * Update the sampling mode of the texture.
  25972. * Default is Trilinear mode.
  25973. *
  25974. * | Value | Type | Description |
  25975. * | ----- | ------------------ | ----------- |
  25976. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25977. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25978. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25979. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25980. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25981. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25982. * | 7 | NEAREST_LINEAR | |
  25983. * | 8 | NEAREST_NEAREST | |
  25984. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25985. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25986. * | 11 | LINEAR_LINEAR | |
  25987. * | 12 | LINEAR_NEAREST | |
  25988. *
  25989. * > _mag_: magnification filter (close to the viewer)
  25990. * > _min_: minification filter (far from the viewer)
  25991. * > _mip_: filter used between mip map levels
  25992. *@param samplingMode Define the new sampling mode of the texture
  25993. */
  25994. updateSamplingMode(samplingMode: number): void;
  25995. /**
  25996. * Scales the texture if is `canRescale()`
  25997. * @param ratio the resize factor we want to use to rescale
  25998. */
  25999. scale(ratio: number): void;
  26000. /**
  26001. * Get if the texture can rescale.
  26002. */
  26003. readonly canRescale: boolean;
  26004. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26005. /** @hidden */ private _rebuild(): void;
  26006. /**
  26007. * Triggers the load sequence in delayed load mode.
  26008. */
  26009. delayLoad(): void;
  26010. /**
  26011. * Clones the texture.
  26012. * @returns the cloned texture
  26013. */
  26014. clone(): Nullable<BaseTexture>;
  26015. /**
  26016. * Get the texture underlying type (INT, FLOAT...)
  26017. */
  26018. readonly textureType: number;
  26019. /**
  26020. * Get the texture underlying format (RGB, RGBA...)
  26021. */
  26022. readonly textureFormat: number;
  26023. /**
  26024. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26025. * This will returns an RGBA array buffer containing either in values (0-255) or
  26026. * float values (0-1) depending of the underlying buffer type.
  26027. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26028. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26029. * @param buffer defines a user defined buffer to fill with data (can be null)
  26030. * @returns The Array buffer containing the pixels data.
  26031. */
  26032. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26033. /**
  26034. * Release and destroy the underlying lower level texture aka internalTexture.
  26035. */
  26036. releaseInternalTexture(): void;
  26037. /**
  26038. * Get the polynomial representation of the texture data.
  26039. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26040. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26041. */
  26042. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26043. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  26044. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  26045. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  26046. /**
  26047. * Dispose the texture and release its associated resources.
  26048. */
  26049. dispose(): void;
  26050. /**
  26051. * Serialize the texture into a JSON representation that can be parsed later on.
  26052. * @returns the JSON representation of the texture
  26053. */
  26054. serialize(): any;
  26055. /**
  26056. * Helper function to be called back once a list of texture contains only ready textures.
  26057. * @param textures Define the list of textures to wait for
  26058. * @param callback Define the callback triggered once the entire list will be ready
  26059. */
  26060. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26061. }
  26062. }
  26063. declare module BABYLON {
  26064. /**
  26065. * Uniform buffer objects.
  26066. *
  26067. * Handles blocks of uniform on the GPU.
  26068. *
  26069. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26070. *
  26071. * For more information, please refer to :
  26072. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26073. */
  26074. export class UniformBuffer {
  26075. private _engine;
  26076. private _buffer;
  26077. private _data;
  26078. private _bufferData;
  26079. private _dynamic?;
  26080. private _uniformLocations;
  26081. private _uniformSizes;
  26082. private _uniformLocationPointer;
  26083. private _needSync;
  26084. private _noUBO;
  26085. private _currentEffect;
  26086. private static _MAX_UNIFORM_SIZE;
  26087. private static _tempBuffer;
  26088. /**
  26089. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26090. * This is dynamic to allow compat with webgl 1 and 2.
  26091. * You will need to pass the name of the uniform as well as the value.
  26092. */
  26093. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26094. /**
  26095. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26096. * This is dynamic to allow compat with webgl 1 and 2.
  26097. * You will need to pass the name of the uniform as well as the value.
  26098. */
  26099. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26100. /**
  26101. * Lambda to Update a single float in a uniform buffer.
  26102. * This is dynamic to allow compat with webgl 1 and 2.
  26103. * You will need to pass the name of the uniform as well as the value.
  26104. */
  26105. updateFloat: (name: string, x: number) => void;
  26106. /**
  26107. * Lambda to Update a vec2 of float in a uniform buffer.
  26108. * This is dynamic to allow compat with webgl 1 and 2.
  26109. * You will need to pass the name of the uniform as well as the value.
  26110. */
  26111. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26112. /**
  26113. * Lambda to Update a vec3 of float in a uniform buffer.
  26114. * This is dynamic to allow compat with webgl 1 and 2.
  26115. * You will need to pass the name of the uniform as well as the value.
  26116. */
  26117. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26118. /**
  26119. * Lambda to Update a vec4 of float in a uniform buffer.
  26120. * This is dynamic to allow compat with webgl 1 and 2.
  26121. * You will need to pass the name of the uniform as well as the value.
  26122. */
  26123. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26124. /**
  26125. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26126. * This is dynamic to allow compat with webgl 1 and 2.
  26127. * You will need to pass the name of the uniform as well as the value.
  26128. */
  26129. updateMatrix: (name: string, mat: Matrix) => void;
  26130. /**
  26131. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26132. * This is dynamic to allow compat with webgl 1 and 2.
  26133. * You will need to pass the name of the uniform as well as the value.
  26134. */
  26135. updateVector3: (name: string, vector: Vector3) => void;
  26136. /**
  26137. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26138. * This is dynamic to allow compat with webgl 1 and 2.
  26139. * You will need to pass the name of the uniform as well as the value.
  26140. */
  26141. updateVector4: (name: string, vector: Vector4) => void;
  26142. /**
  26143. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26144. * This is dynamic to allow compat with webgl 1 and 2.
  26145. * You will need to pass the name of the uniform as well as the value.
  26146. */
  26147. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26148. /**
  26149. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26150. * This is dynamic to allow compat with webgl 1 and 2.
  26151. * You will need to pass the name of the uniform as well as the value.
  26152. */
  26153. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26154. /**
  26155. * Instantiates a new Uniform buffer objects.
  26156. *
  26157. * Handles blocks of uniform on the GPU.
  26158. *
  26159. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26160. *
  26161. * For more information, please refer to :
  26162. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26163. * @param engine Define the engine the buffer is associated with
  26164. * @param data Define the data contained in the buffer
  26165. * @param dynamic Define if the buffer is updatable
  26166. */
  26167. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26168. /**
  26169. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26170. * or just falling back on setUniformXXX calls.
  26171. */
  26172. readonly useUbo: boolean;
  26173. /**
  26174. * Indicates if the WebGL underlying uniform buffer is in sync
  26175. * with the javascript cache data.
  26176. */
  26177. readonly isSync: boolean;
  26178. /**
  26179. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26180. * Also, a dynamic UniformBuffer will disable cache verification and always
  26181. * update the underlying WebGL uniform buffer to the GPU.
  26182. * @returns if Dynamic, otherwise false
  26183. */
  26184. isDynamic(): boolean;
  26185. /**
  26186. * The data cache on JS side.
  26187. * @returns the underlying data as a float array
  26188. */
  26189. getData(): Float32Array;
  26190. /**
  26191. * The underlying WebGL Uniform buffer.
  26192. * @returns the webgl buffer
  26193. */
  26194. getBuffer(): Nullable<DataBuffer>;
  26195. /**
  26196. * std140 layout specifies how to align data within an UBO structure.
  26197. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26198. * for specs.
  26199. */
  26200. private _fillAlignment;
  26201. /**
  26202. * Adds an uniform in the buffer.
  26203. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26204. * for the layout to be correct !
  26205. * @param name Name of the uniform, as used in the uniform block in the shader.
  26206. * @param size Data size, or data directly.
  26207. */
  26208. addUniform(name: string, size: number | number[]): void;
  26209. /**
  26210. * Adds a Matrix 4x4 to the uniform buffer.
  26211. * @param name Name of the uniform, as used in the uniform block in the shader.
  26212. * @param mat A 4x4 matrix.
  26213. */
  26214. addMatrix(name: string, mat: Matrix): void;
  26215. /**
  26216. * Adds a vec2 to the uniform buffer.
  26217. * @param name Name of the uniform, as used in the uniform block in the shader.
  26218. * @param x Define the x component value of the vec2
  26219. * @param y Define the y component value of the vec2
  26220. */
  26221. addFloat2(name: string, x: number, y: number): void;
  26222. /**
  26223. * Adds a vec3 to the uniform buffer.
  26224. * @param name Name of the uniform, as used in the uniform block in the shader.
  26225. * @param x Define the x component value of the vec3
  26226. * @param y Define the y component value of the vec3
  26227. * @param z Define the z component value of the vec3
  26228. */
  26229. addFloat3(name: string, x: number, y: number, z: number): void;
  26230. /**
  26231. * Adds a vec3 to the uniform buffer.
  26232. * @param name Name of the uniform, as used in the uniform block in the shader.
  26233. * @param color Define the vec3 from a Color
  26234. */
  26235. addColor3(name: string, color: Color3): void;
  26236. /**
  26237. * Adds a vec4 to the uniform buffer.
  26238. * @param name Name of the uniform, as used in the uniform block in the shader.
  26239. * @param color Define the rgb components from a Color
  26240. * @param alpha Define the a component of the vec4
  26241. */
  26242. addColor4(name: string, color: Color3, alpha: number): void;
  26243. /**
  26244. * Adds a vec3 to the uniform buffer.
  26245. * @param name Name of the uniform, as used in the uniform block in the shader.
  26246. * @param vector Define the vec3 components from a Vector
  26247. */
  26248. addVector3(name: string, vector: Vector3): void;
  26249. /**
  26250. * Adds a Matrix 3x3 to the uniform buffer.
  26251. * @param name Name of the uniform, as used in the uniform block in the shader.
  26252. */
  26253. addMatrix3x3(name: string): void;
  26254. /**
  26255. * Adds a Matrix 2x2 to the uniform buffer.
  26256. * @param name Name of the uniform, as used in the uniform block in the shader.
  26257. */
  26258. addMatrix2x2(name: string): void;
  26259. /**
  26260. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26261. */
  26262. create(): void;
  26263. /** @hidden */ private _rebuild(): void;
  26264. /**
  26265. * Updates the WebGL Uniform Buffer on the GPU.
  26266. * If the `dynamic` flag is set to true, no cache comparison is done.
  26267. * Otherwise, the buffer will be updated only if the cache differs.
  26268. */
  26269. update(): void;
  26270. /**
  26271. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26272. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26273. * @param data Define the flattened data
  26274. * @param size Define the size of the data.
  26275. */
  26276. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26277. private _updateMatrix3x3ForUniform;
  26278. private _updateMatrix3x3ForEffect;
  26279. private _updateMatrix2x2ForEffect;
  26280. private _updateMatrix2x2ForUniform;
  26281. private _updateFloatForEffect;
  26282. private _updateFloatForUniform;
  26283. private _updateFloat2ForEffect;
  26284. private _updateFloat2ForUniform;
  26285. private _updateFloat3ForEffect;
  26286. private _updateFloat3ForUniform;
  26287. private _updateFloat4ForEffect;
  26288. private _updateFloat4ForUniform;
  26289. private _updateMatrixForEffect;
  26290. private _updateMatrixForUniform;
  26291. private _updateVector3ForEffect;
  26292. private _updateVector3ForUniform;
  26293. private _updateVector4ForEffect;
  26294. private _updateVector4ForUniform;
  26295. private _updateColor3ForEffect;
  26296. private _updateColor3ForUniform;
  26297. private _updateColor4ForEffect;
  26298. private _updateColor4ForUniform;
  26299. /**
  26300. * Sets a sampler uniform on the effect.
  26301. * @param name Define the name of the sampler.
  26302. * @param texture Define the texture to set in the sampler
  26303. */
  26304. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26305. /**
  26306. * Directly updates the value of the uniform in the cache AND on the GPU.
  26307. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26308. * @param data Define the flattened data
  26309. */
  26310. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26311. /**
  26312. * Binds this uniform buffer to an effect.
  26313. * @param effect Define the effect to bind the buffer to
  26314. * @param name Name of the uniform block in the shader.
  26315. */
  26316. bindToEffect(effect: Effect, name: string): void;
  26317. /**
  26318. * Disposes the uniform buffer.
  26319. */
  26320. dispose(): void;
  26321. }
  26322. }
  26323. declare module BABYLON {
  26324. /**
  26325. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26327. */
  26328. export class Analyser {
  26329. /**
  26330. * Gets or sets the smoothing
  26331. * @ignorenaming
  26332. */
  26333. SMOOTHING: number;
  26334. /**
  26335. * Gets or sets the FFT table size
  26336. * @ignorenaming
  26337. */
  26338. FFT_SIZE: number;
  26339. /**
  26340. * Gets or sets the bar graph amplitude
  26341. * @ignorenaming
  26342. */
  26343. BARGRAPHAMPLITUDE: number;
  26344. /**
  26345. * Gets or sets the position of the debug canvas
  26346. * @ignorenaming
  26347. */
  26348. DEBUGCANVASPOS: {
  26349. x: number;
  26350. y: number;
  26351. };
  26352. /**
  26353. * Gets or sets the debug canvas size
  26354. * @ignorenaming
  26355. */
  26356. DEBUGCANVASSIZE: {
  26357. width: number;
  26358. height: number;
  26359. };
  26360. private _byteFreqs;
  26361. private _byteTime;
  26362. private _floatFreqs;
  26363. private _webAudioAnalyser;
  26364. private _debugCanvas;
  26365. private _debugCanvasContext;
  26366. private _scene;
  26367. private _registerFunc;
  26368. private _audioEngine;
  26369. /**
  26370. * Creates a new analyser
  26371. * @param scene defines hosting scene
  26372. */
  26373. constructor(scene: Scene);
  26374. /**
  26375. * Get the number of data values you will have to play with for the visualization
  26376. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26377. * @returns a number
  26378. */
  26379. getFrequencyBinCount(): number;
  26380. /**
  26381. * Gets the current frequency data as a byte array
  26382. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26383. * @returns a Uint8Array
  26384. */
  26385. getByteFrequencyData(): Uint8Array;
  26386. /**
  26387. * Gets the current waveform as a byte array
  26388. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26389. * @returns a Uint8Array
  26390. */
  26391. getByteTimeDomainData(): Uint8Array;
  26392. /**
  26393. * Gets the current frequency data as a float array
  26394. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26395. * @returns a Float32Array
  26396. */
  26397. getFloatFrequencyData(): Float32Array;
  26398. /**
  26399. * Renders the debug canvas
  26400. */
  26401. drawDebugCanvas(): void;
  26402. /**
  26403. * Stops rendering the debug canvas and removes it
  26404. */
  26405. stopDebugCanvas(): void;
  26406. /**
  26407. * Connects two audio nodes
  26408. * @param inputAudioNode defines first node to connect
  26409. * @param outputAudioNode defines second node to connect
  26410. */
  26411. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26412. /**
  26413. * Releases all associated resources
  26414. */
  26415. dispose(): void;
  26416. }
  26417. }
  26418. declare module BABYLON {
  26419. /**
  26420. * This represents an audio engine and it is responsible
  26421. * to play, synchronize and analyse sounds throughout the application.
  26422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26423. */
  26424. export interface IAudioEngine extends IDisposable {
  26425. /**
  26426. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26427. */
  26428. readonly canUseWebAudio: boolean;
  26429. /**
  26430. * Gets the current AudioContext if available.
  26431. */
  26432. readonly audioContext: Nullable<AudioContext>;
  26433. /**
  26434. * The master gain node defines the global audio volume of your audio engine.
  26435. */
  26436. readonly masterGain: GainNode;
  26437. /**
  26438. * Gets whether or not mp3 are supported by your browser.
  26439. */
  26440. readonly isMP3supported: boolean;
  26441. /**
  26442. * Gets whether or not ogg are supported by your browser.
  26443. */
  26444. readonly isOGGsupported: boolean;
  26445. /**
  26446. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26447. * @ignoreNaming
  26448. */
  26449. WarnedWebAudioUnsupported: boolean;
  26450. /**
  26451. * Defines if the audio engine relies on a custom unlocked button.
  26452. * In this case, the embedded button will not be displayed.
  26453. */
  26454. useCustomUnlockedButton: boolean;
  26455. /**
  26456. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26457. */
  26458. readonly unlocked: boolean;
  26459. /**
  26460. * Event raised when audio has been unlocked on the browser.
  26461. */
  26462. onAudioUnlockedObservable: Observable<AudioEngine>;
  26463. /**
  26464. * Event raised when audio has been locked on the browser.
  26465. */
  26466. onAudioLockedObservable: Observable<AudioEngine>;
  26467. /**
  26468. * Flags the audio engine in Locked state.
  26469. * This happens due to new browser policies preventing audio to autoplay.
  26470. */
  26471. lock(): void;
  26472. /**
  26473. * Unlocks the audio engine once a user action has been done on the dom.
  26474. * This is helpful to resume play once browser policies have been satisfied.
  26475. */
  26476. unlock(): void;
  26477. }
  26478. /**
  26479. * This represents the default audio engine used in babylon.
  26480. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26482. */
  26483. export class AudioEngine implements IAudioEngine {
  26484. private _audioContext;
  26485. private _audioContextInitialized;
  26486. private _muteButton;
  26487. private _hostElement;
  26488. /**
  26489. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26490. */
  26491. canUseWebAudio: boolean;
  26492. /**
  26493. * The master gain node defines the global audio volume of your audio engine.
  26494. */
  26495. masterGain: GainNode;
  26496. /**
  26497. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26498. * @ignoreNaming
  26499. */
  26500. WarnedWebAudioUnsupported: boolean;
  26501. /**
  26502. * Gets whether or not mp3 are supported by your browser.
  26503. */
  26504. isMP3supported: boolean;
  26505. /**
  26506. * Gets whether or not ogg are supported by your browser.
  26507. */
  26508. isOGGsupported: boolean;
  26509. /**
  26510. * Gets whether audio has been unlocked on the device.
  26511. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26512. * a user interaction has happened.
  26513. */
  26514. unlocked: boolean;
  26515. /**
  26516. * Defines if the audio engine relies on a custom unlocked button.
  26517. * In this case, the embedded button will not be displayed.
  26518. */
  26519. useCustomUnlockedButton: boolean;
  26520. /**
  26521. * Event raised when audio has been unlocked on the browser.
  26522. */
  26523. onAudioUnlockedObservable: Observable<AudioEngine>;
  26524. /**
  26525. * Event raised when audio has been locked on the browser.
  26526. */
  26527. onAudioLockedObservable: Observable<AudioEngine>;
  26528. /**
  26529. * Gets the current AudioContext if available.
  26530. */
  26531. readonly audioContext: Nullable<AudioContext>;
  26532. private _connectedAnalyser;
  26533. /**
  26534. * Instantiates a new audio engine.
  26535. *
  26536. * There should be only one per page as some browsers restrict the number
  26537. * of audio contexts you can create.
  26538. * @param hostElement defines the host element where to display the mute icon if necessary
  26539. */
  26540. constructor(hostElement?: Nullable<HTMLElement>);
  26541. /**
  26542. * Flags the audio engine in Locked state.
  26543. * This happens due to new browser policies preventing audio to autoplay.
  26544. */
  26545. lock(): void;
  26546. /**
  26547. * Unlocks the audio engine once a user action has been done on the dom.
  26548. * This is helpful to resume play once browser policies have been satisfied.
  26549. */
  26550. unlock(): void;
  26551. private _resumeAudioContext;
  26552. private _initializeAudioContext;
  26553. private _tryToRun;
  26554. private _triggerRunningState;
  26555. private _triggerSuspendedState;
  26556. private _displayMuteButton;
  26557. private _moveButtonToTopLeft;
  26558. private _onResize;
  26559. private _hideMuteButton;
  26560. /**
  26561. * Destroy and release the resources associated with the audio ccontext.
  26562. */
  26563. dispose(): void;
  26564. /**
  26565. * Gets the global volume sets on the master gain.
  26566. * @returns the global volume if set or -1 otherwise
  26567. */
  26568. getGlobalVolume(): number;
  26569. /**
  26570. * Sets the global volume of your experience (sets on the master gain).
  26571. * @param newVolume Defines the new global volume of the application
  26572. */
  26573. setGlobalVolume(newVolume: number): void;
  26574. /**
  26575. * Connect the audio engine to an audio analyser allowing some amazing
  26576. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26578. * @param analyser The analyser to connect to the engine
  26579. */
  26580. connectToAnalyser(analyser: Analyser): void;
  26581. }
  26582. }
  26583. declare module BABYLON {
  26584. /**
  26585. * Interface used to present a loading screen while loading a scene
  26586. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26587. */
  26588. export interface ILoadingScreen {
  26589. /**
  26590. * Function called to display the loading screen
  26591. */
  26592. displayLoadingUI: () => void;
  26593. /**
  26594. * Function called to hide the loading screen
  26595. */
  26596. hideLoadingUI: () => void;
  26597. /**
  26598. * Gets or sets the color to use for the background
  26599. */
  26600. loadingUIBackgroundColor: string;
  26601. /**
  26602. * Gets or sets the text to display while loading
  26603. */
  26604. loadingUIText: string;
  26605. }
  26606. /**
  26607. * Class used for the default loading screen
  26608. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26609. */
  26610. export class DefaultLoadingScreen implements ILoadingScreen {
  26611. private _renderingCanvas;
  26612. private _loadingText;
  26613. private _loadingDivBackgroundColor;
  26614. private _loadingDiv;
  26615. private _loadingTextDiv;
  26616. /** Gets or sets the logo url to use for the default loading screen */
  26617. static DefaultLogoUrl: string;
  26618. /** Gets or sets the spinner url to use for the default loading screen */
  26619. static DefaultSpinnerUrl: string;
  26620. /**
  26621. * Creates a new default loading screen
  26622. * @param _renderingCanvas defines the canvas used to render the scene
  26623. * @param _loadingText defines the default text to display
  26624. * @param _loadingDivBackgroundColor defines the default background color
  26625. */
  26626. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26627. /**
  26628. * Function called to display the loading screen
  26629. */
  26630. displayLoadingUI(): void;
  26631. /**
  26632. * Function called to hide the loading screen
  26633. */
  26634. hideLoadingUI(): void;
  26635. /**
  26636. * Gets or sets the text to display while loading
  26637. */
  26638. loadingUIText: string;
  26639. /**
  26640. * Gets or sets the color to use for the background
  26641. */
  26642. loadingUIBackgroundColor: string;
  26643. private _resizeLoadingUI;
  26644. }
  26645. }
  26646. declare module BABYLON {
  26647. /** @hidden */
  26648. export class WebGLPipelineContext implements IPipelineContext {
  26649. engine: Engine;
  26650. program: Nullable<WebGLProgram>;
  26651. context?: WebGLRenderingContext;
  26652. vertexShader?: WebGLShader;
  26653. fragmentShader?: WebGLShader;
  26654. isParallelCompiled: boolean;
  26655. onCompiled?: () => void;
  26656. transformFeedback?: WebGLTransformFeedback | null;
  26657. readonly isAsync: boolean;
  26658. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26659. }
  26660. }
  26661. declare module BABYLON {
  26662. /** @hidden */
  26663. export class WebGLDataBuffer extends DataBuffer {
  26664. private _buffer;
  26665. constructor(resource: WebGLBuffer);
  26666. readonly underlyingResource: any;
  26667. }
  26668. }
  26669. declare module BABYLON {
  26670. /** @hidden */
  26671. export class WebGL2ShaderProcessor implements IShaderProcessor {
  26672. attributeProcessor(attribute: string): string;
  26673. varyingProcessor(varying: string, isFragment: boolean): string;
  26674. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  26675. }
  26676. }
  26677. declare module BABYLON {
  26678. /**
  26679. * Settings for finer control over video usage
  26680. */
  26681. export interface VideoTextureSettings {
  26682. /**
  26683. * Applies `autoplay` to video, if specified
  26684. */
  26685. autoPlay?: boolean;
  26686. /**
  26687. * Applies `loop` to video, if specified
  26688. */
  26689. loop?: boolean;
  26690. /**
  26691. * Automatically updates internal texture from video at every frame in the render loop
  26692. */
  26693. autoUpdateTexture: boolean;
  26694. /**
  26695. * Image src displayed during the video loading or until the user interacts with the video.
  26696. */
  26697. poster?: string;
  26698. }
  26699. /**
  26700. * If you want to display a video in your scene, this is the special texture for that.
  26701. * This special texture works similar to other textures, with the exception of a few parameters.
  26702. * @see https://doc.babylonjs.com/how_to/video_texture
  26703. */
  26704. export class VideoTexture extends Texture {
  26705. /**
  26706. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26707. */
  26708. readonly autoUpdateTexture: boolean;
  26709. /**
  26710. * The video instance used by the texture internally
  26711. */
  26712. readonly video: HTMLVideoElement;
  26713. private _onUserActionRequestedObservable;
  26714. /**
  26715. * Event triggerd when a dom action is required by the user to play the video.
  26716. * This happens due to recent changes in browser policies preventing video to auto start.
  26717. */
  26718. readonly onUserActionRequestedObservable: Observable<Texture>;
  26719. private _generateMipMaps;
  26720. private _engine;
  26721. private _stillImageCaptured;
  26722. private _displayingPosterTexture;
  26723. private _settings;
  26724. private _createInternalTextureOnEvent;
  26725. /**
  26726. * Creates a video texture.
  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. * @param name optional name, will detect from video source, if not defined
  26731. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26732. * @param scene is obviously the current scene.
  26733. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26734. * @param invertY is false by default but can be used to invert video on Y axis
  26735. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26736. * @param settings allows finer control over video usage
  26737. */
  26738. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26739. private _getName;
  26740. private _getVideo;
  26741. private _createInternalTexture;
  26742. private reset;
  26743. /**
  26744. * @hidden Internal method to initiate `update`.
  26745. */ private _rebuild(): void;
  26746. /**
  26747. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26748. */
  26749. update(): void;
  26750. /**
  26751. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26752. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26753. */
  26754. updateTexture(isVisible: boolean): void;
  26755. protected _updateInternalTexture: () => void;
  26756. /**
  26757. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26758. * @param url New url.
  26759. */
  26760. updateURL(url: string): void;
  26761. /**
  26762. * Dispose the texture and release its associated resources.
  26763. */
  26764. dispose(): void;
  26765. /**
  26766. * Creates a video texture straight from a stream.
  26767. * @param scene Define the scene the texture should be created in
  26768. * @param stream Define the stream the texture should be created from
  26769. * @returns The created video texture as a promise
  26770. */
  26771. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26772. /**
  26773. * Creates a video texture straight from your WebCam video feed.
  26774. * @param scene Define the scene the texture should be created in
  26775. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26776. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26777. * @returns The created video texture as a promise
  26778. */
  26779. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26780. minWidth: number;
  26781. maxWidth: number;
  26782. minHeight: number;
  26783. maxHeight: number;
  26784. deviceId: string;
  26785. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26786. /**
  26787. * Creates a video texture straight from your WebCam video feed.
  26788. * @param scene Define the scene the texture should be created in
  26789. * @param onReady Define a callback to triggered once the texture will be ready
  26790. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26791. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26792. */
  26793. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26794. minWidth: number;
  26795. maxWidth: number;
  26796. minHeight: number;
  26797. maxHeight: number;
  26798. deviceId: string;
  26799. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26800. }
  26801. }
  26802. declare module BABYLON {
  26803. /**
  26804. * Interface for attribute information associated with buffer instanciation
  26805. */
  26806. export class InstancingAttributeInfo {
  26807. /**
  26808. * Index/offset of the attribute in the vertex shader
  26809. */
  26810. index: number;
  26811. /**
  26812. * size of the attribute, 1, 2, 3 or 4
  26813. */
  26814. attributeSize: number;
  26815. /**
  26816. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26817. * default is FLOAT
  26818. */
  26819. attribyteType: number;
  26820. /**
  26821. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26822. */
  26823. normalized: boolean;
  26824. /**
  26825. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26826. */
  26827. offset: number;
  26828. /**
  26829. * Name of the GLSL attribute, for debugging purpose only
  26830. */
  26831. attributeName: string;
  26832. }
  26833. /**
  26834. * Define options used to create a depth texture
  26835. */
  26836. export class DepthTextureCreationOptions {
  26837. /** Specifies whether or not a stencil should be allocated in the texture */
  26838. generateStencil?: boolean;
  26839. /** Specifies whether or not bilinear filtering is enable on the texture */
  26840. bilinearFiltering?: boolean;
  26841. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26842. comparisonFunction?: number;
  26843. /** Specifies if the created texture is a cube texture */
  26844. isCube?: boolean;
  26845. }
  26846. /**
  26847. * Class used to describe the capabilities of the engine relatively to the current browser
  26848. */
  26849. export class EngineCapabilities {
  26850. /** Maximum textures units per fragment shader */
  26851. maxTexturesImageUnits: number;
  26852. /** Maximum texture units per vertex shader */
  26853. maxVertexTextureImageUnits: number;
  26854. /** Maximum textures units in the entire pipeline */
  26855. maxCombinedTexturesImageUnits: number;
  26856. /** Maximum texture size */
  26857. maxTextureSize: number;
  26858. /** Maximum cube texture size */
  26859. maxCubemapTextureSize: number;
  26860. /** Maximum render texture size */
  26861. maxRenderTextureSize: number;
  26862. /** Maximum number of vertex attributes */
  26863. maxVertexAttribs: number;
  26864. /** Maximum number of varyings */
  26865. maxVaryingVectors: number;
  26866. /** Maximum number of uniforms per vertex shader */
  26867. maxVertexUniformVectors: number;
  26868. /** Maximum number of uniforms per fragment shader */
  26869. maxFragmentUniformVectors: number;
  26870. /** Defines if standard derivates (dx/dy) are supported */
  26871. standardDerivatives: boolean;
  26872. /** Defines if s3tc texture compression is supported */
  26873. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26874. /** Defines if pvrtc texture compression is supported */
  26875. pvrtc: any;
  26876. /** Defines if etc1 texture compression is supported */
  26877. etc1: any;
  26878. /** Defines if etc2 texture compression is supported */
  26879. etc2: any;
  26880. /** Defines if astc texture compression is supported */
  26881. astc: any;
  26882. /** Defines if float textures are supported */
  26883. textureFloat: boolean;
  26884. /** Defines if vertex array objects are supported */
  26885. vertexArrayObject: boolean;
  26886. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26887. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26888. /** Gets the maximum level of anisotropy supported */
  26889. maxAnisotropy: number;
  26890. /** Defines if instancing is supported */
  26891. instancedArrays: boolean;
  26892. /** Defines if 32 bits indices are supported */
  26893. uintIndices: boolean;
  26894. /** Defines if high precision shaders are supported */
  26895. highPrecisionShaderSupported: boolean;
  26896. /** Defines if depth reading in the fragment shader is supported */
  26897. fragmentDepthSupported: boolean;
  26898. /** Defines if float texture linear filtering is supported*/
  26899. textureFloatLinearFiltering: boolean;
  26900. /** Defines if rendering to float textures is supported */
  26901. textureFloatRender: boolean;
  26902. /** Defines if half float textures are supported*/
  26903. textureHalfFloat: boolean;
  26904. /** Defines if half float texture linear filtering is supported*/
  26905. textureHalfFloatLinearFiltering: boolean;
  26906. /** Defines if rendering to half float textures is supported */
  26907. textureHalfFloatRender: boolean;
  26908. /** Defines if textureLOD shader command is supported */
  26909. textureLOD: boolean;
  26910. /** Defines if draw buffers extension is supported */
  26911. drawBuffersExtension: boolean;
  26912. /** Defines if depth textures are supported */
  26913. depthTextureExtension: boolean;
  26914. /** Defines if float color buffer are supported */
  26915. colorBufferFloat: boolean;
  26916. /** Gets disjoint timer query extension (null if not supported) */
  26917. timerQuery: EXT_disjoint_timer_query;
  26918. /** Defines if timestamp can be used with timer query */
  26919. canUseTimestampForTimerQuery: boolean;
  26920. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26921. multiview: any;
  26922. /** Function used to let the system compiles shaders in background */
  26923. parallelShaderCompile: {
  26924. COMPLETION_STATUS_KHR: number;
  26925. };
  26926. }
  26927. /** Interface defining initialization parameters for Engine class */
  26928. export interface EngineOptions extends WebGLContextAttributes {
  26929. /**
  26930. * Defines if the engine should no exceed a specified device ratio
  26931. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26932. */
  26933. limitDeviceRatio?: number;
  26934. /**
  26935. * Defines if webvr should be enabled automatically
  26936. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26937. */
  26938. autoEnableWebVR?: boolean;
  26939. /**
  26940. * Defines if webgl2 should be turned off even if supported
  26941. * @see http://doc.babylonjs.com/features/webgl2
  26942. */
  26943. disableWebGL2Support?: boolean;
  26944. /**
  26945. * Defines if webaudio should be initialized as well
  26946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26947. */
  26948. audioEngine?: boolean;
  26949. /**
  26950. * Defines if animations should run using a deterministic lock step
  26951. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26952. */
  26953. deterministicLockstep?: boolean;
  26954. /** Defines the maximum steps to use with deterministic lock step mode */
  26955. lockstepMaxSteps?: number;
  26956. /**
  26957. * Defines that engine should ignore context lost events
  26958. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26959. */
  26960. doNotHandleContextLost?: boolean;
  26961. /**
  26962. * Defines that engine should ignore modifying touch action attribute and style
  26963. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26964. */
  26965. doNotHandleTouchAction?: boolean;
  26966. /**
  26967. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26968. */
  26969. useHighPrecisionFloats?: boolean;
  26970. }
  26971. /**
  26972. * Defines the interface used by display changed events
  26973. */
  26974. export interface IDisplayChangedEventArgs {
  26975. /** Gets the vrDisplay object (if any) */
  26976. vrDisplay: Nullable<any>;
  26977. /** Gets a boolean indicating if webVR is supported */
  26978. vrSupported: boolean;
  26979. }
  26980. /**
  26981. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26982. */
  26983. export class Engine {
  26984. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26985. static ExceptionList: ({
  26986. key: string;
  26987. capture: string;
  26988. captureConstraint: number;
  26989. targets: string[];
  26990. } | {
  26991. key: string;
  26992. capture: null;
  26993. captureConstraint: null;
  26994. targets: string[];
  26995. })[];
  26996. /** Gets the list of created engines */
  26997. static readonly Instances: Engine[];
  26998. /**
  26999. * Gets the latest created engine
  27000. */
  27001. static readonly LastCreatedEngine: Nullable<Engine>;
  27002. /**
  27003. * Gets the latest created scene
  27004. */
  27005. static readonly LastCreatedScene: Nullable<Scene>;
  27006. /**
  27007. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27008. * @param flag defines which part of the materials must be marked as dirty
  27009. * @param predicate defines a predicate used to filter which materials should be affected
  27010. */
  27011. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27012. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  27013. /** Defines that alpha blending is disabled */
  27014. static readonly ALPHA_DISABLE: number;
  27015. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27016. static readonly ALPHA_ADD: number;
  27017. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27018. static readonly ALPHA_COMBINE: number;
  27019. /** Defines that alpha blending to DEST - SRC * DEST */
  27020. static readonly ALPHA_SUBTRACT: number;
  27021. /** Defines that alpha blending to SRC * DEST */
  27022. static readonly ALPHA_MULTIPLY: number;
  27023. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27024. static readonly ALPHA_MAXIMIZED: number;
  27025. /** Defines that alpha blending to SRC + DEST */
  27026. static readonly ALPHA_ONEONE: number;
  27027. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27028. static readonly ALPHA_PREMULTIPLIED: number;
  27029. /**
  27030. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27031. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27032. */
  27033. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27034. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27035. static readonly ALPHA_INTERPOLATE: number;
  27036. /**
  27037. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27038. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27039. */
  27040. static readonly ALPHA_SCREENMODE: number;
  27041. /** Defines that the ressource is not delayed*/
  27042. static readonly DELAYLOADSTATE_NONE: number;
  27043. /** Defines that the ressource was successfully delay loaded */
  27044. static readonly DELAYLOADSTATE_LOADED: number;
  27045. /** Defines that the ressource is currently delay loading */
  27046. static readonly DELAYLOADSTATE_LOADING: number;
  27047. /** Defines that the ressource is delayed and has not started loading */
  27048. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27050. static readonly NEVER: number;
  27051. /** 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 */
  27052. static readonly ALWAYS: number;
  27053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27054. static readonly LESS: number;
  27055. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27056. static readonly EQUAL: number;
  27057. /** 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 */
  27058. static readonly LEQUAL: number;
  27059. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27060. static readonly GREATER: number;
  27061. /** 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 */
  27062. static readonly GEQUAL: number;
  27063. /** 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 */
  27064. static readonly NOTEQUAL: number;
  27065. /** Passed to stencilOperation to specify that stencil value must be kept */
  27066. static readonly KEEP: number;
  27067. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27068. static readonly REPLACE: number;
  27069. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27070. static readonly INCR: number;
  27071. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27072. static readonly DECR: number;
  27073. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27074. static readonly INVERT: number;
  27075. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27076. static readonly INCR_WRAP: number;
  27077. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27078. static readonly DECR_WRAP: number;
  27079. /** Texture is not repeating outside of 0..1 UVs */
  27080. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27081. /** Texture is repeating outside of 0..1 UVs */
  27082. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27083. /** Texture is repeating and mirrored */
  27084. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27085. /** ALPHA */
  27086. static readonly TEXTUREFORMAT_ALPHA: number;
  27087. /** LUMINANCE */
  27088. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27089. /** LUMINANCE_ALPHA */
  27090. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27091. /** RGB */
  27092. static readonly TEXTUREFORMAT_RGB: number;
  27093. /** RGBA */
  27094. static readonly TEXTUREFORMAT_RGBA: number;
  27095. /** RED */
  27096. static readonly TEXTUREFORMAT_RED: number;
  27097. /** RED (2nd reference) */
  27098. static readonly TEXTUREFORMAT_R: number;
  27099. /** RG */
  27100. static readonly TEXTUREFORMAT_RG: number;
  27101. /** RED_INTEGER */
  27102. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27103. /** RED_INTEGER (2nd reference) */
  27104. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27105. /** RG_INTEGER */
  27106. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27107. /** RGB_INTEGER */
  27108. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27109. /** RGBA_INTEGER */
  27110. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27111. /** UNSIGNED_BYTE */
  27112. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27113. /** UNSIGNED_BYTE (2nd reference) */
  27114. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27115. /** FLOAT */
  27116. static readonly TEXTURETYPE_FLOAT: number;
  27117. /** HALF_FLOAT */
  27118. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27119. /** BYTE */
  27120. static readonly TEXTURETYPE_BYTE: number;
  27121. /** SHORT */
  27122. static readonly TEXTURETYPE_SHORT: number;
  27123. /** UNSIGNED_SHORT */
  27124. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27125. /** INT */
  27126. static readonly TEXTURETYPE_INT: number;
  27127. /** UNSIGNED_INT */
  27128. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27129. /** UNSIGNED_SHORT_4_4_4_4 */
  27130. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27131. /** UNSIGNED_SHORT_5_5_5_1 */
  27132. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27133. /** UNSIGNED_SHORT_5_6_5 */
  27134. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27135. /** UNSIGNED_INT_2_10_10_10_REV */
  27136. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27137. /** UNSIGNED_INT_24_8 */
  27138. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27139. /** UNSIGNED_INT_10F_11F_11F_REV */
  27140. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27141. /** UNSIGNED_INT_5_9_9_9_REV */
  27142. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27143. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27144. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27145. /** nearest is mag = nearest and min = nearest and mip = linear */
  27146. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27147. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27148. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27149. /** Trilinear is mag = linear and min = linear and mip = linear */
  27150. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27151. /** nearest is mag = nearest and min = nearest and mip = linear */
  27152. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27153. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27154. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27155. /** Trilinear is mag = linear and min = linear and mip = linear */
  27156. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27157. /** mag = nearest and min = nearest and mip = nearest */
  27158. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27159. /** mag = nearest and min = linear and mip = nearest */
  27160. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27161. /** mag = nearest and min = linear and mip = linear */
  27162. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27163. /** mag = nearest and min = linear and mip = none */
  27164. static readonly TEXTURE_NEAREST_LINEAR: number;
  27165. /** mag = nearest and min = nearest and mip = none */
  27166. static readonly TEXTURE_NEAREST_NEAREST: number;
  27167. /** mag = linear and min = nearest and mip = nearest */
  27168. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27169. /** mag = linear and min = nearest and mip = linear */
  27170. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27171. /** mag = linear and min = linear and mip = none */
  27172. static readonly TEXTURE_LINEAR_LINEAR: number;
  27173. /** mag = linear and min = nearest and mip = none */
  27174. static readonly TEXTURE_LINEAR_NEAREST: number;
  27175. /** Explicit coordinates mode */
  27176. static readonly TEXTURE_EXPLICIT_MODE: number;
  27177. /** Spherical coordinates mode */
  27178. static readonly TEXTURE_SPHERICAL_MODE: number;
  27179. /** Planar coordinates mode */
  27180. static readonly TEXTURE_PLANAR_MODE: number;
  27181. /** Cubic coordinates mode */
  27182. static readonly TEXTURE_CUBIC_MODE: number;
  27183. /** Projection coordinates mode */
  27184. static readonly TEXTURE_PROJECTION_MODE: number;
  27185. /** Skybox coordinates mode */
  27186. static readonly TEXTURE_SKYBOX_MODE: number;
  27187. /** Inverse Cubic coordinates mode */
  27188. static readonly TEXTURE_INVCUBIC_MODE: number;
  27189. /** Equirectangular coordinates mode */
  27190. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27191. /** Equirectangular Fixed coordinates mode */
  27192. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27193. /** Equirectangular Fixed Mirrored coordinates mode */
  27194. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27195. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27196. static readonly SCALEMODE_FLOOR: number;
  27197. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27198. static readonly SCALEMODE_NEAREST: number;
  27199. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27200. static readonly SCALEMODE_CEILING: number;
  27201. /**
  27202. * Returns the current npm package of the sdk
  27203. */
  27204. static readonly NpmPackage: string;
  27205. /**
  27206. * Returns the current version of the framework
  27207. */
  27208. static readonly Version: string;
  27209. /**
  27210. * Returns a string describing the current engine
  27211. */
  27212. readonly description: string;
  27213. /**
  27214. * Gets or sets the epsilon value used by collision engine
  27215. */
  27216. static CollisionsEpsilon: number;
  27217. /**
  27218. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27219. */
  27220. static ShadersRepository: string;
  27221. /**
  27222. * Method called to create the default loading screen.
  27223. * This can be overriden in your own app.
  27224. * @param canvas The rendering canvas element
  27225. * @returns The loading screen
  27226. */
  27227. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27228. /**
  27229. * Method called to create the default rescale post process on each engine.
  27230. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27231. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  27232. /**
  27233. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27234. */
  27235. forcePOTTextures: boolean;
  27236. /**
  27237. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27238. */
  27239. isFullscreen: boolean;
  27240. /**
  27241. * Gets a boolean indicating if the pointer is currently locked
  27242. */
  27243. isPointerLock: boolean;
  27244. /**
  27245. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27246. */
  27247. cullBackFaces: boolean;
  27248. /**
  27249. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27250. */
  27251. renderEvenInBackground: boolean;
  27252. /**
  27253. * Gets or sets a boolean indicating that cache can be kept between frames
  27254. */
  27255. preventCacheWipeBetweenFrames: boolean;
  27256. /**
  27257. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27258. **/
  27259. enableOfflineSupport: boolean;
  27260. /**
  27261. * 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)
  27262. **/
  27263. disableManifestCheck: boolean;
  27264. /**
  27265. * Gets the list of created scenes
  27266. */
  27267. scenes: Scene[];
  27268. /**
  27269. * Event raised when a new scene is created
  27270. */
  27271. onNewSceneAddedObservable: Observable<Scene>;
  27272. /**
  27273. * Gets the list of created postprocesses
  27274. */
  27275. postProcesses: PostProcess[];
  27276. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27277. validateShaderPrograms: boolean;
  27278. /**
  27279. * Observable event triggered each time the rendering canvas is resized
  27280. */
  27281. onResizeObservable: Observable<Engine>;
  27282. /**
  27283. * Observable event triggered each time the canvas loses focus
  27284. */
  27285. onCanvasBlurObservable: Observable<Engine>;
  27286. /**
  27287. * Observable event triggered each time the canvas gains focus
  27288. */
  27289. onCanvasFocusObservable: Observable<Engine>;
  27290. /**
  27291. * Observable event triggered each time the canvas receives pointerout event
  27292. */
  27293. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27294. /**
  27295. * Observable event triggered before each texture is initialized
  27296. */
  27297. onBeforeTextureInitObservable: Observable<Texture>;
  27298. /**
  27299. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27300. */
  27301. disableUniformBuffers: boolean;
  27302. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  27303. /**
  27304. * Gets a boolean indicating that the engine supports uniform buffers
  27305. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27306. */
  27307. readonly supportsUniformBuffers: boolean;
  27308. /**
  27309. * Observable raised when the engine begins a new frame
  27310. */
  27311. onBeginFrameObservable: Observable<Engine>;
  27312. /**
  27313. * If set, will be used to request the next animation frame for the render loop
  27314. */
  27315. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27316. /**
  27317. * Observable raised when the engine ends the current frame
  27318. */
  27319. onEndFrameObservable: Observable<Engine>;
  27320. /**
  27321. * Observable raised when the engine is about to compile a shader
  27322. */
  27323. onBeforeShaderCompilationObservable: Observable<Engine>;
  27324. /**
  27325. * Observable raised when the engine has jsut compiled a shader
  27326. */
  27327. onAfterShaderCompilationObservable: Observable<Engine>;
  27328. /** @hidden */ private _gl: WebGLRenderingContext;
  27329. private _renderingCanvas;
  27330. private _windowIsBackground;
  27331. private _webGLVersion;
  27332. protected _highPrecisionShadersAllowed: boolean;
  27333. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27334. /**
  27335. * Gets a boolean indicating that only power of 2 textures are supported
  27336. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27337. */
  27338. readonly needPOTTextures: boolean;
  27339. /** @hidden */ private _badOS: boolean;
  27340. /** @hidden */ private _badDesktopOS: boolean;
  27341. /**
  27342. * Gets the audio engine
  27343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27344. * @ignorenaming
  27345. */
  27346. static audioEngine: IAudioEngine;
  27347. /**
  27348. * Default AudioEngine factory responsible of creating the Audio Engine.
  27349. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27350. */
  27351. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27352. /**
  27353. * Default offline support factory responsible of creating a tool used to store data locally.
  27354. * By default, this will create a Database object if the workload has been embedded.
  27355. */
  27356. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27357. private _onFocus;
  27358. private _onBlur;
  27359. private _onCanvasPointerOut;
  27360. private _onCanvasBlur;
  27361. private _onCanvasFocus;
  27362. private _onFullscreenChange;
  27363. private _onPointerLockChange;
  27364. private _hardwareScalingLevel;
  27365. /** @hidden */ private _caps: EngineCapabilities;
  27366. private _pointerLockRequested;
  27367. private _isStencilEnable;
  27368. private _colorWrite;
  27369. private _loadingScreen;
  27370. /** @hidden */ private _drawCalls: PerfCounter;
  27371. private _glVersion;
  27372. private _glRenderer;
  27373. private _glVendor;
  27374. private _videoTextureSupported;
  27375. private _renderingQueueLaunched;
  27376. private _activeRenderLoops;
  27377. private _deterministicLockstep;
  27378. private _lockstepMaxSteps;
  27379. /**
  27380. * Observable signaled when a context lost event is raised
  27381. */
  27382. onContextLostObservable: Observable<Engine>;
  27383. /**
  27384. * Observable signaled when a context restored event is raised
  27385. */
  27386. onContextRestoredObservable: Observable<Engine>;
  27387. private _onContextLost;
  27388. private _onContextRestored;
  27389. private _contextWasLost;
  27390. /** @hidden */ private _doNotHandleContextLost: boolean;
  27391. /**
  27392. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27393. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27394. */
  27395. doNotHandleContextLost: boolean;
  27396. private _performanceMonitor;
  27397. private _fps;
  27398. private _deltaTime;
  27399. /**
  27400. * Turn this value on if you want to pause FPS computation when in background
  27401. */
  27402. disablePerformanceMonitorInBackground: boolean;
  27403. /**
  27404. * Gets the performance monitor attached to this engine
  27405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27406. */
  27407. readonly performanceMonitor: PerformanceMonitor;
  27408. /**
  27409. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27410. */
  27411. disableVertexArrayObjects: boolean;
  27412. /** @hidden */
  27413. protected _depthCullingState: _DepthCullingState;
  27414. /** @hidden */
  27415. protected _stencilState: _StencilState;
  27416. /** @hidden */
  27417. protected _alphaState: _AlphaState;
  27418. /** @hidden */
  27419. protected _alphaMode: number;
  27420. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  27421. /** @hidden */
  27422. protected _activeChannel: number;
  27423. private _currentTextureChannel;
  27424. /** @hidden */
  27425. protected _boundTexturesCache: {
  27426. [key: string]: Nullable<InternalTexture>;
  27427. };
  27428. /** @hidden */
  27429. protected _currentEffect: Nullable<Effect>;
  27430. /** @hidden */
  27431. protected _currentProgram: Nullable<WebGLProgram>;
  27432. private _compiledEffects;
  27433. private _vertexAttribArraysEnabled;
  27434. /** @hidden */
  27435. protected _cachedViewport: Nullable<Viewport>;
  27436. private _cachedVertexArrayObject;
  27437. /** @hidden */
  27438. protected _cachedVertexBuffers: any;
  27439. /** @hidden */
  27440. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27441. /** @hidden */
  27442. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27443. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  27444. private _uintIndicesCurrentlySet;
  27445. private _currentBoundBuffer;
  27446. /** @hidden */
  27447. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27448. private _currentBufferPointers;
  27449. private _currentInstanceLocations;
  27450. private _currentInstanceBuffers;
  27451. private _textureUnits;
  27452. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27453. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27454. private _rescalePostProcess;
  27455. private _dummyFramebuffer;
  27456. private _externalData;
  27457. /** @hidden */ private _bindedRenderFunction: any;
  27458. private _vaoRecordInProgress;
  27459. private _mustWipeVertexAttributes;
  27460. private _emptyTexture;
  27461. private _emptyCubeTexture;
  27462. private _emptyTexture3D;
  27463. /** @hidden */ private _frameHandler: number;
  27464. private _nextFreeTextureSlots;
  27465. private _maxSimultaneousTextures;
  27466. private _activeRequests;
  27467. private _texturesSupported;
  27468. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  27469. /**
  27470. * Gets the list of texture formats supported
  27471. */
  27472. readonly texturesSupported: Array<string>;
  27473. /**
  27474. * Gets the list of texture formats in use
  27475. */
  27476. readonly textureFormatInUse: Nullable<string>;
  27477. /**
  27478. * Gets the current viewport
  27479. */
  27480. readonly currentViewport: Nullable<Viewport>;
  27481. /**
  27482. * Gets the default empty texture
  27483. */
  27484. readonly emptyTexture: InternalTexture;
  27485. /**
  27486. * Gets the default empty 3D texture
  27487. */
  27488. readonly emptyTexture3D: InternalTexture;
  27489. /**
  27490. * Gets the default empty cube texture
  27491. */
  27492. readonly emptyCubeTexture: InternalTexture;
  27493. /**
  27494. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27495. */
  27496. readonly premultipliedAlpha: boolean;
  27497. /**
  27498. * Creates a new engine
  27499. * @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
  27500. * @param antialias defines enable antialiasing (default: false)
  27501. * @param options defines further options to be sent to the getContext() function
  27502. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27503. */
  27504. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27505. /**
  27506. * Initializes a webVR display and starts listening to display change events
  27507. * The onVRDisplayChangedObservable will be notified upon these changes
  27508. * @returns The onVRDisplayChangedObservable
  27509. */
  27510. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27511. /** @hidden */ private _prepareVRComponent(): void;
  27512. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27513. /** @hidden */ private _submitVRFrame(): void;
  27514. /**
  27515. * Call this function to leave webVR mode
  27516. * Will do nothing if webVR is not supported or if there is no webVR device
  27517. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27518. */
  27519. disableVR(): void;
  27520. /**
  27521. * Gets a boolean indicating that the system is in VR mode and is presenting
  27522. * @returns true if VR mode is engaged
  27523. */
  27524. isVRPresenting(): boolean;
  27525. /** @hidden */ private _requestVRFrame(): void;
  27526. private _disableTouchAction;
  27527. private _rebuildInternalTextures;
  27528. private _rebuildEffects;
  27529. /**
  27530. * Gets a boolean indicating if all created effects are ready
  27531. * @returns true if all effects are ready
  27532. */
  27533. areAllEffectsReady(): boolean;
  27534. private _rebuildBuffers;
  27535. private _initGLContext;
  27536. /**
  27537. * Gets version of the current webGL context
  27538. */
  27539. readonly webGLVersion: number;
  27540. /**
  27541. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27542. */
  27543. readonly isStencilEnable: boolean;
  27544. /** @hidden */ private _prepareWorkingCanvas(): void;
  27545. /**
  27546. * Reset the texture cache to empty state
  27547. */
  27548. resetTextureCache(): void;
  27549. /**
  27550. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27552. * @returns true if engine is in deterministic lock step mode
  27553. */
  27554. isDeterministicLockStep(): boolean;
  27555. /**
  27556. * Gets the max steps when engine is running in deterministic lock step
  27557. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27558. * @returns the max steps
  27559. */
  27560. getLockstepMaxSteps(): number;
  27561. /**
  27562. * Gets an object containing information about the current webGL context
  27563. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27564. */
  27565. getGlInfo(): {
  27566. vendor: string;
  27567. renderer: string;
  27568. version: string;
  27569. };
  27570. /**
  27571. * Gets current aspect ratio
  27572. * @param camera defines the camera to use to get the aspect ratio
  27573. * @param useScreen defines if screen size must be used (or the current render target if any)
  27574. * @returns a number defining the aspect ratio
  27575. */
  27576. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27577. /**
  27578. * Gets current screen aspect ratio
  27579. * @returns a number defining the aspect ratio
  27580. */
  27581. getScreenAspectRatio(): number;
  27582. /**
  27583. * Gets the current render width
  27584. * @param useScreen defines if screen size must be used (or the current render target if any)
  27585. * @returns a number defining the current render width
  27586. */
  27587. getRenderWidth(useScreen?: boolean): number;
  27588. /**
  27589. * Gets the current render height
  27590. * @param useScreen defines if screen size must be used (or the current render target if any)
  27591. * @returns a number defining the current render height
  27592. */
  27593. getRenderHeight(useScreen?: boolean): number;
  27594. /**
  27595. * Gets the HTML canvas attached with the current webGL context
  27596. * @returns a HTML canvas
  27597. */
  27598. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27599. /**
  27600. * Gets the client rect of the HTML canvas attached with the current webGL context
  27601. * @returns a client rectanglee
  27602. */
  27603. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27604. /**
  27605. * Defines the hardware scaling level.
  27606. * By default the hardware scaling level is computed from the window device ratio.
  27607. * 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.
  27608. * @param level defines the level to use
  27609. */
  27610. setHardwareScalingLevel(level: number): void;
  27611. /**
  27612. * Gets the current hardware scaling level.
  27613. * By default the hardware scaling level is computed from the window device ratio.
  27614. * 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.
  27615. * @returns a number indicating the current hardware scaling level
  27616. */
  27617. getHardwareScalingLevel(): number;
  27618. /**
  27619. * Gets the list of loaded textures
  27620. * @returns an array containing all loaded textures
  27621. */
  27622. getLoadedTexturesCache(): InternalTexture[];
  27623. /**
  27624. * Gets the object containing all engine capabilities
  27625. * @returns the EngineCapabilities object
  27626. */
  27627. getCaps(): EngineCapabilities;
  27628. /**
  27629. * Gets the current depth function
  27630. * @returns a number defining the depth function
  27631. */
  27632. getDepthFunction(): Nullable<number>;
  27633. /**
  27634. * Sets the current depth function
  27635. * @param depthFunc defines the function to use
  27636. */
  27637. setDepthFunction(depthFunc: number): void;
  27638. /**
  27639. * Sets the current depth function to GREATER
  27640. */
  27641. setDepthFunctionToGreater(): void;
  27642. /**
  27643. * Sets the current depth function to GEQUAL
  27644. */
  27645. setDepthFunctionToGreaterOrEqual(): void;
  27646. /**
  27647. * Sets the current depth function to LESS
  27648. */
  27649. setDepthFunctionToLess(): void;
  27650. private _cachedStencilBuffer;
  27651. private _cachedStencilFunction;
  27652. private _cachedStencilMask;
  27653. private _cachedStencilOperationPass;
  27654. private _cachedStencilOperationFail;
  27655. private _cachedStencilOperationDepthFail;
  27656. private _cachedStencilReference;
  27657. /**
  27658. * Caches the the state of the stencil buffer
  27659. */
  27660. cacheStencilState(): void;
  27661. /**
  27662. * Restores the state of the stencil buffer
  27663. */
  27664. restoreStencilState(): void;
  27665. /**
  27666. * Sets the current depth function to LEQUAL
  27667. */
  27668. setDepthFunctionToLessOrEqual(): void;
  27669. /**
  27670. * Gets a boolean indicating if stencil buffer is enabled
  27671. * @returns the current stencil buffer state
  27672. */
  27673. getStencilBuffer(): boolean;
  27674. /**
  27675. * Enable or disable the stencil buffer
  27676. * @param enable defines if the stencil buffer must be enabled or disabled
  27677. */
  27678. setStencilBuffer(enable: boolean): void;
  27679. /**
  27680. * Gets the current stencil mask
  27681. * @returns a number defining the new stencil mask to use
  27682. */
  27683. getStencilMask(): number;
  27684. /**
  27685. * Sets the current stencil mask
  27686. * @param mask defines the new stencil mask to use
  27687. */
  27688. setStencilMask(mask: number): void;
  27689. /**
  27690. * Gets the current stencil function
  27691. * @returns a number defining the stencil function to use
  27692. */
  27693. getStencilFunction(): number;
  27694. /**
  27695. * Gets the current stencil reference value
  27696. * @returns a number defining the stencil reference value to use
  27697. */
  27698. getStencilFunctionReference(): number;
  27699. /**
  27700. * Gets the current stencil mask
  27701. * @returns a number defining the stencil mask to use
  27702. */
  27703. getStencilFunctionMask(): number;
  27704. /**
  27705. * Sets the current stencil function
  27706. * @param stencilFunc defines the new stencil function to use
  27707. */
  27708. setStencilFunction(stencilFunc: number): void;
  27709. /**
  27710. * Sets the current stencil reference
  27711. * @param reference defines the new stencil reference to use
  27712. */
  27713. setStencilFunctionReference(reference: number): void;
  27714. /**
  27715. * Sets the current stencil mask
  27716. * @param mask defines the new stencil mask to use
  27717. */
  27718. setStencilFunctionMask(mask: number): void;
  27719. /**
  27720. * Gets the current stencil operation when stencil fails
  27721. * @returns a number defining stencil operation to use when stencil fails
  27722. */
  27723. getStencilOperationFail(): number;
  27724. /**
  27725. * Gets the current stencil operation when depth fails
  27726. * @returns a number defining stencil operation to use when depth fails
  27727. */
  27728. getStencilOperationDepthFail(): number;
  27729. /**
  27730. * Gets the current stencil operation when stencil passes
  27731. * @returns a number defining stencil operation to use when stencil passes
  27732. */
  27733. getStencilOperationPass(): number;
  27734. /**
  27735. * Sets the stencil operation to use when stencil fails
  27736. * @param operation defines the stencil operation to use when stencil fails
  27737. */
  27738. setStencilOperationFail(operation: number): void;
  27739. /**
  27740. * Sets the stencil operation to use when depth fails
  27741. * @param operation defines the stencil operation to use when depth fails
  27742. */
  27743. setStencilOperationDepthFail(operation: number): void;
  27744. /**
  27745. * Sets the stencil operation to use when stencil passes
  27746. * @param operation defines the stencil operation to use when stencil passes
  27747. */
  27748. setStencilOperationPass(operation: number): void;
  27749. /**
  27750. * Sets a boolean indicating if the dithering state is enabled or disabled
  27751. * @param value defines the dithering state
  27752. */
  27753. setDitheringState(value: boolean): void;
  27754. /**
  27755. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27756. * @param value defines the rasterizer state
  27757. */
  27758. setRasterizerState(value: boolean): void;
  27759. /**
  27760. * stop executing a render loop function and remove it from the execution array
  27761. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27762. */
  27763. stopRenderLoop(renderFunction?: () => void): void;
  27764. /** @hidden */ private _renderLoop(): void;
  27765. /**
  27766. * Register and execute a render loop. The engine can have more than one render function
  27767. * @param renderFunction defines the function to continuously execute
  27768. */
  27769. runRenderLoop(renderFunction: () => void): void;
  27770. /**
  27771. * Toggle full screen mode
  27772. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27773. */
  27774. switchFullscreen(requestPointerLock: boolean): void;
  27775. /**
  27776. * Enters full screen mode
  27777. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27778. */
  27779. enterFullscreen(requestPointerLock: boolean): void;
  27780. /**
  27781. * Exits full screen mode
  27782. */
  27783. exitFullscreen(): void;
  27784. /**
  27785. * Enters Pointerlock mode
  27786. */
  27787. enterPointerlock(): void;
  27788. /**
  27789. * Exits Pointerlock mode
  27790. */
  27791. exitPointerlock(): void;
  27792. /**
  27793. * Clear the current render buffer or the current render target (if any is set up)
  27794. * @param color defines the color to use
  27795. * @param backBuffer defines if the back buffer must be cleared
  27796. * @param depth defines if the depth buffer must be cleared
  27797. * @param stencil defines if the stencil buffer must be cleared
  27798. */
  27799. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27800. /**
  27801. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27802. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27803. * @param y defines the y-coordinate of the corner of the clear rectangle
  27804. * @param width defines the width of the clear rectangle
  27805. * @param height defines the height of the clear rectangle
  27806. * @param clearColor defines the clear color
  27807. */
  27808. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27809. /**
  27810. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27811. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27812. * @param y defines the y-coordinate of the corner of the clear rectangle
  27813. * @param width defines the width of the clear rectangle
  27814. * @param height defines the height of the clear rectangle
  27815. */
  27816. enableScissor(x: number, y: number, width: number, height: number): void;
  27817. /**
  27818. * Disable previously set scissor test rectangle
  27819. */
  27820. disableScissor(): void;
  27821. private _viewportCached;
  27822. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  27823. /**
  27824. * Set the WebGL's viewport
  27825. * @param viewport defines the viewport element to be used
  27826. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27827. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27828. */
  27829. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27830. /**
  27831. * Directly set the WebGL Viewport
  27832. * @param x defines the x coordinate of the viewport (in screen space)
  27833. * @param y defines the y coordinate of the viewport (in screen space)
  27834. * @param width defines the width of the viewport (in screen space)
  27835. * @param height defines the height of the viewport (in screen space)
  27836. * @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
  27837. */
  27838. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27839. /**
  27840. * Begin a new frame
  27841. */
  27842. beginFrame(): void;
  27843. /**
  27844. * Enf the current frame
  27845. */
  27846. endFrame(): void;
  27847. /**
  27848. * Resize the view according to the canvas' size
  27849. */
  27850. resize(): void;
  27851. /**
  27852. * Force a specific size of the canvas
  27853. * @param width defines the new canvas' width
  27854. * @param height defines the new canvas' height
  27855. */
  27856. setSize(width: number, height: number): void;
  27857. /**
  27858. * Binds the frame buffer to the specified texture.
  27859. * @param texture The texture to render to or null for the default canvas
  27860. * @param faceIndex The face of the texture to render to in case of cube texture
  27861. * @param requiredWidth The width of the target to render to
  27862. * @param requiredHeight The height of the target to render to
  27863. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27864. * @param depthStencilTexture The depth stencil texture to use to render
  27865. * @param lodLevel defines le lod level to bind to the frame buffer
  27866. */
  27867. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27868. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27869. /**
  27870. * Unbind the current render target texture from the webGL context
  27871. * @param texture defines the render target texture to unbind
  27872. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27873. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27874. */
  27875. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27876. /**
  27877. * Force the mipmap generation for the given render target texture
  27878. * @param texture defines the render target texture to use
  27879. */
  27880. generateMipMapsForCubemap(texture: InternalTexture): void;
  27881. /**
  27882. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27883. */
  27884. flushFramebuffer(): void;
  27885. /**
  27886. * Unbind the current render target and bind the default framebuffer
  27887. */
  27888. restoreDefaultFramebuffer(): void;
  27889. /**
  27890. * Create an uniform buffer
  27891. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27892. * @param elements defines the content of the uniform buffer
  27893. * @returns the webGL uniform buffer
  27894. */
  27895. createUniformBuffer(elements: FloatArray): DataBuffer;
  27896. /**
  27897. * Create a dynamic uniform buffer
  27898. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27899. * @param elements defines the content of the uniform buffer
  27900. * @returns the webGL uniform buffer
  27901. */
  27902. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27903. /**
  27904. * Update an existing uniform buffer
  27905. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27906. * @param uniformBuffer defines the target uniform buffer
  27907. * @param elements defines the content to update
  27908. * @param offset defines the offset in the uniform buffer where update should start
  27909. * @param count defines the size of the data to update
  27910. */
  27911. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27912. private _resetVertexBufferBinding;
  27913. /**
  27914. * Creates a vertex buffer
  27915. * @param data the data for the vertex buffer
  27916. * @returns the new WebGL static buffer
  27917. */
  27918. createVertexBuffer(data: DataArray): DataBuffer;
  27919. /**
  27920. * Creates a dynamic vertex buffer
  27921. * @param data the data for the dynamic vertex buffer
  27922. * @returns the new WebGL dynamic buffer
  27923. */
  27924. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27925. /**
  27926. * Update a dynamic index buffer
  27927. * @param indexBuffer defines the target index buffer
  27928. * @param indices defines the data to update
  27929. * @param offset defines the offset in the target index buffer where update should start
  27930. */
  27931. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27932. /**
  27933. * Updates a dynamic vertex buffer.
  27934. * @param vertexBuffer the vertex buffer to update
  27935. * @param data the data used to update the vertex buffer
  27936. * @param byteOffset the byte offset of the data
  27937. * @param byteLength the byte length of the data
  27938. */
  27939. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27940. private _resetIndexBufferBinding;
  27941. /**
  27942. * Creates a new index buffer
  27943. * @param indices defines the content of the index buffer
  27944. * @param updatable defines if the index buffer must be updatable
  27945. * @returns a new webGL buffer
  27946. */
  27947. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27948. /**
  27949. * Bind a webGL buffer to the webGL context
  27950. * @param buffer defines the buffer to bind
  27951. */
  27952. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27953. /**
  27954. * Bind an uniform buffer to the current webGL context
  27955. * @param buffer defines the buffer to bind
  27956. */
  27957. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27958. /**
  27959. * Bind a buffer to the current webGL context at a given location
  27960. * @param buffer defines the buffer to bind
  27961. * @param location defines the index where to bind the buffer
  27962. */
  27963. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27964. /**
  27965. * Bind a specific block at a given index in a specific shader program
  27966. * @param pipelineContext defines the pipeline context to use
  27967. * @param blockName defines the block name
  27968. * @param index defines the index where to bind the block
  27969. */
  27970. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27971. private bindIndexBuffer;
  27972. private bindBuffer;
  27973. /**
  27974. * update the bound buffer with the given data
  27975. * @param data defines the data to update
  27976. */
  27977. updateArrayBuffer(data: Float32Array): void;
  27978. private _vertexAttribPointer;
  27979. private _bindIndexBufferWithCache;
  27980. private _bindVertexBuffersAttributes;
  27981. /**
  27982. * Records a vertex array object
  27983. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27984. * @param vertexBuffers defines the list of vertex buffers to store
  27985. * @param indexBuffer defines the index buffer to store
  27986. * @param effect defines the effect to store
  27987. * @returns the new vertex array object
  27988. */
  27989. recordVertexArrayObject(vertexBuffers: {
  27990. [key: string]: VertexBuffer;
  27991. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27992. /**
  27993. * Bind a specific vertex array object
  27994. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27995. * @param vertexArrayObject defines the vertex array object to bind
  27996. * @param indexBuffer defines the index buffer to bind
  27997. */
  27998. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27999. /**
  28000. * Bind webGl buffers directly to the webGL context
  28001. * @param vertexBuffer defines the vertex buffer to bind
  28002. * @param indexBuffer defines the index buffer to bind
  28003. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28004. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28005. * @param effect defines the effect associated with the vertex buffer
  28006. */
  28007. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28008. private _unbindVertexArrayObject;
  28009. /**
  28010. * Bind a list of vertex buffers to the webGL context
  28011. * @param vertexBuffers defines the list of vertex buffers to bind
  28012. * @param indexBuffer defines the index buffer to bind
  28013. * @param effect defines the effect associated with the vertex buffers
  28014. */
  28015. bindBuffers(vertexBuffers: {
  28016. [key: string]: Nullable<VertexBuffer>;
  28017. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28018. /**
  28019. * Unbind all instance attributes
  28020. */
  28021. unbindInstanceAttributes(): void;
  28022. /**
  28023. * Release and free the memory of a vertex array object
  28024. * @param vao defines the vertex array object to delete
  28025. */
  28026. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28027. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  28028. /**
  28029. * Creates a webGL buffer to use with instanciation
  28030. * @param capacity defines the size of the buffer
  28031. * @returns the webGL buffer
  28032. */
  28033. createInstancesBuffer(capacity: number): DataBuffer;
  28034. /**
  28035. * Delete a webGL buffer used with instanciation
  28036. * @param buffer defines the webGL buffer to delete
  28037. */
  28038. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28039. /**
  28040. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28041. * @param instancesBuffer defines the webGL buffer to update and bind
  28042. * @param data defines the data to store in the buffer
  28043. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28044. */
  28045. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28046. /**
  28047. * Apply all cached states (depth, culling, stencil and alpha)
  28048. */
  28049. applyStates(): void;
  28050. /**
  28051. * Send a draw order
  28052. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28053. * @param indexStart defines the starting index
  28054. * @param indexCount defines the number of index to draw
  28055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28056. */
  28057. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28058. /**
  28059. * Draw a list of points
  28060. * @param verticesStart defines the index of first vertex to draw
  28061. * @param verticesCount defines the count of vertices to draw
  28062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28063. */
  28064. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28065. /**
  28066. * Draw a list of unindexed primitives
  28067. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28068. * @param verticesStart defines the index of first vertex to draw
  28069. * @param verticesCount defines the count of vertices to draw
  28070. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28071. */
  28072. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28073. /**
  28074. * Draw a list of indexed primitives
  28075. * @param fillMode defines the primitive to use
  28076. * @param indexStart defines the starting index
  28077. * @param indexCount defines the number of index to draw
  28078. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28079. */
  28080. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28081. /**
  28082. * Draw a list of unindexed primitives
  28083. * @param fillMode defines the primitive to use
  28084. * @param verticesStart defines the index of first vertex to draw
  28085. * @param verticesCount defines the count of vertices to draw
  28086. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28087. */
  28088. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28089. private _drawMode;
  28090. /** @hidden */ private _releaseEffect(effect: Effect): void;
  28091. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28092. /**
  28093. * Create a new effect (used to store vertex/fragment shaders)
  28094. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28095. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28096. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28097. * @param samplers defines an array of string used to represent textures
  28098. * @param defines defines the string containing the defines to use to compile the shaders
  28099. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28100. * @param onCompiled defines a function to call when the effect creation is successful
  28101. * @param onError defines a function to call when the effect creation has failed
  28102. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28103. * @returns the new Effect
  28104. */
  28105. 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;
  28106. private _compileShader;
  28107. private _compileRawShader;
  28108. /**
  28109. * Directly creates a webGL program
  28110. * @param pipelineContext defines the pipeline context to attach to
  28111. * @param vertexCode defines the vertex shader code to use
  28112. * @param fragmentCode defines the fragment shader code to use
  28113. * @param context defines the webGL context to use (if not set, the current one will be used)
  28114. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28115. * @returns the new webGL program
  28116. */
  28117. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28118. /**
  28119. * Creates a webGL program
  28120. * @param pipelineContext defines the pipeline context to attach to
  28121. * @param vertexCode defines the vertex shader code to use
  28122. * @param fragmentCode defines the fragment shader code to use
  28123. * @param defines defines the string containing the defines to use to compile the shaders
  28124. * @param context defines the webGL context to use (if not set, the current one will be used)
  28125. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28126. * @returns the new webGL program
  28127. */
  28128. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28129. /**
  28130. * Creates a new pipeline context
  28131. * @returns the new pipeline
  28132. */
  28133. createPipelineContext(): WebGLPipelineContext;
  28134. private _createShaderProgram;
  28135. private _finalizePipelineContext;
  28136. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28137. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28138. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28139. /**
  28140. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28141. * @param pipelineContext defines the pipeline context to use
  28142. * @param uniformsNames defines the list of uniform names
  28143. * @returns an array of webGL uniform locations
  28144. */
  28145. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28146. /**
  28147. * Gets the lsit of active attributes for a given webGL program
  28148. * @param pipelineContext defines the pipeline context to use
  28149. * @param attributesNames defines the list of attribute names to get
  28150. * @returns an array of indices indicating the offset of each attribute
  28151. */
  28152. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28153. /**
  28154. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28155. * @param effect defines the effect to activate
  28156. */
  28157. enableEffect(effect: Nullable<Effect>): void;
  28158. /**
  28159. * Set the value of an uniform to an array of int32
  28160. * @param uniform defines the webGL uniform location where to store the value
  28161. * @param array defines the array of int32 to store
  28162. */
  28163. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28164. /**
  28165. * Set the value of an uniform to an array of int32 (stored as vec2)
  28166. * @param uniform defines the webGL uniform location where to store the value
  28167. * @param array defines the array of int32 to store
  28168. */
  28169. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28170. /**
  28171. * Set the value of an uniform to an array of int32 (stored as vec3)
  28172. * @param uniform defines the webGL uniform location where to store the value
  28173. * @param array defines the array of int32 to store
  28174. */
  28175. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28176. /**
  28177. * Set the value of an uniform to an array of int32 (stored as vec4)
  28178. * @param uniform defines the webGL uniform location where to store the value
  28179. * @param array defines the array of int32 to store
  28180. */
  28181. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28182. /**
  28183. * Set the value of an uniform to an array of float32
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param array defines the array of float32 to store
  28186. */
  28187. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28188. /**
  28189. * Set the value of an uniform to an array of float32 (stored as vec2)
  28190. * @param uniform defines the webGL uniform location where to store the value
  28191. * @param array defines the array of float32 to store
  28192. */
  28193. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28194. /**
  28195. * Set the value of an uniform to an array of float32 (stored as vec3)
  28196. * @param uniform defines the webGL uniform location where to store the value
  28197. * @param array defines the array of float32 to store
  28198. */
  28199. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28200. /**
  28201. * Set the value of an uniform to an array of float32 (stored as vec4)
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param array defines the array of float32 to store
  28204. */
  28205. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28206. /**
  28207. * Set the value of an uniform to an array of number
  28208. * @param uniform defines the webGL uniform location where to store the value
  28209. * @param array defines the array of number to store
  28210. */
  28211. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28212. /**
  28213. * Set the value of an uniform to an array of number (stored as vec2)
  28214. * @param uniform defines the webGL uniform location where to store the value
  28215. * @param array defines the array of number to store
  28216. */
  28217. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28218. /**
  28219. * Set the value of an uniform to an array of number (stored as vec3)
  28220. * @param uniform defines the webGL uniform location where to store the value
  28221. * @param array defines the array of number to store
  28222. */
  28223. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28224. /**
  28225. * Set the value of an uniform to an array of number (stored as vec4)
  28226. * @param uniform defines the webGL uniform location where to store the value
  28227. * @param array defines the array of number to store
  28228. */
  28229. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28230. /**
  28231. * Set the value of an uniform to an array of float32 (stored as matrices)
  28232. * @param uniform defines the webGL uniform location where to store the value
  28233. * @param matrices defines the array of float32 to store
  28234. */
  28235. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28236. /**
  28237. * Set the value of an uniform to a matrix
  28238. * @param uniform defines the webGL uniform location where to store the value
  28239. * @param matrix defines the matrix to store
  28240. */
  28241. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28242. /**
  28243. * Set the value of an uniform to a matrix (3x3)
  28244. * @param uniform defines the webGL uniform location where to store the value
  28245. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28246. */
  28247. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28248. /**
  28249. * Set the value of an uniform to a matrix (2x2)
  28250. * @param uniform defines the webGL uniform location where to store the value
  28251. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28252. */
  28253. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28254. /**
  28255. * Set the value of an uniform to a number (int)
  28256. * @param uniform defines the webGL uniform location where to store the value
  28257. * @param value defines the int number to store
  28258. */
  28259. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28260. /**
  28261. * Set the value of an uniform to a number (float)
  28262. * @param uniform defines the webGL uniform location where to store the value
  28263. * @param value defines the float number to store
  28264. */
  28265. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28266. /**
  28267. * Set the value of an uniform to a vec2
  28268. * @param uniform defines the webGL uniform location where to store the value
  28269. * @param x defines the 1st component of the value
  28270. * @param y defines the 2nd component of the value
  28271. */
  28272. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28273. /**
  28274. * Set the value of an uniform to a vec3
  28275. * @param uniform defines the webGL uniform location where to store the value
  28276. * @param x defines the 1st component of the value
  28277. * @param y defines the 2nd component of the value
  28278. * @param z defines the 3rd component of the value
  28279. */
  28280. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28281. /**
  28282. * Set the value of an uniform to a boolean
  28283. * @param uniform defines the webGL uniform location where to store the value
  28284. * @param bool defines the boolean to store
  28285. */
  28286. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28287. /**
  28288. * Set the value of an uniform to a vec4
  28289. * @param uniform defines the webGL uniform location where to store the value
  28290. * @param x defines the 1st component of the value
  28291. * @param y defines the 2nd component of the value
  28292. * @param z defines the 3rd component of the value
  28293. * @param w defines the 4th component of the value
  28294. */
  28295. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28296. /**
  28297. * Set the value of an uniform to a Color3
  28298. * @param uniform defines the webGL uniform location where to store the value
  28299. * @param color3 defines the color to store
  28300. */
  28301. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28302. /**
  28303. * Set the value of an uniform to a Color3 and an alpha value
  28304. * @param uniform defines the webGL uniform location where to store the value
  28305. * @param color3 defines the color to store
  28306. * @param alpha defines the alpha component to store
  28307. */
  28308. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28309. /**
  28310. * Sets a Color4 on a uniform variable
  28311. * @param uniform defines the uniform location
  28312. * @param color4 defines the value to be set
  28313. */
  28314. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28315. /**
  28316. * Set various states to the webGL context
  28317. * @param culling defines backface culling state
  28318. * @param zOffset defines the value to apply to zOffset (0 by default)
  28319. * @param force defines if states must be applied even if cache is up to date
  28320. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28321. */
  28322. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28323. /**
  28324. * Set the z offset to apply to current rendering
  28325. * @param value defines the offset to apply
  28326. */
  28327. setZOffset(value: number): void;
  28328. /**
  28329. * Gets the current value of the zOffset
  28330. * @returns the current zOffset state
  28331. */
  28332. getZOffset(): number;
  28333. /**
  28334. * Enable or disable depth buffering
  28335. * @param enable defines the state to set
  28336. */
  28337. setDepthBuffer(enable: boolean): void;
  28338. /**
  28339. * Gets a boolean indicating if depth writing is enabled
  28340. * @returns the current depth writing state
  28341. */
  28342. getDepthWrite(): boolean;
  28343. /**
  28344. * Enable or disable depth writing
  28345. * @param enable defines the state to set
  28346. */
  28347. setDepthWrite(enable: boolean): void;
  28348. /**
  28349. * Enable or disable color writing
  28350. * @param enable defines the state to set
  28351. */
  28352. setColorWrite(enable: boolean): void;
  28353. /**
  28354. * Gets a boolean indicating if color writing is enabled
  28355. * @returns the current color writing state
  28356. */
  28357. getColorWrite(): boolean;
  28358. /**
  28359. * Sets alpha constants used by some alpha blending modes
  28360. * @param r defines the red component
  28361. * @param g defines the green component
  28362. * @param b defines the blue component
  28363. * @param a defines the alpha component
  28364. */
  28365. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28366. /**
  28367. * Sets the current alpha mode
  28368. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28369. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28371. */
  28372. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28373. /**
  28374. * Gets the current alpha mode
  28375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28376. * @returns the current alpha mode
  28377. */
  28378. getAlphaMode(): number;
  28379. /**
  28380. * Clears the list of texture accessible through engine.
  28381. * This can help preventing texture load conflict due to name collision.
  28382. */
  28383. clearInternalTexturesCache(): void;
  28384. /**
  28385. * Force the entire cache to be cleared
  28386. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28387. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28388. */
  28389. wipeCaches(bruteForce?: boolean): void;
  28390. /**
  28391. * Set the compressed texture format to use, based on the formats you have, and the formats
  28392. * supported by the hardware / browser.
  28393. *
  28394. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28395. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28396. * to API arguments needed to compressed textures. This puts the burden on the container
  28397. * generator to house the arcane code for determining these for current & future formats.
  28398. *
  28399. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28400. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28401. *
  28402. * Note: The result of this call is not taken into account when a texture is base64.
  28403. *
  28404. * @param formatsAvailable defines the list of those format families you have created
  28405. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28406. *
  28407. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28408. * @returns The extension selected.
  28409. */
  28410. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28411. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28412. min: number;
  28413. mag: number;
  28414. };
  28415. /** @hidden */ private _createTexture(): WebGLTexture;
  28416. /**
  28417. * Usually called from Texture.ts.
  28418. * Passed information to create a WebGLTexture
  28419. * @param urlArg defines a value which contains one of the following:
  28420. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28421. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28422. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28424. * @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)
  28425. * @param scene needed for loading to the correct scene
  28426. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28427. * @param onLoad optional callback to be called upon successful completion
  28428. * @param onError optional callback to be called upon failure
  28429. * @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
  28430. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28431. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28432. * @param forcedExtension defines the extension to use to pick the right loader
  28433. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28434. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28435. */
  28436. 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;
  28437. /**
  28438. * @hidden
  28439. * Rescales a texture
  28440. * @param source input texutre
  28441. * @param destination destination texture
  28442. * @param scene scene to use to render the resize
  28443. * @param internalFormat format to use when resizing
  28444. * @param onComplete callback to be called when resize has completed
  28445. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28446. private _unpackFlipYCached;
  28447. /**
  28448. * In case you are sharing the context with other applications, it might
  28449. * be interested to not cache the unpack flip y state to ensure a consistent
  28450. * value would be set.
  28451. */
  28452. enableUnpackFlipYCached: boolean;
  28453. /** @hidden */ private _unpackFlipY(value: boolean): void;
  28454. /** @hidden */ private _getUnpackAlignement(): number;
  28455. /**
  28456. * Creates a dynamic texture
  28457. * @param width defines the width of the texture
  28458. * @param height defines the height of the texture
  28459. * @param generateMipMaps defines if the engine should generate the mip levels
  28460. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28461. * @returns the dynamic texture inside an InternalTexture
  28462. */
  28463. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28464. /**
  28465. * Update the sampling mode of a given texture
  28466. * @param samplingMode defines the required sampling mode
  28467. * @param texture defines the texture to update
  28468. */
  28469. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28470. /**
  28471. * Update the content of a dynamic texture
  28472. * @param texture defines the texture to update
  28473. * @param canvas defines the canvas containing the source
  28474. * @param invertY defines if data must be stored with Y axis inverted
  28475. * @param premulAlpha defines if alpha is stored as premultiplied
  28476. * @param format defines the format of the data
  28477. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28478. */
  28479. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28480. /**
  28481. * Update a video texture
  28482. * @param texture defines the texture to update
  28483. * @param video defines the video element to use
  28484. * @param invertY defines if data must be stored with Y axis inverted
  28485. */
  28486. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28487. /**
  28488. * Updates a depth texture Comparison Mode and Function.
  28489. * If the comparison Function is equal to 0, the mode will be set to none.
  28490. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28491. * @param texture The texture to set the comparison function for
  28492. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28493. */
  28494. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28495. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28496. width: number;
  28497. height: number;
  28498. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28499. /**
  28500. * Creates a depth stencil texture.
  28501. * This is only available in WebGL 2 or with the depth texture extension available.
  28502. * @param size The size of face edge in the texture.
  28503. * @param options The options defining the texture.
  28504. * @returns The texture
  28505. */
  28506. createDepthStencilTexture(size: number | {
  28507. width: number;
  28508. height: number;
  28509. }, options: DepthTextureCreationOptions): InternalTexture;
  28510. /**
  28511. * Creates a depth stencil texture.
  28512. * This is only available in WebGL 2 or with the depth texture extension available.
  28513. * @param size The size of face edge in the texture.
  28514. * @param options The options defining the texture.
  28515. * @returns The texture
  28516. */
  28517. private _createDepthStencilTexture;
  28518. /**
  28519. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28520. * @param renderTarget The render target to set the frame buffer for
  28521. */
  28522. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28523. /**
  28524. * Creates a new render target texture
  28525. * @param size defines the size of the texture
  28526. * @param options defines the options used to create the texture
  28527. * @returns a new render target texture stored in an InternalTexture
  28528. */
  28529. createRenderTargetTexture(size: number | {
  28530. width: number;
  28531. height: number;
  28532. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28533. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28534. /**
  28535. * Updates the sample count of a render target texture
  28536. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28537. * @param texture defines the texture to update
  28538. * @param samples defines the sample count to set
  28539. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28540. */
  28541. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28542. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28543. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  28544. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28545. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28546. /**
  28547. * @hidden
  28548. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  28549. private _prepareWebGLTextureContinuation;
  28550. private _prepareWebGLTexture;
  28551. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28552. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  28553. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  28554. private setProgram;
  28555. private _boundUniforms;
  28556. /**
  28557. * Binds an effect to the webGL context
  28558. * @param effect defines the effect to bind
  28559. */
  28560. bindSamplers(effect: Effect): void;
  28561. private _activateCurrentTexture;
  28562. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28563. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28564. /**
  28565. * Sets a texture to the webGL context from a postprocess
  28566. * @param channel defines the channel to use
  28567. * @param postProcess defines the source postprocess
  28568. */
  28569. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28570. /**
  28571. * Binds the output of the passed in post process to the texture channel specified
  28572. * @param channel The channel the texture should be bound to
  28573. * @param postProcess The post process which's output should be bound
  28574. */
  28575. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28576. /**
  28577. * Unbind all textures from the webGL context
  28578. */
  28579. unbindAllTextures(): void;
  28580. /**
  28581. * Sets a texture to the according uniform.
  28582. * @param channel The texture channel
  28583. * @param uniform The uniform to set
  28584. * @param texture The texture to apply
  28585. */
  28586. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28587. /**
  28588. * Sets a depth stencil texture from a render target to the according uniform.
  28589. * @param channel The texture channel
  28590. * @param uniform The uniform to set
  28591. * @param texture The render target texture containing the depth stencil texture to apply
  28592. */
  28593. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28594. private _bindSamplerUniformToChannel;
  28595. private _getTextureWrapMode;
  28596. private _setTexture;
  28597. /**
  28598. * Sets an array of texture to the webGL context
  28599. * @param channel defines the channel where the texture array must be set
  28600. * @param uniform defines the associated uniform location
  28601. * @param textures defines the array of textures to bind
  28602. */
  28603. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28604. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28605. private _setTextureParameterFloat;
  28606. private _setTextureParameterInteger;
  28607. /**
  28608. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28609. * @param x defines the x coordinate of the rectangle where pixels must be read
  28610. * @param y defines the y coordinate of the rectangle where pixels must be read
  28611. * @param width defines the width of the rectangle where pixels must be read
  28612. * @param height defines the height of the rectangle where pixels must be read
  28613. * @returns a Uint8Array containing RGBA colors
  28614. */
  28615. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28616. /**
  28617. * Add an externaly attached data from its key.
  28618. * This method call will fail and return false, if such key already exists.
  28619. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28620. * @param key the unique key that identifies the data
  28621. * @param data the data object to associate to the key for this Engine instance
  28622. * @return true if no such key were already present and the data was added successfully, false otherwise
  28623. */
  28624. addExternalData<T>(key: string, data: T): boolean;
  28625. /**
  28626. * Get an externaly attached data from its key
  28627. * @param key the unique key that identifies the data
  28628. * @return the associated data, if present (can be null), or undefined if not present
  28629. */
  28630. getExternalData<T>(key: string): T;
  28631. /**
  28632. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28633. * @param key the unique key that identifies the data
  28634. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28635. * @return the associated data, can be null if the factory returned null.
  28636. */
  28637. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28638. /**
  28639. * Remove an externaly attached data from the Engine instance
  28640. * @param key the unique key that identifies the data
  28641. * @return true if the data was successfully removed, false if it doesn't exist
  28642. */
  28643. removeExternalData(key: string): boolean;
  28644. /**
  28645. * Unbind all vertex attributes from the webGL context
  28646. */
  28647. unbindAllAttributes(): void;
  28648. /**
  28649. * 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
  28650. */
  28651. releaseEffects(): void;
  28652. /**
  28653. * Dispose and release all associated resources
  28654. */
  28655. dispose(): void;
  28656. /**
  28657. * Display the loading screen
  28658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28659. */
  28660. displayLoadingUI(): void;
  28661. /**
  28662. * Hide the loading screen
  28663. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28664. */
  28665. hideLoadingUI(): void;
  28666. /**
  28667. * Gets the current loading screen object
  28668. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28669. */
  28670. /**
  28671. * Sets the current loading screen object
  28672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28673. */
  28674. loadingScreen: ILoadingScreen;
  28675. /**
  28676. * Sets the current loading screen text
  28677. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28678. */
  28679. loadingUIText: string;
  28680. /**
  28681. * Sets the current loading screen background color
  28682. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28683. */
  28684. loadingUIBackgroundColor: string;
  28685. /**
  28686. * Attach a new callback raised when context lost event is fired
  28687. * @param callback defines the callback to call
  28688. */
  28689. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28690. /**
  28691. * Attach a new callback raised when context restored event is fired
  28692. * @param callback defines the callback to call
  28693. */
  28694. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28695. /**
  28696. * Gets the source code of the vertex shader associated with a specific webGL program
  28697. * @param program defines the program to use
  28698. * @returns a string containing the source code of the vertex shader associated with the program
  28699. */
  28700. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28701. /**
  28702. * Gets the source code of the fragment shader associated with a specific webGL program
  28703. * @param program defines the program to use
  28704. * @returns a string containing the source code of the fragment shader associated with the program
  28705. */
  28706. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28707. /**
  28708. * Get the current error code of the webGL context
  28709. * @returns the error code
  28710. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28711. */
  28712. getError(): number;
  28713. /**
  28714. * Gets the current framerate
  28715. * @returns a number representing the framerate
  28716. */
  28717. getFps(): number;
  28718. /**
  28719. * Gets the time spent between current and previous frame
  28720. * @returns a number representing the delta time in ms
  28721. */
  28722. getDeltaTime(): number;
  28723. private _measureFps;
  28724. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28725. private _canRenderToFloatFramebuffer;
  28726. private _canRenderToHalfFloatFramebuffer;
  28727. private _canRenderToFramebuffer;
  28728. /** @hidden */ private _getWebGLTextureType(type: number): number;
  28729. /** @hidden */ private _getInternalFormat(format: number): number;
  28730. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28731. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  28732. /** @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;
  28733. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28734. /**
  28735. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28736. * @returns true if the engine can be created
  28737. * @ignorenaming
  28738. */
  28739. static isSupported(): boolean;
  28740. }
  28741. }
  28742. declare module BABYLON {
  28743. /**
  28744. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28745. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28746. */
  28747. export class EffectFallbacks {
  28748. private _defines;
  28749. private _currentRank;
  28750. private _maxRank;
  28751. private _mesh;
  28752. /**
  28753. * Removes the fallback from the bound mesh.
  28754. */
  28755. unBindMesh(): void;
  28756. /**
  28757. * Adds a fallback on the specified property.
  28758. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28759. * @param define The name of the define in the shader
  28760. */
  28761. addFallback(rank: number, define: string): void;
  28762. /**
  28763. * Sets the mesh to use CPU skinning when needing to fallback.
  28764. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28765. * @param mesh The mesh to use the fallbacks.
  28766. */
  28767. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28768. /**
  28769. * Checks to see if more fallbacks are still availible.
  28770. */
  28771. readonly isMoreFallbacks: boolean;
  28772. /**
  28773. * Removes the defines that should be removed when falling back.
  28774. * @param currentDefines defines the current define statements for the shader.
  28775. * @param effect defines the current effect we try to compile
  28776. * @returns The resulting defines with defines of the current rank removed.
  28777. */
  28778. reduce(currentDefines: string, effect: Effect): string;
  28779. }
  28780. /**
  28781. * Options to be used when creating an effect.
  28782. */
  28783. export class EffectCreationOptions {
  28784. /**
  28785. * Atrributes that will be used in the shader.
  28786. */
  28787. attributes: string[];
  28788. /**
  28789. * Uniform varible names that will be set in the shader.
  28790. */
  28791. uniformsNames: string[];
  28792. /**
  28793. * Uniform buffer varible names that will be set in the shader.
  28794. */
  28795. uniformBuffersNames: string[];
  28796. /**
  28797. * Sampler texture variable names that will be set in the shader.
  28798. */
  28799. samplers: string[];
  28800. /**
  28801. * Define statements that will be set in the shader.
  28802. */
  28803. defines: any;
  28804. /**
  28805. * Possible fallbacks for this effect to improve performance when needed.
  28806. */
  28807. fallbacks: Nullable<EffectFallbacks>;
  28808. /**
  28809. * Callback that will be called when the shader is compiled.
  28810. */
  28811. onCompiled: Nullable<(effect: Effect) => void>;
  28812. /**
  28813. * Callback that will be called if an error occurs during shader compilation.
  28814. */
  28815. onError: Nullable<(effect: Effect, errors: string) => void>;
  28816. /**
  28817. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28818. */
  28819. indexParameters: any;
  28820. /**
  28821. * Max number of lights that can be used in the shader.
  28822. */
  28823. maxSimultaneousLights: number;
  28824. /**
  28825. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28826. */
  28827. transformFeedbackVaryings: Nullable<string[]>;
  28828. }
  28829. /**
  28830. * Effect containing vertex and fragment shader that can be executed on an object.
  28831. */
  28832. export class Effect implements IDisposable {
  28833. /**
  28834. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28835. */
  28836. static ShadersRepository: string;
  28837. /**
  28838. * Name of the effect.
  28839. */
  28840. name: any;
  28841. /**
  28842. * String container all the define statements that should be set on the shader.
  28843. */
  28844. defines: string;
  28845. /**
  28846. * Callback that will be called when the shader is compiled.
  28847. */
  28848. onCompiled: Nullable<(effect: Effect) => void>;
  28849. /**
  28850. * Callback that will be called if an error occurs during shader compilation.
  28851. */
  28852. onError: Nullable<(effect: Effect, errors: string) => void>;
  28853. /**
  28854. * Callback that will be called when effect is bound.
  28855. */
  28856. onBind: Nullable<(effect: Effect) => void>;
  28857. /**
  28858. * Unique ID of the effect.
  28859. */
  28860. uniqueId: number;
  28861. /**
  28862. * Observable that will be called when the shader is compiled.
  28863. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28864. */
  28865. onCompileObservable: Observable<Effect>;
  28866. /**
  28867. * Observable that will be called if an error occurs during shader compilation.
  28868. */
  28869. onErrorObservable: Observable<Effect>;
  28870. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  28871. /**
  28872. * Observable that will be called when effect is bound.
  28873. */
  28874. readonly onBindObservable: Observable<Effect>;
  28875. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  28876. private static _uniqueIdSeed;
  28877. private _engine;
  28878. private _uniformBuffersNames;
  28879. private _uniformsNames;
  28880. private _samplerList;
  28881. private _samplers;
  28882. private _isReady;
  28883. private _compilationError;
  28884. private _attributesNames;
  28885. private _attributes;
  28886. private _uniforms;
  28887. /**
  28888. * Key for the effect.
  28889. * @hidden
  28890. */ private _key: string;
  28891. private _indexParameters;
  28892. private _fallbacks;
  28893. private _vertexSourceCode;
  28894. private _fragmentSourceCode;
  28895. private _vertexSourceCodeOverride;
  28896. private _fragmentSourceCodeOverride;
  28897. private _transformFeedbackVaryings;
  28898. /**
  28899. * Compiled shader to webGL program.
  28900. * @hidden
  28901. */ private _pipelineContext: Nullable<IPipelineContext>;
  28902. private _valueCache;
  28903. private static _baseCache;
  28904. /**
  28905. * Instantiates an effect.
  28906. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28907. * @param baseName Name of the effect.
  28908. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28909. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28910. * @param samplers List of sampler variables that will be passed to the shader.
  28911. * @param engine Engine to be used to render the effect
  28912. * @param defines Define statements to be added to the shader.
  28913. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28914. * @param onCompiled Callback that will be called when the shader is compiled.
  28915. * @param onError Callback that will be called if an error occurs during shader compilation.
  28916. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28917. */
  28918. 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);
  28919. private _useFinalCode;
  28920. /**
  28921. * Unique key for this effect
  28922. */
  28923. readonly key: string;
  28924. /**
  28925. * If the effect has been compiled and prepared.
  28926. * @returns if the effect is compiled and prepared.
  28927. */
  28928. isReady(): boolean;
  28929. /**
  28930. * The engine the effect was initialized with.
  28931. * @returns the engine.
  28932. */
  28933. getEngine(): Engine;
  28934. /**
  28935. * The pipeline context for this effect
  28936. * @returns the associated pipeline context
  28937. */
  28938. getPipelineContext(): Nullable<IPipelineContext>;
  28939. /**
  28940. * The set of names of attribute variables for the shader.
  28941. * @returns An array of attribute names.
  28942. */
  28943. getAttributesNames(): string[];
  28944. /**
  28945. * Returns the attribute at the given index.
  28946. * @param index The index of the attribute.
  28947. * @returns The location of the attribute.
  28948. */
  28949. getAttributeLocation(index: number): number;
  28950. /**
  28951. * Returns the attribute based on the name of the variable.
  28952. * @param name of the attribute to look up.
  28953. * @returns the attribute location.
  28954. */
  28955. getAttributeLocationByName(name: string): number;
  28956. /**
  28957. * The number of attributes.
  28958. * @returns the numnber of attributes.
  28959. */
  28960. getAttributesCount(): number;
  28961. /**
  28962. * Gets the index of a uniform variable.
  28963. * @param uniformName of the uniform to look up.
  28964. * @returns the index.
  28965. */
  28966. getUniformIndex(uniformName: string): number;
  28967. /**
  28968. * Returns the attribute based on the name of the variable.
  28969. * @param uniformName of the uniform to look up.
  28970. * @returns the location of the uniform.
  28971. */
  28972. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28973. /**
  28974. * Returns an array of sampler variable names
  28975. * @returns The array of sampler variable neames.
  28976. */
  28977. getSamplers(): string[];
  28978. /**
  28979. * The error from the last compilation.
  28980. * @returns the error string.
  28981. */
  28982. getCompilationError(): string;
  28983. /**
  28984. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28985. * @param func The callback to be used.
  28986. */
  28987. executeWhenCompiled(func: (effect: Effect) => void): void;
  28988. private _checkIsReady;
  28989. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28990. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28991. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28992. /**
  28993. * Recompiles the webGL program
  28994. * @param vertexSourceCode The source code for the vertex shader.
  28995. * @param fragmentSourceCode The source code for the fragment shader.
  28996. * @param onCompiled Callback called when completed.
  28997. * @param onError Callback called on error.
  28998. * @hidden
  28999. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29000. /**
  29001. * Prepares the effect
  29002. * @hidden
  29003. */ private _prepareEffect(): void;
  29004. /**
  29005. * Checks if the effect is supported. (Must be called after compilation)
  29006. */
  29007. readonly isSupported: boolean;
  29008. /**
  29009. * Binds a texture to the engine to be used as output of the shader.
  29010. * @param channel Name of the output variable.
  29011. * @param texture Texture to bind.
  29012. * @hidden
  29013. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  29014. /**
  29015. * Sets a texture on the engine to be used in the shader.
  29016. * @param channel Name of the sampler variable.
  29017. * @param texture Texture to set.
  29018. */
  29019. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29020. /**
  29021. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29022. * @param channel Name of the sampler variable.
  29023. * @param texture Texture to set.
  29024. */
  29025. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29026. /**
  29027. * Sets an array of textures on the engine to be used in the shader.
  29028. * @param channel Name of the variable.
  29029. * @param textures Textures to set.
  29030. */
  29031. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29032. /**
  29033. * 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)
  29034. * @param channel Name of the sampler variable.
  29035. * @param postProcess Post process to get the input texture from.
  29036. */
  29037. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29038. /**
  29039. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29040. * 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)
  29041. * @param channel Name of the sampler variable.
  29042. * @param postProcess Post process to get the output texture from.
  29043. */
  29044. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29045. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29046. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29047. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29048. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29049. /**
  29050. * Binds a buffer to a uniform.
  29051. * @param buffer Buffer to bind.
  29052. * @param name Name of the uniform variable to bind to.
  29053. */
  29054. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29055. /**
  29056. * Binds block to a uniform.
  29057. * @param blockName Name of the block to bind.
  29058. * @param index Index to bind.
  29059. */
  29060. bindUniformBlock(blockName: string, index: number): void;
  29061. /**
  29062. * Sets an interger value on a uniform variable.
  29063. * @param uniformName Name of the variable.
  29064. * @param value Value to be set.
  29065. * @returns this effect.
  29066. */
  29067. setInt(uniformName: string, value: number): Effect;
  29068. /**
  29069. * Sets an int array on a uniform variable.
  29070. * @param uniformName Name of the variable.
  29071. * @param array array to be set.
  29072. * @returns this effect.
  29073. */
  29074. setIntArray(uniformName: string, array: Int32Array): Effect;
  29075. /**
  29076. * 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)
  29077. * @param uniformName Name of the variable.
  29078. * @param array array to be set.
  29079. * @returns this effect.
  29080. */
  29081. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29082. /**
  29083. * 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)
  29084. * @param uniformName Name of the variable.
  29085. * @param array array to be set.
  29086. * @returns this effect.
  29087. */
  29088. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29089. /**
  29090. * 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)
  29091. * @param uniformName Name of the variable.
  29092. * @param array array to be set.
  29093. * @returns this effect.
  29094. */
  29095. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29096. /**
  29097. * Sets an float array on a uniform variable.
  29098. * @param uniformName Name of the variable.
  29099. * @param array array to be set.
  29100. * @returns this effect.
  29101. */
  29102. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29103. /**
  29104. * 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)
  29105. * @param uniformName Name of the variable.
  29106. * @param array array to be set.
  29107. * @returns this effect.
  29108. */
  29109. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29110. /**
  29111. * 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)
  29112. * @param uniformName Name of the variable.
  29113. * @param array array to be set.
  29114. * @returns this effect.
  29115. */
  29116. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29117. /**
  29118. * 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)
  29119. * @param uniformName Name of the variable.
  29120. * @param array array to be set.
  29121. * @returns this effect.
  29122. */
  29123. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29124. /**
  29125. * Sets an array on a uniform variable.
  29126. * @param uniformName Name of the variable.
  29127. * @param array array to be set.
  29128. * @returns this effect.
  29129. */
  29130. setArray(uniformName: string, array: number[]): Effect;
  29131. /**
  29132. * 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)
  29133. * @param uniformName Name of the variable.
  29134. * @param array array to be set.
  29135. * @returns this effect.
  29136. */
  29137. setArray2(uniformName: string, array: number[]): Effect;
  29138. /**
  29139. * 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)
  29140. * @param uniformName Name of the variable.
  29141. * @param array array to be set.
  29142. * @returns this effect.
  29143. */
  29144. setArray3(uniformName: string, array: number[]): Effect;
  29145. /**
  29146. * 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)
  29147. * @param uniformName Name of the variable.
  29148. * @param array array to be set.
  29149. * @returns this effect.
  29150. */
  29151. setArray4(uniformName: string, array: number[]): Effect;
  29152. /**
  29153. * Sets matrices on a uniform variable.
  29154. * @param uniformName Name of the variable.
  29155. * @param matrices matrices to be set.
  29156. * @returns this effect.
  29157. */
  29158. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29159. /**
  29160. * Sets matrix on a uniform variable.
  29161. * @param uniformName Name of the variable.
  29162. * @param matrix matrix to be set.
  29163. * @returns this effect.
  29164. */
  29165. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29166. /**
  29167. * 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)
  29168. * @param uniformName Name of the variable.
  29169. * @param matrix matrix to be set.
  29170. * @returns this effect.
  29171. */
  29172. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29173. /**
  29174. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29175. * @param uniformName Name of the variable.
  29176. * @param matrix matrix to be set.
  29177. * @returns this effect.
  29178. */
  29179. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29180. /**
  29181. * Sets a float on a uniform variable.
  29182. * @param uniformName Name of the variable.
  29183. * @param value value to be set.
  29184. * @returns this effect.
  29185. */
  29186. setFloat(uniformName: string, value: number): Effect;
  29187. /**
  29188. * Sets a boolean on a uniform variable.
  29189. * @param uniformName Name of the variable.
  29190. * @param bool value to be set.
  29191. * @returns this effect.
  29192. */
  29193. setBool(uniformName: string, bool: boolean): Effect;
  29194. /**
  29195. * Sets a Vector2 on a uniform variable.
  29196. * @param uniformName Name of the variable.
  29197. * @param vector2 vector2 to be set.
  29198. * @returns this effect.
  29199. */
  29200. setVector2(uniformName: string, vector2: Vector2): Effect;
  29201. /**
  29202. * Sets a float2 on a uniform variable.
  29203. * @param uniformName Name of the variable.
  29204. * @param x First float in float2.
  29205. * @param y Second float in float2.
  29206. * @returns this effect.
  29207. */
  29208. setFloat2(uniformName: string, x: number, y: number): Effect;
  29209. /**
  29210. * Sets a Vector3 on a uniform variable.
  29211. * @param uniformName Name of the variable.
  29212. * @param vector3 Value to be set.
  29213. * @returns this effect.
  29214. */
  29215. setVector3(uniformName: string, vector3: Vector3): Effect;
  29216. /**
  29217. * Sets a float3 on a uniform variable.
  29218. * @param uniformName Name of the variable.
  29219. * @param x First float in float3.
  29220. * @param y Second float in float3.
  29221. * @param z Third float in float3.
  29222. * @returns this effect.
  29223. */
  29224. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29225. /**
  29226. * Sets a Vector4 on a uniform variable.
  29227. * @param uniformName Name of the variable.
  29228. * @param vector4 Value to be set.
  29229. * @returns this effect.
  29230. */
  29231. setVector4(uniformName: string, vector4: Vector4): Effect;
  29232. /**
  29233. * Sets a float4 on a uniform variable.
  29234. * @param uniformName Name of the variable.
  29235. * @param x First float in float4.
  29236. * @param y Second float in float4.
  29237. * @param z Third float in float4.
  29238. * @param w Fourth float in float4.
  29239. * @returns this effect.
  29240. */
  29241. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29242. /**
  29243. * Sets a Color3 on a uniform variable.
  29244. * @param uniformName Name of the variable.
  29245. * @param color3 Value to be set.
  29246. * @returns this effect.
  29247. */
  29248. setColor3(uniformName: string, color3: Color3): Effect;
  29249. /**
  29250. * Sets a Color4 on a uniform variable.
  29251. * @param uniformName Name of the variable.
  29252. * @param color3 Value to be set.
  29253. * @param alpha Alpha value to be set.
  29254. * @returns this effect.
  29255. */
  29256. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29257. /**
  29258. * Sets a Color4 on a uniform variable
  29259. * @param uniformName defines the name of the variable
  29260. * @param color4 defines the value to be set
  29261. * @returns this effect.
  29262. */
  29263. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29264. /** Release all associated resources */
  29265. dispose(): void;
  29266. /**
  29267. * This function will add a new shader to the shader store
  29268. * @param name the name of the shader
  29269. * @param pixelShader optional pixel shader content
  29270. * @param vertexShader optional vertex shader content
  29271. */
  29272. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29273. /**
  29274. * Store of each shader (The can be looked up using effect.key)
  29275. */
  29276. static ShadersStore: {
  29277. [key: string]: string;
  29278. };
  29279. /**
  29280. * Store of each included file for a shader (The can be looked up using effect.key)
  29281. */
  29282. static IncludesShadersStore: {
  29283. [key: string]: string;
  29284. };
  29285. /**
  29286. * Resets the cache of effects.
  29287. */
  29288. static ResetCache(): void;
  29289. }
  29290. }
  29291. declare module BABYLON {
  29292. /**
  29293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29295. * 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;
  29296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29297. */
  29298. export class ColorCurves {
  29299. private _dirty;
  29300. private _tempColor;
  29301. private _globalCurve;
  29302. private _highlightsCurve;
  29303. private _midtonesCurve;
  29304. private _shadowsCurve;
  29305. private _positiveCurve;
  29306. private _negativeCurve;
  29307. private _globalHue;
  29308. private _globalDensity;
  29309. private _globalSaturation;
  29310. private _globalExposure;
  29311. /**
  29312. * Gets the global Hue value.
  29313. * 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).
  29314. */
  29315. /**
  29316. * Sets the global Hue value.
  29317. * 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).
  29318. */
  29319. globalHue: number;
  29320. /**
  29321. * Gets the global Density value.
  29322. * 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.
  29323. * Values less than zero provide a filter of opposite hue.
  29324. */
  29325. /**
  29326. * Sets the global Density value.
  29327. * 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.
  29328. * Values less than zero provide a filter of opposite hue.
  29329. */
  29330. globalDensity: number;
  29331. /**
  29332. * Gets the global Saturation value.
  29333. * 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.
  29334. */
  29335. /**
  29336. * Sets the global Saturation value.
  29337. * 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.
  29338. */
  29339. globalSaturation: number;
  29340. /**
  29341. * Gets the global Exposure value.
  29342. * 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.
  29343. */
  29344. /**
  29345. * Sets the global Exposure value.
  29346. * 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.
  29347. */
  29348. globalExposure: number;
  29349. private _highlightsHue;
  29350. private _highlightsDensity;
  29351. private _highlightsSaturation;
  29352. private _highlightsExposure;
  29353. /**
  29354. * Gets the highlights Hue value.
  29355. * 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).
  29356. */
  29357. /**
  29358. * Sets the highlights Hue value.
  29359. * 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).
  29360. */
  29361. highlightsHue: number;
  29362. /**
  29363. * Gets the highlights Density value.
  29364. * 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.
  29365. * Values less than zero provide a filter of opposite hue.
  29366. */
  29367. /**
  29368. * Sets the highlights Density value.
  29369. * 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.
  29370. * Values less than zero provide a filter of opposite hue.
  29371. */
  29372. highlightsDensity: number;
  29373. /**
  29374. * Gets the highlights Saturation value.
  29375. * 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.
  29376. */
  29377. /**
  29378. * Sets the highlights Saturation value.
  29379. * 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.
  29380. */
  29381. highlightsSaturation: number;
  29382. /**
  29383. * Gets the highlights Exposure value.
  29384. * 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.
  29385. */
  29386. /**
  29387. * Sets the highlights Exposure value.
  29388. * 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.
  29389. */
  29390. highlightsExposure: number;
  29391. private _midtonesHue;
  29392. private _midtonesDensity;
  29393. private _midtonesSaturation;
  29394. private _midtonesExposure;
  29395. /**
  29396. * Gets the midtones Hue value.
  29397. * 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).
  29398. */
  29399. /**
  29400. * Sets the midtones Hue value.
  29401. * 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).
  29402. */
  29403. midtonesHue: number;
  29404. /**
  29405. * Gets the midtones Density value.
  29406. * 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.
  29407. * Values less than zero provide a filter of opposite hue.
  29408. */
  29409. /**
  29410. * Sets the midtones Density value.
  29411. * 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.
  29412. * Values less than zero provide a filter of opposite hue.
  29413. */
  29414. midtonesDensity: number;
  29415. /**
  29416. * Gets the midtones Saturation value.
  29417. * 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.
  29418. */
  29419. /**
  29420. * Sets the midtones Saturation value.
  29421. * 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.
  29422. */
  29423. midtonesSaturation: number;
  29424. /**
  29425. * Gets the midtones Exposure value.
  29426. * 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.
  29427. */
  29428. /**
  29429. * Sets the midtones Exposure value.
  29430. * 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.
  29431. */
  29432. midtonesExposure: number;
  29433. private _shadowsHue;
  29434. private _shadowsDensity;
  29435. private _shadowsSaturation;
  29436. private _shadowsExposure;
  29437. /**
  29438. * Gets the shadows Hue value.
  29439. * 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).
  29440. */
  29441. /**
  29442. * Sets the shadows Hue value.
  29443. * 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).
  29444. */
  29445. shadowsHue: number;
  29446. /**
  29447. * Gets the shadows Density value.
  29448. * 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.
  29449. * Values less than zero provide a filter of opposite hue.
  29450. */
  29451. /**
  29452. * Sets the shadows Density value.
  29453. * 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.
  29454. * Values less than zero provide a filter of opposite hue.
  29455. */
  29456. shadowsDensity: number;
  29457. /**
  29458. * Gets the shadows Saturation value.
  29459. * 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.
  29460. */
  29461. /**
  29462. * Sets the shadows Saturation value.
  29463. * 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.
  29464. */
  29465. shadowsSaturation: number;
  29466. /**
  29467. * Gets the shadows Exposure value.
  29468. * 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.
  29469. */
  29470. /**
  29471. * Sets the shadows Exposure value.
  29472. * 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.
  29473. */
  29474. shadowsExposure: number;
  29475. /**
  29476. * Returns the class name
  29477. * @returns The class name
  29478. */
  29479. getClassName(): string;
  29480. /**
  29481. * Binds the color curves to the shader.
  29482. * @param colorCurves The color curve to bind
  29483. * @param effect The effect to bind to
  29484. * @param positiveUniform The positive uniform shader parameter
  29485. * @param neutralUniform The neutral uniform shader parameter
  29486. * @param negativeUniform The negative uniform shader parameter
  29487. */
  29488. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29489. /**
  29490. * Prepare the list of uniforms associated with the ColorCurves effects.
  29491. * @param uniformsList The list of uniforms used in the effect
  29492. */
  29493. static PrepareUniforms(uniformsList: string[]): void;
  29494. /**
  29495. * Returns color grading data based on a hue, density, saturation and exposure value.
  29496. * @param filterHue The hue of the color filter.
  29497. * @param filterDensity The density of the color filter.
  29498. * @param saturation The saturation.
  29499. * @param exposure The exposure.
  29500. * @param result The result data container.
  29501. */
  29502. private getColorGradingDataToRef;
  29503. /**
  29504. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29505. * @param value The input slider value in range [-100,100].
  29506. * @returns Adjusted value.
  29507. */
  29508. private static applyColorGradingSliderNonlinear;
  29509. /**
  29510. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29511. * @param hue The hue (H) input.
  29512. * @param saturation The saturation (S) input.
  29513. * @param brightness The brightness (B) input.
  29514. * @result An RGBA color represented as Vector4.
  29515. */
  29516. private static fromHSBToRef;
  29517. /**
  29518. * Returns a value clamped between min and max
  29519. * @param value The value to clamp
  29520. * @param min The minimum of value
  29521. * @param max The maximum of value
  29522. * @returns The clamped value.
  29523. */
  29524. private static clamp;
  29525. /**
  29526. * Clones the current color curve instance.
  29527. * @return The cloned curves
  29528. */
  29529. clone(): ColorCurves;
  29530. /**
  29531. * Serializes the current color curve instance to a json representation.
  29532. * @return a JSON representation
  29533. */
  29534. serialize(): any;
  29535. /**
  29536. * Parses the color curve from a json representation.
  29537. * @param source the JSON source to parse
  29538. * @return The parsed curves
  29539. */
  29540. static Parse(source: any): ColorCurves;
  29541. }
  29542. }
  29543. declare module BABYLON {
  29544. /**
  29545. * Interface to follow in your material defines to integrate easily the
  29546. * Image proccessing functions.
  29547. * @hidden
  29548. */
  29549. export interface IImageProcessingConfigurationDefines {
  29550. IMAGEPROCESSING: boolean;
  29551. VIGNETTE: boolean;
  29552. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29553. VIGNETTEBLENDMODEOPAQUE: boolean;
  29554. TONEMAPPING: boolean;
  29555. TONEMAPPING_ACES: boolean;
  29556. CONTRAST: boolean;
  29557. EXPOSURE: boolean;
  29558. COLORCURVES: boolean;
  29559. COLORGRADING: boolean;
  29560. COLORGRADING3D: boolean;
  29561. SAMPLER3DGREENDEPTH: boolean;
  29562. SAMPLER3DBGRMAP: boolean;
  29563. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29564. }
  29565. /**
  29566. * @hidden
  29567. */
  29568. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29569. IMAGEPROCESSING: boolean;
  29570. VIGNETTE: boolean;
  29571. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29572. VIGNETTEBLENDMODEOPAQUE: boolean;
  29573. TONEMAPPING: boolean;
  29574. TONEMAPPING_ACES: boolean;
  29575. CONTRAST: boolean;
  29576. COLORCURVES: boolean;
  29577. COLORGRADING: boolean;
  29578. COLORGRADING3D: boolean;
  29579. SAMPLER3DGREENDEPTH: boolean;
  29580. SAMPLER3DBGRMAP: boolean;
  29581. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29582. EXPOSURE: boolean;
  29583. constructor();
  29584. }
  29585. /**
  29586. * This groups together the common properties used for image processing either in direct forward pass
  29587. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29588. * or not.
  29589. */
  29590. export class ImageProcessingConfiguration {
  29591. /**
  29592. * Default tone mapping applied in BabylonJS.
  29593. */
  29594. static readonly TONEMAPPING_STANDARD: number;
  29595. /**
  29596. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29597. * to other engines rendering to increase portability.
  29598. */
  29599. static readonly TONEMAPPING_ACES: number;
  29600. /**
  29601. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29602. */
  29603. colorCurves: Nullable<ColorCurves>;
  29604. private _colorCurvesEnabled;
  29605. /**
  29606. * Gets wether the color curves effect is enabled.
  29607. */
  29608. /**
  29609. * Sets wether the color curves effect is enabled.
  29610. */
  29611. colorCurvesEnabled: boolean;
  29612. private _colorGradingTexture;
  29613. /**
  29614. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29615. */
  29616. /**
  29617. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29618. */
  29619. colorGradingTexture: Nullable<BaseTexture>;
  29620. private _colorGradingEnabled;
  29621. /**
  29622. * Gets wether the color grading effect is enabled.
  29623. */
  29624. /**
  29625. * Sets wether the color grading effect is enabled.
  29626. */
  29627. colorGradingEnabled: boolean;
  29628. private _colorGradingWithGreenDepth;
  29629. /**
  29630. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29631. */
  29632. /**
  29633. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29634. */
  29635. colorGradingWithGreenDepth: boolean;
  29636. private _colorGradingBGR;
  29637. /**
  29638. * Gets wether the color grading texture contains BGR values.
  29639. */
  29640. /**
  29641. * Sets wether the color grading texture contains BGR values.
  29642. */
  29643. colorGradingBGR: boolean;
  29644. /** @hidden */ private _exposure: number;
  29645. /**
  29646. * Gets the Exposure used in the effect.
  29647. */
  29648. /**
  29649. * Sets the Exposure used in the effect.
  29650. */
  29651. exposure: number;
  29652. private _toneMappingEnabled;
  29653. /**
  29654. * Gets wether the tone mapping effect is enabled.
  29655. */
  29656. /**
  29657. * Sets wether the tone mapping effect is enabled.
  29658. */
  29659. toneMappingEnabled: boolean;
  29660. private _toneMappingType;
  29661. /**
  29662. * Gets the type of tone mapping effect.
  29663. */
  29664. /**
  29665. * Sets the type of tone mapping effect used in BabylonJS.
  29666. */
  29667. toneMappingType: number;
  29668. protected _contrast: number;
  29669. /**
  29670. * Gets the contrast used in the effect.
  29671. */
  29672. /**
  29673. * Sets the contrast used in the effect.
  29674. */
  29675. contrast: number;
  29676. /**
  29677. * Vignette stretch size.
  29678. */
  29679. vignetteStretch: number;
  29680. /**
  29681. * Vignette centre X Offset.
  29682. */
  29683. vignetteCentreX: number;
  29684. /**
  29685. * Vignette centre Y Offset.
  29686. */
  29687. vignetteCentreY: number;
  29688. /**
  29689. * Vignette weight or intensity of the vignette effect.
  29690. */
  29691. vignetteWeight: number;
  29692. /**
  29693. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29694. * if vignetteEnabled is set to true.
  29695. */
  29696. vignetteColor: Color4;
  29697. /**
  29698. * Camera field of view used by the Vignette effect.
  29699. */
  29700. vignetteCameraFov: number;
  29701. private _vignetteBlendMode;
  29702. /**
  29703. * Gets the vignette blend mode allowing different kind of effect.
  29704. */
  29705. /**
  29706. * Sets the vignette blend mode allowing different kind of effect.
  29707. */
  29708. vignetteBlendMode: number;
  29709. private _vignetteEnabled;
  29710. /**
  29711. * Gets wether the vignette effect is enabled.
  29712. */
  29713. /**
  29714. * Sets wether the vignette effect is enabled.
  29715. */
  29716. vignetteEnabled: boolean;
  29717. private _applyByPostProcess;
  29718. /**
  29719. * Gets wether the image processing is applied through a post process or not.
  29720. */
  29721. /**
  29722. * Sets wether the image processing is applied through a post process or not.
  29723. */
  29724. applyByPostProcess: boolean;
  29725. private _isEnabled;
  29726. /**
  29727. * Gets wether the image processing is enabled or not.
  29728. */
  29729. /**
  29730. * Sets wether the image processing is enabled or not.
  29731. */
  29732. isEnabled: boolean;
  29733. /**
  29734. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29735. */
  29736. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29737. /**
  29738. * Method called each time the image processing information changes requires to recompile the effect.
  29739. */
  29740. protected _updateParameters(): void;
  29741. /**
  29742. * Gets the current class name.
  29743. * @return "ImageProcessingConfiguration"
  29744. */
  29745. getClassName(): string;
  29746. /**
  29747. * Prepare the list of uniforms associated with the Image Processing effects.
  29748. * @param uniforms The list of uniforms used in the effect
  29749. * @param defines the list of defines currently in use
  29750. */
  29751. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29752. /**
  29753. * Prepare the list of samplers associated with the Image Processing effects.
  29754. * @param samplersList The list of uniforms used in the effect
  29755. * @param defines the list of defines currently in use
  29756. */
  29757. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29758. /**
  29759. * Prepare the list of defines associated to the shader.
  29760. * @param defines the list of defines to complete
  29761. * @param forPostProcess Define if we are currently in post process mode or not
  29762. */
  29763. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29764. /**
  29765. * Returns true if all the image processing information are ready.
  29766. * @returns True if ready, otherwise, false
  29767. */
  29768. isReady(): boolean;
  29769. /**
  29770. * Binds the image processing to the shader.
  29771. * @param effect The effect to bind to
  29772. * @param aspectRatio Define the current aspect ratio of the effect
  29773. */
  29774. bind(effect: Effect, aspectRatio?: number): void;
  29775. /**
  29776. * Clones the current image processing instance.
  29777. * @return The cloned image processing
  29778. */
  29779. clone(): ImageProcessingConfiguration;
  29780. /**
  29781. * Serializes the current image processing instance to a json representation.
  29782. * @return a JSON representation
  29783. */
  29784. serialize(): any;
  29785. /**
  29786. * Parses the image processing from a json representation.
  29787. * @param source the JSON source to parse
  29788. * @return The parsed image processing
  29789. */
  29790. static Parse(source: any): ImageProcessingConfiguration;
  29791. private static _VIGNETTEMODE_MULTIPLY;
  29792. private static _VIGNETTEMODE_OPAQUE;
  29793. /**
  29794. * Used to apply the vignette as a mix with the pixel color.
  29795. */
  29796. static readonly VIGNETTEMODE_MULTIPLY: number;
  29797. /**
  29798. * Used to apply the vignette as a replacement of the pixel color.
  29799. */
  29800. static readonly VIGNETTEMODE_OPAQUE: number;
  29801. }
  29802. }
  29803. declare module BABYLON {
  29804. /**
  29805. * This represents all the required information to add a fresnel effect on a material:
  29806. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29807. */
  29808. export class FresnelParameters {
  29809. private _isEnabled;
  29810. /**
  29811. * Define if the fresnel effect is enable or not.
  29812. */
  29813. isEnabled: boolean;
  29814. /**
  29815. * Define the color used on edges (grazing angle)
  29816. */
  29817. leftColor: Color3;
  29818. /**
  29819. * Define the color used on center
  29820. */
  29821. rightColor: Color3;
  29822. /**
  29823. * Define bias applied to computed fresnel term
  29824. */
  29825. bias: number;
  29826. /**
  29827. * Defined the power exponent applied to fresnel term
  29828. */
  29829. power: number;
  29830. /**
  29831. * Clones the current fresnel and its valuues
  29832. * @returns a clone fresnel configuration
  29833. */
  29834. clone(): FresnelParameters;
  29835. /**
  29836. * Serializes the current fresnel parameters to a JSON representation.
  29837. * @return the JSON serialization
  29838. */
  29839. serialize(): any;
  29840. /**
  29841. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29842. * @param parsedFresnelParameters Define the JSON representation
  29843. * @returns the parsed parameters
  29844. */
  29845. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29846. }
  29847. }
  29848. declare module BABYLON {
  29849. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29850. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29851. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29852. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29853. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29854. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29855. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29856. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29857. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29858. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29859. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29860. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29861. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29862. /**
  29863. * Decorator used to define property that can be serialized as reference to a camera
  29864. * @param sourceName defines the name of the property to decorate
  29865. */
  29866. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29867. /**
  29868. * Class used to help serialization objects
  29869. */
  29870. export class SerializationHelper {
  29871. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29872. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29873. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29874. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29875. /**
  29876. * Appends the serialized animations from the source animations
  29877. * @param source Source containing the animations
  29878. * @param destination Target to store the animations
  29879. */
  29880. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29881. /**
  29882. * Static function used to serialized a specific entity
  29883. * @param entity defines the entity to serialize
  29884. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29885. * @returns a JSON compatible object representing the serialization of the entity
  29886. */
  29887. static Serialize<T>(entity: T, serializationObject?: any): any;
  29888. /**
  29889. * Creates a new entity from a serialization data object
  29890. * @param creationFunction defines a function used to instanciated the new entity
  29891. * @param source defines the source serialization data
  29892. * @param scene defines the hosting scene
  29893. * @param rootUrl defines the root url for resources
  29894. * @returns a new entity
  29895. */
  29896. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29897. /**
  29898. * Clones an object
  29899. * @param creationFunction defines the function used to instanciate the new object
  29900. * @param source defines the source object
  29901. * @returns the cloned object
  29902. */
  29903. static Clone<T>(creationFunction: () => T, source: T): T;
  29904. /**
  29905. * Instanciates a new object based on a source one (some data will be shared between both object)
  29906. * @param creationFunction defines the function used to instanciate the new object
  29907. * @param source defines the source object
  29908. * @returns the new object
  29909. */
  29910. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29911. }
  29912. }
  29913. declare module BABYLON {
  29914. /**
  29915. * This is the base class of all the camera used in the application.
  29916. * @see http://doc.babylonjs.com/features/cameras
  29917. */
  29918. export class Camera extends Node {
  29919. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29920. /**
  29921. * This is the default projection mode used by the cameras.
  29922. * It helps recreating a feeling of perspective and better appreciate depth.
  29923. * This is the best way to simulate real life cameras.
  29924. */
  29925. static readonly PERSPECTIVE_CAMERA: number;
  29926. /**
  29927. * This helps creating camera with an orthographic mode.
  29928. * 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.
  29929. */
  29930. static readonly ORTHOGRAPHIC_CAMERA: number;
  29931. /**
  29932. * This is the default FOV mode for perspective cameras.
  29933. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29934. */
  29935. static readonly FOVMODE_VERTICAL_FIXED: number;
  29936. /**
  29937. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29938. */
  29939. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29940. /**
  29941. * This specifies ther is no need for a camera rig.
  29942. * Basically only one eye is rendered corresponding to the camera.
  29943. */
  29944. static readonly RIG_MODE_NONE: number;
  29945. /**
  29946. * Simulates a camera Rig with one blue eye and one red eye.
  29947. * This can be use with 3d blue and red glasses.
  29948. */
  29949. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29950. /**
  29951. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29952. */
  29953. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29954. /**
  29955. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29956. */
  29957. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29958. /**
  29959. * Defines that both eyes of the camera will be rendered over under each other.
  29960. */
  29961. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29962. /**
  29963. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29964. */
  29965. static readonly RIG_MODE_VR: number;
  29966. /**
  29967. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29968. */
  29969. static readonly RIG_MODE_WEBVR: number;
  29970. /**
  29971. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29972. */
  29973. static readonly RIG_MODE_CUSTOM: number;
  29974. /**
  29975. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29976. */
  29977. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29978. /**
  29979. * Define the input manager associated with the camera.
  29980. */
  29981. inputs: CameraInputsManager<Camera>;
  29982. /** @hidden */ private _position: Vector3;
  29983. /**
  29984. * Define the current local position of the camera in the scene
  29985. */
  29986. position: Vector3;
  29987. /**
  29988. * The vector the camera should consider as up.
  29989. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29990. */
  29991. upVector: Vector3;
  29992. /**
  29993. * Define the current limit on the left side for an orthographic camera
  29994. * In scene unit
  29995. */
  29996. orthoLeft: Nullable<number>;
  29997. /**
  29998. * Define the current limit on the right side for an orthographic camera
  29999. * In scene unit
  30000. */
  30001. orthoRight: Nullable<number>;
  30002. /**
  30003. * Define the current limit on the bottom side for an orthographic camera
  30004. * In scene unit
  30005. */
  30006. orthoBottom: Nullable<number>;
  30007. /**
  30008. * Define the current limit on the top side for an orthographic camera
  30009. * In scene unit
  30010. */
  30011. orthoTop: Nullable<number>;
  30012. /**
  30013. * Field Of View is set in Radians. (default is 0.8)
  30014. */
  30015. fov: number;
  30016. /**
  30017. * Define the minimum distance the camera can see from.
  30018. * This is important to note that the depth buffer are not infinite and the closer it starts
  30019. * the more your scene might encounter depth fighting issue.
  30020. */
  30021. minZ: number;
  30022. /**
  30023. * Define the maximum distance the camera can see to.
  30024. * This is important to note that the depth buffer are not infinite and the further it end
  30025. * the more your scene might encounter depth fighting issue.
  30026. */
  30027. maxZ: number;
  30028. /**
  30029. * Define the default inertia of the camera.
  30030. * This helps giving a smooth feeling to the camera movement.
  30031. */
  30032. inertia: number;
  30033. /**
  30034. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30035. */
  30036. mode: number;
  30037. /**
  30038. * Define wether the camera is intermediate.
  30039. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30040. */
  30041. isIntermediate: boolean;
  30042. /**
  30043. * Define the viewport of the camera.
  30044. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30045. */
  30046. viewport: Viewport;
  30047. /**
  30048. * Restricts the camera to viewing objects with the same layerMask.
  30049. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30050. */
  30051. layerMask: number;
  30052. /**
  30053. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30054. */
  30055. fovMode: number;
  30056. /**
  30057. * Rig mode of the camera.
  30058. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30059. * This is normally controlled byt the camera themselves as internal use.
  30060. */
  30061. cameraRigMode: number;
  30062. /**
  30063. * Defines the distance between both "eyes" in case of a RIG
  30064. */
  30065. interaxialDistance: number;
  30066. /**
  30067. * Defines if stereoscopic rendering is done side by side or over under.
  30068. */
  30069. isStereoscopicSideBySide: boolean;
  30070. /**
  30071. * 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
  30072. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30073. * else in the scene.
  30074. */
  30075. customRenderTargets: RenderTargetTexture[];
  30076. /**
  30077. * When set, the camera will render to this render target instead of the default canvas
  30078. */
  30079. outputRenderTarget: Nullable<RenderTargetTexture>;
  30080. /**
  30081. * Observable triggered when the camera view matrix has changed.
  30082. */
  30083. onViewMatrixChangedObservable: Observable<Camera>;
  30084. /**
  30085. * Observable triggered when the camera Projection matrix has changed.
  30086. */
  30087. onProjectionMatrixChangedObservable: Observable<Camera>;
  30088. /**
  30089. * Observable triggered when the inputs have been processed.
  30090. */
  30091. onAfterCheckInputsObservable: Observable<Camera>;
  30092. /**
  30093. * Observable triggered when reset has been called and applied to the camera.
  30094. */
  30095. onRestoreStateObservable: Observable<Camera>;
  30096. /** @hidden */ private _cameraRigParams: any;
  30097. /** @hidden */ private _rigCameras: Camera[];
  30098. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  30099. protected _webvrViewMatrix: Matrix;
  30100. /** @hidden */ private _skipRendering: boolean;
  30101. /** @hidden */ private _projectionMatrix: Matrix;
  30102. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  30103. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  30104. protected _globalPosition: Vector3;
  30105. /** @hidden */ private _computedViewMatrix: Matrix;
  30106. private _doNotComputeProjectionMatrix;
  30107. private _transformMatrix;
  30108. private _frustumPlanes;
  30109. private _refreshFrustumPlanes;
  30110. private _storedFov;
  30111. private _stateStored;
  30112. /**
  30113. * Instantiates a new camera object.
  30114. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30115. * @see http://doc.babylonjs.com/features/cameras
  30116. * @param name Defines the name of the camera in the scene
  30117. * @param position Defines the position of the camera
  30118. * @param scene Defines the scene the camera belongs too
  30119. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30120. */
  30121. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30122. /**
  30123. * Store current camera state (fov, position, etc..)
  30124. * @returns the camera
  30125. */
  30126. storeState(): Camera;
  30127. /**
  30128. * Restores the camera state values if it has been stored. You must call storeState() first
  30129. */
  30130. protected _restoreStateValues(): boolean;
  30131. /**
  30132. * Restored camera state. You must call storeState() first.
  30133. * @returns true if restored and false otherwise
  30134. */
  30135. restoreState(): boolean;
  30136. /**
  30137. * Gets the class name of the camera.
  30138. * @returns the class name
  30139. */
  30140. getClassName(): string;
  30141. /** @hidden */ protected readonly _isCamera: boolean;
  30142. /**
  30143. * Gets a string representation of the camera useful for debug purpose.
  30144. * @param fullDetails Defines that a more verboe level of logging is required
  30145. * @returns the string representation
  30146. */
  30147. toString(fullDetails?: boolean): string;
  30148. /**
  30149. * Gets the current world space position of the camera.
  30150. */
  30151. readonly globalPosition: Vector3;
  30152. /**
  30153. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30154. * @returns the active meshe list
  30155. */
  30156. getActiveMeshes(): SmartArray<AbstractMesh>;
  30157. /**
  30158. * Check wether a mesh is part of the current active mesh list of the camera
  30159. * @param mesh Defines the mesh to check
  30160. * @returns true if active, false otherwise
  30161. */
  30162. isActiveMesh(mesh: Mesh): boolean;
  30163. /**
  30164. * Is this camera ready to be used/rendered
  30165. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30166. * @return true if the camera is ready
  30167. */
  30168. isReady(completeCheck?: boolean): boolean;
  30169. /** @hidden */ private _initCache(): void;
  30170. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  30171. /** @hidden */ private _isSynchronized(): boolean;
  30172. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  30173. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  30174. /**
  30175. * Attach the input controls to a specific dom element to get the input from.
  30176. * @param element Defines the element the controls should be listened from
  30177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30178. */
  30179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30180. /**
  30181. * Detach the current controls from the specified dom element.
  30182. * @param element Defines the element to stop listening the inputs from
  30183. */
  30184. detachControl(element: HTMLElement): void;
  30185. /**
  30186. * Update the camera state according to the different inputs gathered during the frame.
  30187. */
  30188. update(): void;
  30189. /** @hidden */ private _checkInputs(): void;
  30190. /** @hidden */
  30191. readonly rigCameras: Camera[];
  30192. /**
  30193. * Gets the post process used by the rig cameras
  30194. */
  30195. readonly rigPostProcess: Nullable<PostProcess>;
  30196. /**
  30197. * Internal, gets the first post proces.
  30198. * @returns the first post process to be run on this camera.
  30199. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  30200. private _cascadePostProcessesToRigCams;
  30201. /**
  30202. * Attach a post process to the camera.
  30203. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30204. * @param postProcess The post process to attach to the camera
  30205. * @param insertAt The position of the post process in case several of them are in use in the scene
  30206. * @returns the position the post process has been inserted at
  30207. */
  30208. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30209. /**
  30210. * Detach a post process to the camera.
  30211. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30212. * @param postProcess The post process to detach from the camera
  30213. */
  30214. detachPostProcess(postProcess: PostProcess): void;
  30215. /**
  30216. * Gets the current world matrix of the camera
  30217. */
  30218. getWorldMatrix(): Matrix;
  30219. /** @hidden */ private _getViewMatrix(): Matrix;
  30220. /**
  30221. * Gets the current view matrix of the camera.
  30222. * @param force forces the camera to recompute the matrix without looking at the cached state
  30223. * @returns the view matrix
  30224. */
  30225. getViewMatrix(force?: boolean): Matrix;
  30226. /**
  30227. * Freeze the projection matrix.
  30228. * It will prevent the cache check of the camera projection compute and can speed up perf
  30229. * if no parameter of the camera are meant to change
  30230. * @param projection Defines manually a projection if necessary
  30231. */
  30232. freezeProjectionMatrix(projection?: Matrix): void;
  30233. /**
  30234. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30235. */
  30236. unfreezeProjectionMatrix(): void;
  30237. /**
  30238. * Gets the current projection matrix of the camera.
  30239. * @param force forces the camera to recompute the matrix without looking at the cached state
  30240. * @returns the projection matrix
  30241. */
  30242. getProjectionMatrix(force?: boolean): Matrix;
  30243. /**
  30244. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30245. * @returns a Matrix
  30246. */
  30247. getTransformationMatrix(): Matrix;
  30248. private _updateFrustumPlanes;
  30249. /**
  30250. * Checks if a cullable object (mesh...) is in the camera frustum
  30251. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30252. * @param target The object to check
  30253. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30254. * @returns true if the object is in frustum otherwise false
  30255. */
  30256. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30257. /**
  30258. * Checks if a cullable object (mesh...) is in the camera frustum
  30259. * Unlike isInFrustum this cheks the full bounding box
  30260. * @param target The object to check
  30261. * @returns true if the object is in frustum otherwise false
  30262. */
  30263. isCompletelyInFrustum(target: ICullable): boolean;
  30264. /**
  30265. * Gets a ray in the forward direction from the camera.
  30266. * @param length Defines the length of the ray to create
  30267. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30268. * @param origin Defines the start point of the ray which defaults to the camera position
  30269. * @returns the forward ray
  30270. */
  30271. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30272. /**
  30273. * Releases resources associated with this node.
  30274. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30275. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30276. */
  30277. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30278. /** @hidden */ private _isLeftCamera: boolean;
  30279. /**
  30280. * Gets the left camera of a rig setup in case of Rigged Camera
  30281. */
  30282. readonly isLeftCamera: boolean;
  30283. /** @hidden */ private _isRightCamera: boolean;
  30284. /**
  30285. * Gets the right camera of a rig setup in case of Rigged Camera
  30286. */
  30287. readonly isRightCamera: boolean;
  30288. /**
  30289. * Gets the left camera of a rig setup in case of Rigged Camera
  30290. */
  30291. readonly leftCamera: Nullable<FreeCamera>;
  30292. /**
  30293. * Gets the right camera of a rig setup in case of Rigged Camera
  30294. */
  30295. readonly rightCamera: Nullable<FreeCamera>;
  30296. /**
  30297. * Gets the left camera target of a rig setup in case of Rigged Camera
  30298. * @returns the target position
  30299. */
  30300. getLeftTarget(): Nullable<Vector3>;
  30301. /**
  30302. * Gets the right camera target of a rig setup in case of Rigged Camera
  30303. * @returns the target position
  30304. */
  30305. getRightTarget(): Nullable<Vector3>;
  30306. /**
  30307. * @hidden
  30308. */
  30309. setCameraRigMode(mode: number, rigParams: any): void;
  30310. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30311. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30312. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30313. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30314. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  30315. protected _updateCameraRotationMatrix(): void;
  30316. protected _updateWebVRCameraRotationMatrix(): void;
  30317. /**
  30318. * This function MUST be overwritten by the different WebVR cameras available.
  30319. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30320. * @hidden
  30321. */ private _getWebVRProjectionMatrix(): Matrix;
  30322. /**
  30323. * This function MUST be overwritten by the different WebVR cameras available.
  30324. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30325. * @hidden
  30326. */ private _getWebVRViewMatrix(): Matrix;
  30327. /** @hidden */
  30328. setCameraRigParameter(name: string, value: any): void;
  30329. /**
  30330. * needs to be overridden by children so sub has required properties to be copied
  30331. * @hidden
  30332. */
  30333. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30334. /**
  30335. * May need to be overridden by children
  30336. * @hidden
  30337. */ private _updateRigCameras(): void;
  30338. /** @hidden */ private _setupInputs(): void;
  30339. /**
  30340. * Serialiaze the camera setup to a json represention
  30341. * @returns the JSON representation
  30342. */
  30343. serialize(): any;
  30344. /**
  30345. * Clones the current camera.
  30346. * @param name The cloned camera name
  30347. * @returns the cloned camera
  30348. */
  30349. clone(name: string): Camera;
  30350. /**
  30351. * Gets the direction of the camera relative to a given local axis.
  30352. * @param localAxis Defines the reference axis to provide a relative direction.
  30353. * @return the direction
  30354. */
  30355. getDirection(localAxis: Vector3): Vector3;
  30356. /**
  30357. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30358. * @param localAxis Defines the reference axis to provide a relative direction.
  30359. * @param result Defines the vector to store the result in
  30360. */
  30361. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30362. /**
  30363. * Gets a camera constructor for a given camera type
  30364. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30365. * @param name The name of the camera the result will be able to instantiate
  30366. * @param scene The scene the result will construct the camera in
  30367. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30368. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30369. * @returns a factory method to construc the camera
  30370. */
  30371. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30372. /**
  30373. * Compute the world matrix of the camera.
  30374. * @returns the camera workd matrix
  30375. */
  30376. computeWorldMatrix(): Matrix;
  30377. /**
  30378. * Parse a JSON and creates the camera from the parsed information
  30379. * @param parsedCamera The JSON to parse
  30380. * @param scene The scene to instantiate the camera in
  30381. * @returns the newly constructed camera
  30382. */
  30383. static Parse(parsedCamera: any, scene: Scene): Camera;
  30384. }
  30385. }
  30386. declare module BABYLON {
  30387. /**
  30388. * Interface for any object that can request an animation frame
  30389. */
  30390. export interface ICustomAnimationFrameRequester {
  30391. /**
  30392. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30393. */
  30394. renderFunction?: Function;
  30395. /**
  30396. * Called to request the next frame to render to
  30397. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30398. */
  30399. requestAnimationFrame: Function;
  30400. /**
  30401. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30402. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30403. */
  30404. requestID?: number;
  30405. }
  30406. /**
  30407. * Interface containing an array of animations
  30408. */
  30409. export interface IAnimatable {
  30410. /**
  30411. * Array of animations
  30412. */
  30413. animations: Nullable<Array<Animation>>;
  30414. }
  30415. /** Interface used by value gradients (color, factor, ...) */
  30416. export interface IValueGradient {
  30417. /**
  30418. * Gets or sets the gradient value (between 0 and 1)
  30419. */
  30420. gradient: number;
  30421. }
  30422. /** Class used to store color4 gradient */
  30423. export class ColorGradient implements IValueGradient {
  30424. /**
  30425. * Gets or sets the gradient value (between 0 and 1)
  30426. */
  30427. gradient: number;
  30428. /**
  30429. * Gets or sets first associated color
  30430. */
  30431. color1: Color4;
  30432. /**
  30433. * Gets or sets second associated color
  30434. */
  30435. color2?: Color4;
  30436. /**
  30437. * Will get a color picked randomly between color1 and color2.
  30438. * If color2 is undefined then color1 will be used
  30439. * @param result defines the target Color4 to store the result in
  30440. */
  30441. getColorToRef(result: Color4): void;
  30442. }
  30443. /** Class used to store color 3 gradient */
  30444. export class Color3Gradient implements IValueGradient {
  30445. /**
  30446. * Gets or sets the gradient value (between 0 and 1)
  30447. */
  30448. gradient: number;
  30449. /**
  30450. * Gets or sets the associated color
  30451. */
  30452. color: Color3;
  30453. }
  30454. /** Class used to store factor gradient */
  30455. export class FactorGradient implements IValueGradient {
  30456. /**
  30457. * Gets or sets the gradient value (between 0 and 1)
  30458. */
  30459. gradient: number;
  30460. /**
  30461. * Gets or sets first associated factor
  30462. */
  30463. factor1: number;
  30464. /**
  30465. * Gets or sets second associated factor
  30466. */
  30467. factor2?: number;
  30468. /**
  30469. * Will get a number picked randomly between factor1 and factor2.
  30470. * If factor2 is undefined then factor1 will be used
  30471. * @returns the picked number
  30472. */
  30473. getFactor(): number;
  30474. }
  30475. /**
  30476. * @ignore
  30477. * Application error to support additional information when loading a file
  30478. */
  30479. export class LoadFileError extends Error {
  30480. /** defines the optional web request */
  30481. request?: WebRequest | undefined;
  30482. private static _setPrototypeOf;
  30483. /**
  30484. * Creates a new LoadFileError
  30485. * @param message defines the message of the error
  30486. * @param request defines the optional web request
  30487. */
  30488. constructor(message: string,
  30489. /** defines the optional web request */
  30490. request?: WebRequest | undefined);
  30491. }
  30492. /**
  30493. * Class used to define a retry strategy when error happens while loading assets
  30494. */
  30495. export class RetryStrategy {
  30496. /**
  30497. * Function used to defines an exponential back off strategy
  30498. * @param maxRetries defines the maximum number of retries (3 by default)
  30499. * @param baseInterval defines the interval between retries
  30500. * @returns the strategy function to use
  30501. */
  30502. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30503. }
  30504. /**
  30505. * File request interface
  30506. */
  30507. export interface IFileRequest {
  30508. /**
  30509. * Raised when the request is complete (success or error).
  30510. */
  30511. onCompleteObservable: Observable<IFileRequest>;
  30512. /**
  30513. * Aborts the request for a file.
  30514. */
  30515. abort: () => void;
  30516. }
  30517. /**
  30518. * Class containing a set of static utilities functions
  30519. */
  30520. export class Tools {
  30521. /**
  30522. * Gets or sets the base URL to use to load assets
  30523. */
  30524. static BaseUrl: string;
  30525. /**
  30526. * Enable/Disable Custom HTTP Request Headers globally.
  30527. * default = false
  30528. * @see CustomRequestHeaders
  30529. */
  30530. static UseCustomRequestHeaders: boolean;
  30531. /**
  30532. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30533. * i.e. when loading files, where the server/service expects an Authorization header
  30534. */
  30535. static CustomRequestHeaders: {
  30536. [key: string]: string;
  30537. };
  30538. /**
  30539. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30540. */
  30541. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30542. /**
  30543. * Default behaviour for cors in the application.
  30544. * It can be a string if the expected behavior is identical in the entire app.
  30545. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30546. */
  30547. static CorsBehavior: string | ((url: string | string[]) => string);
  30548. /**
  30549. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30550. * @ignorenaming
  30551. */
  30552. static UseFallbackTexture: boolean;
  30553. /**
  30554. * Use this object to register external classes like custom textures or material
  30555. * to allow the laoders to instantiate them
  30556. */
  30557. static RegisteredExternalClasses: {
  30558. [key: string]: Object;
  30559. };
  30560. /**
  30561. * Texture content used if a texture cannot loaded
  30562. * @ignorenaming
  30563. */
  30564. static fallbackTexture: string;
  30565. /**
  30566. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30567. * @param u defines the coordinate on X axis
  30568. * @param v defines the coordinate on Y axis
  30569. * @param width defines the width of the source data
  30570. * @param height defines the height of the source data
  30571. * @param pixels defines the source byte array
  30572. * @param color defines the output color
  30573. */
  30574. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30575. /**
  30576. * Interpolates between a and b via alpha
  30577. * @param a The lower value (returned when alpha = 0)
  30578. * @param b The upper value (returned when alpha = 1)
  30579. * @param alpha The interpolation-factor
  30580. * @return The mixed value
  30581. */
  30582. static Mix(a: number, b: number, alpha: number): number;
  30583. /**
  30584. * Tries to instantiate a new object from a given class name
  30585. * @param className defines the class name to instantiate
  30586. * @returns the new object or null if the system was not able to do the instantiation
  30587. */
  30588. static Instantiate(className: string): any;
  30589. /**
  30590. * Provides a slice function that will work even on IE
  30591. * @param data defines the array to slice
  30592. * @param start defines the start of the data (optional)
  30593. * @param end defines the end of the data (optional)
  30594. * @returns the new sliced array
  30595. */
  30596. static Slice<T>(data: T, start?: number, end?: number): T;
  30597. /**
  30598. * Polyfill for setImmediate
  30599. * @param action defines the action to execute after the current execution block
  30600. */
  30601. static SetImmediate(action: () => void): void;
  30602. /**
  30603. * Function indicating if a number is an exponent of 2
  30604. * @param value defines the value to test
  30605. * @returns true if the value is an exponent of 2
  30606. */
  30607. static IsExponentOfTwo(value: number): boolean;
  30608. private static _tmpFloatArray;
  30609. /**
  30610. * Returns the nearest 32-bit single precision float representation of a Number
  30611. * @param value A Number. If the parameter is of a different type, it will get converted
  30612. * to a number or to NaN if it cannot be converted
  30613. * @returns number
  30614. */
  30615. static FloatRound(value: number): number;
  30616. /**
  30617. * Find the next highest power of two.
  30618. * @param x Number to start search from.
  30619. * @return Next highest power of two.
  30620. */
  30621. static CeilingPOT(x: number): number;
  30622. /**
  30623. * Find the next lowest power of two.
  30624. * @param x Number to start search from.
  30625. * @return Next lowest power of two.
  30626. */
  30627. static FloorPOT(x: number): number;
  30628. /**
  30629. * Find the nearest power of two.
  30630. * @param x Number to start search from.
  30631. * @return Next nearest power of two.
  30632. */
  30633. static NearestPOT(x: number): number;
  30634. /**
  30635. * Get the closest exponent of two
  30636. * @param value defines the value to approximate
  30637. * @param max defines the maximum value to return
  30638. * @param mode defines how to define the closest value
  30639. * @returns closest exponent of two of the given value
  30640. */
  30641. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30642. /**
  30643. * Extracts the filename from a path
  30644. * @param path defines the path to use
  30645. * @returns the filename
  30646. */
  30647. static GetFilename(path: string): string;
  30648. /**
  30649. * Extracts the "folder" part of a path (everything before the filename).
  30650. * @param uri The URI to extract the info from
  30651. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30652. * @returns The "folder" part of the path
  30653. */
  30654. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30655. /**
  30656. * Extracts text content from a DOM element hierarchy
  30657. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30658. */
  30659. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30660. /**
  30661. * Convert an angle in radians to degrees
  30662. * @param angle defines the angle to convert
  30663. * @returns the angle in degrees
  30664. */
  30665. static ToDegrees(angle: number): number;
  30666. /**
  30667. * Convert an angle in degrees to radians
  30668. * @param angle defines the angle to convert
  30669. * @returns the angle in radians
  30670. */
  30671. static ToRadians(angle: number): number;
  30672. /**
  30673. * Encode a buffer to a base64 string
  30674. * @param buffer defines the buffer to encode
  30675. * @returns the encoded string
  30676. */
  30677. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30678. /**
  30679. * Extracts minimum and maximum values from a list of indexed positions
  30680. * @param positions defines the positions to use
  30681. * @param indices defines the indices to the positions
  30682. * @param indexStart defines the start index
  30683. * @param indexCount defines the end index
  30684. * @param bias defines bias value to add to the result
  30685. * @return minimum and maximum values
  30686. */
  30687. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30688. minimum: Vector3;
  30689. maximum: Vector3;
  30690. };
  30691. /**
  30692. * Extracts minimum and maximum values from a list of positions
  30693. * @param positions defines the positions to use
  30694. * @param start defines the start index in the positions array
  30695. * @param count defines the number of positions to handle
  30696. * @param bias defines bias value to add to the result
  30697. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30698. * @return minimum and maximum values
  30699. */
  30700. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30701. minimum: Vector3;
  30702. maximum: Vector3;
  30703. };
  30704. /**
  30705. * Returns an array if obj is not an array
  30706. * @param obj defines the object to evaluate as an array
  30707. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30708. * @returns either obj directly if obj is an array or a new array containing obj
  30709. */
  30710. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30711. /**
  30712. * Gets the pointer prefix to use
  30713. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30714. */
  30715. static GetPointerPrefix(): string;
  30716. /**
  30717. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30718. * @param func - the function to be called
  30719. * @param requester - the object that will request the next frame. Falls back to window.
  30720. * @returns frame number
  30721. */
  30722. static QueueNewFrame(func: () => void, requester?: any): number;
  30723. /**
  30724. * Ask the browser to promote the current element to fullscreen rendering mode
  30725. * @param element defines the DOM element to promote
  30726. */
  30727. static RequestFullscreen(element: HTMLElement): void;
  30728. /**
  30729. * Asks the browser to exit fullscreen mode
  30730. */
  30731. static ExitFullscreen(): void;
  30732. /**
  30733. * Ask the browser to promote the current element to pointerlock mode
  30734. * @param element defines the DOM element to promote
  30735. */
  30736. static RequestPointerlock(element: HTMLElement): void;
  30737. /**
  30738. * Asks the browser to exit pointerlock mode
  30739. */
  30740. static ExitPointerlock(): void;
  30741. /**
  30742. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30743. * @param url define the url we are trying
  30744. * @param element define the dom element where to configure the cors policy
  30745. */
  30746. static SetCorsBehavior(url: string | string[], element: {
  30747. crossOrigin: string | null;
  30748. }): void;
  30749. /**
  30750. * Removes unwanted characters from an url
  30751. * @param url defines the url to clean
  30752. * @returns the cleaned url
  30753. */
  30754. static CleanUrl(url: string): string;
  30755. /**
  30756. * Gets or sets a function used to pre-process url before using them to load assets
  30757. */
  30758. static PreprocessUrl: (url: string) => string;
  30759. /**
  30760. * Loads an image as an HTMLImageElement.
  30761. * @param input url string, ArrayBuffer, or Blob to load
  30762. * @param onLoad callback called when the image successfully loads
  30763. * @param onError callback called when the image fails to load
  30764. * @param offlineProvider offline provider for caching
  30765. * @returns the HTMLImageElement of the loaded image
  30766. */
  30767. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30768. /**
  30769. * Loads a file
  30770. * @param url url string, ArrayBuffer, or Blob to load
  30771. * @param onSuccess callback called when the file successfully loads
  30772. * @param onProgress callback called while file is loading (if the server supports this mode)
  30773. * @param offlineProvider defines the offline provider for caching
  30774. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30775. * @param onError callback called when the file fails to load
  30776. * @returns a file request object
  30777. */
  30778. 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;
  30779. /**
  30780. * Loads a file from a url
  30781. * @param url the file url to load
  30782. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  30783. */
  30784. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  30785. /**
  30786. * Load a script (identified by an url). When the url returns, the
  30787. * content of this file is added into a new script element, attached to the DOM (body element)
  30788. * @param scriptUrl defines the url of the script to laod
  30789. * @param onSuccess defines the callback called when the script is loaded
  30790. * @param onError defines the callback to call if an error occurs
  30791. * @param scriptId defines the id of the script element
  30792. */
  30793. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30794. /**
  30795. * Load an asynchronous script (identified by an url). When the url returns, the
  30796. * content of this file is added into a new script element, attached to the DOM (body element)
  30797. * @param scriptUrl defines the url of the script to laod
  30798. * @param scriptId defines the id of the script element
  30799. * @returns a promise request object
  30800. */
  30801. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  30802. /**
  30803. * Loads a file from a blob
  30804. * @param fileToLoad defines the blob to use
  30805. * @param callback defines the callback to call when data is loaded
  30806. * @param progressCallback defines the callback to call during loading process
  30807. * @returns a file request object
  30808. */
  30809. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30810. /**
  30811. * Loads a file
  30812. * @param fileToLoad defines the file to load
  30813. * @param callback defines the callback to call when data is loaded
  30814. * @param progressCallBack defines the callback to call during loading process
  30815. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30816. * @returns a file request object
  30817. */
  30818. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30819. /**
  30820. * Creates a data url from a given string content
  30821. * @param content defines the content to convert
  30822. * @returns the new data url link
  30823. */
  30824. static FileAsURL(content: string): string;
  30825. /**
  30826. * Format the given number to a specific decimal format
  30827. * @param value defines the number to format
  30828. * @param decimals defines the number of decimals to use
  30829. * @returns the formatted string
  30830. */
  30831. static Format(value: number, decimals?: number): string;
  30832. /**
  30833. * Checks if a given vector is inside a specific range
  30834. * @param v defines the vector to test
  30835. * @param min defines the minimum range
  30836. * @param max defines the maximum range
  30837. */
  30838. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30839. /**
  30840. * Tries to copy an object by duplicating every property
  30841. * @param source defines the source object
  30842. * @param destination defines the target object
  30843. * @param doNotCopyList defines a list of properties to avoid
  30844. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30845. */
  30846. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30847. /**
  30848. * Gets a boolean indicating if the given object has no own property
  30849. * @param obj defines the object to test
  30850. * @returns true if object has no own property
  30851. */
  30852. static IsEmpty(obj: any): boolean;
  30853. /**
  30854. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30855. * @param str Source string
  30856. * @param suffix Suffix to search for in the source string
  30857. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30858. */
  30859. static EndsWith(str: string, suffix: string): boolean;
  30860. /**
  30861. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  30862. * @param str Source string
  30863. * @param suffix Suffix to search for in the source string
  30864. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30865. */
  30866. static StartsWith(str: string, suffix: string): boolean;
  30867. /**
  30868. * Function used to register events at window level
  30869. * @param events defines the events to register
  30870. */
  30871. static RegisterTopRootEvents(events: {
  30872. name: string;
  30873. handler: Nullable<(e: FocusEvent) => any>;
  30874. }[]): void;
  30875. /**
  30876. * Function used to unregister events from window level
  30877. * @param events defines the events to unregister
  30878. */
  30879. static UnregisterTopRootEvents(events: {
  30880. name: string;
  30881. handler: Nullable<(e: FocusEvent) => any>;
  30882. }[]): void;
  30883. /**
  30884. * @ignore
  30885. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30886. /**
  30887. * Dumps the current bound framebuffer
  30888. * @param width defines the rendering width
  30889. * @param height defines the rendering height
  30890. * @param engine defines the hosting engine
  30891. * @param successCallback defines the callback triggered once the data are available
  30892. * @param mimeType defines the mime type of the result
  30893. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30894. */
  30895. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30896. /**
  30897. * Converts the canvas data to blob.
  30898. * This acts as a polyfill for browsers not supporting the to blob function.
  30899. * @param canvas Defines the canvas to extract the data from
  30900. * @param successCallback Defines the callback triggered once the data are available
  30901. * @param mimeType Defines the mime type of the result
  30902. */
  30903. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30904. /**
  30905. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30906. * @param successCallback defines the callback triggered once the data are available
  30907. * @param mimeType defines the mime type of the result
  30908. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30909. */
  30910. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30911. /**
  30912. * Downloads a blob in the browser
  30913. * @param blob defines the blob to download
  30914. * @param fileName defines the name of the downloaded file
  30915. */
  30916. static Download(blob: Blob, fileName: string): void;
  30917. /**
  30918. * Captures a screenshot of the current rendering
  30919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30920. * @param engine defines the rendering engine
  30921. * @param camera defines the source camera
  30922. * @param size This parameter can be set to a single number or to an object with the
  30923. * following (optional) properties: precision, width, height. If a single number is passed,
  30924. * it will be used for both width and height. If an object is passed, the screenshot size
  30925. * will be derived from the parameters. The precision property is a multiplier allowing
  30926. * rendering at a higher or lower resolution
  30927. * @param successCallback defines the callback receives a single parameter which contains the
  30928. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30929. * src parameter of an <img> to display it
  30930. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30931. * Check your browser for supported MIME types
  30932. */
  30933. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30934. /**
  30935. * Generates an image screenshot from the specified camera.
  30936. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30937. * @param engine The engine to use for rendering
  30938. * @param camera The camera to use for rendering
  30939. * @param size This parameter can be set to a single number or to an object with the
  30940. * following (optional) properties: precision, width, height. If a single number is passed,
  30941. * it will be used for both width and height. If an object is passed, the screenshot size
  30942. * will be derived from the parameters. The precision property is a multiplier allowing
  30943. * rendering at a higher or lower resolution
  30944. * @param successCallback The callback receives a single parameter which contains the
  30945. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30946. * src parameter of an <img> to display it
  30947. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30948. * Check your browser for supported MIME types
  30949. * @param samples Texture samples (default: 1)
  30950. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30951. * @param fileName A name for for the downloaded file.
  30952. */
  30953. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30954. /**
  30955. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30956. * Be aware Math.random() could cause collisions, but:
  30957. * "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"
  30958. * @returns a pseudo random id
  30959. */
  30960. static RandomId(): string;
  30961. /**
  30962. * Test if the given uri is a base64 string
  30963. * @param uri The uri to test
  30964. * @return True if the uri is a base64 string or false otherwise
  30965. */
  30966. static IsBase64(uri: string): boolean;
  30967. /**
  30968. * Decode the given base64 uri.
  30969. * @param uri The uri to decode
  30970. * @return The decoded base64 data.
  30971. */
  30972. static DecodeBase64(uri: string): ArrayBuffer;
  30973. /**
  30974. * Gets the absolute url.
  30975. * @param url the input url
  30976. * @return the absolute url
  30977. */
  30978. static GetAbsoluteUrl(url: string): string;
  30979. /**
  30980. * No log
  30981. */
  30982. static readonly NoneLogLevel: number;
  30983. /**
  30984. * Only message logs
  30985. */
  30986. static readonly MessageLogLevel: number;
  30987. /**
  30988. * Only warning logs
  30989. */
  30990. static readonly WarningLogLevel: number;
  30991. /**
  30992. * Only error logs
  30993. */
  30994. static readonly ErrorLogLevel: number;
  30995. /**
  30996. * All logs
  30997. */
  30998. static readonly AllLogLevel: number;
  30999. /**
  31000. * Gets a value indicating the number of loading errors
  31001. * @ignorenaming
  31002. */
  31003. static readonly errorsCount: number;
  31004. /**
  31005. * Callback called when a new log is added
  31006. */
  31007. static OnNewCacheEntry: (entry: string) => void;
  31008. /**
  31009. * Log a message to the console
  31010. * @param message defines the message to log
  31011. */
  31012. static Log(message: string): void;
  31013. /**
  31014. * Write a warning message to the console
  31015. * @param message defines the message to log
  31016. */
  31017. static Warn(message: string): void;
  31018. /**
  31019. * Write an error message to the console
  31020. * @param message defines the message to log
  31021. */
  31022. static Error(message: string): void;
  31023. /**
  31024. * Gets current log cache (list of logs)
  31025. */
  31026. static readonly LogCache: string;
  31027. /**
  31028. * Clears the log cache
  31029. */
  31030. static ClearLogCache(): void;
  31031. /**
  31032. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31033. */
  31034. static LogLevels: number;
  31035. /**
  31036. * Checks if the loaded document was accessed via `file:`-Protocol.
  31037. * @returns boolean
  31038. */
  31039. static IsFileURL(): boolean;
  31040. /**
  31041. * Checks if the window object exists
  31042. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31043. */
  31044. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31045. /**
  31046. * No performance log
  31047. */
  31048. static readonly PerformanceNoneLogLevel: number;
  31049. /**
  31050. * Use user marks to log performance
  31051. */
  31052. static readonly PerformanceUserMarkLogLevel: number;
  31053. /**
  31054. * Log performance to the console
  31055. */
  31056. static readonly PerformanceConsoleLogLevel: number;
  31057. private static _performance;
  31058. /**
  31059. * Sets the current performance log level
  31060. */
  31061. static PerformanceLogLevel: number;
  31062. private static _StartPerformanceCounterDisabled;
  31063. private static _EndPerformanceCounterDisabled;
  31064. private static _StartUserMark;
  31065. private static _EndUserMark;
  31066. private static _StartPerformanceConsole;
  31067. private static _EndPerformanceConsole;
  31068. /**
  31069. * Starts a performance counter
  31070. */
  31071. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31072. /**
  31073. * Ends a specific performance coutner
  31074. */
  31075. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31076. /**
  31077. * Gets either window.performance.now() if supported or Date.now() else
  31078. */
  31079. static readonly Now: number;
  31080. /**
  31081. * This method will return the name of the class used to create the instance of the given object.
  31082. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31083. * @param object the object to get the class name from
  31084. * @param isType defines if the object is actually a type
  31085. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31086. */
  31087. static GetClassName(object: any, isType?: boolean): string;
  31088. /**
  31089. * Gets the first element of an array satisfying a given predicate
  31090. * @param array defines the array to browse
  31091. * @param predicate defines the predicate to use
  31092. * @returns null if not found or the element
  31093. */
  31094. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31095. /**
  31096. * This method will return the name of the full name of the class, including its owning module (if any).
  31097. * 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).
  31098. * @param object the object to get the class name from
  31099. * @param isType defines if the object is actually a type
  31100. * @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.
  31101. * @ignorenaming
  31102. */
  31103. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31104. /**
  31105. * Returns a promise that resolves after the given amount of time.
  31106. * @param delay Number of milliseconds to delay
  31107. * @returns Promise that resolves after the given amount of time
  31108. */
  31109. static DelayAsync(delay: number): Promise<void>;
  31110. /**
  31111. * Gets the current gradient from an array of IValueGradient
  31112. * @param ratio defines the current ratio to get
  31113. * @param gradients defines the array of IValueGradient
  31114. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31115. */
  31116. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31117. }
  31118. /**
  31119. * This class is used to track a performance counter which is number based.
  31120. * The user has access to many properties which give statistics of different nature.
  31121. *
  31122. * The implementer can track two kinds of Performance Counter: time and count.
  31123. * 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.
  31124. * 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.
  31125. */
  31126. export class PerfCounter {
  31127. /**
  31128. * Gets or sets a global boolean to turn on and off all the counters
  31129. */
  31130. static Enabled: boolean;
  31131. /**
  31132. * Returns the smallest value ever
  31133. */
  31134. readonly min: number;
  31135. /**
  31136. * Returns the biggest value ever
  31137. */
  31138. readonly max: number;
  31139. /**
  31140. * Returns the average value since the performance counter is running
  31141. */
  31142. readonly average: number;
  31143. /**
  31144. * Returns the average value of the last second the counter was monitored
  31145. */
  31146. readonly lastSecAverage: number;
  31147. /**
  31148. * Returns the current value
  31149. */
  31150. readonly current: number;
  31151. /**
  31152. * Gets the accumulated total
  31153. */
  31154. readonly total: number;
  31155. /**
  31156. * Gets the total value count
  31157. */
  31158. readonly count: number;
  31159. /**
  31160. * Creates a new counter
  31161. */
  31162. constructor();
  31163. /**
  31164. * Call this method to start monitoring a new frame.
  31165. * 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.
  31166. */
  31167. fetchNewFrame(): void;
  31168. /**
  31169. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31170. * @param newCount the count value to add to the monitored count
  31171. * @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.
  31172. */
  31173. addCount(newCount: number, fetchResult: boolean): void;
  31174. /**
  31175. * Start monitoring this performance counter
  31176. */
  31177. beginMonitoring(): void;
  31178. /**
  31179. * Compute the time lapsed since the previous beginMonitoring() call.
  31180. * @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
  31181. */
  31182. endMonitoring(newFrame?: boolean): void;
  31183. private _fetchResult;
  31184. private _startMonitoringTime;
  31185. private _min;
  31186. private _max;
  31187. private _average;
  31188. private _current;
  31189. private _totalValueCount;
  31190. private _totalAccumulated;
  31191. private _lastSecAverage;
  31192. private _lastSecAccumulated;
  31193. private _lastSecTime;
  31194. private _lastSecValueCount;
  31195. }
  31196. /**
  31197. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31198. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31199. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31200. * @param name The name of the class, case should be preserved
  31201. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31202. */
  31203. export function className(name: string, module?: string): (target: Object) => void;
  31204. /**
  31205. * An implementation of a loop for asynchronous functions.
  31206. */
  31207. export class AsyncLoop {
  31208. /**
  31209. * Defines the number of iterations for the loop
  31210. */
  31211. iterations: number;
  31212. /**
  31213. * Defines the current index of the loop.
  31214. */
  31215. index: number;
  31216. private _done;
  31217. private _fn;
  31218. private _successCallback;
  31219. /**
  31220. * Constructor.
  31221. * @param iterations the number of iterations.
  31222. * @param func the function to run each iteration
  31223. * @param successCallback the callback that will be called upon succesful execution
  31224. * @param offset starting offset.
  31225. */
  31226. constructor(
  31227. /**
  31228. * Defines the number of iterations for the loop
  31229. */
  31230. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31231. /**
  31232. * Execute the next iteration. Must be called after the last iteration was finished.
  31233. */
  31234. executeNext(): void;
  31235. /**
  31236. * Break the loop and run the success callback.
  31237. */
  31238. breakLoop(): void;
  31239. /**
  31240. * Create and run an async loop.
  31241. * @param iterations the number of iterations.
  31242. * @param fn the function to run each iteration
  31243. * @param successCallback the callback that will be called upon succesful execution
  31244. * @param offset starting offset.
  31245. * @returns the created async loop object
  31246. */
  31247. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31248. /**
  31249. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31250. * @param iterations total number of iterations
  31251. * @param syncedIterations number of synchronous iterations in each async iteration.
  31252. * @param fn the function to call each iteration.
  31253. * @param callback a success call back that will be called when iterating stops.
  31254. * @param breakFunction a break condition (optional)
  31255. * @param timeout timeout settings for the setTimeout function. default - 0.
  31256. * @returns the created async loop object
  31257. */
  31258. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31259. }
  31260. }
  31261. declare module BABYLON {
  31262. /** @hidden */
  31263. export interface ICollisionCoordinator {
  31264. createCollider(): Collider;
  31265. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31266. init(scene: Scene): void;
  31267. }
  31268. /** @hidden */
  31269. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31270. private _scene;
  31271. private _scaledPosition;
  31272. private _scaledVelocity;
  31273. private _finalPosition;
  31274. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31275. createCollider(): Collider;
  31276. init(scene: Scene): void;
  31277. private _collideWithWorld;
  31278. }
  31279. }
  31280. declare module BABYLON {
  31281. /**
  31282. * Class used to manage all inputs for the scene.
  31283. */
  31284. export class InputManager {
  31285. /** The distance in pixel that you have to move to prevent some events */
  31286. static DragMovementThreshold: number;
  31287. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31288. static LongPressDelay: number;
  31289. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31290. static DoubleClickDelay: number;
  31291. /** If you need to check double click without raising a single click at first click, enable this flag */
  31292. static ExclusiveDoubleClickMode: boolean;
  31293. private _wheelEventName;
  31294. private _onPointerMove;
  31295. private _onPointerDown;
  31296. private _onPointerUp;
  31297. private _initClickEvent;
  31298. private _initActionManager;
  31299. private _delayedSimpleClick;
  31300. private _delayedSimpleClickTimeout;
  31301. private _previousDelayedSimpleClickTimeout;
  31302. private _meshPickProceed;
  31303. private _previousButtonPressed;
  31304. private _currentPickResult;
  31305. private _previousPickResult;
  31306. private _totalPointersPressed;
  31307. private _doubleClickOccured;
  31308. private _pointerOverMesh;
  31309. private _pickedDownMesh;
  31310. private _pickedUpMesh;
  31311. private _pointerX;
  31312. private _pointerY;
  31313. private _unTranslatedPointerX;
  31314. private _unTranslatedPointerY;
  31315. private _startingPointerPosition;
  31316. private _previousStartingPointerPosition;
  31317. private _startingPointerTime;
  31318. private _previousStartingPointerTime;
  31319. private _pointerCaptures;
  31320. private _onKeyDown;
  31321. private _onKeyUp;
  31322. private _onCanvasFocusObserver;
  31323. private _onCanvasBlurObserver;
  31324. private _scene;
  31325. /**
  31326. * Creates a new InputManager
  31327. * @param scene defines the hosting scene
  31328. */
  31329. constructor(scene: Scene);
  31330. /**
  31331. * Gets the mesh that is currently under the pointer
  31332. */
  31333. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31334. /**
  31335. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31336. */
  31337. readonly unTranslatedPointer: Vector2;
  31338. /**
  31339. * Gets or sets the current on-screen X position of the pointer
  31340. */
  31341. pointerX: number;
  31342. /**
  31343. * Gets or sets the current on-screen Y position of the pointer
  31344. */
  31345. pointerY: number;
  31346. private _updatePointerPosition;
  31347. private _processPointerMove;
  31348. private _setRayOnPointerInfo;
  31349. private _checkPrePointerObservable;
  31350. /**
  31351. * Use this method to simulate a pointer move on a mesh
  31352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31355. */
  31356. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31357. /**
  31358. * Use this method to simulate a pointer down on a mesh
  31359. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31360. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31361. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31362. */
  31363. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31364. private _processPointerDown;
  31365. /** @hidden */ private _isPointerSwiping(): boolean;
  31366. /**
  31367. * Use this method to simulate a pointer up on a mesh
  31368. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31369. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31370. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31371. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31372. */
  31373. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31374. private _processPointerUp;
  31375. /**
  31376. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31377. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31378. * @returns true if the pointer was captured
  31379. */
  31380. isPointerCaptured(pointerId?: number): boolean;
  31381. /**
  31382. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31383. * @param attachUp defines if you want to attach events to pointerup
  31384. * @param attachDown defines if you want to attach events to pointerdown
  31385. * @param attachMove defines if you want to attach events to pointermove
  31386. */
  31387. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31388. /**
  31389. * Detaches all event handlers
  31390. */
  31391. detachControl(): void;
  31392. /**
  31393. * Force the value of meshUnderPointer
  31394. * @param mesh defines the mesh to use
  31395. */
  31396. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31397. /**
  31398. * Gets the mesh under the pointer
  31399. * @returns a Mesh or null if no mesh is under the pointer
  31400. */
  31401. getPointerOverMesh(): Nullable<AbstractMesh>;
  31402. }
  31403. }
  31404. declare module BABYLON {
  31405. /**
  31406. * This class defines the direct association between an animation and a target
  31407. */
  31408. export class TargetedAnimation {
  31409. /**
  31410. * Animation to perform
  31411. */
  31412. animation: Animation;
  31413. /**
  31414. * Target to animate
  31415. */
  31416. target: any;
  31417. /**
  31418. * Serialize the object
  31419. * @returns the JSON object representing the current entity
  31420. */
  31421. serialize(): any;
  31422. }
  31423. /**
  31424. * Use this class to create coordinated animations on multiple targets
  31425. */
  31426. export class AnimationGroup implements IDisposable {
  31427. /** The name of the animation group */
  31428. name: string;
  31429. private _scene;
  31430. private _targetedAnimations;
  31431. private _animatables;
  31432. private _from;
  31433. private _to;
  31434. private _isStarted;
  31435. private _isPaused;
  31436. private _speedRatio;
  31437. private _loopAnimation;
  31438. /**
  31439. * Gets or sets the unique id of the node
  31440. */
  31441. uniqueId: number;
  31442. /**
  31443. * This observable will notify when one animation have ended
  31444. */
  31445. onAnimationEndObservable: Observable<TargetedAnimation>;
  31446. /**
  31447. * Observer raised when one animation loops
  31448. */
  31449. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31450. /**
  31451. * This observable will notify when all animations have ended.
  31452. */
  31453. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31454. /**
  31455. * This observable will notify when all animations have paused.
  31456. */
  31457. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31458. /**
  31459. * This observable will notify when all animations are playing.
  31460. */
  31461. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31462. /**
  31463. * Gets the first frame
  31464. */
  31465. readonly from: number;
  31466. /**
  31467. * Gets the last frame
  31468. */
  31469. readonly to: number;
  31470. /**
  31471. * Define if the animations are started
  31472. */
  31473. readonly isStarted: boolean;
  31474. /**
  31475. * Gets a value indicating that the current group is playing
  31476. */
  31477. readonly isPlaying: boolean;
  31478. /**
  31479. * Gets or sets the speed ratio to use for all animations
  31480. */
  31481. /**
  31482. * Gets or sets the speed ratio to use for all animations
  31483. */
  31484. speedRatio: number;
  31485. /**
  31486. * Gets or sets if all animations should loop or not
  31487. */
  31488. loopAnimation: boolean;
  31489. /**
  31490. * Gets the targeted animations for this animation group
  31491. */
  31492. readonly targetedAnimations: Array<TargetedAnimation>;
  31493. /**
  31494. * returning the list of animatables controlled by this animation group.
  31495. */
  31496. readonly animatables: Array<Animatable>;
  31497. /**
  31498. * Instantiates a new Animation Group.
  31499. * This helps managing several animations at once.
  31500. * @see http://doc.babylonjs.com/how_to/group
  31501. * @param name Defines the name of the group
  31502. * @param scene Defines the scene the group belongs to
  31503. */
  31504. constructor(
  31505. /** The name of the animation group */
  31506. name: string, scene?: Nullable<Scene>);
  31507. /**
  31508. * Add an animation (with its target) in the group
  31509. * @param animation defines the animation we want to add
  31510. * @param target defines the target of the animation
  31511. * @returns the TargetedAnimation object
  31512. */
  31513. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31514. /**
  31515. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31516. * It can add constant keys at begin or end
  31517. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31518. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31519. * @returns the animation group
  31520. */
  31521. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31522. /**
  31523. * Start all animations on given targets
  31524. * @param loop defines if animations must loop
  31525. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31526. * @param from defines the from key (optional)
  31527. * @param to defines the to key (optional)
  31528. * @returns the current animation group
  31529. */
  31530. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31531. /**
  31532. * Pause all animations
  31533. * @returns the animation group
  31534. */
  31535. pause(): AnimationGroup;
  31536. /**
  31537. * Play all animations to initial state
  31538. * This function will start() the animations if they were not started or will restart() them if they were paused
  31539. * @param loop defines if animations must loop
  31540. * @returns the animation group
  31541. */
  31542. play(loop?: boolean): AnimationGroup;
  31543. /**
  31544. * Reset all animations to initial state
  31545. * @returns the animation group
  31546. */
  31547. reset(): AnimationGroup;
  31548. /**
  31549. * Restart animations from key 0
  31550. * @returns the animation group
  31551. */
  31552. restart(): AnimationGroup;
  31553. /**
  31554. * Stop all animations
  31555. * @returns the animation group
  31556. */
  31557. stop(): AnimationGroup;
  31558. /**
  31559. * Set animation weight for all animatables
  31560. * @param weight defines the weight to use
  31561. * @return the animationGroup
  31562. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31563. */
  31564. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31565. /**
  31566. * Synchronize and normalize all animatables with a source animatable
  31567. * @param root defines the root animatable to synchronize with
  31568. * @return the animationGroup
  31569. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31570. */
  31571. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31572. /**
  31573. * Goes to a specific frame in this animation group
  31574. * @param frame the frame number to go to
  31575. * @return the animationGroup
  31576. */
  31577. goToFrame(frame: number): AnimationGroup;
  31578. /**
  31579. * Dispose all associated resources
  31580. */
  31581. dispose(): void;
  31582. private _checkAnimationGroupEnded;
  31583. /**
  31584. * Clone the current animation group and returns a copy
  31585. * @param newName defines the name of the new group
  31586. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31587. * @returns the new aniamtion group
  31588. */
  31589. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31590. /**
  31591. * Serializes the animationGroup to an object
  31592. * @returns Serialized object
  31593. */
  31594. serialize(): any;
  31595. /**
  31596. * Returns a new AnimationGroup object parsed from the source provided.
  31597. * @param parsedAnimationGroup defines the source
  31598. * @param scene defines the scene that will receive the animationGroup
  31599. * @returns a new AnimationGroup
  31600. */
  31601. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31602. /**
  31603. * Returns the string "AnimationGroup"
  31604. * @returns "AnimationGroup"
  31605. */
  31606. getClassName(): string;
  31607. /**
  31608. * Creates a detailled string about the object
  31609. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31610. * @returns a string representing the object
  31611. */
  31612. toString(fullDetails?: boolean): string;
  31613. }
  31614. }
  31615. declare module BABYLON {
  31616. /**
  31617. * Define an interface for all classes that will hold resources
  31618. */
  31619. export interface IDisposable {
  31620. /**
  31621. * Releases all held resources
  31622. */
  31623. dispose(): void;
  31624. }
  31625. /** Interface defining initialization parameters for Scene class */
  31626. export interface SceneOptions {
  31627. /**
  31628. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31629. * It will improve performance when the number of geometries becomes important.
  31630. */
  31631. useGeometryUniqueIdsMap?: boolean;
  31632. /**
  31633. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31634. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31635. */
  31636. useMaterialMeshMap?: boolean;
  31637. /**
  31638. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31639. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31640. */
  31641. useClonedMeshhMap?: boolean;
  31642. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31643. virtual?: boolean;
  31644. }
  31645. /**
  31646. * Represents a scene to be rendered by the engine.
  31647. * @see http://doc.babylonjs.com/features/scene
  31648. */
  31649. export class Scene extends AbstractScene implements IAnimatable {
  31650. private static _uniqueIdCounter;
  31651. /** The fog is deactivated */
  31652. static readonly FOGMODE_NONE: number;
  31653. /** The fog density is following an exponential function */
  31654. static readonly FOGMODE_EXP: number;
  31655. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31656. static readonly FOGMODE_EXP2: number;
  31657. /** The fog density is following a linear function. */
  31658. static readonly FOGMODE_LINEAR: number;
  31659. /**
  31660. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31662. */
  31663. static MinDeltaTime: number;
  31664. /**
  31665. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31667. */
  31668. static MaxDeltaTime: number;
  31669. /**
  31670. * Factory used to create the default material.
  31671. * @param name The name of the material to create
  31672. * @param scene The scene to create the material for
  31673. * @returns The default material
  31674. */
  31675. static DefaultMaterialFactory(scene: Scene): Material;
  31676. /**
  31677. * Factory used to create the a collision coordinator.
  31678. * @returns The collision coordinator
  31679. */
  31680. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31681. /** @hidden */ private _inputManager: InputManager;
  31682. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31683. cameraToUseForPointers: Nullable<Camera>;
  31684. /** @hidden */ protected readonly _isScene: boolean;
  31685. /**
  31686. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31687. */
  31688. autoClear: boolean;
  31689. /**
  31690. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31691. */
  31692. autoClearDepthAndStencil: boolean;
  31693. /**
  31694. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31695. */
  31696. clearColor: Color4;
  31697. /**
  31698. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31699. */
  31700. ambientColor: Color3;
  31701. /**
  31702. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31703. * It should only be one of the following (if not the default embedded one):
  31704. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31705. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31706. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31707. * The material properties need to be setup according to the type of texture in use.
  31708. */
  31709. environmentBRDFTexture: BaseTexture;
  31710. /** @hidden */
  31711. protected _environmentTexture: Nullable<BaseTexture>;
  31712. /**
  31713. * Texture used in all pbr material as the reflection texture.
  31714. * As in the majority of the scene they are the same (exception for multi room and so on),
  31715. * this is easier to reference from here than from all the materials.
  31716. */
  31717. /**
  31718. * Texture used in all pbr material as the reflection texture.
  31719. * As in the majority of the scene they are the same (exception for multi room and so on),
  31720. * this is easier to set here than in all the materials.
  31721. */
  31722. environmentTexture: Nullable<BaseTexture>;
  31723. /** @hidden */
  31724. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31725. /**
  31726. * Default image processing configuration used either in the rendering
  31727. * Forward main pass or through the imageProcessingPostProcess if present.
  31728. * As in the majority of the scene they are the same (exception for multi camera),
  31729. * this is easier to reference from here than from all the materials and post process.
  31730. *
  31731. * No setter as we it is a shared configuration, you can set the values instead.
  31732. */
  31733. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31734. private _forceWireframe;
  31735. /**
  31736. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31737. */
  31738. forceWireframe: boolean;
  31739. private _forcePointsCloud;
  31740. /**
  31741. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31742. */
  31743. forcePointsCloud: boolean;
  31744. /**
  31745. * Gets or sets the active clipplane 1
  31746. */
  31747. clipPlane: Nullable<Plane>;
  31748. /**
  31749. * Gets or sets the active clipplane 2
  31750. */
  31751. clipPlane2: Nullable<Plane>;
  31752. /**
  31753. * Gets or sets the active clipplane 3
  31754. */
  31755. clipPlane3: Nullable<Plane>;
  31756. /**
  31757. * Gets or sets the active clipplane 4
  31758. */
  31759. clipPlane4: Nullable<Plane>;
  31760. /**
  31761. * Gets or sets a boolean indicating if animations are enabled
  31762. */
  31763. animationsEnabled: boolean;
  31764. private _animationPropertiesOverride;
  31765. /**
  31766. * Gets or sets the animation properties override
  31767. */
  31768. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31769. /**
  31770. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31771. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31772. */
  31773. useConstantAnimationDeltaTime: boolean;
  31774. /**
  31775. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31776. * Please note that it requires to run a ray cast through the scene on every frame
  31777. */
  31778. constantlyUpdateMeshUnderPointer: boolean;
  31779. /**
  31780. * Defines the HTML cursor to use when hovering over interactive elements
  31781. */
  31782. hoverCursor: string;
  31783. /**
  31784. * Defines the HTML default cursor to use (empty by default)
  31785. */
  31786. defaultCursor: string;
  31787. /**
  31788. * This is used to call preventDefault() on pointer down
  31789. * in order to block unwanted artifacts like system double clicks
  31790. */
  31791. preventDefaultOnPointerDown: boolean;
  31792. /**
  31793. * This is used to call preventDefault() on pointer up
  31794. * in order to block unwanted artifacts like system double clicks
  31795. */
  31796. preventDefaultOnPointerUp: boolean;
  31797. /**
  31798. * Gets or sets user defined metadata
  31799. */
  31800. metadata: any;
  31801. /**
  31802. * For internal use only. Please do not use.
  31803. */
  31804. reservedDataStore: any;
  31805. /**
  31806. * Gets the name of the plugin used to load this scene (null by default)
  31807. */
  31808. loadingPluginName: string;
  31809. /**
  31810. * Use this array to add regular expressions used to disable offline support for specific urls
  31811. */
  31812. disableOfflineSupportExceptionRules: RegExp[];
  31813. /**
  31814. * An event triggered when the scene is disposed.
  31815. */
  31816. onDisposeObservable: Observable<Scene>;
  31817. private _onDisposeObserver;
  31818. /** Sets a function to be executed when this scene is disposed. */
  31819. onDispose: () => void;
  31820. /**
  31821. * An event triggered before rendering the scene (right after animations and physics)
  31822. */
  31823. onBeforeRenderObservable: Observable<Scene>;
  31824. private _onBeforeRenderObserver;
  31825. /** Sets a function to be executed before rendering this scene */
  31826. beforeRender: Nullable<() => void>;
  31827. /**
  31828. * An event triggered after rendering the scene
  31829. */
  31830. onAfterRenderObservable: Observable<Scene>;
  31831. /**
  31832. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  31833. */
  31834. onAfterRenderCameraObservable: Observable<Camera>;
  31835. private _onAfterRenderObserver;
  31836. /** Sets a function to be executed after rendering this scene */
  31837. afterRender: Nullable<() => void>;
  31838. /**
  31839. * An event triggered before animating the scene
  31840. */
  31841. onBeforeAnimationsObservable: Observable<Scene>;
  31842. /**
  31843. * An event triggered after animations processing
  31844. */
  31845. onAfterAnimationsObservable: Observable<Scene>;
  31846. /**
  31847. * An event triggered before draw calls are ready to be sent
  31848. */
  31849. onBeforeDrawPhaseObservable: Observable<Scene>;
  31850. /**
  31851. * An event triggered after draw calls have been sent
  31852. */
  31853. onAfterDrawPhaseObservable: Observable<Scene>;
  31854. /**
  31855. * An event triggered when the scene is ready
  31856. */
  31857. onReadyObservable: Observable<Scene>;
  31858. /**
  31859. * An event triggered before rendering a camera
  31860. */
  31861. onBeforeCameraRenderObservable: Observable<Camera>;
  31862. private _onBeforeCameraRenderObserver;
  31863. /** Sets a function to be executed before rendering a camera*/
  31864. beforeCameraRender: () => void;
  31865. /**
  31866. * An event triggered after rendering a camera
  31867. */
  31868. onAfterCameraRenderObservable: Observable<Camera>;
  31869. private _onAfterCameraRenderObserver;
  31870. /** Sets a function to be executed after rendering a camera*/
  31871. afterCameraRender: () => void;
  31872. /**
  31873. * An event triggered when active meshes evaluation is about to start
  31874. */
  31875. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31876. /**
  31877. * An event triggered when active meshes evaluation is done
  31878. */
  31879. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31880. /**
  31881. * An event triggered when particles rendering is about to start
  31882. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31883. */
  31884. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31885. /**
  31886. * An event triggered when particles rendering is done
  31887. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31888. */
  31889. onAfterParticlesRenderingObservable: Observable<Scene>;
  31890. /**
  31891. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31892. */
  31893. onDataLoadedObservable: Observable<Scene>;
  31894. /**
  31895. * An event triggered when a camera is created
  31896. */
  31897. onNewCameraAddedObservable: Observable<Camera>;
  31898. /**
  31899. * An event triggered when a camera is removed
  31900. */
  31901. onCameraRemovedObservable: Observable<Camera>;
  31902. /**
  31903. * An event triggered when a light is created
  31904. */
  31905. onNewLightAddedObservable: Observable<Light>;
  31906. /**
  31907. * An event triggered when a light is removed
  31908. */
  31909. onLightRemovedObservable: Observable<Light>;
  31910. /**
  31911. * An event triggered when a geometry is created
  31912. */
  31913. onNewGeometryAddedObservable: Observable<Geometry>;
  31914. /**
  31915. * An event triggered when a geometry is removed
  31916. */
  31917. onGeometryRemovedObservable: Observable<Geometry>;
  31918. /**
  31919. * An event triggered when a transform node is created
  31920. */
  31921. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31922. /**
  31923. * An event triggered when a transform node is removed
  31924. */
  31925. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31926. /**
  31927. * An event triggered when a mesh is created
  31928. */
  31929. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31930. /**
  31931. * An event triggered when a mesh is removed
  31932. */
  31933. onMeshRemovedObservable: Observable<AbstractMesh>;
  31934. /**
  31935. * An event triggered when a skeleton is created
  31936. */
  31937. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31938. /**
  31939. * An event triggered when a skeleton is removed
  31940. */
  31941. onSkeletonRemovedObservable: Observable<Skeleton>;
  31942. /**
  31943. * An event triggered when a material is created
  31944. */
  31945. onNewMaterialAddedObservable: Observable<Material>;
  31946. /**
  31947. * An event triggered when a material is removed
  31948. */
  31949. onMaterialRemovedObservable: Observable<Material>;
  31950. /**
  31951. * An event triggered when a texture is created
  31952. */
  31953. onNewTextureAddedObservable: Observable<BaseTexture>;
  31954. /**
  31955. * An event triggered when a texture is removed
  31956. */
  31957. onTextureRemovedObservable: Observable<BaseTexture>;
  31958. /**
  31959. * An event triggered when render targets are about to be rendered
  31960. * Can happen multiple times per frame.
  31961. */
  31962. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31963. /**
  31964. * An event triggered when render targets were rendered.
  31965. * Can happen multiple times per frame.
  31966. */
  31967. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31968. /**
  31969. * An event triggered before calculating deterministic simulation step
  31970. */
  31971. onBeforeStepObservable: Observable<Scene>;
  31972. /**
  31973. * An event triggered after calculating deterministic simulation step
  31974. */
  31975. onAfterStepObservable: Observable<Scene>;
  31976. /**
  31977. * An event triggered when the activeCamera property is updated
  31978. */
  31979. onActiveCameraChanged: Observable<Scene>;
  31980. /**
  31981. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31982. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31983. * 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)
  31984. */
  31985. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31986. /**
  31987. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31988. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31989. * 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)
  31990. */
  31991. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31992. /**
  31993. * This Observable will when a mesh has been imported into the scene.
  31994. */
  31995. onMeshImportedObservable: Observable<AbstractMesh>;
  31996. /**
  31997. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31998. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31999. */
  32000. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32001. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32002. /**
  32003. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32004. */
  32005. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32006. /**
  32007. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32008. */
  32009. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32010. /**
  32011. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32012. */
  32013. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32014. /** Callback called when a pointer move is detected */
  32015. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32016. /** Callback called when a pointer down is detected */
  32017. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32018. /** Callback called when a pointer up is detected */
  32019. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32020. /** Callback called when a pointer pick is detected */
  32021. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32022. /**
  32023. * 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).
  32024. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32025. */
  32026. onPrePointerObservable: Observable<PointerInfoPre>;
  32027. /**
  32028. * Observable event triggered each time an input event is received from the rendering canvas
  32029. */
  32030. onPointerObservable: Observable<PointerInfo>;
  32031. /**
  32032. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32033. */
  32034. readonly unTranslatedPointer: Vector2;
  32035. /**
  32036. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32037. */
  32038. static DragMovementThreshold: number;
  32039. /**
  32040. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32041. */
  32042. static LongPressDelay: number;
  32043. /**
  32044. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32045. */
  32046. static DoubleClickDelay: number;
  32047. /** If you need to check double click without raising a single click at first click, enable this flag */
  32048. static ExclusiveDoubleClickMode: boolean;
  32049. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32050. /**
  32051. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32052. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32053. */
  32054. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32055. /**
  32056. * Observable event triggered each time an keyboard event is received from the hosting window
  32057. */
  32058. onKeyboardObservable: Observable<KeyboardInfo>;
  32059. private _useRightHandedSystem;
  32060. /**
  32061. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32062. */
  32063. useRightHandedSystem: boolean;
  32064. private _timeAccumulator;
  32065. private _currentStepId;
  32066. private _currentInternalStep;
  32067. /**
  32068. * Sets the step Id used by deterministic lock step
  32069. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32070. * @param newStepId defines the step Id
  32071. */
  32072. setStepId(newStepId: number): void;
  32073. /**
  32074. * Gets the step Id used by deterministic lock step
  32075. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32076. * @returns the step Id
  32077. */
  32078. getStepId(): number;
  32079. /**
  32080. * Gets the internal step used by deterministic lock step
  32081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32082. * @returns the internal step
  32083. */
  32084. getInternalStep(): number;
  32085. private _fogEnabled;
  32086. /**
  32087. * Gets or sets a boolean indicating if fog is enabled on this scene
  32088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32089. * (Default is true)
  32090. */
  32091. fogEnabled: boolean;
  32092. private _fogMode;
  32093. /**
  32094. * Gets or sets the fog mode to use
  32095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32096. * | mode | value |
  32097. * | --- | --- |
  32098. * | FOGMODE_NONE | 0 |
  32099. * | FOGMODE_EXP | 1 |
  32100. * | FOGMODE_EXP2 | 2 |
  32101. * | FOGMODE_LINEAR | 3 |
  32102. */
  32103. fogMode: number;
  32104. /**
  32105. * Gets or sets the fog color to use
  32106. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32107. * (Default is Color3(0.2, 0.2, 0.3))
  32108. */
  32109. fogColor: Color3;
  32110. /**
  32111. * Gets or sets the fog density to use
  32112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32113. * (Default is 0.1)
  32114. */
  32115. fogDensity: number;
  32116. /**
  32117. * Gets or sets the fog start distance to use
  32118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32119. * (Default is 0)
  32120. */
  32121. fogStart: number;
  32122. /**
  32123. * Gets or sets the fog end distance to use
  32124. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32125. * (Default is 1000)
  32126. */
  32127. fogEnd: number;
  32128. private _shadowsEnabled;
  32129. /**
  32130. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32131. */
  32132. shadowsEnabled: boolean;
  32133. private _lightsEnabled;
  32134. /**
  32135. * Gets or sets a boolean indicating if lights are enabled on this scene
  32136. */
  32137. lightsEnabled: boolean;
  32138. /** All of the active cameras added to this scene. */
  32139. activeCameras: Camera[];
  32140. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32141. /** Gets or sets the current active camera */
  32142. activeCamera: Nullable<Camera>;
  32143. private _defaultMaterial;
  32144. /** The default material used on meshes when no material is affected */
  32145. /** The default material used on meshes when no material is affected */
  32146. defaultMaterial: Material;
  32147. private _texturesEnabled;
  32148. /**
  32149. * Gets or sets a boolean indicating if textures are enabled on this scene
  32150. */
  32151. texturesEnabled: boolean;
  32152. /**
  32153. * Gets or sets a boolean indicating if particles are enabled on this scene
  32154. */
  32155. particlesEnabled: boolean;
  32156. /**
  32157. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32158. */
  32159. spritesEnabled: boolean;
  32160. private _skeletonsEnabled;
  32161. /**
  32162. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32163. */
  32164. skeletonsEnabled: boolean;
  32165. /**
  32166. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32167. */
  32168. lensFlaresEnabled: boolean;
  32169. /**
  32170. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32171. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32172. */
  32173. collisionsEnabled: boolean;
  32174. private _collisionCoordinator;
  32175. /** @hidden */
  32176. readonly collisionCoordinator: ICollisionCoordinator;
  32177. /**
  32178. * Defines the gravity applied to this scene (used only for collisions)
  32179. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32180. */
  32181. gravity: Vector3;
  32182. /**
  32183. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32184. */
  32185. postProcessesEnabled: boolean;
  32186. /**
  32187. * The list of postprocesses added to the scene
  32188. */
  32189. postProcesses: PostProcess[];
  32190. /**
  32191. * Gets the current postprocess manager
  32192. */
  32193. postProcessManager: PostProcessManager;
  32194. /**
  32195. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32196. */
  32197. renderTargetsEnabled: boolean;
  32198. /**
  32199. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32200. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32201. */
  32202. dumpNextRenderTargets: boolean;
  32203. /**
  32204. * The list of user defined render targets added to the scene
  32205. */
  32206. customRenderTargets: RenderTargetTexture[];
  32207. /**
  32208. * Defines if texture loading must be delayed
  32209. * If true, textures will only be loaded when they need to be rendered
  32210. */
  32211. useDelayedTextureLoading: boolean;
  32212. /**
  32213. * Gets the list of meshes imported to the scene through SceneLoader
  32214. */
  32215. importedMeshesFiles: String[];
  32216. /**
  32217. * Gets or sets a boolean indicating if probes are enabled on this scene
  32218. */
  32219. probesEnabled: boolean;
  32220. /**
  32221. * Gets or sets the current offline provider to use to store scene data
  32222. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32223. */
  32224. offlineProvider: IOfflineProvider;
  32225. /**
  32226. * Gets or sets the action manager associated with the scene
  32227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32228. */
  32229. actionManager: AbstractActionManager;
  32230. private _meshesForIntersections;
  32231. /**
  32232. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32233. */
  32234. proceduralTexturesEnabled: boolean;
  32235. private _engine;
  32236. private _totalVertices;
  32237. /** @hidden */ private _activeIndices: PerfCounter;
  32238. /** @hidden */ private _activeParticles: PerfCounter;
  32239. /** @hidden */ private _activeBones: PerfCounter;
  32240. private _animationRatio;
  32241. /** @hidden */ private _animationTimeLast: number;
  32242. /** @hidden */ private _animationTime: number;
  32243. /**
  32244. * Gets or sets a general scale for animation speed
  32245. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32246. */
  32247. animationTimeScale: number;
  32248. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32249. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32250. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32251. private _renderId;
  32252. private _frameId;
  32253. private _executeWhenReadyTimeoutId;
  32254. private _intermediateRendering;
  32255. private _viewUpdateFlag;
  32256. private _projectionUpdateFlag;
  32257. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32258. private _activeRequests;
  32259. /** @hidden */ private _pendingData: any[];
  32260. private _isDisposed;
  32261. /**
  32262. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32263. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32264. */
  32265. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32266. private _activeMeshes;
  32267. private _processedMaterials;
  32268. private _renderTargets;
  32269. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32270. private _activeSkeletons;
  32271. private _softwareSkinnedMeshes;
  32272. private _renderingManager;
  32273. /** @hidden */ private _activeAnimatables: Animatable[];
  32274. private _transformMatrix;
  32275. private _sceneUbo;
  32276. /** @hidden */ private _viewMatrix: Matrix;
  32277. private _projectionMatrix;
  32278. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32279. /** @hidden */ private _frustumPlanes: Plane[];
  32280. /**
  32281. * Gets the list of frustum planes (built from the active camera)
  32282. */
  32283. readonly frustumPlanes: Plane[];
  32284. /**
  32285. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32286. * This is useful if there are more lights that the maximum simulteanous authorized
  32287. */
  32288. requireLightSorting: boolean;
  32289. /** @hidden */
  32290. readonly useMaterialMeshMap: boolean;
  32291. /** @hidden */
  32292. readonly useClonedMeshhMap: boolean;
  32293. private _externalData;
  32294. private _uid;
  32295. /**
  32296. * @hidden
  32297. * Backing store of defined scene components.
  32298. */ private _components: ISceneComponent[];
  32299. /**
  32300. * @hidden
  32301. * Backing store of defined scene components.
  32302. */ private _serializableComponents: ISceneSerializableComponent[];
  32303. /**
  32304. * List of components to register on the next registration step.
  32305. */
  32306. private _transientComponents;
  32307. /**
  32308. * Registers the transient components if needed.
  32309. */
  32310. private _registerTransientComponents;
  32311. /**
  32312. * @hidden
  32313. * Add a component to the scene.
  32314. * Note that the ccomponent could be registered on th next frame if this is called after
  32315. * the register component stage.
  32316. * @param component Defines the component to add to the scene
  32317. */ private _addComponent(component: ISceneComponent): void;
  32318. /**
  32319. * @hidden
  32320. * Gets a component from the scene.
  32321. * @param name defines the name of the component to retrieve
  32322. * @returns the component or null if not present
  32323. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32324. /**
  32325. * @hidden
  32326. * Defines the actions happening before camera updates.
  32327. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32328. /**
  32329. * @hidden
  32330. * Defines the actions happening before clear the canvas.
  32331. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32332. /**
  32333. * @hidden
  32334. * Defines the actions when collecting render targets for the frame.
  32335. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32336. /**
  32337. * @hidden
  32338. * Defines the actions happening for one camera in the frame.
  32339. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32340. /**
  32341. * @hidden
  32342. * Defines the actions happening during the per mesh ready checks.
  32343. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32344. /**
  32345. * @hidden
  32346. * Defines the actions happening before evaluate active mesh checks.
  32347. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32348. /**
  32349. * @hidden
  32350. * Defines the actions happening during the evaluate sub mesh checks.
  32351. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32352. /**
  32353. * @hidden
  32354. * Defines the actions happening during the active mesh stage.
  32355. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32356. /**
  32357. * @hidden
  32358. * Defines the actions happening during the per camera render target step.
  32359. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32360. /**
  32361. * @hidden
  32362. * Defines the actions happening just before the active camera is drawing.
  32363. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32364. /**
  32365. * @hidden
  32366. * Defines the actions happening just before a render target is drawing.
  32367. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32368. /**
  32369. * @hidden
  32370. * Defines the actions happening just before a rendering group is drawing.
  32371. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32372. /**
  32373. * @hidden
  32374. * Defines the actions happening just before a mesh is drawing.
  32375. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32376. /**
  32377. * @hidden
  32378. * Defines the actions happening just after a mesh has been drawn.
  32379. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32380. /**
  32381. * @hidden
  32382. * Defines the actions happening just after a rendering group has been drawn.
  32383. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32384. /**
  32385. * @hidden
  32386. * Defines the actions happening just after the active camera has been drawn.
  32387. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32388. /**
  32389. * @hidden
  32390. * Defines the actions happening just after a render target has been drawn.
  32391. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32392. /**
  32393. * @hidden
  32394. * Defines the actions happening just after rendering all cameras and computing intersections.
  32395. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32396. /**
  32397. * @hidden
  32398. * Defines the actions happening when a pointer move event happens.
  32399. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32400. /**
  32401. * @hidden
  32402. * Defines the actions happening when a pointer down event happens.
  32403. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32404. /**
  32405. * @hidden
  32406. * Defines the actions happening when a pointer up event happens.
  32407. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32408. /**
  32409. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32410. */
  32411. private geometriesByUniqueId;
  32412. /**
  32413. * Creates a new Scene
  32414. * @param engine defines the engine to use to render this scene
  32415. * @param options defines the scene options
  32416. */
  32417. constructor(engine: Engine, options?: SceneOptions);
  32418. /**
  32419. * Gets a string idenfifying the name of the class
  32420. * @returns "Scene" string
  32421. */
  32422. getClassName(): string;
  32423. private _defaultMeshCandidates;
  32424. /**
  32425. * @hidden
  32426. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32427. private _defaultSubMeshCandidates;
  32428. /**
  32429. * @hidden
  32430. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32431. /**
  32432. * Sets the default candidate providers for the scene.
  32433. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32434. * and getCollidingSubMeshCandidates to their default function
  32435. */
  32436. setDefaultCandidateProviders(): void;
  32437. /**
  32438. * Gets the mesh that is currently under the pointer
  32439. */
  32440. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32441. /**
  32442. * Gets or sets the current on-screen X position of the pointer
  32443. */
  32444. pointerX: number;
  32445. /**
  32446. * Gets or sets the current on-screen Y position of the pointer
  32447. */
  32448. pointerY: number;
  32449. /**
  32450. * Gets the cached material (ie. the latest rendered one)
  32451. * @returns the cached material
  32452. */
  32453. getCachedMaterial(): Nullable<Material>;
  32454. /**
  32455. * Gets the cached effect (ie. the latest rendered one)
  32456. * @returns the cached effect
  32457. */
  32458. getCachedEffect(): Nullable<Effect>;
  32459. /**
  32460. * Gets the cached visibility state (ie. the latest rendered one)
  32461. * @returns the cached visibility state
  32462. */
  32463. getCachedVisibility(): Nullable<number>;
  32464. /**
  32465. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32466. * @param material defines the current material
  32467. * @param effect defines the current effect
  32468. * @param visibility defines the current visibility state
  32469. * @returns true if one parameter is not cached
  32470. */
  32471. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32472. /**
  32473. * Gets the engine associated with the scene
  32474. * @returns an Engine
  32475. */
  32476. getEngine(): Engine;
  32477. /**
  32478. * Gets the total number of vertices rendered per frame
  32479. * @returns the total number of vertices rendered per frame
  32480. */
  32481. getTotalVertices(): number;
  32482. /**
  32483. * Gets the performance counter for total vertices
  32484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32485. */
  32486. readonly totalVerticesPerfCounter: PerfCounter;
  32487. /**
  32488. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32489. * @returns the total number of active indices rendered per frame
  32490. */
  32491. getActiveIndices(): number;
  32492. /**
  32493. * Gets the performance counter for active indices
  32494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32495. */
  32496. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32497. /**
  32498. * Gets the total number of active particles rendered per frame
  32499. * @returns the total number of active particles rendered per frame
  32500. */
  32501. getActiveParticles(): number;
  32502. /**
  32503. * Gets the performance counter for active particles
  32504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32505. */
  32506. readonly activeParticlesPerfCounter: PerfCounter;
  32507. /**
  32508. * Gets the total number of active bones rendered per frame
  32509. * @returns the total number of active bones rendered per frame
  32510. */
  32511. getActiveBones(): number;
  32512. /**
  32513. * Gets the performance counter for active bones
  32514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32515. */
  32516. readonly activeBonesPerfCounter: PerfCounter;
  32517. /**
  32518. * Gets the array of active meshes
  32519. * @returns an array of AbstractMesh
  32520. */
  32521. getActiveMeshes(): SmartArray<AbstractMesh>;
  32522. /**
  32523. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32524. * @returns a number
  32525. */
  32526. getAnimationRatio(): number;
  32527. /**
  32528. * Gets an unique Id for the current render phase
  32529. * @returns a number
  32530. */
  32531. getRenderId(): number;
  32532. /**
  32533. * Gets an unique Id for the current frame
  32534. * @returns a number
  32535. */
  32536. getFrameId(): number;
  32537. /** Call this function if you want to manually increment the render Id*/
  32538. incrementRenderId(): void;
  32539. private _createUbo;
  32540. /**
  32541. * Use this method to simulate a pointer move on a mesh
  32542. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32543. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32544. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32545. * @returns the current scene
  32546. */
  32547. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32548. /**
  32549. * Use this method to simulate a pointer down on a mesh
  32550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32553. * @returns the current scene
  32554. */
  32555. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32556. /**
  32557. * Use this method to simulate a pointer up on a mesh
  32558. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32559. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32560. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32561. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32562. * @returns the current scene
  32563. */
  32564. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32565. /**
  32566. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32567. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32568. * @returns true if the pointer was captured
  32569. */
  32570. isPointerCaptured(pointerId?: number): boolean;
  32571. /**
  32572. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32573. * @param attachUp defines if you want to attach events to pointerup
  32574. * @param attachDown defines if you want to attach events to pointerdown
  32575. * @param attachMove defines if you want to attach events to pointermove
  32576. */
  32577. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32578. /** Detaches all event handlers*/
  32579. detachControl(): void;
  32580. /**
  32581. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32582. * Delay loaded resources are not taking in account
  32583. * @return true if all required resources are ready
  32584. */
  32585. isReady(): boolean;
  32586. /** Resets all cached information relative to material (including effect and visibility) */
  32587. resetCachedMaterial(): void;
  32588. /**
  32589. * Registers a function to be called before every frame render
  32590. * @param func defines the function to register
  32591. */
  32592. registerBeforeRender(func: () => void): void;
  32593. /**
  32594. * Unregisters a function called before every frame render
  32595. * @param func defines the function to unregister
  32596. */
  32597. unregisterBeforeRender(func: () => void): void;
  32598. /**
  32599. * Registers a function to be called after every frame render
  32600. * @param func defines the function to register
  32601. */
  32602. registerAfterRender(func: () => void): void;
  32603. /**
  32604. * Unregisters a function called after every frame render
  32605. * @param func defines the function to unregister
  32606. */
  32607. unregisterAfterRender(func: () => void): void;
  32608. private _executeOnceBeforeRender;
  32609. /**
  32610. * The provided function will run before render once and will be disposed afterwards.
  32611. * A timeout delay can be provided so that the function will be executed in N ms.
  32612. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32613. * @param func The function to be executed.
  32614. * @param timeout optional delay in ms
  32615. */
  32616. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32617. /** @hidden */ private _addPendingData(data: any): void;
  32618. /** @hidden */ private _removePendingData(data: any): void;
  32619. /**
  32620. * Returns the number of items waiting to be loaded
  32621. * @returns the number of items waiting to be loaded
  32622. */
  32623. getWaitingItemsCount(): number;
  32624. /**
  32625. * Returns a boolean indicating if the scene is still loading data
  32626. */
  32627. readonly isLoading: boolean;
  32628. /**
  32629. * Registers a function to be executed when the scene is ready
  32630. * @param {Function} func - the function to be executed
  32631. */
  32632. executeWhenReady(func: () => void): void;
  32633. /**
  32634. * Returns a promise that resolves when the scene is ready
  32635. * @returns A promise that resolves when the scene is ready
  32636. */
  32637. whenReadyAsync(): Promise<void>;
  32638. /** @hidden */ private _checkIsReady(): void;
  32639. /**
  32640. * Gets all animatable attached to the scene
  32641. */
  32642. readonly animatables: Animatable[];
  32643. /**
  32644. * Resets the last animation time frame.
  32645. * Useful to override when animations start running when loading a scene for the first time.
  32646. */
  32647. resetLastAnimationTimeFrame(): void;
  32648. /**
  32649. * Gets the current view matrix
  32650. * @returns a Matrix
  32651. */
  32652. getViewMatrix(): Matrix;
  32653. /**
  32654. * Gets the current projection matrix
  32655. * @returns a Matrix
  32656. */
  32657. getProjectionMatrix(): Matrix;
  32658. /**
  32659. * Gets the current transform matrix
  32660. * @returns a Matrix made of View * Projection
  32661. */
  32662. getTransformMatrix(): Matrix;
  32663. /**
  32664. * Sets the current transform matrix
  32665. * @param viewL defines the View matrix to use
  32666. * @param projectionL defines the Projection matrix to use
  32667. * @param viewR defines the right View matrix to use (if provided)
  32668. * @param projectionR defines the right Projection matrix to use (if provided)
  32669. */
  32670. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32671. /**
  32672. * Gets the uniform buffer used to store scene data
  32673. * @returns a UniformBuffer
  32674. */
  32675. getSceneUniformBuffer(): UniformBuffer;
  32676. /**
  32677. * Gets an unique (relatively to the current scene) Id
  32678. * @returns an unique number for the scene
  32679. */
  32680. getUniqueId(): number;
  32681. /**
  32682. * Add a mesh to the list of scene's meshes
  32683. * @param newMesh defines the mesh to add
  32684. * @param recursive if all child meshes should also be added to the scene
  32685. */
  32686. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32687. /**
  32688. * Remove a mesh for the list of scene's meshes
  32689. * @param toRemove defines the mesh to remove
  32690. * @param recursive if all child meshes should also be removed from the scene
  32691. * @returns the index where the mesh was in the mesh list
  32692. */
  32693. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32694. /**
  32695. * Add a transform node to the list of scene's transform nodes
  32696. * @param newTransformNode defines the transform node to add
  32697. */
  32698. addTransformNode(newTransformNode: TransformNode): void;
  32699. /**
  32700. * Remove a transform node for the list of scene's transform nodes
  32701. * @param toRemove defines the transform node to remove
  32702. * @returns the index where the transform node was in the transform node list
  32703. */
  32704. removeTransformNode(toRemove: TransformNode): number;
  32705. /**
  32706. * Remove a skeleton for the list of scene's skeletons
  32707. * @param toRemove defines the skeleton to remove
  32708. * @returns the index where the skeleton was in the skeleton list
  32709. */
  32710. removeSkeleton(toRemove: Skeleton): number;
  32711. /**
  32712. * Remove a morph target for the list of scene's morph targets
  32713. * @param toRemove defines the morph target to remove
  32714. * @returns the index where the morph target was in the morph target list
  32715. */
  32716. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32717. /**
  32718. * Remove a light for the list of scene's lights
  32719. * @param toRemove defines the light to remove
  32720. * @returns the index where the light was in the light list
  32721. */
  32722. removeLight(toRemove: Light): number;
  32723. /**
  32724. * Remove a camera for the list of scene's cameras
  32725. * @param toRemove defines the camera to remove
  32726. * @returns the index where the camera was in the camera list
  32727. */
  32728. removeCamera(toRemove: Camera): number;
  32729. /**
  32730. * Remove a particle system for the list of scene's particle systems
  32731. * @param toRemove defines the particle system to remove
  32732. * @returns the index where the particle system was in the particle system list
  32733. */
  32734. removeParticleSystem(toRemove: IParticleSystem): number;
  32735. /**
  32736. * Remove a animation for the list of scene's animations
  32737. * @param toRemove defines the animation to remove
  32738. * @returns the index where the animation was in the animation list
  32739. */
  32740. removeAnimation(toRemove: Animation): number;
  32741. /**
  32742. * Will stop the animation of the given target
  32743. * @param target - the target
  32744. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32745. * @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)
  32746. */
  32747. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32748. /**
  32749. * Removes the given animation group from this scene.
  32750. * @param toRemove The animation group to remove
  32751. * @returns The index of the removed animation group
  32752. */
  32753. removeAnimationGroup(toRemove: AnimationGroup): number;
  32754. /**
  32755. * Removes the given multi-material from this scene.
  32756. * @param toRemove The multi-material to remove
  32757. * @returns The index of the removed multi-material
  32758. */
  32759. removeMultiMaterial(toRemove: MultiMaterial): number;
  32760. /**
  32761. * Removes the given material from this scene.
  32762. * @param toRemove The material to remove
  32763. * @returns The index of the removed material
  32764. */
  32765. removeMaterial(toRemove: Material): number;
  32766. /**
  32767. * Removes the given action manager from this scene.
  32768. * @param toRemove The action manager to remove
  32769. * @returns The index of the removed action manager
  32770. */
  32771. removeActionManager(toRemove: AbstractActionManager): number;
  32772. /**
  32773. * Removes the given texture from this scene.
  32774. * @param toRemove The texture to remove
  32775. * @returns The index of the removed texture
  32776. */
  32777. removeTexture(toRemove: BaseTexture): number;
  32778. /**
  32779. * Adds the given light to this scene
  32780. * @param newLight The light to add
  32781. */
  32782. addLight(newLight: Light): void;
  32783. /**
  32784. * Sorts the list list based on light priorities
  32785. */
  32786. sortLightsByPriority(): void;
  32787. /**
  32788. * Adds the given camera to this scene
  32789. * @param newCamera The camera to add
  32790. */
  32791. addCamera(newCamera: Camera): void;
  32792. /**
  32793. * Adds the given skeleton to this scene
  32794. * @param newSkeleton The skeleton to add
  32795. */
  32796. addSkeleton(newSkeleton: Skeleton): void;
  32797. /**
  32798. * Adds the given particle system to this scene
  32799. * @param newParticleSystem The particle system to add
  32800. */
  32801. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32802. /**
  32803. * Adds the given animation to this scene
  32804. * @param newAnimation The animation to add
  32805. */
  32806. addAnimation(newAnimation: Animation): void;
  32807. /**
  32808. * Adds the given animation group to this scene.
  32809. * @param newAnimationGroup The animation group to add
  32810. */
  32811. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32812. /**
  32813. * Adds the given multi-material to this scene
  32814. * @param newMultiMaterial The multi-material to add
  32815. */
  32816. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32817. /**
  32818. * Adds the given material to this scene
  32819. * @param newMaterial The material to add
  32820. */
  32821. addMaterial(newMaterial: Material): void;
  32822. /**
  32823. * Adds the given morph target to this scene
  32824. * @param newMorphTargetManager The morph target to add
  32825. */
  32826. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32827. /**
  32828. * Adds the given geometry to this scene
  32829. * @param newGeometry The geometry to add
  32830. */
  32831. addGeometry(newGeometry: Geometry): void;
  32832. /**
  32833. * Adds the given action manager to this scene
  32834. * @param newActionManager The action manager to add
  32835. */
  32836. addActionManager(newActionManager: AbstractActionManager): void;
  32837. /**
  32838. * Adds the given texture to this scene.
  32839. * @param newTexture The texture to add
  32840. */
  32841. addTexture(newTexture: BaseTexture): void;
  32842. /**
  32843. * Switch active camera
  32844. * @param newCamera defines the new active camera
  32845. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32846. */
  32847. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32848. /**
  32849. * sets the active camera of the scene using its ID
  32850. * @param id defines the camera's ID
  32851. * @return the new active camera or null if none found.
  32852. */
  32853. setActiveCameraByID(id: string): Nullable<Camera>;
  32854. /**
  32855. * sets the active camera of the scene using its name
  32856. * @param name defines the camera's name
  32857. * @returns the new active camera or null if none found.
  32858. */
  32859. setActiveCameraByName(name: string): Nullable<Camera>;
  32860. /**
  32861. * get an animation group using its name
  32862. * @param name defines the material's name
  32863. * @return the animation group or null if none found.
  32864. */
  32865. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32866. /**
  32867. * Get a material using its unique id
  32868. * @param uniqueId defines the material's unique id
  32869. * @return the material or null if none found.
  32870. */
  32871. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32872. /**
  32873. * get a material using its id
  32874. * @param id defines the material's ID
  32875. * @return the material or null if none found.
  32876. */
  32877. getMaterialByID(id: string): Nullable<Material>;
  32878. /**
  32879. * Gets a material using its name
  32880. * @param name defines the material's name
  32881. * @return the material or null if none found.
  32882. */
  32883. getMaterialByName(name: string): Nullable<Material>;
  32884. /**
  32885. * Gets a camera using its id
  32886. * @param id defines the id to look for
  32887. * @returns the camera or null if not found
  32888. */
  32889. getCameraByID(id: string): Nullable<Camera>;
  32890. /**
  32891. * Gets a camera using its unique id
  32892. * @param uniqueId defines the unique id to look for
  32893. * @returns the camera or null if not found
  32894. */
  32895. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32896. /**
  32897. * Gets a camera using its name
  32898. * @param name defines the camera's name
  32899. * @return the camera or null if none found.
  32900. */
  32901. getCameraByName(name: string): Nullable<Camera>;
  32902. /**
  32903. * Gets a bone using its id
  32904. * @param id defines the bone's id
  32905. * @return the bone or null if not found
  32906. */
  32907. getBoneByID(id: string): Nullable<Bone>;
  32908. /**
  32909. * Gets a bone using its id
  32910. * @param name defines the bone's name
  32911. * @return the bone or null if not found
  32912. */
  32913. getBoneByName(name: string): Nullable<Bone>;
  32914. /**
  32915. * Gets a light node using its name
  32916. * @param name defines the the light's name
  32917. * @return the light or null if none found.
  32918. */
  32919. getLightByName(name: string): Nullable<Light>;
  32920. /**
  32921. * Gets a light node using its id
  32922. * @param id defines the light's id
  32923. * @return the light or null if none found.
  32924. */
  32925. getLightByID(id: string): Nullable<Light>;
  32926. /**
  32927. * Gets a light node using its scene-generated unique ID
  32928. * @param uniqueId defines the light's unique id
  32929. * @return the light or null if none found.
  32930. */
  32931. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32932. /**
  32933. * Gets a particle system by id
  32934. * @param id defines the particle system id
  32935. * @return the corresponding system or null if none found
  32936. */
  32937. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32938. /**
  32939. * Gets a geometry using its ID
  32940. * @param id defines the geometry's id
  32941. * @return the geometry or null if none found.
  32942. */
  32943. getGeometryByID(id: string): Nullable<Geometry>;
  32944. private _getGeometryByUniqueID;
  32945. /**
  32946. * Add a new geometry to this scene
  32947. * @param geometry defines the geometry to be added to the scene.
  32948. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32949. * @return a boolean defining if the geometry was added or not
  32950. */
  32951. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32952. /**
  32953. * Removes an existing geometry
  32954. * @param geometry defines the geometry to be removed from the scene
  32955. * @return a boolean defining if the geometry was removed or not
  32956. */
  32957. removeGeometry(geometry: Geometry): boolean;
  32958. /**
  32959. * Gets the list of geometries attached to the scene
  32960. * @returns an array of Geometry
  32961. */
  32962. getGeometries(): Geometry[];
  32963. /**
  32964. * Gets the first added mesh found of a given ID
  32965. * @param id defines the id to search for
  32966. * @return the mesh found or null if not found at all
  32967. */
  32968. getMeshByID(id: string): Nullable<AbstractMesh>;
  32969. /**
  32970. * Gets a list of meshes using their id
  32971. * @param id defines the id to search for
  32972. * @returns a list of meshes
  32973. */
  32974. getMeshesByID(id: string): Array<AbstractMesh>;
  32975. /**
  32976. * Gets the first added transform node found of a given ID
  32977. * @param id defines the id to search for
  32978. * @return the found transform node or null if not found at all.
  32979. */
  32980. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32981. /**
  32982. * Gets a transform node with its auto-generated unique id
  32983. * @param uniqueId efines the unique id to search for
  32984. * @return the found transform node or null if not found at all.
  32985. */
  32986. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32987. /**
  32988. * Gets a list of transform nodes using their id
  32989. * @param id defines the id to search for
  32990. * @returns a list of transform nodes
  32991. */
  32992. getTransformNodesByID(id: string): Array<TransformNode>;
  32993. /**
  32994. * Gets a mesh with its auto-generated unique id
  32995. * @param uniqueId defines the unique id to search for
  32996. * @return the found mesh or null if not found at all.
  32997. */
  32998. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32999. /**
  33000. * Gets a the last added mesh using a given id
  33001. * @param id defines the id to search for
  33002. * @return the found mesh or null if not found at all.
  33003. */
  33004. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33005. /**
  33006. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33007. * @param id defines the id to search for
  33008. * @return the found node or null if not found at all
  33009. */
  33010. getLastEntryByID(id: string): Nullable<Node>;
  33011. /**
  33012. * Gets a node (Mesh, Camera, Light) using a given id
  33013. * @param id defines the id to search for
  33014. * @return the found node or null if not found at all
  33015. */
  33016. getNodeByID(id: string): Nullable<Node>;
  33017. /**
  33018. * Gets a node (Mesh, Camera, Light) using a given name
  33019. * @param name defines the name to search for
  33020. * @return the found node or null if not found at all.
  33021. */
  33022. getNodeByName(name: string): Nullable<Node>;
  33023. /**
  33024. * Gets a mesh using a given name
  33025. * @param name defines the name to search for
  33026. * @return the found mesh or null if not found at all.
  33027. */
  33028. getMeshByName(name: string): Nullable<AbstractMesh>;
  33029. /**
  33030. * Gets a transform node using a given name
  33031. * @param name defines the name to search for
  33032. * @return the found transform node or null if not found at all.
  33033. */
  33034. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33035. /**
  33036. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33037. * @param id defines the id to search for
  33038. * @return the found skeleton or null if not found at all.
  33039. */
  33040. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33041. /**
  33042. * Gets a skeleton using a given auto generated unique id
  33043. * @param uniqueId defines the unique id to search for
  33044. * @return the found skeleton or null if not found at all.
  33045. */
  33046. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33047. /**
  33048. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33049. * @param id defines the id to search for
  33050. * @return the found skeleton or null if not found at all.
  33051. */
  33052. getSkeletonById(id: string): Nullable<Skeleton>;
  33053. /**
  33054. * Gets a skeleton using a given name
  33055. * @param name defines the name to search for
  33056. * @return the found skeleton or null if not found at all.
  33057. */
  33058. getSkeletonByName(name: string): Nullable<Skeleton>;
  33059. /**
  33060. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33061. * @param id defines the id to search for
  33062. * @return the found morph target manager or null if not found at all.
  33063. */
  33064. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33065. /**
  33066. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33067. * @param id defines the id to search for
  33068. * @return the found morph target or null if not found at all.
  33069. */
  33070. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33071. /**
  33072. * Gets a boolean indicating if the given mesh is active
  33073. * @param mesh defines the mesh to look for
  33074. * @returns true if the mesh is in the active list
  33075. */
  33076. isActiveMesh(mesh: AbstractMesh): boolean;
  33077. /**
  33078. * Return a unique id as a string which can serve as an identifier for the scene
  33079. */
  33080. readonly uid: string;
  33081. /**
  33082. * Add an externaly attached data from its key.
  33083. * This method call will fail and return false, if such key already exists.
  33084. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33085. * @param key the unique key that identifies the data
  33086. * @param data the data object to associate to the key for this Engine instance
  33087. * @return true if no such key were already present and the data was added successfully, false otherwise
  33088. */
  33089. addExternalData<T>(key: string, data: T): boolean;
  33090. /**
  33091. * Get an externaly attached data from its key
  33092. * @param key the unique key that identifies the data
  33093. * @return the associated data, if present (can be null), or undefined if not present
  33094. */
  33095. getExternalData<T>(key: string): Nullable<T>;
  33096. /**
  33097. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33098. * @param key the unique key that identifies the data
  33099. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33100. * @return the associated data, can be null if the factory returned null.
  33101. */
  33102. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33103. /**
  33104. * Remove an externaly attached data from the Engine instance
  33105. * @param key the unique key that identifies the data
  33106. * @return true if the data was successfully removed, false if it doesn't exist
  33107. */
  33108. removeExternalData(key: string): boolean;
  33109. private _evaluateSubMesh;
  33110. /**
  33111. * Clear the processed materials smart array preventing retention point in material dispose.
  33112. */
  33113. freeProcessedMaterials(): void;
  33114. private _preventFreeActiveMeshesAndRenderingGroups;
  33115. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33116. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33117. * when disposing several meshes in a row or a hierarchy of meshes.
  33118. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33119. */
  33120. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33121. /**
  33122. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33123. */
  33124. freeActiveMeshes(): void;
  33125. /**
  33126. * Clear the info related to rendering groups preventing retention points during dispose.
  33127. */
  33128. freeRenderingGroups(): void;
  33129. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33130. /**
  33131. * Lambda returning the list of potentially active meshes.
  33132. */
  33133. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33134. /**
  33135. * Lambda returning the list of potentially active sub meshes.
  33136. */
  33137. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33138. /**
  33139. * Lambda returning the list of potentially intersecting sub meshes.
  33140. */
  33141. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33142. /**
  33143. * Lambda returning the list of potentially colliding sub meshes.
  33144. */
  33145. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33146. private _activeMeshesFrozen;
  33147. /**
  33148. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33149. * @returns the current scene
  33150. */
  33151. freezeActiveMeshes(): Scene;
  33152. /**
  33153. * Use this function to restart evaluating active meshes on every frame
  33154. * @returns the current scene
  33155. */
  33156. unfreezeActiveMeshes(): Scene;
  33157. private _evaluateActiveMeshes;
  33158. private _activeMesh;
  33159. /**
  33160. * Update the transform matrix to update from the current active camera
  33161. * @param force defines a boolean used to force the update even if cache is up to date
  33162. */
  33163. updateTransformMatrix(force?: boolean): void;
  33164. private _bindFrameBuffer;
  33165. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33166. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33167. private _processSubCameras;
  33168. private _checkIntersections;
  33169. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33170. /**
  33171. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33172. */
  33173. getDeterministicFrameTime: () => number;
  33174. /** @hidden */ private _animate(): void;
  33175. /** Execute all animations (for a frame) */
  33176. animate(): void;
  33177. /**
  33178. * Render the scene
  33179. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33180. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33181. */
  33182. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33183. /**
  33184. * Freeze all materials
  33185. * A frozen material will not be updatable but should be faster to render
  33186. */
  33187. freezeMaterials(): void;
  33188. /**
  33189. * Unfreeze all materials
  33190. * A frozen material will not be updatable but should be faster to render
  33191. */
  33192. unfreezeMaterials(): void;
  33193. /**
  33194. * Releases all held ressources
  33195. */
  33196. dispose(): void;
  33197. /**
  33198. * Gets if the scene is already disposed
  33199. */
  33200. readonly isDisposed: boolean;
  33201. /**
  33202. * Call this function to reduce memory footprint of the scene.
  33203. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33204. */
  33205. clearCachedVertexData(): void;
  33206. /**
  33207. * This function will remove the local cached buffer data from texture.
  33208. * It will save memory but will prevent the texture from being rebuilt
  33209. */
  33210. cleanCachedTextureBuffer(): void;
  33211. /**
  33212. * Get the world extend vectors with an optional filter
  33213. *
  33214. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33215. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33216. */
  33217. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33218. min: Vector3;
  33219. max: Vector3;
  33220. };
  33221. /**
  33222. * Creates a ray that can be used to pick in the scene
  33223. * @param x defines the x coordinate of the origin (on-screen)
  33224. * @param y defines the y coordinate of the origin (on-screen)
  33225. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33226. * @param camera defines the camera to use for the picking
  33227. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33228. * @returns a Ray
  33229. */
  33230. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33231. /**
  33232. * Creates a ray that can be used to pick in the scene
  33233. * @param x defines the x coordinate of the origin (on-screen)
  33234. * @param y defines the y coordinate of the origin (on-screen)
  33235. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33236. * @param result defines the ray where to store the picking ray
  33237. * @param camera defines the camera to use for the picking
  33238. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33239. * @returns the current scene
  33240. */
  33241. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33242. /**
  33243. * Creates a ray that can be used to pick in the scene
  33244. * @param x defines the x coordinate of the origin (on-screen)
  33245. * @param y defines the y coordinate of the origin (on-screen)
  33246. * @param camera defines the camera to use for the picking
  33247. * @returns a Ray
  33248. */
  33249. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33250. /**
  33251. * Creates a ray that can be used to pick in the scene
  33252. * @param x defines the x coordinate of the origin (on-screen)
  33253. * @param y defines the y coordinate of the origin (on-screen)
  33254. * @param result defines the ray where to store the picking ray
  33255. * @param camera defines the camera to use for the picking
  33256. * @returns the current scene
  33257. */
  33258. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33259. /** Launch a ray to try to pick a mesh in the scene
  33260. * @param x position on screen
  33261. * @param y position on screen
  33262. * @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
  33263. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33264. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33266. * @returns a PickingInfo
  33267. */
  33268. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33269. /** Use the given ray to pick a mesh in the scene
  33270. * @param ray The ray to use to pick meshes
  33271. * @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
  33272. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33273. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33274. * @returns a PickingInfo
  33275. */
  33276. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33277. /**
  33278. * Launch a ray to try to pick a mesh in the scene
  33279. * @param x X position on screen
  33280. * @param y Y position on screen
  33281. * @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
  33282. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33283. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33284. * @returns an array of PickingInfo
  33285. */
  33286. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33287. /**
  33288. * Launch a ray to try to pick a mesh in the scene
  33289. * @param ray Ray to use
  33290. * @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
  33291. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33292. * @returns an array of PickingInfo
  33293. */
  33294. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33295. /**
  33296. * Force the value of meshUnderPointer
  33297. * @param mesh defines the mesh to use
  33298. */
  33299. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33300. /**
  33301. * Gets the mesh under the pointer
  33302. * @returns a Mesh or null if no mesh is under the pointer
  33303. */
  33304. getPointerOverMesh(): Nullable<AbstractMesh>;
  33305. /** @hidden */ private _rebuildGeometries(): void;
  33306. /** @hidden */ private _rebuildTextures(): void;
  33307. private _getByTags;
  33308. /**
  33309. * Get a list of meshes by tags
  33310. * @param tagsQuery defines the tags query to use
  33311. * @param forEach defines a predicate used to filter results
  33312. * @returns an array of Mesh
  33313. */
  33314. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33315. /**
  33316. * Get a list of cameras by tags
  33317. * @param tagsQuery defines the tags query to use
  33318. * @param forEach defines a predicate used to filter results
  33319. * @returns an array of Camera
  33320. */
  33321. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33322. /**
  33323. * Get a list of lights by tags
  33324. * @param tagsQuery defines the tags query to use
  33325. * @param forEach defines a predicate used to filter results
  33326. * @returns an array of Light
  33327. */
  33328. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33329. /**
  33330. * Get a list of materials by tags
  33331. * @param tagsQuery defines the tags query to use
  33332. * @param forEach defines a predicate used to filter results
  33333. * @returns an array of Material
  33334. */
  33335. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33336. /**
  33337. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33338. * This allowed control for front to back rendering or reversly depending of the special needs.
  33339. *
  33340. * @param renderingGroupId The rendering group id corresponding to its index
  33341. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33342. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33343. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33344. */
  33345. 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;
  33346. /**
  33347. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33348. *
  33349. * @param renderingGroupId The rendering group id corresponding to its index
  33350. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33351. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33352. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33353. */
  33354. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33355. /**
  33356. * Gets the current auto clear configuration for one rendering group of the rendering
  33357. * manager.
  33358. * @param index the rendering group index to get the information for
  33359. * @returns The auto clear setup for the requested rendering group
  33360. */
  33361. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33362. private _blockMaterialDirtyMechanism;
  33363. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33364. blockMaterialDirtyMechanism: boolean;
  33365. /**
  33366. * Will flag all materials as dirty to trigger new shader compilation
  33367. * @param flag defines the flag used to specify which material part must be marked as dirty
  33368. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33369. */
  33370. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33371. /** @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;
  33372. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33373. }
  33374. }
  33375. declare module BABYLON {
  33376. /**
  33377. * Set of assets to keep when moving a scene into an asset container.
  33378. */
  33379. export class KeepAssets extends AbstractScene {
  33380. }
  33381. /**
  33382. * Container with a set of assets that can be added or removed from a scene.
  33383. */
  33384. export class AssetContainer extends AbstractScene {
  33385. /**
  33386. * The scene the AssetContainer belongs to.
  33387. */
  33388. scene: Scene;
  33389. /**
  33390. * Instantiates an AssetContainer.
  33391. * @param scene The scene the AssetContainer belongs to.
  33392. */
  33393. constructor(scene: Scene);
  33394. /**
  33395. * Adds all the assets from the container to the scene.
  33396. */
  33397. addAllToScene(): void;
  33398. /**
  33399. * Removes all the assets in the container from the scene
  33400. */
  33401. removeAllFromScene(): void;
  33402. /**
  33403. * Disposes all the assets in the container
  33404. */
  33405. dispose(): void;
  33406. private _moveAssets;
  33407. /**
  33408. * Removes all the assets contained in the scene and adds them to the container.
  33409. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33410. */
  33411. moveAllFromScene(keepAssets?: KeepAssets): void;
  33412. /**
  33413. * 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.
  33414. * @returns the root mesh
  33415. */
  33416. createRootMesh(): Mesh;
  33417. }
  33418. }
  33419. declare module BABYLON {
  33420. /**
  33421. * Defines how the parser contract is defined.
  33422. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33423. */
  33424. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33425. /**
  33426. * Defines how the individual parser contract is defined.
  33427. * These parser can parse an individual asset
  33428. */
  33429. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33430. /**
  33431. * Base class of the scene acting as a container for the different elements composing a scene.
  33432. * This class is dynamically extended by the different components of the scene increasing
  33433. * flexibility and reducing coupling
  33434. */
  33435. export abstract class AbstractScene {
  33436. /**
  33437. * Stores the list of available parsers in the application.
  33438. */
  33439. private static _BabylonFileParsers;
  33440. /**
  33441. * Stores the list of available individual parsers in the application.
  33442. */
  33443. private static _IndividualBabylonFileParsers;
  33444. /**
  33445. * Adds a parser in the list of available ones
  33446. * @param name Defines the name of the parser
  33447. * @param parser Defines the parser to add
  33448. */
  33449. static AddParser(name: string, parser: BabylonFileParser): void;
  33450. /**
  33451. * Gets a general parser from the list of avaialble ones
  33452. * @param name Defines the name of the parser
  33453. * @returns the requested parser or null
  33454. */
  33455. static GetParser(name: string): Nullable<BabylonFileParser>;
  33456. /**
  33457. * Adds n individual parser in the list of available ones
  33458. * @param name Defines the name of the parser
  33459. * @param parser Defines the parser to add
  33460. */
  33461. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33462. /**
  33463. * Gets an individual parser from the list of avaialble ones
  33464. * @param name Defines the name of the parser
  33465. * @returns the requested parser or null
  33466. */
  33467. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33468. /**
  33469. * Parser json data and populate both a scene and its associated container object
  33470. * @param jsonData Defines the data to parse
  33471. * @param scene Defines the scene to parse the data for
  33472. * @param container Defines the container attached to the parsing sequence
  33473. * @param rootUrl Defines the root url of the data
  33474. */
  33475. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33476. /**
  33477. * Gets the list of root nodes (ie. nodes with no parent)
  33478. */
  33479. rootNodes: Node[];
  33480. /** All of the cameras added to this scene
  33481. * @see http://doc.babylonjs.com/babylon101/cameras
  33482. */
  33483. cameras: Camera[];
  33484. /**
  33485. * All of the lights added to this scene
  33486. * @see http://doc.babylonjs.com/babylon101/lights
  33487. */
  33488. lights: Light[];
  33489. /**
  33490. * All of the (abstract) meshes added to this scene
  33491. */
  33492. meshes: AbstractMesh[];
  33493. /**
  33494. * The list of skeletons added to the scene
  33495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33496. */
  33497. skeletons: Skeleton[];
  33498. /**
  33499. * All of the particle systems added to this scene
  33500. * @see http://doc.babylonjs.com/babylon101/particles
  33501. */
  33502. particleSystems: IParticleSystem[];
  33503. /**
  33504. * Gets a list of Animations associated with the scene
  33505. */
  33506. animations: Animation[];
  33507. /**
  33508. * All of the animation groups added to this scene
  33509. * @see http://doc.babylonjs.com/how_to/group
  33510. */
  33511. animationGroups: AnimationGroup[];
  33512. /**
  33513. * All of the multi-materials added to this scene
  33514. * @see http://doc.babylonjs.com/how_to/multi_materials
  33515. */
  33516. multiMaterials: MultiMaterial[];
  33517. /**
  33518. * All of the materials added to this scene
  33519. * In the context of a Scene, it is not supposed to be modified manually.
  33520. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33521. * Note also that the order of the Material wihin the array is not significant and might change.
  33522. * @see http://doc.babylonjs.com/babylon101/materials
  33523. */
  33524. materials: Material[];
  33525. /**
  33526. * The list of morph target managers added to the scene
  33527. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33528. */
  33529. morphTargetManagers: MorphTargetManager[];
  33530. /**
  33531. * The list of geometries used in the scene.
  33532. */
  33533. geometries: Geometry[];
  33534. /**
  33535. * All of the tranform nodes added to this scene
  33536. * In the context of a Scene, it is not supposed to be modified manually.
  33537. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33538. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33539. * @see http://doc.babylonjs.com/how_to/transformnode
  33540. */
  33541. transformNodes: TransformNode[];
  33542. /**
  33543. * ActionManagers available on the scene.
  33544. */
  33545. actionManagers: AbstractActionManager[];
  33546. /**
  33547. * Textures to keep.
  33548. */
  33549. textures: BaseTexture[];
  33550. /**
  33551. * Environment texture for the scene
  33552. */
  33553. environmentTexture: Nullable<BaseTexture>;
  33554. }
  33555. }
  33556. declare module BABYLON {
  33557. /**
  33558. * Defines a sound that can be played in the application.
  33559. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33561. */
  33562. export class Sound {
  33563. /**
  33564. * The name of the sound in the scene.
  33565. */
  33566. name: string;
  33567. /**
  33568. * Does the sound autoplay once loaded.
  33569. */
  33570. autoplay: boolean;
  33571. /**
  33572. * Does the sound loop after it finishes playing once.
  33573. */
  33574. loop: boolean;
  33575. /**
  33576. * Does the sound use a custom attenuation curve to simulate the falloff
  33577. * happening when the source gets further away from the camera.
  33578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33579. */
  33580. useCustomAttenuation: boolean;
  33581. /**
  33582. * The sound track id this sound belongs to.
  33583. */
  33584. soundTrackId: number;
  33585. /**
  33586. * Is this sound currently played.
  33587. */
  33588. isPlaying: boolean;
  33589. /**
  33590. * Is this sound currently paused.
  33591. */
  33592. isPaused: boolean;
  33593. /**
  33594. * Does this sound enables spatial sound.
  33595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33596. */
  33597. spatialSound: boolean;
  33598. /**
  33599. * Define the reference distance the sound should be heard perfectly.
  33600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33601. */
  33602. refDistance: number;
  33603. /**
  33604. * Define the roll off factor of spatial sounds.
  33605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33606. */
  33607. rolloffFactor: number;
  33608. /**
  33609. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33611. */
  33612. maxDistance: number;
  33613. /**
  33614. * Define the distance attenuation model the sound will follow.
  33615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33616. */
  33617. distanceModel: string;
  33618. /**
  33619. * @hidden
  33620. * Back Compat
  33621. **/
  33622. onended: () => any;
  33623. /**
  33624. * Observable event when the current playing sound finishes.
  33625. */
  33626. onEndedObservable: Observable<Sound>;
  33627. private _panningModel;
  33628. private _playbackRate;
  33629. private _streaming;
  33630. private _startTime;
  33631. private _startOffset;
  33632. private _position;
  33633. /** @hidden */ private _positionInEmitterSpace: boolean;
  33634. private _localDirection;
  33635. private _volume;
  33636. private _isReadyToPlay;
  33637. private _isDirectional;
  33638. private _readyToPlayCallback;
  33639. private _audioBuffer;
  33640. private _soundSource;
  33641. private _streamingSource;
  33642. private _soundPanner;
  33643. private _soundGain;
  33644. private _inputAudioNode;
  33645. private _outputAudioNode;
  33646. private _coneInnerAngle;
  33647. private _coneOuterAngle;
  33648. private _coneOuterGain;
  33649. private _scene;
  33650. private _connectedTransformNode;
  33651. private _customAttenuationFunction;
  33652. private _registerFunc;
  33653. private _isOutputConnected;
  33654. private _htmlAudioElement;
  33655. private _urlType;
  33656. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33657. /**
  33658. * Create a sound and attach it to a scene
  33659. * @param name Name of your sound
  33660. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33661. * @param scene defines the scene the sound belongs to
  33662. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33663. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33664. */
  33665. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33666. /**
  33667. * Release the sound and its associated resources
  33668. */
  33669. dispose(): void;
  33670. /**
  33671. * Gets if the sounds is ready to be played or not.
  33672. * @returns true if ready, otherwise false
  33673. */
  33674. isReady(): boolean;
  33675. private _soundLoaded;
  33676. /**
  33677. * Sets the data of the sound from an audiobuffer
  33678. * @param audioBuffer The audioBuffer containing the data
  33679. */
  33680. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33681. /**
  33682. * Updates the current sounds options such as maxdistance, loop...
  33683. * @param options A JSON object containing values named as the object properties
  33684. */
  33685. updateOptions(options: any): void;
  33686. private _createSpatialParameters;
  33687. private _updateSpatialParameters;
  33688. /**
  33689. * Switch the panning model to HRTF:
  33690. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33692. */
  33693. switchPanningModelToHRTF(): void;
  33694. /**
  33695. * Switch the panning model to Equal Power:
  33696. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33698. */
  33699. switchPanningModelToEqualPower(): void;
  33700. private _switchPanningModel;
  33701. /**
  33702. * Connect this sound to a sound track audio node like gain...
  33703. * @param soundTrackAudioNode the sound track audio node to connect to
  33704. */
  33705. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33706. /**
  33707. * Transform this sound into a directional source
  33708. * @param coneInnerAngle Size of the inner cone in degree
  33709. * @param coneOuterAngle Size of the outer cone in degree
  33710. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33711. */
  33712. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33713. /**
  33714. * Gets or sets the inner angle for the directional cone.
  33715. */
  33716. /**
  33717. * Gets or sets the inner angle for the directional cone.
  33718. */
  33719. directionalConeInnerAngle: number;
  33720. /**
  33721. * Gets or sets the outer angle for the directional cone.
  33722. */
  33723. /**
  33724. * Gets or sets the outer angle for the directional cone.
  33725. */
  33726. directionalConeOuterAngle: number;
  33727. /**
  33728. * Sets the position of the emitter if spatial sound is enabled
  33729. * @param newPosition Defines the new posisiton
  33730. */
  33731. setPosition(newPosition: Vector3): void;
  33732. /**
  33733. * Sets the local direction of the emitter if spatial sound is enabled
  33734. * @param newLocalDirection Defines the new local direction
  33735. */
  33736. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33737. private _updateDirection;
  33738. /** @hidden */
  33739. updateDistanceFromListener(): void;
  33740. /**
  33741. * Sets a new custom attenuation function for the sound.
  33742. * @param callback Defines the function used for the attenuation
  33743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33744. */
  33745. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33746. /**
  33747. * Play the sound
  33748. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33749. * @param offset (optional) Start the sound setting it at a specific time
  33750. */
  33751. play(time?: number, offset?: number): void;
  33752. private _onended;
  33753. /**
  33754. * Stop the sound
  33755. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33756. */
  33757. stop(time?: number): void;
  33758. /**
  33759. * Put the sound in pause
  33760. */
  33761. pause(): void;
  33762. /**
  33763. * Sets a dedicated volume for this sounds
  33764. * @param newVolume Define the new volume of the sound
  33765. * @param time Define time for gradual change to new volume
  33766. */
  33767. setVolume(newVolume: number, time?: number): void;
  33768. /**
  33769. * Set the sound play back rate
  33770. * @param newPlaybackRate Define the playback rate the sound should be played at
  33771. */
  33772. setPlaybackRate(newPlaybackRate: number): void;
  33773. /**
  33774. * Gets the volume of the sound.
  33775. * @returns the volume of the sound
  33776. */
  33777. getVolume(): number;
  33778. /**
  33779. * Attach the sound to a dedicated mesh
  33780. * @param transformNode The transform node to connect the sound with
  33781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33782. */
  33783. attachToMesh(transformNode: TransformNode): void;
  33784. /**
  33785. * Detach the sound from the previously attached mesh
  33786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33787. */
  33788. detachFromMesh(): void;
  33789. private _onRegisterAfterWorldMatrixUpdate;
  33790. /**
  33791. * Clone the current sound in the scene.
  33792. * @returns the new sound clone
  33793. */
  33794. clone(): Nullable<Sound>;
  33795. /**
  33796. * Gets the current underlying audio buffer containing the data
  33797. * @returns the audio buffer
  33798. */
  33799. getAudioBuffer(): Nullable<AudioBuffer>;
  33800. /**
  33801. * Serializes the Sound in a JSON representation
  33802. * @returns the JSON representation of the sound
  33803. */
  33804. serialize(): any;
  33805. /**
  33806. * Parse a JSON representation of a sound to innstantiate in a given scene
  33807. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33808. * @param scene Define the scene the new parsed sound should be created in
  33809. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33810. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33811. * @returns the newly parsed sound
  33812. */
  33813. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33814. }
  33815. }
  33816. declare module BABYLON {
  33817. /**
  33818. * This defines an action helpful to play a defined sound on a triggered action.
  33819. */
  33820. export class PlaySoundAction extends Action {
  33821. private _sound;
  33822. /**
  33823. * Instantiate the action
  33824. * @param triggerOptions defines the trigger options
  33825. * @param sound defines the sound to play
  33826. * @param condition defines the trigger related conditions
  33827. */
  33828. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33829. /** @hidden */ private _prepare(): void;
  33830. /**
  33831. * Execute the action and play the sound.
  33832. */
  33833. execute(): void;
  33834. /**
  33835. * Serializes the actions and its related information.
  33836. * @param parent defines the object to serialize in
  33837. * @returns the serialized object
  33838. */
  33839. serialize(parent: any): any;
  33840. }
  33841. /**
  33842. * This defines an action helpful to stop a defined sound on a triggered action.
  33843. */
  33844. export class StopSoundAction extends Action {
  33845. private _sound;
  33846. /**
  33847. * Instantiate the action
  33848. * @param triggerOptions defines the trigger options
  33849. * @param sound defines the sound to stop
  33850. * @param condition defines the trigger related conditions
  33851. */
  33852. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33853. /** @hidden */ private _prepare(): void;
  33854. /**
  33855. * Execute the action and stop the sound.
  33856. */
  33857. execute(): void;
  33858. /**
  33859. * Serializes the actions and its related information.
  33860. * @param parent defines the object to serialize in
  33861. * @returns the serialized object
  33862. */
  33863. serialize(parent: any): any;
  33864. }
  33865. }
  33866. declare module BABYLON {
  33867. /**
  33868. * This defines an action responsible to change the value of a property
  33869. * by interpolating between its current value and the newly set one once triggered.
  33870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33871. */
  33872. export class InterpolateValueAction extends Action {
  33873. /**
  33874. * Defines the path of the property where the value should be interpolated
  33875. */
  33876. propertyPath: string;
  33877. /**
  33878. * Defines the target value at the end of the interpolation.
  33879. */
  33880. value: any;
  33881. /**
  33882. * Defines the time it will take for the property to interpolate to the value.
  33883. */
  33884. duration: number;
  33885. /**
  33886. * Defines if the other scene animations should be stopped when the action has been triggered
  33887. */
  33888. stopOtherAnimations?: boolean;
  33889. /**
  33890. * Defines a callback raised once the interpolation animation has been done.
  33891. */
  33892. onInterpolationDone?: () => void;
  33893. /**
  33894. * Observable triggered once the interpolation animation has been done.
  33895. */
  33896. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33897. private _target;
  33898. private _effectiveTarget;
  33899. private _property;
  33900. /**
  33901. * Instantiate the action
  33902. * @param triggerOptions defines the trigger options
  33903. * @param target defines the object containing the value to interpolate
  33904. * @param propertyPath defines the path to the property in the target object
  33905. * @param value defines the target value at the end of the interpolation
  33906. * @param duration deines the time it will take for the property to interpolate to the value.
  33907. * @param condition defines the trigger related conditions
  33908. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33909. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33910. */
  33911. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33912. /** @hidden */ private _prepare(): void;
  33913. /**
  33914. * Execute the action starts the value interpolation.
  33915. */
  33916. execute(): void;
  33917. /**
  33918. * Serializes the actions and its related information.
  33919. * @param parent defines the object to serialize in
  33920. * @returns the serialized object
  33921. */
  33922. serialize(parent: any): any;
  33923. }
  33924. }
  33925. declare module BABYLON {
  33926. /**
  33927. * Options allowed during the creation of a sound track.
  33928. */
  33929. export interface ISoundTrackOptions {
  33930. /**
  33931. * The volume the sound track should take during creation
  33932. */
  33933. volume?: number;
  33934. /**
  33935. * Define if the sound track is the main sound track of the scene
  33936. */
  33937. mainTrack?: boolean;
  33938. }
  33939. /**
  33940. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33941. * It will be also used in a future release to apply effects on a specific track.
  33942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33943. */
  33944. export class SoundTrack {
  33945. /**
  33946. * The unique identifier of the sound track in the scene.
  33947. */
  33948. id: number;
  33949. /**
  33950. * The list of sounds included in the sound track.
  33951. */
  33952. soundCollection: Array<Sound>;
  33953. private _outputAudioNode;
  33954. private _scene;
  33955. private _isMainTrack;
  33956. private _connectedAnalyser;
  33957. private _options;
  33958. private _isInitialized;
  33959. /**
  33960. * Creates a new sound track.
  33961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33962. * @param scene Define the scene the sound track belongs to
  33963. * @param options
  33964. */
  33965. constructor(scene: Scene, options?: ISoundTrackOptions);
  33966. private _initializeSoundTrackAudioGraph;
  33967. /**
  33968. * Release the sound track and its associated resources
  33969. */
  33970. dispose(): void;
  33971. /**
  33972. * Adds a sound to this sound track
  33973. * @param sound define the cound to add
  33974. * @ignoreNaming
  33975. */
  33976. AddSound(sound: Sound): void;
  33977. /**
  33978. * Removes a sound to this sound track
  33979. * @param sound define the cound to remove
  33980. * @ignoreNaming
  33981. */
  33982. RemoveSound(sound: Sound): void;
  33983. /**
  33984. * Set a global volume for the full sound track.
  33985. * @param newVolume Define the new volume of the sound track
  33986. */
  33987. setVolume(newVolume: number): void;
  33988. /**
  33989. * Switch the panning model to HRTF:
  33990. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33992. */
  33993. switchPanningModelToHRTF(): void;
  33994. /**
  33995. * Switch the panning model to Equal Power:
  33996. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33998. */
  33999. switchPanningModelToEqualPower(): void;
  34000. /**
  34001. * Connect the sound track to an audio analyser allowing some amazing
  34002. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34004. * @param analyser The analyser to connect to the engine
  34005. */
  34006. connectToAnalyser(analyser: Analyser): void;
  34007. }
  34008. }
  34009. declare module BABYLON {
  34010. interface AbstractScene {
  34011. /**
  34012. * The list of sounds used in the scene.
  34013. */
  34014. sounds: Nullable<Array<Sound>>;
  34015. }
  34016. interface Scene {
  34017. /**
  34018. * @hidden
  34019. * Backing field
  34020. */ private _mainSoundTrack: SoundTrack;
  34021. /**
  34022. * The main sound track played by the scene.
  34023. * It cotains your primary collection of sounds.
  34024. */
  34025. mainSoundTrack: SoundTrack;
  34026. /**
  34027. * The list of sound tracks added to the scene
  34028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34029. */
  34030. soundTracks: Nullable<Array<SoundTrack>>;
  34031. /**
  34032. * Gets a sound using a given name
  34033. * @param name defines the name to search for
  34034. * @return the found sound or null if not found at all.
  34035. */
  34036. getSoundByName(name: string): Nullable<Sound>;
  34037. /**
  34038. * Gets or sets if audio support is enabled
  34039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34040. */
  34041. audioEnabled: boolean;
  34042. /**
  34043. * Gets or sets if audio will be output to headphones
  34044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34045. */
  34046. headphone: boolean;
  34047. }
  34048. /**
  34049. * Defines the sound scene component responsible to manage any sounds
  34050. * in a given scene.
  34051. */
  34052. export class AudioSceneComponent implements ISceneSerializableComponent {
  34053. /**
  34054. * The component name helpfull to identify the component in the list of scene components.
  34055. */
  34056. readonly name: string;
  34057. /**
  34058. * The scene the component belongs to.
  34059. */
  34060. scene: Scene;
  34061. private _audioEnabled;
  34062. /**
  34063. * Gets whether audio is enabled or not.
  34064. * Please use related enable/disable method to switch state.
  34065. */
  34066. readonly audioEnabled: boolean;
  34067. private _headphone;
  34068. /**
  34069. * Gets whether audio is outputing to headphone or not.
  34070. * Please use the according Switch methods to change output.
  34071. */
  34072. readonly headphone: boolean;
  34073. /**
  34074. * Creates a new instance of the component for the given scene
  34075. * @param scene Defines the scene to register the component in
  34076. */
  34077. constructor(scene: Scene);
  34078. /**
  34079. * Registers the component in a given scene
  34080. */
  34081. register(): void;
  34082. /**
  34083. * Rebuilds the elements related to this component in case of
  34084. * context lost for instance.
  34085. */
  34086. rebuild(): void;
  34087. /**
  34088. * Serializes the component data to the specified json object
  34089. * @param serializationObject The object to serialize to
  34090. */
  34091. serialize(serializationObject: any): void;
  34092. /**
  34093. * Adds all the elements from the container to the scene
  34094. * @param container the container holding the elements
  34095. */
  34096. addFromContainer(container: AbstractScene): void;
  34097. /**
  34098. * Removes all the elements in the container from the scene
  34099. * @param container contains the elements to remove
  34100. * @param dispose if the removed element should be disposed (default: false)
  34101. */
  34102. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34103. /**
  34104. * Disposes the component and the associated ressources.
  34105. */
  34106. dispose(): void;
  34107. /**
  34108. * Disables audio in the associated scene.
  34109. */
  34110. disableAudio(): void;
  34111. /**
  34112. * Enables audio in the associated scene.
  34113. */
  34114. enableAudio(): void;
  34115. /**
  34116. * Switch audio to headphone output.
  34117. */
  34118. switchAudioModeForHeadphones(): void;
  34119. /**
  34120. * Switch audio to normal speakers.
  34121. */
  34122. switchAudioModeForNormalSpeakers(): void;
  34123. private _afterRender;
  34124. }
  34125. }
  34126. declare module BABYLON {
  34127. /**
  34128. * Wraps one or more Sound objects and selects one with random weight for playback.
  34129. */
  34130. export class WeightedSound {
  34131. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34132. loop: boolean;
  34133. private _coneInnerAngle;
  34134. private _coneOuterAngle;
  34135. private _volume;
  34136. /** A Sound is currently playing. */
  34137. isPlaying: boolean;
  34138. /** A Sound is currently paused. */
  34139. isPaused: boolean;
  34140. private _sounds;
  34141. private _weights;
  34142. private _currentIndex?;
  34143. /**
  34144. * Creates a new WeightedSound from the list of sounds given.
  34145. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34146. * @param sounds Array of Sounds that will be selected from.
  34147. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34148. */
  34149. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34150. /**
  34151. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34152. */
  34153. /**
  34154. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34155. */
  34156. directionalConeInnerAngle: number;
  34157. /**
  34158. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34159. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34160. */
  34161. /**
  34162. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34163. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34164. */
  34165. directionalConeOuterAngle: number;
  34166. /**
  34167. * Playback volume.
  34168. */
  34169. /**
  34170. * Playback volume.
  34171. */
  34172. volume: number;
  34173. private _onended;
  34174. /**
  34175. * Suspend playback
  34176. */
  34177. pause(): void;
  34178. /**
  34179. * Stop playback
  34180. */
  34181. stop(): void;
  34182. /**
  34183. * Start playback.
  34184. * @param startOffset Position the clip head at a specific time in seconds.
  34185. */
  34186. play(startOffset?: number): void;
  34187. }
  34188. }
  34189. declare module BABYLON {
  34190. /**
  34191. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34192. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34193. */
  34194. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34195. /**
  34196. * Gets the name of the behavior.
  34197. */
  34198. readonly name: string;
  34199. /**
  34200. * The easing function used by animations
  34201. */
  34202. static EasingFunction: BackEase;
  34203. /**
  34204. * The easing mode used by animations
  34205. */
  34206. static EasingMode: number;
  34207. /**
  34208. * The duration of the animation, in milliseconds
  34209. */
  34210. transitionDuration: number;
  34211. /**
  34212. * Length of the distance animated by the transition when lower radius is reached
  34213. */
  34214. lowerRadiusTransitionRange: number;
  34215. /**
  34216. * Length of the distance animated by the transition when upper radius is reached
  34217. */
  34218. upperRadiusTransitionRange: number;
  34219. private _autoTransitionRange;
  34220. /**
  34221. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34222. */
  34223. /**
  34224. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34225. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34226. */
  34227. autoTransitionRange: boolean;
  34228. private _attachedCamera;
  34229. private _onAfterCheckInputsObserver;
  34230. private _onMeshTargetChangedObserver;
  34231. /**
  34232. * Initializes the behavior.
  34233. */
  34234. init(): void;
  34235. /**
  34236. * Attaches the behavior to its arc rotate camera.
  34237. * @param camera Defines the camera to attach the behavior to
  34238. */
  34239. attach(camera: ArcRotateCamera): void;
  34240. /**
  34241. * Detaches the behavior from its current arc rotate camera.
  34242. */
  34243. detach(): void;
  34244. private _radiusIsAnimating;
  34245. private _radiusBounceTransition;
  34246. private _animatables;
  34247. private _cachedWheelPrecision;
  34248. /**
  34249. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34250. * @param radiusLimit The limit to check against.
  34251. * @return Bool to indicate if at limit.
  34252. */
  34253. private _isRadiusAtLimit;
  34254. /**
  34255. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34256. * @param radiusDelta The delta by which to animate to. Can be negative.
  34257. */
  34258. private _applyBoundRadiusAnimation;
  34259. /**
  34260. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34261. */
  34262. protected _clearAnimationLocks(): void;
  34263. /**
  34264. * Stops and removes all animations that have been applied to the camera
  34265. */
  34266. stopAllAnimations(): void;
  34267. }
  34268. }
  34269. declare module BABYLON {
  34270. /**
  34271. * 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.
  34272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34273. */
  34274. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34275. /**
  34276. * Gets the name of the behavior.
  34277. */
  34278. readonly name: string;
  34279. private _mode;
  34280. private _radiusScale;
  34281. private _positionScale;
  34282. private _defaultElevation;
  34283. private _elevationReturnTime;
  34284. private _elevationReturnWaitTime;
  34285. private _zoomStopsAnimation;
  34286. private _framingTime;
  34287. /**
  34288. * The easing function used by animations
  34289. */
  34290. static EasingFunction: ExponentialEase;
  34291. /**
  34292. * The easing mode used by animations
  34293. */
  34294. static EasingMode: number;
  34295. /**
  34296. * Sets the current mode used by the behavior
  34297. */
  34298. /**
  34299. * Gets current mode used by the behavior.
  34300. */
  34301. mode: number;
  34302. /**
  34303. * Sets the scale applied to the radius (1 by default)
  34304. */
  34305. /**
  34306. * Gets the scale applied to the radius
  34307. */
  34308. radiusScale: number;
  34309. /**
  34310. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34311. */
  34312. /**
  34313. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34314. */
  34315. positionScale: number;
  34316. /**
  34317. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34318. * behaviour is triggered, in radians.
  34319. */
  34320. /**
  34321. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34322. * behaviour is triggered, in radians.
  34323. */
  34324. defaultElevation: number;
  34325. /**
  34326. * Sets the time (in milliseconds) taken to return to the default beta position.
  34327. * Negative value indicates camera should not return to default.
  34328. */
  34329. /**
  34330. * Gets the time (in milliseconds) taken to return to the default beta position.
  34331. * Negative value indicates camera should not return to default.
  34332. */
  34333. elevationReturnTime: number;
  34334. /**
  34335. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34336. */
  34337. /**
  34338. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34339. */
  34340. elevationReturnWaitTime: number;
  34341. /**
  34342. * Sets the flag that indicates if user zooming should stop animation.
  34343. */
  34344. /**
  34345. * Gets the flag that indicates if user zooming should stop animation.
  34346. */
  34347. zoomStopsAnimation: boolean;
  34348. /**
  34349. * Sets the transition time when framing the mesh, in milliseconds
  34350. */
  34351. /**
  34352. * Gets the transition time when framing the mesh, in milliseconds
  34353. */
  34354. framingTime: number;
  34355. /**
  34356. * Define if the behavior should automatically change the configured
  34357. * camera limits and sensibilities.
  34358. */
  34359. autoCorrectCameraLimitsAndSensibility: boolean;
  34360. private _onPrePointerObservableObserver;
  34361. private _onAfterCheckInputsObserver;
  34362. private _onMeshTargetChangedObserver;
  34363. private _attachedCamera;
  34364. private _isPointerDown;
  34365. private _lastInteractionTime;
  34366. /**
  34367. * Initializes the behavior.
  34368. */
  34369. init(): void;
  34370. /**
  34371. * Attaches the behavior to its arc rotate camera.
  34372. * @param camera Defines the camera to attach the behavior to
  34373. */
  34374. attach(camera: ArcRotateCamera): void;
  34375. /**
  34376. * Detaches the behavior from its current arc rotate camera.
  34377. */
  34378. detach(): void;
  34379. private _animatables;
  34380. private _betaIsAnimating;
  34381. private _betaTransition;
  34382. private _radiusTransition;
  34383. private _vectorTransition;
  34384. /**
  34385. * Targets the given mesh and updates zoom level accordingly.
  34386. * @param mesh The mesh to target.
  34387. * @param radius Optional. If a cached radius position already exists, overrides default.
  34388. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34389. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34390. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34391. */
  34392. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34393. /**
  34394. * Targets the given mesh with its children and updates zoom level accordingly.
  34395. * @param mesh The mesh to target.
  34396. * @param radius Optional. If a cached radius position already exists, overrides default.
  34397. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34398. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34399. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34400. */
  34401. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34402. /**
  34403. * Targets the given meshes with their children and updates zoom level accordingly.
  34404. * @param meshes The mesh to target.
  34405. * @param radius Optional. If a cached radius position already exists, overrides default.
  34406. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34407. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34408. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34409. */
  34410. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34411. /**
  34412. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34413. * @param minimumWorld Determines the smaller position of the bounding box extend
  34414. * @param maximumWorld Determines the bigger position of the bounding box extend
  34415. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34416. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34417. */
  34418. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34419. /**
  34420. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34421. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34422. * frustum width.
  34423. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34424. * to fully enclose the mesh in the viewing frustum.
  34425. */
  34426. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34427. /**
  34428. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34429. * is automatically returned to its default position (expected to be above ground plane).
  34430. */
  34431. private _maintainCameraAboveGround;
  34432. /**
  34433. * Returns the frustum slope based on the canvas ratio and camera FOV
  34434. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34435. */
  34436. private _getFrustumSlope;
  34437. /**
  34438. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34439. */
  34440. private _clearAnimationLocks;
  34441. /**
  34442. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34443. */
  34444. private _applyUserInteraction;
  34445. /**
  34446. * Stops and removes all animations that have been applied to the camera
  34447. */
  34448. stopAllAnimations(): void;
  34449. /**
  34450. * Gets a value indicating if the user is moving the camera
  34451. */
  34452. readonly isUserIsMoving: boolean;
  34453. /**
  34454. * The camera can move all the way towards the mesh.
  34455. */
  34456. static IgnoreBoundsSizeMode: number;
  34457. /**
  34458. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34459. */
  34460. static FitFrustumSidesMode: number;
  34461. }
  34462. }
  34463. declare module BABYLON {
  34464. /**
  34465. * Base class for Camera Pointer Inputs.
  34466. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34467. * for example usage.
  34468. */
  34469. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34470. /**
  34471. * Defines the camera the input is attached to.
  34472. */
  34473. abstract camera: Camera;
  34474. /**
  34475. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34476. */
  34477. protected _altKey: boolean;
  34478. protected _ctrlKey: boolean;
  34479. protected _metaKey: boolean;
  34480. protected _shiftKey: boolean;
  34481. /**
  34482. * Which mouse buttons were pressed at time of last mouse event.
  34483. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34484. */
  34485. protected _buttonsPressed: number;
  34486. /**
  34487. * Defines the buttons associated with the input to handle camera move.
  34488. */
  34489. buttons: number[];
  34490. /**
  34491. * Attach the input controls to a specific dom element to get the input from.
  34492. * @param element Defines the element the controls should be listened from
  34493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34494. */
  34495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34496. /**
  34497. * Detach the current controls from the specified dom element.
  34498. * @param element Defines the element to stop listening the inputs from
  34499. */
  34500. detachControl(element: Nullable<HTMLElement>): void;
  34501. /**
  34502. * Gets the class name of the current input.
  34503. * @returns the class name
  34504. */
  34505. getClassName(): string;
  34506. /**
  34507. * Get the friendly name associated with the input class.
  34508. * @returns the input friendly name
  34509. */
  34510. getSimpleName(): string;
  34511. /**
  34512. * Called on pointer POINTERDOUBLETAP event.
  34513. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34514. */
  34515. protected onDoubleTap(type: string): void;
  34516. /**
  34517. * Called on pointer POINTERMOVE event if only a single touch is active.
  34518. * Override this method to provide functionality.
  34519. */
  34520. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34521. /**
  34522. * Called on pointer POINTERMOVE event if multiple touches are active.
  34523. * Override this method to provide functionality.
  34524. */
  34525. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34526. /**
  34527. * Called on JS contextmenu event.
  34528. * Override this method to provide functionality.
  34529. */
  34530. protected onContextMenu(evt: PointerEvent): void;
  34531. /**
  34532. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34533. * press.
  34534. * Override this method to provide functionality.
  34535. */
  34536. protected onButtonDown(evt: PointerEvent): void;
  34537. /**
  34538. * Called each time a new POINTERUP event occurs. Ie, for each button
  34539. * release.
  34540. * Override this method to provide functionality.
  34541. */
  34542. protected onButtonUp(evt: PointerEvent): void;
  34543. /**
  34544. * Called when window becomes inactive.
  34545. * Override this method to provide functionality.
  34546. */
  34547. protected onLostFocus(): void;
  34548. private _pointerInput;
  34549. private _observer;
  34550. private _onLostFocus;
  34551. private pointA;
  34552. private pointB;
  34553. }
  34554. }
  34555. declare module BABYLON {
  34556. /**
  34557. * Manage the pointers inputs to control an arc rotate camera.
  34558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34559. */
  34560. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34561. /**
  34562. * Defines the camera the input is attached to.
  34563. */
  34564. camera: ArcRotateCamera;
  34565. /**
  34566. * Gets the class name of the current input.
  34567. * @returns the class name
  34568. */
  34569. getClassName(): string;
  34570. /**
  34571. * Defines the buttons associated with the input to handle camera move.
  34572. */
  34573. buttons: number[];
  34574. /**
  34575. * Defines the pointer angular sensibility along the X axis or how fast is
  34576. * the camera rotating.
  34577. */
  34578. angularSensibilityX: number;
  34579. /**
  34580. * Defines the pointer angular sensibility along the Y axis or how fast is
  34581. * the camera rotating.
  34582. */
  34583. angularSensibilityY: number;
  34584. /**
  34585. * Defines the pointer pinch precision or how fast is the camera zooming.
  34586. */
  34587. pinchPrecision: number;
  34588. /**
  34589. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34590. * from 0.
  34591. * It defines the percentage of current camera.radius to use as delta when
  34592. * pinch zoom is used.
  34593. */
  34594. pinchDeltaPercentage: number;
  34595. /**
  34596. * Defines the pointer panning sensibility or how fast is the camera moving.
  34597. */
  34598. panningSensibility: number;
  34599. /**
  34600. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34601. */
  34602. multiTouchPanning: boolean;
  34603. /**
  34604. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34605. * zoom (pinch) through multitouch.
  34606. */
  34607. multiTouchPanAndZoom: boolean;
  34608. /**
  34609. * Revers pinch action direction.
  34610. */
  34611. pinchInwards: boolean;
  34612. private _isPanClick;
  34613. private _twoFingerActivityCount;
  34614. private _isPinching;
  34615. /**
  34616. * Called on pointer POINTERMOVE event if only a single touch is active.
  34617. */
  34618. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34619. /**
  34620. * Called on pointer POINTERDOUBLETAP event.
  34621. */
  34622. protected onDoubleTap(type: string): void;
  34623. /**
  34624. * Called on pointer POINTERMOVE event if multiple touches are active.
  34625. */
  34626. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34627. /**
  34628. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34629. * press.
  34630. */
  34631. protected onButtonDown(evt: PointerEvent): void;
  34632. /**
  34633. * Called each time a new POINTERUP event occurs. Ie, for each button
  34634. * release.
  34635. */
  34636. protected onButtonUp(evt: PointerEvent): void;
  34637. /**
  34638. * Called when window becomes inactive.
  34639. */
  34640. protected onLostFocus(): void;
  34641. }
  34642. }
  34643. declare module BABYLON {
  34644. /**
  34645. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34647. */
  34648. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34649. /**
  34650. * Defines the camera the input is attached to.
  34651. */
  34652. camera: ArcRotateCamera;
  34653. /**
  34654. * Defines the list of key codes associated with the up action (increase alpha)
  34655. */
  34656. keysUp: number[];
  34657. /**
  34658. * Defines the list of key codes associated with the down action (decrease alpha)
  34659. */
  34660. keysDown: number[];
  34661. /**
  34662. * Defines the list of key codes associated with the left action (increase beta)
  34663. */
  34664. keysLeft: number[];
  34665. /**
  34666. * Defines the list of key codes associated with the right action (decrease beta)
  34667. */
  34668. keysRight: number[];
  34669. /**
  34670. * Defines the list of key codes associated with the reset action.
  34671. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34672. */
  34673. keysReset: number[];
  34674. /**
  34675. * Defines the panning sensibility of the inputs.
  34676. * (How fast is the camera paning)
  34677. */
  34678. panningSensibility: number;
  34679. /**
  34680. * Defines the zooming sensibility of the inputs.
  34681. * (How fast is the camera zooming)
  34682. */
  34683. zoomingSensibility: number;
  34684. /**
  34685. * Defines wether maintaining the alt key down switch the movement mode from
  34686. * orientation to zoom.
  34687. */
  34688. useAltToZoom: boolean;
  34689. /**
  34690. * Rotation speed of the camera
  34691. */
  34692. angularSpeed: number;
  34693. private _keys;
  34694. private _ctrlPressed;
  34695. private _altPressed;
  34696. private _onCanvasBlurObserver;
  34697. private _onKeyboardObserver;
  34698. private _engine;
  34699. private _scene;
  34700. /**
  34701. * Attach the input controls to a specific dom element to get the input from.
  34702. * @param element Defines the element the controls should be listened from
  34703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34704. */
  34705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34706. /**
  34707. * Detach the current controls from the specified dom element.
  34708. * @param element Defines the element to stop listening the inputs from
  34709. */
  34710. detachControl(element: Nullable<HTMLElement>): void;
  34711. /**
  34712. * Update the current camera state depending on the inputs that have been used this frame.
  34713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34714. */
  34715. checkInputs(): void;
  34716. /**
  34717. * Gets the class name of the current intput.
  34718. * @returns the class name
  34719. */
  34720. getClassName(): string;
  34721. /**
  34722. * Get the friendly name associated with the input class.
  34723. * @returns the input friendly name
  34724. */
  34725. getSimpleName(): string;
  34726. }
  34727. }
  34728. declare module BABYLON {
  34729. /**
  34730. * Manage the mouse wheel inputs to control an arc rotate camera.
  34731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34732. */
  34733. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34734. /**
  34735. * Defines the camera the input is attached to.
  34736. */
  34737. camera: ArcRotateCamera;
  34738. /**
  34739. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34740. */
  34741. wheelPrecision: number;
  34742. /**
  34743. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34744. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34745. */
  34746. wheelDeltaPercentage: number;
  34747. private _wheel;
  34748. private _observer;
  34749. private computeDeltaFromMouseWheelLegacyEvent;
  34750. /**
  34751. * Attach the input controls to a specific dom element to get the input from.
  34752. * @param element Defines the element the controls should be listened from
  34753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34754. */
  34755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34756. /**
  34757. * Detach the current controls from the specified dom element.
  34758. * @param element Defines the element to stop listening the inputs from
  34759. */
  34760. detachControl(element: Nullable<HTMLElement>): void;
  34761. /**
  34762. * Gets the class name of the current intput.
  34763. * @returns the class name
  34764. */
  34765. getClassName(): string;
  34766. /**
  34767. * Get the friendly name associated with the input class.
  34768. * @returns the input friendly name
  34769. */
  34770. getSimpleName(): string;
  34771. }
  34772. }
  34773. declare module BABYLON {
  34774. /**
  34775. * Default Inputs manager for the ArcRotateCamera.
  34776. * It groups all the default supported inputs for ease of use.
  34777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34778. */
  34779. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34780. /**
  34781. * Instantiates a new ArcRotateCameraInputsManager.
  34782. * @param camera Defines the camera the inputs belong to
  34783. */
  34784. constructor(camera: ArcRotateCamera);
  34785. /**
  34786. * Add mouse wheel input support to the input manager.
  34787. * @returns the current input manager
  34788. */
  34789. addMouseWheel(): ArcRotateCameraInputsManager;
  34790. /**
  34791. * Add pointers input support to the input manager.
  34792. * @returns the current input manager
  34793. */
  34794. addPointers(): ArcRotateCameraInputsManager;
  34795. /**
  34796. * Add keyboard input support to the input manager.
  34797. * @returns the current input manager
  34798. */
  34799. addKeyboard(): ArcRotateCameraInputsManager;
  34800. }
  34801. }
  34802. declare module BABYLON {
  34803. /**
  34804. * This represents an orbital type of camera.
  34805. *
  34806. * 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.
  34807. * 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.
  34808. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34809. */
  34810. export class ArcRotateCamera extends TargetCamera {
  34811. /**
  34812. * Defines the rotation angle of the camera along the longitudinal axis.
  34813. */
  34814. alpha: number;
  34815. /**
  34816. * Defines the rotation angle of the camera along the latitudinal axis.
  34817. */
  34818. beta: number;
  34819. /**
  34820. * Defines the radius of the camera from it s target point.
  34821. */
  34822. radius: number;
  34823. protected _target: Vector3;
  34824. protected _targetHost: Nullable<AbstractMesh>;
  34825. /**
  34826. * Defines the target point of the camera.
  34827. * The camera looks towards it form the radius distance.
  34828. */
  34829. target: Vector3;
  34830. /**
  34831. * Define the current local position of the camera in the scene
  34832. */
  34833. position: Vector3;
  34834. protected _upVector: Vector3;
  34835. protected _upToYMatrix: Matrix;
  34836. protected _YToUpMatrix: Matrix;
  34837. /**
  34838. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34839. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34840. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34841. */
  34842. upVector: Vector3;
  34843. /**
  34844. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34845. */
  34846. setMatUp(): void;
  34847. /**
  34848. * Current inertia value on the longitudinal axis.
  34849. * The bigger this number the longer it will take for the camera to stop.
  34850. */
  34851. inertialAlphaOffset: number;
  34852. /**
  34853. * Current inertia value on the latitudinal axis.
  34854. * The bigger this number the longer it will take for the camera to stop.
  34855. */
  34856. inertialBetaOffset: number;
  34857. /**
  34858. * Current inertia value on the radius axis.
  34859. * The bigger this number the longer it will take for the camera to stop.
  34860. */
  34861. inertialRadiusOffset: number;
  34862. /**
  34863. * Minimum allowed angle on the longitudinal axis.
  34864. * This can help limiting how the Camera is able to move in the scene.
  34865. */
  34866. lowerAlphaLimit: Nullable<number>;
  34867. /**
  34868. * Maximum allowed angle on the longitudinal axis.
  34869. * This can help limiting how the Camera is able to move in the scene.
  34870. */
  34871. upperAlphaLimit: Nullable<number>;
  34872. /**
  34873. * Minimum allowed angle on the latitudinal axis.
  34874. * This can help limiting how the Camera is able to move in the scene.
  34875. */
  34876. lowerBetaLimit: number;
  34877. /**
  34878. * Maximum allowed angle on the latitudinal axis.
  34879. * This can help limiting how the Camera is able to move in the scene.
  34880. */
  34881. upperBetaLimit: number;
  34882. /**
  34883. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34884. * This can help limiting how the Camera is able to move in the scene.
  34885. */
  34886. lowerRadiusLimit: Nullable<number>;
  34887. /**
  34888. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34889. * This can help limiting how the Camera is able to move in the scene.
  34890. */
  34891. upperRadiusLimit: Nullable<number>;
  34892. /**
  34893. * Defines the current inertia value used during panning of the camera along the X axis.
  34894. */
  34895. inertialPanningX: number;
  34896. /**
  34897. * Defines the current inertia value used during panning of the camera along the Y axis.
  34898. */
  34899. inertialPanningY: number;
  34900. /**
  34901. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34902. * Basically if your fingers moves away from more than this distance you will be considered
  34903. * in pinch mode.
  34904. */
  34905. pinchToPanMaxDistance: number;
  34906. /**
  34907. * Defines the maximum distance the camera can pan.
  34908. * This could help keeping the cammera always in your scene.
  34909. */
  34910. panningDistanceLimit: Nullable<number>;
  34911. /**
  34912. * Defines the target of the camera before paning.
  34913. */
  34914. panningOriginTarget: Vector3;
  34915. /**
  34916. * Defines the value of the inertia used during panning.
  34917. * 0 would mean stop inertia and one would mean no decelleration at all.
  34918. */
  34919. panningInertia: number;
  34920. /**
  34921. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34922. */
  34923. angularSensibilityX: number;
  34924. /**
  34925. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34926. */
  34927. angularSensibilityY: number;
  34928. /**
  34929. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34930. */
  34931. pinchPrecision: number;
  34932. /**
  34933. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34934. * It will be used instead of pinchDeltaPrecision if different from 0.
  34935. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34936. */
  34937. pinchDeltaPercentage: number;
  34938. /**
  34939. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34940. */
  34941. panningSensibility: number;
  34942. /**
  34943. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34944. */
  34945. keysUp: number[];
  34946. /**
  34947. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34948. */
  34949. keysDown: number[];
  34950. /**
  34951. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34952. */
  34953. keysLeft: number[];
  34954. /**
  34955. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34956. */
  34957. keysRight: number[];
  34958. /**
  34959. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34960. */
  34961. wheelPrecision: number;
  34962. /**
  34963. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34964. * It will be used instead of pinchDeltaPrecision if different from 0.
  34965. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34966. */
  34967. wheelDeltaPercentage: number;
  34968. /**
  34969. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34970. */
  34971. zoomOnFactor: number;
  34972. /**
  34973. * Defines a screen offset for the camera position.
  34974. */
  34975. targetScreenOffset: Vector2;
  34976. /**
  34977. * Allows the camera to be completely reversed.
  34978. * If false the camera can not arrive upside down.
  34979. */
  34980. allowUpsideDown: boolean;
  34981. /**
  34982. * Define if double tap/click is used to restore the previously saved state of the camera.
  34983. */
  34984. useInputToRestoreState: boolean;
  34985. /** @hidden */ private _viewMatrix: Matrix;
  34986. /** @hidden */ private _useCtrlForPanning: boolean;
  34987. /** @hidden */ private _panningMouseButton: number;
  34988. /**
  34989. * Defines the input associated to the camera.
  34990. */
  34991. inputs: ArcRotateCameraInputsManager;
  34992. /** @hidden */ private _reset: () => void;
  34993. /**
  34994. * Defines the allowed panning axis.
  34995. */
  34996. panningAxis: Vector3;
  34997. protected _localDirection: Vector3;
  34998. protected _transformedDirection: Vector3;
  34999. private _bouncingBehavior;
  35000. /**
  35001. * Gets the bouncing behavior of the camera if it has been enabled.
  35002. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35003. */
  35004. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35005. /**
  35006. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35008. */
  35009. useBouncingBehavior: boolean;
  35010. private _framingBehavior;
  35011. /**
  35012. * Gets the framing behavior of the camera if it has been enabled.
  35013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35014. */
  35015. readonly framingBehavior: Nullable<FramingBehavior>;
  35016. /**
  35017. * Defines if the framing behavior of the camera is enabled on the camera.
  35018. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35019. */
  35020. useFramingBehavior: boolean;
  35021. private _autoRotationBehavior;
  35022. /**
  35023. * Gets the auto rotation behavior of the camera if it has been enabled.
  35024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35025. */
  35026. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35027. /**
  35028. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35030. */
  35031. useAutoRotationBehavior: boolean;
  35032. /**
  35033. * Observable triggered when the mesh target has been changed on the camera.
  35034. */
  35035. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35036. /**
  35037. * Event raised when the camera is colliding with a mesh.
  35038. */
  35039. onCollide: (collidedMesh: AbstractMesh) => void;
  35040. /**
  35041. * Defines whether the camera should check collision with the objects oh the scene.
  35042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35043. */
  35044. checkCollisions: boolean;
  35045. /**
  35046. * Defines the collision radius of the camera.
  35047. * This simulates a sphere around the camera.
  35048. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35049. */
  35050. collisionRadius: Vector3;
  35051. protected _collider: Collider;
  35052. protected _previousPosition: Vector3;
  35053. protected _collisionVelocity: Vector3;
  35054. protected _newPosition: Vector3;
  35055. protected _previousAlpha: number;
  35056. protected _previousBeta: number;
  35057. protected _previousRadius: number;
  35058. protected _collisionTriggered: boolean;
  35059. protected _targetBoundingCenter: Nullable<Vector3>;
  35060. private _computationVector;
  35061. /**
  35062. * Instantiates a new ArcRotateCamera in a given scene
  35063. * @param name Defines the name of the camera
  35064. * @param alpha Defines the camera rotation along the logitudinal axis
  35065. * @param beta Defines the camera rotation along the latitudinal axis
  35066. * @param radius Defines the camera distance from its target
  35067. * @param target Defines the camera target
  35068. * @param scene Defines the scene the camera belongs to
  35069. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35070. */
  35071. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35072. /** @hidden */ private _initCache(): void;
  35073. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35074. protected _getTargetPosition(): Vector3;
  35075. private _storedAlpha;
  35076. private _storedBeta;
  35077. private _storedRadius;
  35078. private _storedTarget;
  35079. /**
  35080. * Stores the current state of the camera (alpha, beta, radius and target)
  35081. * @returns the camera itself
  35082. */
  35083. storeState(): Camera;
  35084. /**
  35085. * @hidden
  35086. * Restored camera state. You must call storeState() first
  35087. */ private _restoreStateValues(): boolean;
  35088. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35089. /**
  35090. * Attached controls to the current camera.
  35091. * @param element Defines the element the controls should be listened from
  35092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35093. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35094. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35095. */
  35096. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35097. /**
  35098. * Detach the current controls from the camera.
  35099. * The camera will stop reacting to inputs.
  35100. * @param element Defines the element to stop listening the inputs from
  35101. */
  35102. detachControl(element: HTMLElement): void;
  35103. /** @hidden */ private _checkInputs(): void;
  35104. protected _checkLimits(): void;
  35105. /**
  35106. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35107. */
  35108. rebuildAnglesAndRadius(): void;
  35109. /**
  35110. * Use a position to define the current camera related information like aplha, beta and radius
  35111. * @param position Defines the position to set the camera at
  35112. */
  35113. setPosition(position: Vector3): void;
  35114. /**
  35115. * Defines the target the camera should look at.
  35116. * This will automatically adapt alpha beta and radius to fit within the new target.
  35117. * @param target Defines the new target as a Vector or a mesh
  35118. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35119. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35120. */
  35121. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35122. /** @hidden */ private _getViewMatrix(): Matrix;
  35123. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35124. /**
  35125. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35126. * @param meshes Defines the mesh to zoom on
  35127. * @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)
  35128. */
  35129. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35130. /**
  35131. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35132. * The target will be changed but the radius
  35133. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35134. * @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)
  35135. */
  35136. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35137. min: Vector3;
  35138. max: Vector3;
  35139. distance: number;
  35140. }, doNotUpdateMaxZ?: boolean): void;
  35141. /**
  35142. * @override
  35143. * Override Camera.createRigCamera
  35144. */
  35145. createRigCamera(name: string, cameraIndex: number): Camera;
  35146. /**
  35147. * @hidden
  35148. * @override
  35149. * Override Camera._updateRigCameras
  35150. */ private _updateRigCameras(): void;
  35151. /**
  35152. * Destroy the camera and release the current resources hold by it.
  35153. */
  35154. dispose(): void;
  35155. /**
  35156. * Gets the current object class name.
  35157. * @return the class name
  35158. */
  35159. getClassName(): string;
  35160. }
  35161. }
  35162. declare module BABYLON {
  35163. /**
  35164. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35165. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35166. */
  35167. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35168. /**
  35169. * Gets the name of the behavior.
  35170. */
  35171. readonly name: string;
  35172. private _zoomStopsAnimation;
  35173. private _idleRotationSpeed;
  35174. private _idleRotationWaitTime;
  35175. private _idleRotationSpinupTime;
  35176. /**
  35177. * Sets the flag that indicates if user zooming should stop animation.
  35178. */
  35179. /**
  35180. * Gets the flag that indicates if user zooming should stop animation.
  35181. */
  35182. zoomStopsAnimation: boolean;
  35183. /**
  35184. * Sets the default speed at which the camera rotates around the model.
  35185. */
  35186. /**
  35187. * Gets the default speed at which the camera rotates around the model.
  35188. */
  35189. idleRotationSpeed: number;
  35190. /**
  35191. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35192. */
  35193. /**
  35194. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35195. */
  35196. idleRotationWaitTime: number;
  35197. /**
  35198. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35199. */
  35200. /**
  35201. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35202. */
  35203. idleRotationSpinupTime: number;
  35204. /**
  35205. * Gets a value indicating if the camera is currently rotating because of this behavior
  35206. */
  35207. readonly rotationInProgress: boolean;
  35208. private _onPrePointerObservableObserver;
  35209. private _onAfterCheckInputsObserver;
  35210. private _attachedCamera;
  35211. private _isPointerDown;
  35212. private _lastFrameTime;
  35213. private _lastInteractionTime;
  35214. private _cameraRotationSpeed;
  35215. /**
  35216. * Initializes the behavior.
  35217. */
  35218. init(): void;
  35219. /**
  35220. * Attaches the behavior to its arc rotate camera.
  35221. * @param camera Defines the camera to attach the behavior to
  35222. */
  35223. attach(camera: ArcRotateCamera): void;
  35224. /**
  35225. * Detaches the behavior from its current arc rotate camera.
  35226. */
  35227. detach(): void;
  35228. /**
  35229. * Returns true if user is scrolling.
  35230. * @return true if user is scrolling.
  35231. */
  35232. private _userIsZooming;
  35233. private _lastFrameRadius;
  35234. private _shouldAnimationStopForInteraction;
  35235. /**
  35236. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35237. */
  35238. private _applyUserInteraction;
  35239. private _userIsMoving;
  35240. }
  35241. }
  35242. declare module BABYLON {
  35243. /**
  35244. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35245. */
  35246. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35247. private ui;
  35248. /**
  35249. * The name of the behavior
  35250. */
  35251. name: string;
  35252. /**
  35253. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35254. */
  35255. distanceAwayFromFace: number;
  35256. /**
  35257. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35258. */
  35259. distanceAwayFromBottomOfFace: number;
  35260. private _faceVectors;
  35261. private _target;
  35262. private _scene;
  35263. private _onRenderObserver;
  35264. private _tmpMatrix;
  35265. private _tmpVector;
  35266. /**
  35267. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35268. * @param ui The transform node that should be attched to the mesh
  35269. */
  35270. constructor(ui: TransformNode);
  35271. /**
  35272. * Initializes the behavior
  35273. */
  35274. init(): void;
  35275. private _closestFace;
  35276. private _zeroVector;
  35277. private _lookAtTmpMatrix;
  35278. private _lookAtToRef;
  35279. /**
  35280. * Attaches the AttachToBoxBehavior to the passed in mesh
  35281. * @param target The mesh that the specified node will be attached to
  35282. */
  35283. attach(target: Mesh): void;
  35284. /**
  35285. * Detaches the behavior from the mesh
  35286. */
  35287. detach(): void;
  35288. }
  35289. }
  35290. declare module BABYLON {
  35291. /**
  35292. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35293. */
  35294. export class FadeInOutBehavior implements Behavior<Mesh> {
  35295. /**
  35296. * Time in milliseconds to delay before fading in (Default: 0)
  35297. */
  35298. delay: number;
  35299. /**
  35300. * Time in milliseconds for the mesh to fade in (Default: 300)
  35301. */
  35302. fadeInTime: number;
  35303. private _millisecondsPerFrame;
  35304. private _hovered;
  35305. private _hoverValue;
  35306. private _ownerNode;
  35307. /**
  35308. * Instatiates the FadeInOutBehavior
  35309. */
  35310. constructor();
  35311. /**
  35312. * The name of the behavior
  35313. */
  35314. readonly name: string;
  35315. /**
  35316. * Initializes the behavior
  35317. */
  35318. init(): void;
  35319. /**
  35320. * Attaches the fade behavior on the passed in mesh
  35321. * @param ownerNode The mesh that will be faded in/out once attached
  35322. */
  35323. attach(ownerNode: Mesh): void;
  35324. /**
  35325. * Detaches the behavior from the mesh
  35326. */
  35327. detach(): void;
  35328. /**
  35329. * Triggers the mesh to begin fading in or out
  35330. * @param value if the object should fade in or out (true to fade in)
  35331. */
  35332. fadeIn(value: boolean): void;
  35333. private _update;
  35334. private _setAllVisibility;
  35335. }
  35336. }
  35337. declare module BABYLON {
  35338. /**
  35339. * Class containing a set of static utilities functions for managing Pivots
  35340. * @hidden
  35341. */
  35342. export class PivotTools {
  35343. private static _PivotCached;
  35344. private static _OldPivotPoint;
  35345. private static _PivotTranslation;
  35346. private static _PivotTmpVector;
  35347. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35348. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35349. }
  35350. }
  35351. declare module BABYLON {
  35352. /**
  35353. * Class containing static functions to help procedurally build meshes
  35354. */
  35355. export class PlaneBuilder {
  35356. /**
  35357. * Creates a plane mesh
  35358. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35359. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35360. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35362. * * 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
  35363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35364. * @param name defines the name of the mesh
  35365. * @param options defines the options used to create the mesh
  35366. * @param scene defines the hosting scene
  35367. * @returns the plane mesh
  35368. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35369. */
  35370. static CreatePlane(name: string, options: {
  35371. size?: number;
  35372. width?: number;
  35373. height?: number;
  35374. sideOrientation?: number;
  35375. frontUVs?: Vector4;
  35376. backUVs?: Vector4;
  35377. updatable?: boolean;
  35378. sourcePlane?: Plane;
  35379. }, scene?: Nullable<Scene>): Mesh;
  35380. }
  35381. }
  35382. declare module BABYLON {
  35383. /**
  35384. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35385. */
  35386. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35387. private static _AnyMouseID;
  35388. /**
  35389. * Abstract mesh the behavior is set on
  35390. */
  35391. attachedNode: AbstractMesh;
  35392. private _dragPlane;
  35393. private _scene;
  35394. private _pointerObserver;
  35395. private _beforeRenderObserver;
  35396. private static _planeScene;
  35397. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35398. /**
  35399. * 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)
  35400. */
  35401. maxDragAngle: number;
  35402. /**
  35403. * @hidden
  35404. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35405. /**
  35406. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35407. */
  35408. currentDraggingPointerID: number;
  35409. /**
  35410. * The last position where the pointer hit the drag plane in world space
  35411. */
  35412. lastDragPosition: Vector3;
  35413. /**
  35414. * If the behavior is currently in a dragging state
  35415. */
  35416. dragging: boolean;
  35417. /**
  35418. * 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)
  35419. */
  35420. dragDeltaRatio: number;
  35421. /**
  35422. * If the drag plane orientation should be updated during the dragging (Default: true)
  35423. */
  35424. updateDragPlane: boolean;
  35425. private _debugMode;
  35426. private _moving;
  35427. /**
  35428. * Fires each time the attached mesh is dragged with the pointer
  35429. * * delta between last drag position and current drag position in world space
  35430. * * dragDistance along the drag axis
  35431. * * dragPlaneNormal normal of the current drag plane used during the drag
  35432. * * dragPlanePoint in world space where the drag intersects the drag plane
  35433. */
  35434. onDragObservable: Observable<{
  35435. delta: Vector3;
  35436. dragPlanePoint: Vector3;
  35437. dragPlaneNormal: Vector3;
  35438. dragDistance: number;
  35439. pointerId: number;
  35440. }>;
  35441. /**
  35442. * Fires each time a drag begins (eg. mouse down on mesh)
  35443. */
  35444. onDragStartObservable: Observable<{
  35445. dragPlanePoint: Vector3;
  35446. pointerId: number;
  35447. }>;
  35448. /**
  35449. * Fires each time a drag ends (eg. mouse release after drag)
  35450. */
  35451. onDragEndObservable: Observable<{
  35452. dragPlanePoint: Vector3;
  35453. pointerId: number;
  35454. }>;
  35455. /**
  35456. * If the attached mesh should be moved when dragged
  35457. */
  35458. moveAttached: boolean;
  35459. /**
  35460. * If the drag behavior will react to drag events (Default: true)
  35461. */
  35462. enabled: boolean;
  35463. /**
  35464. * If camera controls should be detached during the drag
  35465. */
  35466. detachCameraControls: boolean;
  35467. /**
  35468. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35469. */
  35470. useObjectOrienationForDragging: boolean;
  35471. private _options;
  35472. /**
  35473. * Creates a pointer drag behavior that can be attached to a mesh
  35474. * @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)
  35475. */
  35476. constructor(options?: {
  35477. dragAxis?: Vector3;
  35478. dragPlaneNormal?: Vector3;
  35479. });
  35480. /**
  35481. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35482. */
  35483. validateDrag: (targetPosition: Vector3) => boolean;
  35484. /**
  35485. * The name of the behavior
  35486. */
  35487. readonly name: string;
  35488. /**
  35489. * Initializes the behavior
  35490. */
  35491. init(): void;
  35492. private _tmpVector;
  35493. private _alternatePickedPoint;
  35494. private _worldDragAxis;
  35495. private _targetPosition;
  35496. private _attachedElement;
  35497. /**
  35498. * Attaches the drag behavior the passed in mesh
  35499. * @param ownerNode The mesh that will be dragged around once attached
  35500. */
  35501. attach(ownerNode: AbstractMesh): void;
  35502. /**
  35503. * Force relase the drag action by code.
  35504. */
  35505. releaseDrag(): void;
  35506. private _startDragRay;
  35507. private _lastPointerRay;
  35508. /**
  35509. * Simulates the start of a pointer drag event on the behavior
  35510. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35511. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35512. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35513. */
  35514. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35515. private _startDrag;
  35516. private _dragDelta;
  35517. private _moveDrag;
  35518. private _pickWithRayOnDragPlane;
  35519. private _pointA;
  35520. private _pointB;
  35521. private _pointC;
  35522. private _lineA;
  35523. private _lineB;
  35524. private _localAxis;
  35525. private _lookAt;
  35526. private _updateDragPlanePosition;
  35527. /**
  35528. * Detaches the behavior from the mesh
  35529. */
  35530. detach(): void;
  35531. }
  35532. }
  35533. declare module BABYLON {
  35534. /**
  35535. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35536. */
  35537. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35538. private _dragBehaviorA;
  35539. private _dragBehaviorB;
  35540. private _startDistance;
  35541. private _initialScale;
  35542. private _targetScale;
  35543. private _ownerNode;
  35544. private _sceneRenderObserver;
  35545. /**
  35546. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35547. */
  35548. constructor();
  35549. /**
  35550. * The name of the behavior
  35551. */
  35552. readonly name: string;
  35553. /**
  35554. * Initializes the behavior
  35555. */
  35556. init(): void;
  35557. private _getCurrentDistance;
  35558. /**
  35559. * Attaches the scale behavior the passed in mesh
  35560. * @param ownerNode The mesh that will be scaled around once attached
  35561. */
  35562. attach(ownerNode: Mesh): void;
  35563. /**
  35564. * Detaches the behavior from the mesh
  35565. */
  35566. detach(): void;
  35567. }
  35568. }
  35569. declare module BABYLON {
  35570. /**
  35571. * 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
  35572. */
  35573. export class SixDofDragBehavior implements Behavior<Mesh> {
  35574. private static _virtualScene;
  35575. private _ownerNode;
  35576. private _sceneRenderObserver;
  35577. private _scene;
  35578. private _targetPosition;
  35579. private _virtualOriginMesh;
  35580. private _virtualDragMesh;
  35581. private _pointerObserver;
  35582. private _moving;
  35583. private _startingOrientation;
  35584. /**
  35585. * 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)
  35586. */
  35587. private zDragFactor;
  35588. /**
  35589. * If the object should rotate to face the drag origin
  35590. */
  35591. rotateDraggedObject: boolean;
  35592. /**
  35593. * If the behavior is currently in a dragging state
  35594. */
  35595. dragging: boolean;
  35596. /**
  35597. * 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)
  35598. */
  35599. dragDeltaRatio: number;
  35600. /**
  35601. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35602. */
  35603. currentDraggingPointerID: number;
  35604. /**
  35605. * If camera controls should be detached during the drag
  35606. */
  35607. detachCameraControls: boolean;
  35608. /**
  35609. * Fires each time a drag starts
  35610. */
  35611. onDragStartObservable: Observable<{}>;
  35612. /**
  35613. * Fires each time a drag ends (eg. mouse release after drag)
  35614. */
  35615. onDragEndObservable: Observable<{}>;
  35616. /**
  35617. * 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
  35618. */
  35619. constructor();
  35620. /**
  35621. * The name of the behavior
  35622. */
  35623. readonly name: string;
  35624. /**
  35625. * Initializes the behavior
  35626. */
  35627. init(): void;
  35628. /**
  35629. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  35630. */
  35631. private readonly _pointerCamera;
  35632. /**
  35633. * Attaches the scale behavior the passed in mesh
  35634. * @param ownerNode The mesh that will be scaled around once attached
  35635. */
  35636. attach(ownerNode: Mesh): void;
  35637. /**
  35638. * Detaches the behavior from the mesh
  35639. */
  35640. detach(): void;
  35641. }
  35642. }
  35643. declare module BABYLON {
  35644. /**
  35645. * Class used to apply inverse kinematics to bones
  35646. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35647. */
  35648. export class BoneIKController {
  35649. private static _tmpVecs;
  35650. private static _tmpQuat;
  35651. private static _tmpMats;
  35652. /**
  35653. * Gets or sets the target mesh
  35654. */
  35655. targetMesh: AbstractMesh;
  35656. /** Gets or sets the mesh used as pole */
  35657. poleTargetMesh: AbstractMesh;
  35658. /**
  35659. * Gets or sets the bone used as pole
  35660. */
  35661. poleTargetBone: Nullable<Bone>;
  35662. /**
  35663. * Gets or sets the target position
  35664. */
  35665. targetPosition: Vector3;
  35666. /**
  35667. * Gets or sets the pole target position
  35668. */
  35669. poleTargetPosition: Vector3;
  35670. /**
  35671. * Gets or sets the pole target local offset
  35672. */
  35673. poleTargetLocalOffset: Vector3;
  35674. /**
  35675. * Gets or sets the pole angle
  35676. */
  35677. poleAngle: number;
  35678. /**
  35679. * Gets or sets the mesh associated with the controller
  35680. */
  35681. mesh: AbstractMesh;
  35682. /**
  35683. * 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)
  35684. */
  35685. slerpAmount: number;
  35686. private _bone1Quat;
  35687. private _bone1Mat;
  35688. private _bone2Ang;
  35689. private _bone1;
  35690. private _bone2;
  35691. private _bone1Length;
  35692. private _bone2Length;
  35693. private _maxAngle;
  35694. private _maxReach;
  35695. private _rightHandedSystem;
  35696. private _bendAxis;
  35697. private _slerping;
  35698. private _adjustRoll;
  35699. /**
  35700. * Gets or sets maximum allowed angle
  35701. */
  35702. maxAngle: number;
  35703. /**
  35704. * Creates a new BoneIKController
  35705. * @param mesh defines the mesh to control
  35706. * @param bone defines the bone to control
  35707. * @param options defines options to set up the controller
  35708. */
  35709. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35710. targetMesh?: AbstractMesh;
  35711. poleTargetMesh?: AbstractMesh;
  35712. poleTargetBone?: Bone;
  35713. poleTargetLocalOffset?: Vector3;
  35714. poleAngle?: number;
  35715. bendAxis?: Vector3;
  35716. maxAngle?: number;
  35717. slerpAmount?: number;
  35718. });
  35719. private _setMaxAngle;
  35720. /**
  35721. * Force the controller to update the bones
  35722. */
  35723. update(): void;
  35724. }
  35725. }
  35726. declare module BABYLON {
  35727. /**
  35728. * Class used to make a bone look toward a point in space
  35729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35730. */
  35731. export class BoneLookController {
  35732. private static _tmpVecs;
  35733. private static _tmpQuat;
  35734. private static _tmpMats;
  35735. /**
  35736. * The target Vector3 that the bone will look at
  35737. */
  35738. target: Vector3;
  35739. /**
  35740. * The mesh that the bone is attached to
  35741. */
  35742. mesh: AbstractMesh;
  35743. /**
  35744. * The bone that will be looking to the target
  35745. */
  35746. bone: Bone;
  35747. /**
  35748. * The up axis of the coordinate system that is used when the bone is rotated
  35749. */
  35750. upAxis: Vector3;
  35751. /**
  35752. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35753. */
  35754. upAxisSpace: Space;
  35755. /**
  35756. * Used to make an adjustment to the yaw of the bone
  35757. */
  35758. adjustYaw: number;
  35759. /**
  35760. * Used to make an adjustment to the pitch of the bone
  35761. */
  35762. adjustPitch: number;
  35763. /**
  35764. * Used to make an adjustment to the roll of the bone
  35765. */
  35766. adjustRoll: number;
  35767. /**
  35768. * 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)
  35769. */
  35770. slerpAmount: number;
  35771. private _minYaw;
  35772. private _maxYaw;
  35773. private _minPitch;
  35774. private _maxPitch;
  35775. private _minYawSin;
  35776. private _minYawCos;
  35777. private _maxYawSin;
  35778. private _maxYawCos;
  35779. private _midYawConstraint;
  35780. private _minPitchTan;
  35781. private _maxPitchTan;
  35782. private _boneQuat;
  35783. private _slerping;
  35784. private _transformYawPitch;
  35785. private _transformYawPitchInv;
  35786. private _firstFrameSkipped;
  35787. private _yawRange;
  35788. private _fowardAxis;
  35789. /**
  35790. * Gets or sets the minimum yaw angle that the bone can look to
  35791. */
  35792. minYaw: number;
  35793. /**
  35794. * Gets or sets the maximum yaw angle that the bone can look to
  35795. */
  35796. maxYaw: number;
  35797. /**
  35798. * Gets or sets the minimum pitch angle that the bone can look to
  35799. */
  35800. minPitch: number;
  35801. /**
  35802. * Gets or sets the maximum pitch angle that the bone can look to
  35803. */
  35804. maxPitch: number;
  35805. /**
  35806. * Create a BoneLookController
  35807. * @param mesh the mesh that the bone belongs to
  35808. * @param bone the bone that will be looking to the target
  35809. * @param target the target Vector3 to look at
  35810. * @param options optional settings:
  35811. * * maxYaw: the maximum angle the bone will yaw to
  35812. * * minYaw: the minimum angle the bone will yaw to
  35813. * * maxPitch: the maximum angle the bone will pitch to
  35814. * * minPitch: the minimum angle the bone will yaw to
  35815. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35816. * * upAxis: the up axis of the coordinate system
  35817. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35818. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35819. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35820. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35821. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35822. * * adjustRoll: used to make an adjustment to the roll of the bone
  35823. **/
  35824. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35825. maxYaw?: number;
  35826. minYaw?: number;
  35827. maxPitch?: number;
  35828. minPitch?: number;
  35829. slerpAmount?: number;
  35830. upAxis?: Vector3;
  35831. upAxisSpace?: Space;
  35832. yawAxis?: Vector3;
  35833. pitchAxis?: Vector3;
  35834. adjustYaw?: number;
  35835. adjustPitch?: number;
  35836. adjustRoll?: number;
  35837. });
  35838. /**
  35839. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35840. */
  35841. update(): void;
  35842. private _getAngleDiff;
  35843. private _getAngleBetween;
  35844. private _isAngleBetween;
  35845. }
  35846. }
  35847. declare module BABYLON {
  35848. /**
  35849. * Manage the gamepad inputs to control an arc rotate camera.
  35850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35851. */
  35852. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35853. /**
  35854. * Defines the camera the input is attached to.
  35855. */
  35856. camera: ArcRotateCamera;
  35857. /**
  35858. * Defines the gamepad the input is gathering event from.
  35859. */
  35860. gamepad: Nullable<Gamepad>;
  35861. /**
  35862. * Defines the gamepad rotation sensiblity.
  35863. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35864. */
  35865. gamepadRotationSensibility: number;
  35866. /**
  35867. * Defines the gamepad move sensiblity.
  35868. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35869. */
  35870. gamepadMoveSensibility: number;
  35871. private _onGamepadConnectedObserver;
  35872. private _onGamepadDisconnectedObserver;
  35873. /**
  35874. * Attach the input controls to a specific dom element to get the input from.
  35875. * @param element Defines the element the controls should be listened from
  35876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35877. */
  35878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35879. /**
  35880. * Detach the current controls from the specified dom element.
  35881. * @param element Defines the element to stop listening the inputs from
  35882. */
  35883. detachControl(element: Nullable<HTMLElement>): void;
  35884. /**
  35885. * Update the current camera state depending on the inputs that have been used this frame.
  35886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35887. */
  35888. checkInputs(): void;
  35889. /**
  35890. * Gets the class name of the current intput.
  35891. * @returns the class name
  35892. */
  35893. getClassName(): string;
  35894. /**
  35895. * Get the friendly name associated with the input class.
  35896. * @returns the input friendly name
  35897. */
  35898. getSimpleName(): string;
  35899. }
  35900. }
  35901. declare module BABYLON {
  35902. interface ArcRotateCameraInputsManager {
  35903. /**
  35904. * Add orientation input support to the input manager.
  35905. * @returns the current input manager
  35906. */
  35907. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35908. }
  35909. /**
  35910. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35912. */
  35913. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35914. /**
  35915. * Defines the camera the input is attached to.
  35916. */
  35917. camera: ArcRotateCamera;
  35918. /**
  35919. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35920. */
  35921. alphaCorrection: number;
  35922. /**
  35923. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35924. */
  35925. gammaCorrection: number;
  35926. private _alpha;
  35927. private _gamma;
  35928. private _dirty;
  35929. private _deviceOrientationHandler;
  35930. /**
  35931. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35932. */
  35933. constructor();
  35934. /**
  35935. * Attach the input controls to a specific dom element to get the input from.
  35936. * @param element Defines the element the controls should be listened from
  35937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35938. */
  35939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35940. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35941. /**
  35942. * Update the current camera state depending on the inputs that have been used this frame.
  35943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35944. */
  35945. checkInputs(): void;
  35946. /**
  35947. * Detach the current controls from the specified dom element.
  35948. * @param element Defines the element to stop listening the inputs from
  35949. */
  35950. detachControl(element: Nullable<HTMLElement>): void;
  35951. /**
  35952. * Gets the class name of the current intput.
  35953. * @returns the class name
  35954. */
  35955. getClassName(): string;
  35956. /**
  35957. * Get the friendly name associated with the input class.
  35958. * @returns the input friendly name
  35959. */
  35960. getSimpleName(): string;
  35961. }
  35962. }
  35963. declare module BABYLON {
  35964. /**
  35965. * Listen to mouse events to control the camera.
  35966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35967. */
  35968. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35969. /**
  35970. * Defines the camera the input is attached to.
  35971. */
  35972. camera: FlyCamera;
  35973. /**
  35974. * Defines if touch is enabled. (Default is true.)
  35975. */
  35976. touchEnabled: boolean;
  35977. /**
  35978. * Defines the buttons associated with the input to handle camera rotation.
  35979. */
  35980. buttons: number[];
  35981. /**
  35982. * Assign buttons for Yaw control.
  35983. */
  35984. buttonsYaw: number[];
  35985. /**
  35986. * Assign buttons for Pitch control.
  35987. */
  35988. buttonsPitch: number[];
  35989. /**
  35990. * Assign buttons for Roll control.
  35991. */
  35992. buttonsRoll: number[];
  35993. /**
  35994. * Detect if any button is being pressed while mouse is moved.
  35995. * -1 = Mouse locked.
  35996. * 0 = Left button.
  35997. * 1 = Middle Button.
  35998. * 2 = Right Button.
  35999. */
  36000. activeButton: number;
  36001. /**
  36002. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36003. * Higher values reduce its sensitivity.
  36004. */
  36005. angularSensibility: number;
  36006. private _mousemoveCallback;
  36007. private _observer;
  36008. private _rollObserver;
  36009. private previousPosition;
  36010. private noPreventDefault;
  36011. private element;
  36012. /**
  36013. * Listen to mouse events to control the camera.
  36014. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36016. */
  36017. constructor(touchEnabled?: boolean);
  36018. /**
  36019. * Attach the mouse control to the HTML DOM element.
  36020. * @param element Defines the element that listens to the input events.
  36021. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36022. */
  36023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36024. /**
  36025. * Detach the current controls from the specified dom element.
  36026. * @param element Defines the element to stop listening the inputs from
  36027. */
  36028. detachControl(element: Nullable<HTMLElement>): void;
  36029. /**
  36030. * Gets the class name of the current input.
  36031. * @returns the class name.
  36032. */
  36033. getClassName(): string;
  36034. /**
  36035. * Get the friendly name associated with the input class.
  36036. * @returns the input's friendly name.
  36037. */
  36038. getSimpleName(): string;
  36039. private _pointerInput;
  36040. private _onMouseMove;
  36041. /**
  36042. * Rotate camera by mouse offset.
  36043. */
  36044. private rotateCamera;
  36045. }
  36046. }
  36047. declare module BABYLON {
  36048. /**
  36049. * Default Inputs manager for the FlyCamera.
  36050. * It groups all the default supported inputs for ease of use.
  36051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36052. */
  36053. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36054. /**
  36055. * Instantiates a new FlyCameraInputsManager.
  36056. * @param camera Defines the camera the inputs belong to.
  36057. */
  36058. constructor(camera: FlyCamera);
  36059. /**
  36060. * Add keyboard input support to the input manager.
  36061. * @returns the new FlyCameraKeyboardMoveInput().
  36062. */
  36063. addKeyboard(): FlyCameraInputsManager;
  36064. /**
  36065. * Add mouse input support to the input manager.
  36066. * @param touchEnabled Enable touch screen support.
  36067. * @returns the new FlyCameraMouseInput().
  36068. */
  36069. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36070. }
  36071. }
  36072. declare module BABYLON {
  36073. /**
  36074. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36075. * such as in a 3D Space Shooter or a Flight Simulator.
  36076. */
  36077. export class FlyCamera extends TargetCamera {
  36078. /**
  36079. * Define the collision ellipsoid of the camera.
  36080. * This is helpful for simulating a camera body, like a player's body.
  36081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36082. */
  36083. ellipsoid: Vector3;
  36084. /**
  36085. * Define an offset for the position of the ellipsoid around the camera.
  36086. * This can be helpful if the camera is attached away from the player's body center,
  36087. * such as at its head.
  36088. */
  36089. ellipsoidOffset: Vector3;
  36090. /**
  36091. * Enable or disable collisions of the camera with the rest of the scene objects.
  36092. */
  36093. checkCollisions: boolean;
  36094. /**
  36095. * Enable or disable gravity on the camera.
  36096. */
  36097. applyGravity: boolean;
  36098. /**
  36099. * Define the current direction the camera is moving to.
  36100. */
  36101. cameraDirection: Vector3;
  36102. /**
  36103. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36104. * This overrides and empties cameraRotation.
  36105. */
  36106. rotationQuaternion: Quaternion;
  36107. /**
  36108. * Track Roll to maintain the wanted Rolling when looking around.
  36109. */ private _trackRoll: number;
  36110. /**
  36111. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36112. */
  36113. rollCorrect: number;
  36114. /**
  36115. * Mimic a banked turn, Rolling the camera when Yawing.
  36116. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36117. */
  36118. bankedTurn: boolean;
  36119. /**
  36120. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36121. */
  36122. bankedTurnLimit: number;
  36123. /**
  36124. * Value of 0 disables the banked Roll.
  36125. * Value of 1 is equal to the Yaw angle in radians.
  36126. */
  36127. bankedTurnMultiplier: number;
  36128. /**
  36129. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36130. */
  36131. inputs: FlyCameraInputsManager;
  36132. /**
  36133. * Gets the input sensibility for mouse input.
  36134. * Higher values reduce sensitivity.
  36135. */
  36136. /**
  36137. * Sets the input sensibility for a mouse input.
  36138. * Higher values reduce sensitivity.
  36139. */
  36140. angularSensibility: number;
  36141. /**
  36142. * Get the keys for camera movement forward.
  36143. */
  36144. /**
  36145. * Set the keys for camera movement forward.
  36146. */
  36147. keysForward: number[];
  36148. /**
  36149. * Get the keys for camera movement backward.
  36150. */
  36151. keysBackward: number[];
  36152. /**
  36153. * Get the keys for camera movement up.
  36154. */
  36155. /**
  36156. * Set the keys for camera movement up.
  36157. */
  36158. keysUp: number[];
  36159. /**
  36160. * Get the keys for camera movement down.
  36161. */
  36162. /**
  36163. * Set the keys for camera movement down.
  36164. */
  36165. keysDown: number[];
  36166. /**
  36167. * Get the keys for camera movement left.
  36168. */
  36169. /**
  36170. * Set the keys for camera movement left.
  36171. */
  36172. keysLeft: number[];
  36173. /**
  36174. * Set the keys for camera movement right.
  36175. */
  36176. /**
  36177. * Set the keys for camera movement right.
  36178. */
  36179. keysRight: number[];
  36180. /**
  36181. * Event raised when the camera collides with a mesh in the scene.
  36182. */
  36183. onCollide: (collidedMesh: AbstractMesh) => void;
  36184. private _collider;
  36185. private _needMoveForGravity;
  36186. private _oldPosition;
  36187. private _diffPosition;
  36188. private _newPosition;
  36189. /** @hidden */ private _localDirection: Vector3;
  36190. /** @hidden */ private _transformedDirection: Vector3;
  36191. /**
  36192. * Instantiates a FlyCamera.
  36193. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36194. * such as in a 3D Space Shooter or a Flight Simulator.
  36195. * @param name Define the name of the camera in the scene.
  36196. * @param position Define the starting position of the camera in the scene.
  36197. * @param scene Define the scene the camera belongs to.
  36198. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36199. */
  36200. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36201. /**
  36202. * Attach a control to the HTML DOM element.
  36203. * @param element Defines the element that listens to the input events.
  36204. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36205. */
  36206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36207. /**
  36208. * Detach a control from the HTML DOM element.
  36209. * The camera will stop reacting to that input.
  36210. * @param element Defines the element that listens to the input events.
  36211. */
  36212. detachControl(element: HTMLElement): void;
  36213. private _collisionMask;
  36214. /**
  36215. * Get the mask that the camera ignores in collision events.
  36216. */
  36217. /**
  36218. * Set the mask that the camera ignores in collision events.
  36219. */
  36220. collisionMask: number;
  36221. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36222. /** @hidden */
  36223. private _onCollisionPositionChange;
  36224. /** @hidden */ private _checkInputs(): void;
  36225. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36226. /** @hidden */ private _updatePosition(): void;
  36227. /**
  36228. * Restore the Roll to its target value at the rate specified.
  36229. * @param rate - Higher means slower restoring.
  36230. * @hidden
  36231. */
  36232. restoreRoll(rate: number): void;
  36233. /**
  36234. * Destroy the camera and release the current resources held by it.
  36235. */
  36236. dispose(): void;
  36237. /**
  36238. * Get the current object class name.
  36239. * @returns the class name.
  36240. */
  36241. getClassName(): string;
  36242. }
  36243. }
  36244. declare module BABYLON {
  36245. /**
  36246. * Listen to keyboard events to control the camera.
  36247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36248. */
  36249. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36250. /**
  36251. * Defines the camera the input is attached to.
  36252. */
  36253. camera: FlyCamera;
  36254. /**
  36255. * The list of keyboard keys used to control the forward move of the camera.
  36256. */
  36257. keysForward: number[];
  36258. /**
  36259. * The list of keyboard keys used to control the backward move of the camera.
  36260. */
  36261. keysBackward: number[];
  36262. /**
  36263. * The list of keyboard keys used to control the forward move of the camera.
  36264. */
  36265. keysUp: number[];
  36266. /**
  36267. * The list of keyboard keys used to control the backward move of the camera.
  36268. */
  36269. keysDown: number[];
  36270. /**
  36271. * The list of keyboard keys used to control the right strafe move of the camera.
  36272. */
  36273. keysRight: number[];
  36274. /**
  36275. * The list of keyboard keys used to control the left strafe move of the camera.
  36276. */
  36277. keysLeft: number[];
  36278. private _keys;
  36279. private _onCanvasBlurObserver;
  36280. private _onKeyboardObserver;
  36281. private _engine;
  36282. private _scene;
  36283. /**
  36284. * Attach the input controls to a specific dom element to get the input from.
  36285. * @param element Defines the element the controls should be listened from
  36286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36287. */
  36288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36289. /**
  36290. * Detach the current controls from the specified dom element.
  36291. * @param element Defines the element to stop listening the inputs from
  36292. */
  36293. detachControl(element: Nullable<HTMLElement>): void;
  36294. /**
  36295. * Gets the class name of the current intput.
  36296. * @returns the class name
  36297. */
  36298. getClassName(): string;
  36299. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36300. /**
  36301. * Get the friendly name associated with the input class.
  36302. * @returns the input friendly name
  36303. */
  36304. getSimpleName(): string;
  36305. /**
  36306. * Update the current camera state depending on the inputs that have been used this frame.
  36307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36308. */
  36309. checkInputs(): void;
  36310. }
  36311. }
  36312. declare module BABYLON {
  36313. /**
  36314. * Manage the mouse wheel inputs to control a follow camera.
  36315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36316. */
  36317. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36318. /**
  36319. * Defines the camera the input is attached to.
  36320. */
  36321. camera: FollowCamera;
  36322. /**
  36323. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36324. */
  36325. axisControlRadius: boolean;
  36326. /**
  36327. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36328. */
  36329. axisControlHeight: boolean;
  36330. /**
  36331. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36332. */
  36333. axisControlRotation: boolean;
  36334. /**
  36335. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36336. * relation to mouseWheel events.
  36337. */
  36338. wheelPrecision: number;
  36339. /**
  36340. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36341. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36342. */
  36343. wheelDeltaPercentage: number;
  36344. private _wheel;
  36345. private _observer;
  36346. /**
  36347. * Attach the input controls to a specific dom element to get the input from.
  36348. * @param element Defines the element the controls should be listened from
  36349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36350. */
  36351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36352. /**
  36353. * Detach the current controls from the specified dom element.
  36354. * @param element Defines the element to stop listening the inputs from
  36355. */
  36356. detachControl(element: Nullable<HTMLElement>): void;
  36357. /**
  36358. * Gets the class name of the current intput.
  36359. * @returns the class name
  36360. */
  36361. getClassName(): string;
  36362. /**
  36363. * Get the friendly name associated with the input class.
  36364. * @returns the input friendly name
  36365. */
  36366. getSimpleName(): string;
  36367. }
  36368. }
  36369. declare module BABYLON {
  36370. /**
  36371. * Manage the pointers inputs to control an follow camera.
  36372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36373. */
  36374. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36375. /**
  36376. * Defines the camera the input is attached to.
  36377. */
  36378. camera: FollowCamera;
  36379. /**
  36380. * Gets the class name of the current input.
  36381. * @returns the class name
  36382. */
  36383. getClassName(): string;
  36384. /**
  36385. * Defines the pointer angular sensibility along the X axis or how fast is
  36386. * the camera rotating.
  36387. * A negative number will reverse the axis direction.
  36388. */
  36389. angularSensibilityX: number;
  36390. /**
  36391. * Defines the pointer angular sensibility along the Y axis or how fast is
  36392. * the camera rotating.
  36393. * A negative number will reverse the axis direction.
  36394. */
  36395. angularSensibilityY: number;
  36396. /**
  36397. * Defines the pointer pinch precision or how fast is the camera zooming.
  36398. * A negative number will reverse the axis direction.
  36399. */
  36400. pinchPrecision: number;
  36401. /**
  36402. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36403. * from 0.
  36404. * It defines the percentage of current camera.radius to use as delta when
  36405. * pinch zoom is used.
  36406. */
  36407. pinchDeltaPercentage: number;
  36408. /**
  36409. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36410. */
  36411. axisXControlRadius: boolean;
  36412. /**
  36413. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36414. */
  36415. axisXControlHeight: boolean;
  36416. /**
  36417. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36418. */
  36419. axisXControlRotation: boolean;
  36420. /**
  36421. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36422. */
  36423. axisYControlRadius: boolean;
  36424. /**
  36425. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36426. */
  36427. axisYControlHeight: boolean;
  36428. /**
  36429. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36430. */
  36431. axisYControlRotation: boolean;
  36432. /**
  36433. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36434. */
  36435. axisPinchControlRadius: boolean;
  36436. /**
  36437. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36438. */
  36439. axisPinchControlHeight: boolean;
  36440. /**
  36441. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36442. */
  36443. axisPinchControlRotation: boolean;
  36444. /**
  36445. * Log error messages if basic misconfiguration has occurred.
  36446. */
  36447. warningEnable: boolean;
  36448. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36449. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36450. private _warningCounter;
  36451. private _warning;
  36452. }
  36453. }
  36454. declare module BABYLON {
  36455. /**
  36456. * Default Inputs manager for the FollowCamera.
  36457. * It groups all the default supported inputs for ease of use.
  36458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36459. */
  36460. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36461. /**
  36462. * Instantiates a new FollowCameraInputsManager.
  36463. * @param camera Defines the camera the inputs belong to
  36464. */
  36465. constructor(camera: FollowCamera);
  36466. /**
  36467. * Add keyboard input support to the input manager.
  36468. * @returns the current input manager
  36469. */
  36470. addKeyboard(): FollowCameraInputsManager;
  36471. /**
  36472. * Add mouse wheel input support to the input manager.
  36473. * @returns the current input manager
  36474. */
  36475. addMouseWheel(): FollowCameraInputsManager;
  36476. /**
  36477. * Add pointers input support to the input manager.
  36478. * @returns the current input manager
  36479. */
  36480. addPointers(): FollowCameraInputsManager;
  36481. /**
  36482. * Add orientation input support to the input manager.
  36483. * @returns the current input manager
  36484. */
  36485. addVRDeviceOrientation(): FollowCameraInputsManager;
  36486. }
  36487. }
  36488. declare module BABYLON {
  36489. /**
  36490. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36491. * an arc rotate version arcFollowCamera are available.
  36492. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36493. */
  36494. export class FollowCamera extends TargetCamera {
  36495. /**
  36496. * Distance the follow camera should follow an object at
  36497. */
  36498. radius: number;
  36499. /**
  36500. * Minimum allowed distance of the camera to the axis of rotation
  36501. * (The camera can not get closer).
  36502. * This can help limiting how the Camera is able to move in the scene.
  36503. */
  36504. lowerRadiusLimit: Nullable<number>;
  36505. /**
  36506. * Maximum allowed distance of the camera to the axis of rotation
  36507. * (The camera can not get further).
  36508. * This can help limiting how the Camera is able to move in the scene.
  36509. */
  36510. upperRadiusLimit: Nullable<number>;
  36511. /**
  36512. * Define a rotation offset between the camera and the object it follows
  36513. */
  36514. rotationOffset: number;
  36515. /**
  36516. * Minimum allowed angle to camera position relative to target object.
  36517. * This can help limiting how the Camera is able to move in the scene.
  36518. */
  36519. lowerRotationOffsetLimit: Nullable<number>;
  36520. /**
  36521. * Maximum allowed angle to camera position relative to target object.
  36522. * This can help limiting how the Camera is able to move in the scene.
  36523. */
  36524. upperRotationOffsetLimit: Nullable<number>;
  36525. /**
  36526. * Define a height offset between the camera and the object it follows.
  36527. * It can help following an object from the top (like a car chaing a plane)
  36528. */
  36529. heightOffset: number;
  36530. /**
  36531. * Minimum allowed height of camera position relative to target object.
  36532. * This can help limiting how the Camera is able to move in the scene.
  36533. */
  36534. lowerHeightOffsetLimit: Nullable<number>;
  36535. /**
  36536. * Maximum allowed height of camera position relative to target object.
  36537. * This can help limiting how the Camera is able to move in the scene.
  36538. */
  36539. upperHeightOffsetLimit: Nullable<number>;
  36540. /**
  36541. * Define how fast the camera can accelerate to follow it s target.
  36542. */
  36543. cameraAcceleration: number;
  36544. /**
  36545. * Define the speed limit of the camera following an object.
  36546. */
  36547. maxCameraSpeed: number;
  36548. /**
  36549. * Define the target of the camera.
  36550. */
  36551. lockedTarget: Nullable<AbstractMesh>;
  36552. /**
  36553. * Defines the input associated with the camera.
  36554. */
  36555. inputs: FollowCameraInputsManager;
  36556. /**
  36557. * Instantiates the follow camera.
  36558. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36559. * @param name Define the name of the camera in the scene
  36560. * @param position Define the position of the camera
  36561. * @param scene Define the scene the camera belong to
  36562. * @param lockedTarget Define the target of the camera
  36563. */
  36564. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36565. private _follow;
  36566. /**
  36567. * Attached controls to the current camera.
  36568. * @param element Defines the element the controls should be listened from
  36569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36570. */
  36571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36572. /**
  36573. * Detach the current controls from the camera.
  36574. * The camera will stop reacting to inputs.
  36575. * @param element Defines the element to stop listening the inputs from
  36576. */
  36577. detachControl(element: HTMLElement): void;
  36578. /** @hidden */ private _checkInputs(): void;
  36579. private _checkLimits;
  36580. /**
  36581. * Gets the camera class name.
  36582. * @returns the class name
  36583. */
  36584. getClassName(): string;
  36585. }
  36586. /**
  36587. * Arc Rotate version of the follow camera.
  36588. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36589. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36590. */
  36591. export class ArcFollowCamera extends TargetCamera {
  36592. /** The longitudinal angle of the camera */
  36593. alpha: number;
  36594. /** The latitudinal angle of the camera */
  36595. beta: number;
  36596. /** The radius of the camera from its target */
  36597. radius: number;
  36598. /** Define the camera target (the messh it should follow) */
  36599. target: Nullable<AbstractMesh>;
  36600. private _cartesianCoordinates;
  36601. /**
  36602. * Instantiates a new ArcFollowCamera
  36603. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36604. * @param name Define the name of the camera
  36605. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36606. * @param beta Define the rotation angle of the camera around the elevation axis
  36607. * @param radius Define the radius of the camera from its target point
  36608. * @param target Define the target of the camera
  36609. * @param scene Define the scene the camera belongs to
  36610. */
  36611. constructor(name: string,
  36612. /** The longitudinal angle of the camera */
  36613. alpha: number,
  36614. /** The latitudinal angle of the camera */
  36615. beta: number,
  36616. /** The radius of the camera from its target */
  36617. radius: number,
  36618. /** Define the camera target (the messh it should follow) */
  36619. target: Nullable<AbstractMesh>, scene: Scene);
  36620. private _follow;
  36621. /** @hidden */ private _checkInputs(): void;
  36622. /**
  36623. * Returns the class name of the object.
  36624. * It is mostly used internally for serialization purposes.
  36625. */
  36626. getClassName(): string;
  36627. }
  36628. }
  36629. declare module BABYLON {
  36630. /**
  36631. * Manage the keyboard inputs to control the movement of a follow camera.
  36632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36633. */
  36634. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36635. /**
  36636. * Defines the camera the input is attached to.
  36637. */
  36638. camera: FollowCamera;
  36639. /**
  36640. * Defines the list of key codes associated with the up action (increase heightOffset)
  36641. */
  36642. keysHeightOffsetIncr: number[];
  36643. /**
  36644. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36645. */
  36646. keysHeightOffsetDecr: number[];
  36647. /**
  36648. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36649. */
  36650. keysHeightOffsetModifierAlt: boolean;
  36651. /**
  36652. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36653. */
  36654. keysHeightOffsetModifierCtrl: boolean;
  36655. /**
  36656. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36657. */
  36658. keysHeightOffsetModifierShift: boolean;
  36659. /**
  36660. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36661. */
  36662. keysRotationOffsetIncr: number[];
  36663. /**
  36664. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36665. */
  36666. keysRotationOffsetDecr: number[];
  36667. /**
  36668. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36669. */
  36670. keysRotationOffsetModifierAlt: boolean;
  36671. /**
  36672. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36673. */
  36674. keysRotationOffsetModifierCtrl: boolean;
  36675. /**
  36676. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36677. */
  36678. keysRotationOffsetModifierShift: boolean;
  36679. /**
  36680. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36681. */
  36682. keysRadiusIncr: number[];
  36683. /**
  36684. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36685. */
  36686. keysRadiusDecr: number[];
  36687. /**
  36688. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36689. */
  36690. keysRadiusModifierAlt: boolean;
  36691. /**
  36692. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36693. */
  36694. keysRadiusModifierCtrl: boolean;
  36695. /**
  36696. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36697. */
  36698. keysRadiusModifierShift: boolean;
  36699. /**
  36700. * Defines the rate of change of heightOffset.
  36701. */
  36702. heightSensibility: number;
  36703. /**
  36704. * Defines the rate of change of rotationOffset.
  36705. */
  36706. rotationSensibility: number;
  36707. /**
  36708. * Defines the rate of change of radius.
  36709. */
  36710. radiusSensibility: number;
  36711. private _keys;
  36712. private _ctrlPressed;
  36713. private _altPressed;
  36714. private _shiftPressed;
  36715. private _onCanvasBlurObserver;
  36716. private _onKeyboardObserver;
  36717. private _engine;
  36718. private _scene;
  36719. /**
  36720. * Attach the input controls to a specific dom element to get the input from.
  36721. * @param element Defines the element the controls should be listened from
  36722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36723. */
  36724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36725. /**
  36726. * Detach the current controls from the specified dom element.
  36727. * @param element Defines the element to stop listening the inputs from
  36728. */
  36729. detachControl(element: Nullable<HTMLElement>): void;
  36730. /**
  36731. * Update the current camera state depending on the inputs that have been used this frame.
  36732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36733. */
  36734. checkInputs(): void;
  36735. /**
  36736. * Gets the class name of the current input.
  36737. * @returns the class name
  36738. */
  36739. getClassName(): string;
  36740. /**
  36741. * Get the friendly name associated with the input class.
  36742. * @returns the input friendly name
  36743. */
  36744. getSimpleName(): string;
  36745. /**
  36746. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36747. * allow modification of the heightOffset value.
  36748. */
  36749. private _modifierHeightOffset;
  36750. /**
  36751. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36752. * allow modification of the rotationOffset value.
  36753. */
  36754. private _modifierRotationOffset;
  36755. /**
  36756. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36757. * allow modification of the radius value.
  36758. */
  36759. private _modifierRadius;
  36760. }
  36761. }
  36762. declare module BABYLON {
  36763. interface FreeCameraInputsManager {
  36764. /**
  36765. * @hidden
  36766. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36767. /**
  36768. * Add orientation input support to the input manager.
  36769. * @returns the current input manager
  36770. */
  36771. addDeviceOrientation(): FreeCameraInputsManager;
  36772. }
  36773. /**
  36774. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36775. * Screen rotation is taken into account.
  36776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36777. */
  36778. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36779. private _camera;
  36780. private _screenOrientationAngle;
  36781. private _constantTranform;
  36782. private _screenQuaternion;
  36783. private _alpha;
  36784. private _beta;
  36785. private _gamma;
  36786. /**
  36787. * Can be used to detect if a device orientation sensor is availible on a device
  36788. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  36789. * @returns a promise that will resolve on orientation change
  36790. */
  36791. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  36792. /**
  36793. * @hidden
  36794. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  36795. /**
  36796. * Instantiates a new input
  36797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36798. */
  36799. constructor();
  36800. /**
  36801. * Define the camera controlled by the input.
  36802. */
  36803. camera: FreeCamera;
  36804. /**
  36805. * Attach the input controls to a specific dom element to get the input from.
  36806. * @param element Defines the element the controls should be listened from
  36807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36808. */
  36809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36810. private _orientationChanged;
  36811. private _deviceOrientation;
  36812. /**
  36813. * Detach the current controls from the specified dom element.
  36814. * @param element Defines the element to stop listening the inputs from
  36815. */
  36816. detachControl(element: Nullable<HTMLElement>): void;
  36817. /**
  36818. * Update the current camera state depending on the inputs that have been used this frame.
  36819. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36820. */
  36821. checkInputs(): void;
  36822. /**
  36823. * Gets the class name of the current intput.
  36824. * @returns the class name
  36825. */
  36826. getClassName(): string;
  36827. /**
  36828. * Get the friendly name associated with the input class.
  36829. * @returns the input friendly name
  36830. */
  36831. getSimpleName(): string;
  36832. }
  36833. }
  36834. declare module BABYLON {
  36835. /**
  36836. * Manage the gamepad inputs to control a free camera.
  36837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36838. */
  36839. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36840. /**
  36841. * Define the camera the input is attached to.
  36842. */
  36843. camera: FreeCamera;
  36844. /**
  36845. * Define the Gamepad controlling the input
  36846. */
  36847. gamepad: Nullable<Gamepad>;
  36848. /**
  36849. * Defines the gamepad rotation sensiblity.
  36850. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36851. */
  36852. gamepadAngularSensibility: number;
  36853. /**
  36854. * Defines the gamepad move sensiblity.
  36855. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36856. */
  36857. gamepadMoveSensibility: number;
  36858. private _onGamepadConnectedObserver;
  36859. private _onGamepadDisconnectedObserver;
  36860. private _cameraTransform;
  36861. private _deltaTransform;
  36862. private _vector3;
  36863. private _vector2;
  36864. /**
  36865. * Attach the input controls to a specific dom element to get the input from.
  36866. * @param element Defines the element the controls should be listened from
  36867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36868. */
  36869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36870. /**
  36871. * Detach the current controls from the specified dom element.
  36872. * @param element Defines the element to stop listening the inputs from
  36873. */
  36874. detachControl(element: Nullable<HTMLElement>): void;
  36875. /**
  36876. * Update the current camera state depending on the inputs that have been used this frame.
  36877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36878. */
  36879. checkInputs(): void;
  36880. /**
  36881. * Gets the class name of the current intput.
  36882. * @returns the class name
  36883. */
  36884. getClassName(): string;
  36885. /**
  36886. * Get the friendly name associated with the input class.
  36887. * @returns the input friendly name
  36888. */
  36889. getSimpleName(): string;
  36890. }
  36891. }
  36892. declare module BABYLON {
  36893. /**
  36894. * Defines the potential axis of a Joystick
  36895. */
  36896. export enum JoystickAxis {
  36897. /** X axis */
  36898. X = 0,
  36899. /** Y axis */
  36900. Y = 1,
  36901. /** Z axis */
  36902. Z = 2
  36903. }
  36904. /**
  36905. * Class used to define virtual joystick (used in touch mode)
  36906. */
  36907. export class VirtualJoystick {
  36908. /**
  36909. * Gets or sets a boolean indicating that left and right values must be inverted
  36910. */
  36911. reverseLeftRight: boolean;
  36912. /**
  36913. * Gets or sets a boolean indicating that up and down values must be inverted
  36914. */
  36915. reverseUpDown: boolean;
  36916. /**
  36917. * Gets the offset value for the position (ie. the change of the position value)
  36918. */
  36919. deltaPosition: Vector3;
  36920. /**
  36921. * Gets a boolean indicating if the virtual joystick was pressed
  36922. */
  36923. pressed: boolean;
  36924. /**
  36925. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36926. */
  36927. static Canvas: Nullable<HTMLCanvasElement>;
  36928. private static _globalJoystickIndex;
  36929. private static vjCanvasContext;
  36930. private static vjCanvasWidth;
  36931. private static vjCanvasHeight;
  36932. private static halfWidth;
  36933. private _action;
  36934. private _axisTargetedByLeftAndRight;
  36935. private _axisTargetedByUpAndDown;
  36936. private _joystickSensibility;
  36937. private _inversedSensibility;
  36938. private _joystickPointerID;
  36939. private _joystickColor;
  36940. private _joystickPointerPos;
  36941. private _joystickPreviousPointerPos;
  36942. private _joystickPointerStartPos;
  36943. private _deltaJoystickVector;
  36944. private _leftJoystick;
  36945. private _touches;
  36946. private _onPointerDownHandlerRef;
  36947. private _onPointerMoveHandlerRef;
  36948. private _onPointerUpHandlerRef;
  36949. private _onResize;
  36950. /**
  36951. * Creates a new virtual joystick
  36952. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36953. */
  36954. constructor(leftJoystick?: boolean);
  36955. /**
  36956. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36957. * @param newJoystickSensibility defines the new sensibility
  36958. */
  36959. setJoystickSensibility(newJoystickSensibility: number): void;
  36960. private _onPointerDown;
  36961. private _onPointerMove;
  36962. private _onPointerUp;
  36963. /**
  36964. * Change the color of the virtual joystick
  36965. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36966. */
  36967. setJoystickColor(newColor: string): void;
  36968. /**
  36969. * Defines a callback to call when the joystick is touched
  36970. * @param action defines the callback
  36971. */
  36972. setActionOnTouch(action: () => any): void;
  36973. /**
  36974. * Defines which axis you'd like to control for left & right
  36975. * @param axis defines the axis to use
  36976. */
  36977. setAxisForLeftRight(axis: JoystickAxis): void;
  36978. /**
  36979. * Defines which axis you'd like to control for up & down
  36980. * @param axis defines the axis to use
  36981. */
  36982. setAxisForUpDown(axis: JoystickAxis): void;
  36983. private _drawVirtualJoystick;
  36984. /**
  36985. * Release internal HTML canvas
  36986. */
  36987. releaseCanvas(): void;
  36988. }
  36989. }
  36990. declare module BABYLON {
  36991. interface FreeCameraInputsManager {
  36992. /**
  36993. * Add virtual joystick input support to the input manager.
  36994. * @returns the current input manager
  36995. */
  36996. addVirtualJoystick(): FreeCameraInputsManager;
  36997. }
  36998. /**
  36999. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37001. */
  37002. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37003. /**
  37004. * Defines the camera the input is attached to.
  37005. */
  37006. camera: FreeCamera;
  37007. private _leftjoystick;
  37008. private _rightjoystick;
  37009. /**
  37010. * Gets the left stick of the virtual joystick.
  37011. * @returns The virtual Joystick
  37012. */
  37013. getLeftJoystick(): VirtualJoystick;
  37014. /**
  37015. * Gets the right stick of the virtual joystick.
  37016. * @returns The virtual Joystick
  37017. */
  37018. getRightJoystick(): VirtualJoystick;
  37019. /**
  37020. * Update the current camera state depending on the inputs that have been used this frame.
  37021. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37022. */
  37023. checkInputs(): void;
  37024. /**
  37025. * Attach the input controls to a specific dom element to get the input from.
  37026. * @param element Defines the element the controls should be listened from
  37027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37028. */
  37029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37030. /**
  37031. * Detach the current controls from the specified dom element.
  37032. * @param element Defines the element to stop listening the inputs from
  37033. */
  37034. detachControl(element: Nullable<HTMLElement>): void;
  37035. /**
  37036. * Gets the class name of the current intput.
  37037. * @returns the class name
  37038. */
  37039. getClassName(): string;
  37040. /**
  37041. * Get the friendly name associated with the input class.
  37042. * @returns the input friendly name
  37043. */
  37044. getSimpleName(): string;
  37045. }
  37046. }
  37047. declare module BABYLON {
  37048. /**
  37049. * This represents a FPS type of camera controlled by touch.
  37050. * This is like a universal camera minus the Gamepad controls.
  37051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37052. */
  37053. export class TouchCamera extends FreeCamera {
  37054. /**
  37055. * Defines the touch sensibility for rotation.
  37056. * The higher the faster.
  37057. */
  37058. touchAngularSensibility: number;
  37059. /**
  37060. * Defines the touch sensibility for move.
  37061. * The higher the faster.
  37062. */
  37063. touchMoveSensibility: number;
  37064. /**
  37065. * Instantiates a new touch camera.
  37066. * This represents a FPS type of camera controlled by touch.
  37067. * This is like a universal camera minus the Gamepad controls.
  37068. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37069. * @param name Define the name of the camera in the scene
  37070. * @param position Define the start position of the camera in the scene
  37071. * @param scene Define the scene the camera belongs to
  37072. */
  37073. constructor(name: string, position: Vector3, scene: Scene);
  37074. /**
  37075. * Gets the current object class name.
  37076. * @return the class name
  37077. */
  37078. getClassName(): string;
  37079. /** @hidden */ private _setupInputs(): void;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. /**
  37084. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37085. * being tilted forward or back and left or right.
  37086. */
  37087. export class DeviceOrientationCamera extends FreeCamera {
  37088. private _initialQuaternion;
  37089. private _quaternionCache;
  37090. private _tmpDragQuaternion;
  37091. /**
  37092. * Creates a new device orientation camera
  37093. * @param name The name of the camera
  37094. * @param position The start position camera
  37095. * @param scene The scene the camera belongs to
  37096. */
  37097. constructor(name: string, position: Vector3, scene: Scene);
  37098. /**
  37099. * @hidden
  37100. * Disabled pointer input on first orientation sensor update (Default: true)
  37101. */ private _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37102. private _dragFactor;
  37103. /**
  37104. * Enabled turning on the y axis when the orientation sensor is active
  37105. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37106. */
  37107. enableHorizontalDragging(dragFactor?: number): void;
  37108. /**
  37109. * Gets the current instance class name ("DeviceOrientationCamera").
  37110. * This helps avoiding instanceof at run time.
  37111. * @returns the class name
  37112. */
  37113. getClassName(): string;
  37114. /**
  37115. * @hidden
  37116. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37117. */ private _checkInputs(): void;
  37118. /**
  37119. * Reset the camera to its default orientation on the specified axis only.
  37120. * @param axis The axis to reset
  37121. */
  37122. resetToCurrentRotation(axis?: Axis): void;
  37123. }
  37124. }
  37125. declare module BABYLON {
  37126. /**
  37127. * Defines supported buttons for XBox360 compatible gamepads
  37128. */
  37129. export enum Xbox360Button {
  37130. /** A */
  37131. A = 0,
  37132. /** B */
  37133. B = 1,
  37134. /** X */
  37135. X = 2,
  37136. /** Y */
  37137. Y = 3,
  37138. /** Start */
  37139. Start = 4,
  37140. /** Back */
  37141. Back = 5,
  37142. /** Left button */
  37143. LB = 6,
  37144. /** Right button */
  37145. RB = 7,
  37146. /** Left stick */
  37147. LeftStick = 8,
  37148. /** Right stick */
  37149. RightStick = 9
  37150. }
  37151. /** Defines values for XBox360 DPad */
  37152. export enum Xbox360Dpad {
  37153. /** Up */
  37154. Up = 0,
  37155. /** Down */
  37156. Down = 1,
  37157. /** Left */
  37158. Left = 2,
  37159. /** Right */
  37160. Right = 3
  37161. }
  37162. /**
  37163. * Defines a XBox360 gamepad
  37164. */
  37165. export class Xbox360Pad extends Gamepad {
  37166. private _leftTrigger;
  37167. private _rightTrigger;
  37168. private _onlefttriggerchanged;
  37169. private _onrighttriggerchanged;
  37170. private _onbuttondown;
  37171. private _onbuttonup;
  37172. private _ondpaddown;
  37173. private _ondpadup;
  37174. /** Observable raised when a button is pressed */
  37175. onButtonDownObservable: Observable<Xbox360Button>;
  37176. /** Observable raised when a button is released */
  37177. onButtonUpObservable: Observable<Xbox360Button>;
  37178. /** Observable raised when a pad is pressed */
  37179. onPadDownObservable: Observable<Xbox360Dpad>;
  37180. /** Observable raised when a pad is released */
  37181. onPadUpObservable: Observable<Xbox360Dpad>;
  37182. private _buttonA;
  37183. private _buttonB;
  37184. private _buttonX;
  37185. private _buttonY;
  37186. private _buttonBack;
  37187. private _buttonStart;
  37188. private _buttonLB;
  37189. private _buttonRB;
  37190. private _buttonLeftStick;
  37191. private _buttonRightStick;
  37192. private _dPadUp;
  37193. private _dPadDown;
  37194. private _dPadLeft;
  37195. private _dPadRight;
  37196. private _isXboxOnePad;
  37197. /**
  37198. * Creates a new XBox360 gamepad object
  37199. * @param id defines the id of this gamepad
  37200. * @param index defines its index
  37201. * @param gamepad defines the internal HTML gamepad object
  37202. * @param xboxOne defines if it is a XBox One gamepad
  37203. */
  37204. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37205. /**
  37206. * Defines the callback to call when left trigger is pressed
  37207. * @param callback defines the callback to use
  37208. */
  37209. onlefttriggerchanged(callback: (value: number) => void): void;
  37210. /**
  37211. * Defines the callback to call when right trigger is pressed
  37212. * @param callback defines the callback to use
  37213. */
  37214. onrighttriggerchanged(callback: (value: number) => void): void;
  37215. /**
  37216. * Gets the left trigger value
  37217. */
  37218. /**
  37219. * Sets the left trigger value
  37220. */
  37221. leftTrigger: number;
  37222. /**
  37223. * Gets the right trigger value
  37224. */
  37225. /**
  37226. * Sets the right trigger value
  37227. */
  37228. rightTrigger: number;
  37229. /**
  37230. * Defines the callback to call when a button is pressed
  37231. * @param callback defines the callback to use
  37232. */
  37233. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37234. /**
  37235. * Defines the callback to call when a button is released
  37236. * @param callback defines the callback to use
  37237. */
  37238. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37239. /**
  37240. * Defines the callback to call when a pad is pressed
  37241. * @param callback defines the callback to use
  37242. */
  37243. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37244. /**
  37245. * Defines the callback to call when a pad is released
  37246. * @param callback defines the callback to use
  37247. */
  37248. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37249. private _setButtonValue;
  37250. private _setDPadValue;
  37251. /**
  37252. * Gets the value of the `A` button
  37253. */
  37254. /**
  37255. * Sets the value of the `A` button
  37256. */
  37257. buttonA: number;
  37258. /**
  37259. * Gets the value of the `B` button
  37260. */
  37261. /**
  37262. * Sets the value of the `B` button
  37263. */
  37264. buttonB: number;
  37265. /**
  37266. * Gets the value of the `X` button
  37267. */
  37268. /**
  37269. * Sets the value of the `X` button
  37270. */
  37271. buttonX: number;
  37272. /**
  37273. * Gets the value of the `Y` button
  37274. */
  37275. /**
  37276. * Sets the value of the `Y` button
  37277. */
  37278. buttonY: number;
  37279. /**
  37280. * Gets the value of the `Start` button
  37281. */
  37282. /**
  37283. * Sets the value of the `Start` button
  37284. */
  37285. buttonStart: number;
  37286. /**
  37287. * Gets the value of the `Back` button
  37288. */
  37289. /**
  37290. * Sets the value of the `Back` button
  37291. */
  37292. buttonBack: number;
  37293. /**
  37294. * Gets the value of the `Left` button
  37295. */
  37296. /**
  37297. * Sets the value of the `Left` button
  37298. */
  37299. buttonLB: number;
  37300. /**
  37301. * Gets the value of the `Right` button
  37302. */
  37303. /**
  37304. * Sets the value of the `Right` button
  37305. */
  37306. buttonRB: number;
  37307. /**
  37308. * Gets the value of the Left joystick
  37309. */
  37310. /**
  37311. * Sets the value of the Left joystick
  37312. */
  37313. buttonLeftStick: number;
  37314. /**
  37315. * Gets the value of the Right joystick
  37316. */
  37317. /**
  37318. * Sets the value of the Right joystick
  37319. */
  37320. buttonRightStick: number;
  37321. /**
  37322. * Gets the value of D-pad up
  37323. */
  37324. /**
  37325. * Sets the value of D-pad up
  37326. */
  37327. dPadUp: number;
  37328. /**
  37329. * Gets the value of D-pad down
  37330. */
  37331. /**
  37332. * Sets the value of D-pad down
  37333. */
  37334. dPadDown: number;
  37335. /**
  37336. * Gets the value of D-pad left
  37337. */
  37338. /**
  37339. * Sets the value of D-pad left
  37340. */
  37341. dPadLeft: number;
  37342. /**
  37343. * Gets the value of D-pad right
  37344. */
  37345. /**
  37346. * Sets the value of D-pad right
  37347. */
  37348. dPadRight: number;
  37349. /**
  37350. * Force the gamepad to synchronize with device values
  37351. */
  37352. update(): void;
  37353. /**
  37354. * Disposes the gamepad
  37355. */
  37356. dispose(): void;
  37357. }
  37358. }
  37359. declare module BABYLON {
  37360. /**
  37361. * Manager for handling gamepads
  37362. */
  37363. export class GamepadManager {
  37364. private _scene?;
  37365. private _babylonGamepads;
  37366. private _oneGamepadConnected;
  37367. /** @hidden */ private _isMonitoring: boolean;
  37368. private _gamepadEventSupported;
  37369. private _gamepadSupport;
  37370. /**
  37371. * observable to be triggered when the gamepad controller has been connected
  37372. */
  37373. onGamepadConnectedObservable: Observable<Gamepad>;
  37374. /**
  37375. * observable to be triggered when the gamepad controller has been disconnected
  37376. */
  37377. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37378. private _onGamepadConnectedEvent;
  37379. private _onGamepadDisconnectedEvent;
  37380. /**
  37381. * Initializes the gamepad manager
  37382. * @param _scene BabylonJS scene
  37383. */
  37384. constructor(_scene?: Scene | undefined);
  37385. /**
  37386. * The gamepads in the game pad manager
  37387. */
  37388. readonly gamepads: Gamepad[];
  37389. /**
  37390. * Get the gamepad controllers based on type
  37391. * @param type The type of gamepad controller
  37392. * @returns Nullable gamepad
  37393. */
  37394. getGamepadByType(type?: number): Nullable<Gamepad>;
  37395. /**
  37396. * Disposes the gamepad manager
  37397. */
  37398. dispose(): void;
  37399. private _addNewGamepad;
  37400. private _startMonitoringGamepads;
  37401. private _stopMonitoringGamepads;
  37402. /** @hidden */ private _checkGamepadsStatus(): void;
  37403. private _updateGamepadObjects;
  37404. }
  37405. }
  37406. declare module BABYLON {
  37407. interface Scene {
  37408. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  37409. /**
  37410. * Gets the gamepad manager associated with the scene
  37411. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37412. */
  37413. gamepadManager: GamepadManager;
  37414. }
  37415. /**
  37416. * Interface representing a free camera inputs manager
  37417. */
  37418. interface FreeCameraInputsManager {
  37419. /**
  37420. * Adds gamepad input support to the FreeCameraInputsManager.
  37421. * @returns the FreeCameraInputsManager
  37422. */
  37423. addGamepad(): FreeCameraInputsManager;
  37424. }
  37425. /**
  37426. * Interface representing an arc rotate camera inputs manager
  37427. */
  37428. interface ArcRotateCameraInputsManager {
  37429. /**
  37430. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37431. * @returns the camera inputs manager
  37432. */
  37433. addGamepad(): ArcRotateCameraInputsManager;
  37434. }
  37435. /**
  37436. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37437. */
  37438. export class GamepadSystemSceneComponent implements ISceneComponent {
  37439. /**
  37440. * The component name helpfull to identify the component in the list of scene components.
  37441. */
  37442. readonly name: string;
  37443. /**
  37444. * The scene the component belongs to.
  37445. */
  37446. scene: Scene;
  37447. /**
  37448. * Creates a new instance of the component for the given scene
  37449. * @param scene Defines the scene to register the component in
  37450. */
  37451. constructor(scene: Scene);
  37452. /**
  37453. * Registers the component in a given scene
  37454. */
  37455. register(): void;
  37456. /**
  37457. * Rebuilds the elements related to this component in case of
  37458. * context lost for instance.
  37459. */
  37460. rebuild(): void;
  37461. /**
  37462. * Disposes the component and the associated ressources
  37463. */
  37464. dispose(): void;
  37465. private _beforeCameraUpdate;
  37466. }
  37467. }
  37468. declare module BABYLON {
  37469. /**
  37470. * 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,
  37471. * which still works and will still be found in many Playgrounds.
  37472. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37473. */
  37474. export class UniversalCamera extends TouchCamera {
  37475. /**
  37476. * Defines the gamepad rotation sensiblity.
  37477. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37478. */
  37479. gamepadAngularSensibility: number;
  37480. /**
  37481. * Defines the gamepad move sensiblity.
  37482. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37483. */
  37484. gamepadMoveSensibility: number;
  37485. /**
  37486. * 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,
  37487. * which still works and will still be found in many Playgrounds.
  37488. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37489. * @param name Define the name of the camera in the scene
  37490. * @param position Define the start position of the camera in the scene
  37491. * @param scene Define the scene the camera belongs to
  37492. */
  37493. constructor(name: string, position: Vector3, scene: Scene);
  37494. /**
  37495. * Gets the current object class name.
  37496. * @return the class name
  37497. */
  37498. getClassName(): string;
  37499. }
  37500. }
  37501. declare module BABYLON {
  37502. /**
  37503. * This represents a FPS type of camera. This is only here for back compat purpose.
  37504. * Please use the UniversalCamera instead as both are identical.
  37505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37506. */
  37507. export class GamepadCamera extends UniversalCamera {
  37508. /**
  37509. * Instantiates a new Gamepad Camera
  37510. * This represents a FPS type of camera. This is only here for back compat purpose.
  37511. * Please use the UniversalCamera instead as both are identical.
  37512. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37513. * @param name Define the name of the camera in the scene
  37514. * @param position Define the start position of the camera in the scene
  37515. * @param scene Define the scene the camera belongs to
  37516. */
  37517. constructor(name: string, position: Vector3, scene: Scene);
  37518. /**
  37519. * Gets the current object class name.
  37520. * @return the class name
  37521. */
  37522. getClassName(): string;
  37523. }
  37524. }
  37525. declare module BABYLON {
  37526. /** @hidden */
  37527. export var passPixelShader: {
  37528. name: string;
  37529. shader: string;
  37530. };
  37531. }
  37532. declare module BABYLON {
  37533. /** @hidden */
  37534. export var passCubePixelShader: {
  37535. name: string;
  37536. shader: string;
  37537. };
  37538. }
  37539. declare module BABYLON {
  37540. /**
  37541. * PassPostProcess which produces an output the same as it's input
  37542. */
  37543. export class PassPostProcess extends PostProcess {
  37544. /**
  37545. * Creates the PassPostProcess
  37546. * @param name The name of the effect.
  37547. * @param options The required width/height ratio to downsize to before computing the render pass.
  37548. * @param camera The camera to apply the render pass to.
  37549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37550. * @param engine The engine which the post process will be applied. (default: current engine)
  37551. * @param reusable If the post process can be reused on the same frame. (default: false)
  37552. * @param textureType The type of texture to be used when performing the post processing.
  37553. * @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)
  37554. */
  37555. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37556. }
  37557. /**
  37558. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37559. */
  37560. export class PassCubePostProcess extends PostProcess {
  37561. private _face;
  37562. /**
  37563. * Gets or sets the cube face to display.
  37564. * * 0 is +X
  37565. * * 1 is -X
  37566. * * 2 is +Y
  37567. * * 3 is -Y
  37568. * * 4 is +Z
  37569. * * 5 is -Z
  37570. */
  37571. face: number;
  37572. /**
  37573. * Creates the PassCubePostProcess
  37574. * @param name The name of the effect.
  37575. * @param options The required width/height ratio to downsize to before computing the render pass.
  37576. * @param camera The camera to apply the render pass to.
  37577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37578. * @param engine The engine which the post process will be applied. (default: current engine)
  37579. * @param reusable If the post process can be reused on the same frame. (default: false)
  37580. * @param textureType The type of texture to be used when performing the post processing.
  37581. * @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)
  37582. */
  37583. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37584. }
  37585. }
  37586. declare module BABYLON {
  37587. /** @hidden */
  37588. export var anaglyphPixelShader: {
  37589. name: string;
  37590. shader: string;
  37591. };
  37592. }
  37593. declare module BABYLON {
  37594. /**
  37595. * Postprocess used to generate anaglyphic rendering
  37596. */
  37597. export class AnaglyphPostProcess extends PostProcess {
  37598. private _passedProcess;
  37599. /**
  37600. * Creates a new AnaglyphPostProcess
  37601. * @param name defines postprocess name
  37602. * @param options defines creation options or target ratio scale
  37603. * @param rigCameras defines cameras using this postprocess
  37604. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37605. * @param engine defines hosting engine
  37606. * @param reusable defines if the postprocess will be reused multiple times per frame
  37607. */
  37608. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37609. }
  37610. }
  37611. declare module BABYLON {
  37612. /**
  37613. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37614. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37615. */
  37616. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37617. /**
  37618. * Creates a new AnaglyphArcRotateCamera
  37619. * @param name defines camera name
  37620. * @param alpha defines alpha angle (in radians)
  37621. * @param beta defines beta angle (in radians)
  37622. * @param radius defines radius
  37623. * @param target defines camera target
  37624. * @param interaxialDistance defines distance between each color axis
  37625. * @param scene defines the hosting scene
  37626. */
  37627. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37628. /**
  37629. * Gets camera class name
  37630. * @returns AnaglyphArcRotateCamera
  37631. */
  37632. getClassName(): string;
  37633. }
  37634. }
  37635. declare module BABYLON {
  37636. /**
  37637. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37638. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37639. */
  37640. export class AnaglyphFreeCamera extends FreeCamera {
  37641. /**
  37642. * Creates a new AnaglyphFreeCamera
  37643. * @param name defines camera name
  37644. * @param position defines initial position
  37645. * @param interaxialDistance defines distance between each color axis
  37646. * @param scene defines the hosting scene
  37647. */
  37648. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37649. /**
  37650. * Gets camera class name
  37651. * @returns AnaglyphFreeCamera
  37652. */
  37653. getClassName(): string;
  37654. }
  37655. }
  37656. declare module BABYLON {
  37657. /**
  37658. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37659. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37660. */
  37661. export class AnaglyphGamepadCamera extends GamepadCamera {
  37662. /**
  37663. * Creates a new AnaglyphGamepadCamera
  37664. * @param name defines camera name
  37665. * @param position defines initial position
  37666. * @param interaxialDistance defines distance between each color axis
  37667. * @param scene defines the hosting scene
  37668. */
  37669. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37670. /**
  37671. * Gets camera class name
  37672. * @returns AnaglyphGamepadCamera
  37673. */
  37674. getClassName(): string;
  37675. }
  37676. }
  37677. declare module BABYLON {
  37678. /**
  37679. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37680. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37681. */
  37682. export class AnaglyphUniversalCamera extends UniversalCamera {
  37683. /**
  37684. * Creates a new AnaglyphUniversalCamera
  37685. * @param name defines camera name
  37686. * @param position defines initial position
  37687. * @param interaxialDistance defines distance between each color axis
  37688. * @param scene defines the hosting scene
  37689. */
  37690. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37691. /**
  37692. * Gets camera class name
  37693. * @returns AnaglyphUniversalCamera
  37694. */
  37695. getClassName(): string;
  37696. }
  37697. }
  37698. declare module BABYLON {
  37699. /** @hidden */
  37700. export var stereoscopicInterlacePixelShader: {
  37701. name: string;
  37702. shader: string;
  37703. };
  37704. }
  37705. declare module BABYLON {
  37706. /**
  37707. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37708. */
  37709. export class StereoscopicInterlacePostProcess extends PostProcess {
  37710. private _stepSize;
  37711. private _passedProcess;
  37712. /**
  37713. * Initializes a StereoscopicInterlacePostProcess
  37714. * @param name The name of the effect.
  37715. * @param rigCameras The rig cameras to be appled to the post process
  37716. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37718. * @param engine The engine which the post process will be applied. (default: current engine)
  37719. * @param reusable If the post process can be reused on the same frame. (default: false)
  37720. */
  37721. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37722. }
  37723. }
  37724. declare module BABYLON {
  37725. /**
  37726. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37727. * @see http://doc.babylonjs.com/features/cameras
  37728. */
  37729. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37730. /**
  37731. * Creates a new StereoscopicArcRotateCamera
  37732. * @param name defines camera name
  37733. * @param alpha defines alpha angle (in radians)
  37734. * @param beta defines beta angle (in radians)
  37735. * @param radius defines radius
  37736. * @param target defines camera target
  37737. * @param interaxialDistance defines distance between each color axis
  37738. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37739. * @param scene defines the hosting scene
  37740. */
  37741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37742. /**
  37743. * Gets camera class name
  37744. * @returns StereoscopicArcRotateCamera
  37745. */
  37746. getClassName(): string;
  37747. }
  37748. }
  37749. declare module BABYLON {
  37750. /**
  37751. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37752. * @see http://doc.babylonjs.com/features/cameras
  37753. */
  37754. export class StereoscopicFreeCamera extends FreeCamera {
  37755. /**
  37756. * Creates a new StereoscopicFreeCamera
  37757. * @param name defines camera name
  37758. * @param position defines initial position
  37759. * @param interaxialDistance defines distance between each color axis
  37760. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37761. * @param scene defines the hosting scene
  37762. */
  37763. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37764. /**
  37765. * Gets camera class name
  37766. * @returns StereoscopicFreeCamera
  37767. */
  37768. getClassName(): string;
  37769. }
  37770. }
  37771. declare module BABYLON {
  37772. /**
  37773. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37774. * @see http://doc.babylonjs.com/features/cameras
  37775. */
  37776. export class StereoscopicGamepadCamera extends GamepadCamera {
  37777. /**
  37778. * Creates a new StereoscopicGamepadCamera
  37779. * @param name defines camera name
  37780. * @param position defines initial position
  37781. * @param interaxialDistance defines distance between each color axis
  37782. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37783. * @param scene defines the hosting scene
  37784. */
  37785. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37786. /**
  37787. * Gets camera class name
  37788. * @returns StereoscopicGamepadCamera
  37789. */
  37790. getClassName(): string;
  37791. }
  37792. }
  37793. declare module BABYLON {
  37794. /**
  37795. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37796. * @see http://doc.babylonjs.com/features/cameras
  37797. */
  37798. export class StereoscopicUniversalCamera extends UniversalCamera {
  37799. /**
  37800. * Creates a new StereoscopicUniversalCamera
  37801. * @param name defines camera name
  37802. * @param position defines initial position
  37803. * @param interaxialDistance defines distance between each color axis
  37804. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37805. * @param scene defines the hosting scene
  37806. */
  37807. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37808. /**
  37809. * Gets camera class name
  37810. * @returns StereoscopicUniversalCamera
  37811. */
  37812. getClassName(): string;
  37813. }
  37814. }
  37815. declare module BABYLON {
  37816. /**
  37817. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37818. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37819. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37820. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37821. */
  37822. export class VirtualJoysticksCamera extends FreeCamera {
  37823. /**
  37824. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37825. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37826. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37827. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37828. * @param name Define the name of the camera in the scene
  37829. * @param position Define the start position of the camera in the scene
  37830. * @param scene Define the scene the camera belongs to
  37831. */
  37832. constructor(name: string, position: Vector3, scene: Scene);
  37833. /**
  37834. * Gets the current object class name.
  37835. * @return the class name
  37836. */
  37837. getClassName(): string;
  37838. }
  37839. }
  37840. declare module BABYLON {
  37841. /**
  37842. * This represents all the required metrics to create a VR camera.
  37843. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37844. */
  37845. export class VRCameraMetrics {
  37846. /**
  37847. * Define the horizontal resolution off the screen.
  37848. */
  37849. hResolution: number;
  37850. /**
  37851. * Define the vertical resolution off the screen.
  37852. */
  37853. vResolution: number;
  37854. /**
  37855. * Define the horizontal screen size.
  37856. */
  37857. hScreenSize: number;
  37858. /**
  37859. * Define the vertical screen size.
  37860. */
  37861. vScreenSize: number;
  37862. /**
  37863. * Define the vertical screen center position.
  37864. */
  37865. vScreenCenter: number;
  37866. /**
  37867. * Define the distance of the eyes to the screen.
  37868. */
  37869. eyeToScreenDistance: number;
  37870. /**
  37871. * Define the distance between both lenses
  37872. */
  37873. lensSeparationDistance: number;
  37874. /**
  37875. * Define the distance between both viewer's eyes.
  37876. */
  37877. interpupillaryDistance: number;
  37878. /**
  37879. * Define the distortion factor of the VR postprocess.
  37880. * Please, touch with care.
  37881. */
  37882. distortionK: number[];
  37883. /**
  37884. * Define the chromatic aberration correction factors for the VR post process.
  37885. */
  37886. chromaAbCorrection: number[];
  37887. /**
  37888. * Define the scale factor of the post process.
  37889. * The smaller the better but the slower.
  37890. */
  37891. postProcessScaleFactor: number;
  37892. /**
  37893. * Define an offset for the lens center.
  37894. */
  37895. lensCenterOffset: number;
  37896. /**
  37897. * Define if the current vr camera should compensate the distortion of the lense or not.
  37898. */
  37899. compensateDistortion: boolean;
  37900. /**
  37901. * Defines if multiview should be enabled when rendering (Default: false)
  37902. */
  37903. multiviewEnabled: boolean;
  37904. /**
  37905. * Gets the rendering aspect ratio based on the provided resolutions.
  37906. */
  37907. readonly aspectRatio: number;
  37908. /**
  37909. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37910. */
  37911. readonly aspectRatioFov: number;
  37912. /**
  37913. * @hidden
  37914. */
  37915. readonly leftHMatrix: Matrix;
  37916. /**
  37917. * @hidden
  37918. */
  37919. readonly rightHMatrix: Matrix;
  37920. /**
  37921. * @hidden
  37922. */
  37923. readonly leftPreViewMatrix: Matrix;
  37924. /**
  37925. * @hidden
  37926. */
  37927. readonly rightPreViewMatrix: Matrix;
  37928. /**
  37929. * Get the default VRMetrics based on the most generic setup.
  37930. * @returns the default vr metrics
  37931. */
  37932. static GetDefault(): VRCameraMetrics;
  37933. }
  37934. }
  37935. declare module BABYLON {
  37936. /** @hidden */
  37937. export var vrDistortionCorrectionPixelShader: {
  37938. name: string;
  37939. shader: string;
  37940. };
  37941. }
  37942. declare module BABYLON {
  37943. /**
  37944. * VRDistortionCorrectionPostProcess used for mobile VR
  37945. */
  37946. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37947. private _isRightEye;
  37948. private _distortionFactors;
  37949. private _postProcessScaleFactor;
  37950. private _lensCenterOffset;
  37951. private _scaleIn;
  37952. private _scaleFactor;
  37953. private _lensCenter;
  37954. /**
  37955. * Initializes the VRDistortionCorrectionPostProcess
  37956. * @param name The name of the effect.
  37957. * @param camera The camera to apply the render pass to.
  37958. * @param isRightEye If this is for the right eye distortion
  37959. * @param vrMetrics All the required metrics for the VR camera
  37960. */
  37961. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37962. }
  37963. }
  37964. declare module BABYLON {
  37965. /**
  37966. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37967. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37968. */
  37969. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37970. /**
  37971. * Creates a new VRDeviceOrientationArcRotateCamera
  37972. * @param name defines camera name
  37973. * @param alpha defines the camera rotation along the logitudinal axis
  37974. * @param beta defines the camera rotation along the latitudinal axis
  37975. * @param radius defines the camera distance from its target
  37976. * @param target defines the camera target
  37977. * @param scene defines the scene the camera belongs to
  37978. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37979. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37980. */
  37981. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37982. /**
  37983. * Gets camera class name
  37984. * @returns VRDeviceOrientationArcRotateCamera
  37985. */
  37986. getClassName(): string;
  37987. }
  37988. }
  37989. declare module BABYLON {
  37990. /**
  37991. * Camera used to simulate VR rendering (based on FreeCamera)
  37992. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37993. */
  37994. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37995. /**
  37996. * Creates a new VRDeviceOrientationFreeCamera
  37997. * @param name defines camera name
  37998. * @param position defines the start position of the camera
  37999. * @param scene defines the scene the camera belongs to
  38000. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38001. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38002. */
  38003. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38004. /**
  38005. * Gets camera class name
  38006. * @returns VRDeviceOrientationFreeCamera
  38007. */
  38008. getClassName(): string;
  38009. }
  38010. }
  38011. declare module BABYLON {
  38012. /**
  38013. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38014. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38015. */
  38016. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38017. /**
  38018. * Creates a new VRDeviceOrientationGamepadCamera
  38019. * @param name defines camera name
  38020. * @param position defines the start position of the camera
  38021. * @param scene defines the scene the camera belongs to
  38022. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38023. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38024. */
  38025. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38026. /**
  38027. * Gets camera class name
  38028. * @returns VRDeviceOrientationGamepadCamera
  38029. */
  38030. getClassName(): string;
  38031. }
  38032. }
  38033. declare module BABYLON {
  38034. /**
  38035. * Base class of materials working in push mode in babylon JS
  38036. * @hidden
  38037. */
  38038. export class PushMaterial extends Material {
  38039. protected _activeEffect: Effect;
  38040. protected _normalMatrix: Matrix;
  38041. /**
  38042. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38043. * This means that the material can keep using a previous shader while a new one is being compiled.
  38044. * This is mostly used when shader parallel compilation is supported (true by default)
  38045. */
  38046. allowShaderHotSwapping: boolean;
  38047. constructor(name: string, scene: Scene);
  38048. getEffect(): Effect;
  38049. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38050. /**
  38051. * Binds the given world matrix to the active effect
  38052. *
  38053. * @param world the matrix to bind
  38054. */
  38055. bindOnlyWorldMatrix(world: Matrix): void;
  38056. /**
  38057. * Binds the given normal matrix to the active effect
  38058. *
  38059. * @param normalMatrix the matrix to bind
  38060. */
  38061. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38062. bind(world: Matrix, mesh?: Mesh): void;
  38063. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38064. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38065. }
  38066. }
  38067. declare module BABYLON {
  38068. /**
  38069. * This groups all the flags used to control the materials channel.
  38070. */
  38071. export class MaterialFlags {
  38072. private static _DiffuseTextureEnabled;
  38073. /**
  38074. * Are diffuse textures enabled in the application.
  38075. */
  38076. static DiffuseTextureEnabled: boolean;
  38077. private static _AmbientTextureEnabled;
  38078. /**
  38079. * Are ambient textures enabled in the application.
  38080. */
  38081. static AmbientTextureEnabled: boolean;
  38082. private static _OpacityTextureEnabled;
  38083. /**
  38084. * Are opacity textures enabled in the application.
  38085. */
  38086. static OpacityTextureEnabled: boolean;
  38087. private static _ReflectionTextureEnabled;
  38088. /**
  38089. * Are reflection textures enabled in the application.
  38090. */
  38091. static ReflectionTextureEnabled: boolean;
  38092. private static _EmissiveTextureEnabled;
  38093. /**
  38094. * Are emissive textures enabled in the application.
  38095. */
  38096. static EmissiveTextureEnabled: boolean;
  38097. private static _SpecularTextureEnabled;
  38098. /**
  38099. * Are specular textures enabled in the application.
  38100. */
  38101. static SpecularTextureEnabled: boolean;
  38102. private static _BumpTextureEnabled;
  38103. /**
  38104. * Are bump textures enabled in the application.
  38105. */
  38106. static BumpTextureEnabled: boolean;
  38107. private static _LightmapTextureEnabled;
  38108. /**
  38109. * Are lightmap textures enabled in the application.
  38110. */
  38111. static LightmapTextureEnabled: boolean;
  38112. private static _RefractionTextureEnabled;
  38113. /**
  38114. * Are refraction textures enabled in the application.
  38115. */
  38116. static RefractionTextureEnabled: boolean;
  38117. private static _ColorGradingTextureEnabled;
  38118. /**
  38119. * Are color grading textures enabled in the application.
  38120. */
  38121. static ColorGradingTextureEnabled: boolean;
  38122. private static _FresnelEnabled;
  38123. /**
  38124. * Are fresnels enabled in the application.
  38125. */
  38126. static FresnelEnabled: boolean;
  38127. private static _ClearCoatTextureEnabled;
  38128. /**
  38129. * Are clear coat textures enabled in the application.
  38130. */
  38131. static ClearCoatTextureEnabled: boolean;
  38132. private static _ClearCoatBumpTextureEnabled;
  38133. /**
  38134. * Are clear coat bump textures enabled in the application.
  38135. */
  38136. static ClearCoatBumpTextureEnabled: boolean;
  38137. private static _ClearCoatTintTextureEnabled;
  38138. /**
  38139. * Are clear coat tint textures enabled in the application.
  38140. */
  38141. static ClearCoatTintTextureEnabled: boolean;
  38142. private static _SheenTextureEnabled;
  38143. /**
  38144. * Are sheen textures enabled in the application.
  38145. */
  38146. static SheenTextureEnabled: boolean;
  38147. private static _AnisotropicTextureEnabled;
  38148. /**
  38149. * Are anisotropic textures enabled in the application.
  38150. */
  38151. static AnisotropicTextureEnabled: boolean;
  38152. private static _ThicknessTextureEnabled;
  38153. /**
  38154. * Are thickness textures enabled in the application.
  38155. */
  38156. static ThicknessTextureEnabled: boolean;
  38157. }
  38158. }
  38159. declare module BABYLON {
  38160. /** @hidden */
  38161. export var defaultFragmentDeclaration: {
  38162. name: string;
  38163. shader: string;
  38164. };
  38165. }
  38166. declare module BABYLON {
  38167. /** @hidden */
  38168. export var defaultUboDeclaration: {
  38169. name: string;
  38170. shader: string;
  38171. };
  38172. }
  38173. declare module BABYLON {
  38174. /** @hidden */
  38175. export var lightFragmentDeclaration: {
  38176. name: string;
  38177. shader: string;
  38178. };
  38179. }
  38180. declare module BABYLON {
  38181. /** @hidden */
  38182. export var lightUboDeclaration: {
  38183. name: string;
  38184. shader: string;
  38185. };
  38186. }
  38187. declare module BABYLON {
  38188. /** @hidden */
  38189. export var lightsFragmentFunctions: {
  38190. name: string;
  38191. shader: string;
  38192. };
  38193. }
  38194. declare module BABYLON {
  38195. /** @hidden */
  38196. export var shadowsFragmentFunctions: {
  38197. name: string;
  38198. shader: string;
  38199. };
  38200. }
  38201. declare module BABYLON {
  38202. /** @hidden */
  38203. export var fresnelFunction: {
  38204. name: string;
  38205. shader: string;
  38206. };
  38207. }
  38208. declare module BABYLON {
  38209. /** @hidden */
  38210. export var reflectionFunction: {
  38211. name: string;
  38212. shader: string;
  38213. };
  38214. }
  38215. declare module BABYLON {
  38216. /** @hidden */
  38217. export var bumpFragmentFunctions: {
  38218. name: string;
  38219. shader: string;
  38220. };
  38221. }
  38222. declare module BABYLON {
  38223. /** @hidden */
  38224. export var logDepthDeclaration: {
  38225. name: string;
  38226. shader: string;
  38227. };
  38228. }
  38229. declare module BABYLON {
  38230. /** @hidden */
  38231. export var bumpFragment: {
  38232. name: string;
  38233. shader: string;
  38234. };
  38235. }
  38236. declare module BABYLON {
  38237. /** @hidden */
  38238. export var depthPrePass: {
  38239. name: string;
  38240. shader: string;
  38241. };
  38242. }
  38243. declare module BABYLON {
  38244. /** @hidden */
  38245. export var lightFragment: {
  38246. name: string;
  38247. shader: string;
  38248. };
  38249. }
  38250. declare module BABYLON {
  38251. /** @hidden */
  38252. export var logDepthFragment: {
  38253. name: string;
  38254. shader: string;
  38255. };
  38256. }
  38257. declare module BABYLON {
  38258. /** @hidden */
  38259. export var defaultPixelShader: {
  38260. name: string;
  38261. shader: string;
  38262. };
  38263. }
  38264. declare module BABYLON {
  38265. /** @hidden */
  38266. export var defaultVertexDeclaration: {
  38267. name: string;
  38268. shader: string;
  38269. };
  38270. }
  38271. declare module BABYLON {
  38272. /** @hidden */
  38273. export var bumpVertexDeclaration: {
  38274. name: string;
  38275. shader: string;
  38276. };
  38277. }
  38278. declare module BABYLON {
  38279. /** @hidden */
  38280. export var bumpVertex: {
  38281. name: string;
  38282. shader: string;
  38283. };
  38284. }
  38285. declare module BABYLON {
  38286. /** @hidden */
  38287. export var fogVertex: {
  38288. name: string;
  38289. shader: string;
  38290. };
  38291. }
  38292. declare module BABYLON {
  38293. /** @hidden */
  38294. export var shadowsVertex: {
  38295. name: string;
  38296. shader: string;
  38297. };
  38298. }
  38299. declare module BABYLON {
  38300. /** @hidden */
  38301. export var pointCloudVertex: {
  38302. name: string;
  38303. shader: string;
  38304. };
  38305. }
  38306. declare module BABYLON {
  38307. /** @hidden */
  38308. export var logDepthVertex: {
  38309. name: string;
  38310. shader: string;
  38311. };
  38312. }
  38313. declare module BABYLON {
  38314. /** @hidden */
  38315. export var defaultVertexShader: {
  38316. name: string;
  38317. shader: string;
  38318. };
  38319. }
  38320. declare module BABYLON {
  38321. /** @hidden */
  38322. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38323. MAINUV1: boolean;
  38324. MAINUV2: boolean;
  38325. DIFFUSE: boolean;
  38326. DIFFUSEDIRECTUV: number;
  38327. AMBIENT: boolean;
  38328. AMBIENTDIRECTUV: number;
  38329. OPACITY: boolean;
  38330. OPACITYDIRECTUV: number;
  38331. OPACITYRGB: boolean;
  38332. REFLECTION: boolean;
  38333. EMISSIVE: boolean;
  38334. EMISSIVEDIRECTUV: number;
  38335. SPECULAR: boolean;
  38336. SPECULARDIRECTUV: number;
  38337. BUMP: boolean;
  38338. BUMPDIRECTUV: number;
  38339. PARALLAX: boolean;
  38340. PARALLAXOCCLUSION: boolean;
  38341. SPECULAROVERALPHA: boolean;
  38342. CLIPPLANE: boolean;
  38343. CLIPPLANE2: boolean;
  38344. CLIPPLANE3: boolean;
  38345. CLIPPLANE4: boolean;
  38346. ALPHATEST: boolean;
  38347. DEPTHPREPASS: boolean;
  38348. ALPHAFROMDIFFUSE: boolean;
  38349. POINTSIZE: boolean;
  38350. FOG: boolean;
  38351. SPECULARTERM: boolean;
  38352. DIFFUSEFRESNEL: boolean;
  38353. OPACITYFRESNEL: boolean;
  38354. REFLECTIONFRESNEL: boolean;
  38355. REFRACTIONFRESNEL: boolean;
  38356. EMISSIVEFRESNEL: boolean;
  38357. FRESNEL: boolean;
  38358. NORMAL: boolean;
  38359. UV1: boolean;
  38360. UV2: boolean;
  38361. VERTEXCOLOR: boolean;
  38362. VERTEXALPHA: boolean;
  38363. NUM_BONE_INFLUENCERS: number;
  38364. BonesPerMesh: number;
  38365. BONETEXTURE: boolean;
  38366. INSTANCES: boolean;
  38367. GLOSSINESS: boolean;
  38368. ROUGHNESS: boolean;
  38369. EMISSIVEASILLUMINATION: boolean;
  38370. LINKEMISSIVEWITHDIFFUSE: boolean;
  38371. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38372. LIGHTMAP: boolean;
  38373. LIGHTMAPDIRECTUV: number;
  38374. OBJECTSPACE_NORMALMAP: boolean;
  38375. USELIGHTMAPASSHADOWMAP: boolean;
  38376. REFLECTIONMAP_3D: boolean;
  38377. REFLECTIONMAP_SPHERICAL: boolean;
  38378. REFLECTIONMAP_PLANAR: boolean;
  38379. REFLECTIONMAP_CUBIC: boolean;
  38380. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38381. REFLECTIONMAP_PROJECTION: boolean;
  38382. REFLECTIONMAP_SKYBOX: boolean;
  38383. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38384. REFLECTIONMAP_EXPLICIT: boolean;
  38385. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38386. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38387. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38388. INVERTCUBICMAP: boolean;
  38389. LOGARITHMICDEPTH: boolean;
  38390. REFRACTION: boolean;
  38391. REFRACTIONMAP_3D: boolean;
  38392. REFLECTIONOVERALPHA: boolean;
  38393. TWOSIDEDLIGHTING: boolean;
  38394. SHADOWFLOAT: boolean;
  38395. MORPHTARGETS: boolean;
  38396. MORPHTARGETS_NORMAL: boolean;
  38397. MORPHTARGETS_TANGENT: boolean;
  38398. MORPHTARGETS_UV: boolean;
  38399. NUM_MORPH_INFLUENCERS: number;
  38400. NONUNIFORMSCALING: boolean;
  38401. PREMULTIPLYALPHA: boolean;
  38402. IMAGEPROCESSING: boolean;
  38403. VIGNETTE: boolean;
  38404. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38405. VIGNETTEBLENDMODEOPAQUE: boolean;
  38406. TONEMAPPING: boolean;
  38407. TONEMAPPING_ACES: boolean;
  38408. CONTRAST: boolean;
  38409. COLORCURVES: boolean;
  38410. COLORGRADING: boolean;
  38411. COLORGRADING3D: boolean;
  38412. SAMPLER3DGREENDEPTH: boolean;
  38413. SAMPLER3DBGRMAP: boolean;
  38414. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38415. MULTIVIEW: boolean;
  38416. /**
  38417. * If the reflection texture on this material is in linear color space
  38418. * @hidden
  38419. */
  38420. IS_REFLECTION_LINEAR: boolean;
  38421. /**
  38422. * If the refraction texture on this material is in linear color space
  38423. * @hidden
  38424. */
  38425. IS_REFRACTION_LINEAR: boolean;
  38426. EXPOSURE: boolean;
  38427. constructor();
  38428. setReflectionMode(modeToEnable: string): void;
  38429. }
  38430. /**
  38431. * This is the default material used in Babylon. It is the best trade off between quality
  38432. * and performances.
  38433. * @see http://doc.babylonjs.com/babylon101/materials
  38434. */
  38435. export class StandardMaterial extends PushMaterial {
  38436. private _diffuseTexture;
  38437. /**
  38438. * The basic texture of the material as viewed under a light.
  38439. */
  38440. diffuseTexture: Nullable<BaseTexture>;
  38441. private _ambientTexture;
  38442. /**
  38443. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38444. */
  38445. ambientTexture: Nullable<BaseTexture>;
  38446. private _opacityTexture;
  38447. /**
  38448. * Define the transparency of the material from a texture.
  38449. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38450. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38451. */
  38452. opacityTexture: Nullable<BaseTexture>;
  38453. private _reflectionTexture;
  38454. /**
  38455. * Define the texture used to display the reflection.
  38456. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38457. */
  38458. reflectionTexture: Nullable<BaseTexture>;
  38459. private _emissiveTexture;
  38460. /**
  38461. * Define texture of the material as if self lit.
  38462. * This will be mixed in the final result even in the absence of light.
  38463. */
  38464. emissiveTexture: Nullable<BaseTexture>;
  38465. private _specularTexture;
  38466. /**
  38467. * Define how the color and intensity of the highlight given by the light in the material.
  38468. */
  38469. specularTexture: Nullable<BaseTexture>;
  38470. private _bumpTexture;
  38471. /**
  38472. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38473. * 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.
  38474. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38475. */
  38476. bumpTexture: Nullable<BaseTexture>;
  38477. private _lightmapTexture;
  38478. /**
  38479. * Complex lighting can be computationally expensive to compute at runtime.
  38480. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38481. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38482. */
  38483. lightmapTexture: Nullable<BaseTexture>;
  38484. private _refractionTexture;
  38485. /**
  38486. * Define the texture used to display the refraction.
  38487. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38488. */
  38489. refractionTexture: Nullable<BaseTexture>;
  38490. /**
  38491. * The color of the material lit by the environmental background lighting.
  38492. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38493. */
  38494. ambientColor: Color3;
  38495. /**
  38496. * The basic color of the material as viewed under a light.
  38497. */
  38498. diffuseColor: Color3;
  38499. /**
  38500. * Define how the color and intensity of the highlight given by the light in the material.
  38501. */
  38502. specularColor: Color3;
  38503. /**
  38504. * Define the color of the material as if self lit.
  38505. * This will be mixed in the final result even in the absence of light.
  38506. */
  38507. emissiveColor: Color3;
  38508. /**
  38509. * Defines how sharp are the highlights in the material.
  38510. * The bigger the value the sharper giving a more glossy feeling to the result.
  38511. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38512. */
  38513. specularPower: number;
  38514. private _useAlphaFromDiffuseTexture;
  38515. /**
  38516. * Does the transparency come from the diffuse texture alpha channel.
  38517. */
  38518. useAlphaFromDiffuseTexture: boolean;
  38519. private _useEmissiveAsIllumination;
  38520. /**
  38521. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38522. */
  38523. useEmissiveAsIllumination: boolean;
  38524. private _linkEmissiveWithDiffuse;
  38525. /**
  38526. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38527. * the emissive level when the final color is close to one.
  38528. */
  38529. linkEmissiveWithDiffuse: boolean;
  38530. private _useSpecularOverAlpha;
  38531. /**
  38532. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38533. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38534. */
  38535. useSpecularOverAlpha: boolean;
  38536. private _useReflectionOverAlpha;
  38537. /**
  38538. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38539. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38540. */
  38541. useReflectionOverAlpha: boolean;
  38542. private _disableLighting;
  38543. /**
  38544. * Does lights from the scene impacts this material.
  38545. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38546. */
  38547. disableLighting: boolean;
  38548. private _useObjectSpaceNormalMap;
  38549. /**
  38550. * Allows using an object space normal map (instead of tangent space).
  38551. */
  38552. useObjectSpaceNormalMap: boolean;
  38553. private _useParallax;
  38554. /**
  38555. * Is parallax enabled or not.
  38556. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38557. */
  38558. useParallax: boolean;
  38559. private _useParallaxOcclusion;
  38560. /**
  38561. * Is parallax occlusion enabled or not.
  38562. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38563. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38564. */
  38565. useParallaxOcclusion: boolean;
  38566. /**
  38567. * 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.
  38568. */
  38569. parallaxScaleBias: number;
  38570. private _roughness;
  38571. /**
  38572. * Helps to define how blurry the reflections should appears in the material.
  38573. */
  38574. roughness: number;
  38575. /**
  38576. * In case of refraction, define the value of the index of refraction.
  38577. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38578. */
  38579. indexOfRefraction: number;
  38580. /**
  38581. * Invert the refraction texture alongside the y axis.
  38582. * It can be useful with procedural textures or probe for instance.
  38583. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38584. */
  38585. invertRefractionY: boolean;
  38586. /**
  38587. * Defines the alpha limits in alpha test mode.
  38588. */
  38589. alphaCutOff: number;
  38590. private _useLightmapAsShadowmap;
  38591. /**
  38592. * In case of light mapping, define whether the map contains light or shadow informations.
  38593. */
  38594. useLightmapAsShadowmap: boolean;
  38595. private _diffuseFresnelParameters;
  38596. /**
  38597. * Define the diffuse fresnel parameters of the material.
  38598. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38599. */
  38600. diffuseFresnelParameters: FresnelParameters;
  38601. private _opacityFresnelParameters;
  38602. /**
  38603. * Define the opacity fresnel parameters of the material.
  38604. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38605. */
  38606. opacityFresnelParameters: FresnelParameters;
  38607. private _reflectionFresnelParameters;
  38608. /**
  38609. * Define the reflection fresnel parameters of the material.
  38610. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38611. */
  38612. reflectionFresnelParameters: FresnelParameters;
  38613. private _refractionFresnelParameters;
  38614. /**
  38615. * Define the refraction fresnel parameters of the material.
  38616. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38617. */
  38618. refractionFresnelParameters: FresnelParameters;
  38619. private _emissiveFresnelParameters;
  38620. /**
  38621. * Define the emissive fresnel parameters of the material.
  38622. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38623. */
  38624. emissiveFresnelParameters: FresnelParameters;
  38625. private _useReflectionFresnelFromSpecular;
  38626. /**
  38627. * If true automatically deducts the fresnels values from the material specularity.
  38628. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38629. */
  38630. useReflectionFresnelFromSpecular: boolean;
  38631. private _useGlossinessFromSpecularMapAlpha;
  38632. /**
  38633. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38634. */
  38635. useGlossinessFromSpecularMapAlpha: boolean;
  38636. private _maxSimultaneousLights;
  38637. /**
  38638. * Defines the maximum number of lights that can be used in the material
  38639. */
  38640. maxSimultaneousLights: number;
  38641. private _invertNormalMapX;
  38642. /**
  38643. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38644. */
  38645. invertNormalMapX: boolean;
  38646. private _invertNormalMapY;
  38647. /**
  38648. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38649. */
  38650. invertNormalMapY: boolean;
  38651. private _twoSidedLighting;
  38652. /**
  38653. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38654. */
  38655. twoSidedLighting: boolean;
  38656. /**
  38657. * Default configuration related to image processing available in the standard Material.
  38658. */
  38659. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38660. /**
  38661. * Gets the image processing configuration used either in this material.
  38662. */
  38663. /**
  38664. * Sets the Default image processing configuration used either in the this material.
  38665. *
  38666. * If sets to null, the scene one is in use.
  38667. */
  38668. imageProcessingConfiguration: ImageProcessingConfiguration;
  38669. /**
  38670. * Keep track of the image processing observer to allow dispose and replace.
  38671. */
  38672. private _imageProcessingObserver;
  38673. /**
  38674. * Attaches a new image processing configuration to the Standard Material.
  38675. * @param configuration
  38676. */
  38677. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38678. /**
  38679. * Gets wether the color curves effect is enabled.
  38680. */
  38681. /**
  38682. * Sets wether the color curves effect is enabled.
  38683. */
  38684. cameraColorCurvesEnabled: boolean;
  38685. /**
  38686. * Gets wether the color grading effect is enabled.
  38687. */
  38688. /**
  38689. * Gets wether the color grading effect is enabled.
  38690. */
  38691. cameraColorGradingEnabled: boolean;
  38692. /**
  38693. * Gets wether tonemapping is enabled or not.
  38694. */
  38695. /**
  38696. * Sets wether tonemapping is enabled or not
  38697. */
  38698. cameraToneMappingEnabled: boolean;
  38699. /**
  38700. * The camera exposure used on this material.
  38701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38702. * This corresponds to a photographic exposure.
  38703. */
  38704. /**
  38705. * The camera exposure used on this material.
  38706. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38707. * This corresponds to a photographic exposure.
  38708. */
  38709. cameraExposure: number;
  38710. /**
  38711. * Gets The camera contrast used on this material.
  38712. */
  38713. /**
  38714. * Sets The camera contrast used on this material.
  38715. */
  38716. cameraContrast: number;
  38717. /**
  38718. * Gets the Color Grading 2D Lookup Texture.
  38719. */
  38720. /**
  38721. * Sets the Color Grading 2D Lookup Texture.
  38722. */
  38723. cameraColorGradingTexture: Nullable<BaseTexture>;
  38724. /**
  38725. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38726. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38727. * 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;
  38728. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38729. */
  38730. /**
  38731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38733. * 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;
  38734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38735. */
  38736. cameraColorCurves: Nullable<ColorCurves>;
  38737. /**
  38738. * Custom callback helping to override the default shader used in the material.
  38739. */
  38740. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38741. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38742. protected _worldViewProjectionMatrix: Matrix;
  38743. protected _globalAmbientColor: Color3;
  38744. protected _useLogarithmicDepth: boolean;
  38745. /**
  38746. * Instantiates a new standard material.
  38747. * This is the default material used in Babylon. It is the best trade off between quality
  38748. * and performances.
  38749. * @see http://doc.babylonjs.com/babylon101/materials
  38750. * @param name Define the name of the material in the scene
  38751. * @param scene Define the scene the material belong to
  38752. */
  38753. constructor(name: string, scene: Scene);
  38754. /**
  38755. * Gets a boolean indicating that current material needs to register RTT
  38756. */
  38757. readonly hasRenderTargetTextures: boolean;
  38758. /**
  38759. * Gets the current class name of the material e.g. "StandardMaterial"
  38760. * Mainly use in serialization.
  38761. * @returns the class name
  38762. */
  38763. getClassName(): string;
  38764. /**
  38765. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38766. * You can try switching to logarithmic depth.
  38767. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38768. */
  38769. useLogarithmicDepth: boolean;
  38770. /**
  38771. * Specifies if the material will require alpha blending
  38772. * @returns a boolean specifying if alpha blending is needed
  38773. */
  38774. needAlphaBlending(): boolean;
  38775. /**
  38776. * Specifies if this material should be rendered in alpha test mode
  38777. * @returns a boolean specifying if an alpha test is needed.
  38778. */
  38779. needAlphaTesting(): boolean;
  38780. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38781. /**
  38782. * Get the texture used for alpha test purpose.
  38783. * @returns the diffuse texture in case of the standard material.
  38784. */
  38785. getAlphaTestTexture(): Nullable<BaseTexture>;
  38786. /**
  38787. * Get if the submesh is ready to be used and all its information available.
  38788. * Child classes can use it to update shaders
  38789. * @param mesh defines the mesh to check
  38790. * @param subMesh defines which submesh to check
  38791. * @param useInstances specifies that instances should be used
  38792. * @returns a boolean indicating that the submesh is ready or not
  38793. */
  38794. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38795. /**
  38796. * Builds the material UBO layouts.
  38797. * Used internally during the effect preparation.
  38798. */
  38799. buildUniformLayout(): void;
  38800. /**
  38801. * Unbinds the material from the mesh
  38802. */
  38803. unbind(): void;
  38804. /**
  38805. * Binds the submesh to this material by preparing the effect and shader to draw
  38806. * @param world defines the world transformation matrix
  38807. * @param mesh defines the mesh containing the submesh
  38808. * @param subMesh defines the submesh to bind the material to
  38809. */
  38810. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38811. /**
  38812. * Get the list of animatables in the material.
  38813. * @returns the list of animatables object used in the material
  38814. */
  38815. getAnimatables(): IAnimatable[];
  38816. /**
  38817. * Gets the active textures from the material
  38818. * @returns an array of textures
  38819. */
  38820. getActiveTextures(): BaseTexture[];
  38821. /**
  38822. * Specifies if the material uses a texture
  38823. * @param texture defines the texture to check against the material
  38824. * @returns a boolean specifying if the material uses the texture
  38825. */
  38826. hasTexture(texture: BaseTexture): boolean;
  38827. /**
  38828. * Disposes the material
  38829. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38830. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38831. */
  38832. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38833. /**
  38834. * Makes a duplicate of the material, and gives it a new name
  38835. * @param name defines the new name for the duplicated material
  38836. * @returns the cloned material
  38837. */
  38838. clone(name: string): StandardMaterial;
  38839. /**
  38840. * Serializes this material in a JSON representation
  38841. * @returns the serialized material object
  38842. */
  38843. serialize(): any;
  38844. /**
  38845. * Creates a standard material from parsed material data
  38846. * @param source defines the JSON representation of the material
  38847. * @param scene defines the hosting scene
  38848. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38849. * @returns a new standard material
  38850. */
  38851. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38852. /**
  38853. * Are diffuse textures enabled in the application.
  38854. */
  38855. static DiffuseTextureEnabled: boolean;
  38856. /**
  38857. * Are ambient textures enabled in the application.
  38858. */
  38859. static AmbientTextureEnabled: boolean;
  38860. /**
  38861. * Are opacity textures enabled in the application.
  38862. */
  38863. static OpacityTextureEnabled: boolean;
  38864. /**
  38865. * Are reflection textures enabled in the application.
  38866. */
  38867. static ReflectionTextureEnabled: boolean;
  38868. /**
  38869. * Are emissive textures enabled in the application.
  38870. */
  38871. static EmissiveTextureEnabled: boolean;
  38872. /**
  38873. * Are specular textures enabled in the application.
  38874. */
  38875. static SpecularTextureEnabled: boolean;
  38876. /**
  38877. * Are bump textures enabled in the application.
  38878. */
  38879. static BumpTextureEnabled: boolean;
  38880. /**
  38881. * Are lightmap textures enabled in the application.
  38882. */
  38883. static LightmapTextureEnabled: boolean;
  38884. /**
  38885. * Are refraction textures enabled in the application.
  38886. */
  38887. static RefractionTextureEnabled: boolean;
  38888. /**
  38889. * Are color grading textures enabled in the application.
  38890. */
  38891. static ColorGradingTextureEnabled: boolean;
  38892. /**
  38893. * Are fresnels enabled in the application.
  38894. */
  38895. static FresnelEnabled: boolean;
  38896. }
  38897. }
  38898. declare module BABYLON {
  38899. /**
  38900. * A class extending Texture allowing drawing on a texture
  38901. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38902. */
  38903. export class DynamicTexture extends Texture {
  38904. private _generateMipMaps;
  38905. private _canvas;
  38906. private _context;
  38907. private _engine;
  38908. /**
  38909. * Creates a DynamicTexture
  38910. * @param name defines the name of the texture
  38911. * @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
  38912. * @param scene defines the scene where you want the texture
  38913. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38914. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38915. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38916. */
  38917. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38918. /**
  38919. * Get the current class name of the texture useful for serialization or dynamic coding.
  38920. * @returns "DynamicTexture"
  38921. */
  38922. getClassName(): string;
  38923. /**
  38924. * Gets the current state of canRescale
  38925. */
  38926. readonly canRescale: boolean;
  38927. private _recreate;
  38928. /**
  38929. * Scales the texture
  38930. * @param ratio the scale factor to apply to both width and height
  38931. */
  38932. scale(ratio: number): void;
  38933. /**
  38934. * Resizes the texture
  38935. * @param width the new width
  38936. * @param height the new height
  38937. */
  38938. scaleTo(width: number, height: number): void;
  38939. /**
  38940. * Gets the context of the canvas used by the texture
  38941. * @returns the canvas context of the dynamic texture
  38942. */
  38943. getContext(): CanvasRenderingContext2D;
  38944. /**
  38945. * Clears the texture
  38946. */
  38947. clear(): void;
  38948. /**
  38949. * Updates the texture
  38950. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38951. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38952. */
  38953. update(invertY?: boolean, premulAlpha?: boolean): void;
  38954. /**
  38955. * Draws text onto the texture
  38956. * @param text defines the text to be drawn
  38957. * @param x defines the placement of the text from the left
  38958. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38959. * @param font defines the font to be used with font-style, font-size, font-name
  38960. * @param color defines the color used for the text
  38961. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38962. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38963. * @param update defines whether texture is immediately update (default is true)
  38964. */
  38965. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38966. /**
  38967. * Clones the texture
  38968. * @returns the clone of the texture.
  38969. */
  38970. clone(): DynamicTexture;
  38971. /**
  38972. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38973. * @returns a serialized dynamic texture object
  38974. */
  38975. serialize(): any;
  38976. /** @hidden */ private _rebuild(): void;
  38977. }
  38978. }
  38979. declare module BABYLON {
  38980. /** @hidden */
  38981. export var imageProcessingPixelShader: {
  38982. name: string;
  38983. shader: string;
  38984. };
  38985. }
  38986. declare module BABYLON {
  38987. /**
  38988. * ImageProcessingPostProcess
  38989. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38990. */
  38991. export class ImageProcessingPostProcess extends PostProcess {
  38992. /**
  38993. * Default configuration related to image processing available in the PBR Material.
  38994. */
  38995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38996. /**
  38997. * Gets the image processing configuration used either in this material.
  38998. */
  38999. /**
  39000. * Sets the Default image processing configuration used either in the this material.
  39001. *
  39002. * If sets to null, the scene one is in use.
  39003. */
  39004. imageProcessingConfiguration: ImageProcessingConfiguration;
  39005. /**
  39006. * Keep track of the image processing observer to allow dispose and replace.
  39007. */
  39008. private _imageProcessingObserver;
  39009. /**
  39010. * Attaches a new image processing configuration to the PBR Material.
  39011. * @param configuration
  39012. */
  39013. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39014. /**
  39015. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39016. */
  39017. /**
  39018. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39019. */
  39020. colorCurves: Nullable<ColorCurves>;
  39021. /**
  39022. * Gets wether the color curves effect is enabled.
  39023. */
  39024. /**
  39025. * Sets wether the color curves effect is enabled.
  39026. */
  39027. colorCurvesEnabled: boolean;
  39028. /**
  39029. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39030. */
  39031. /**
  39032. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39033. */
  39034. colorGradingTexture: Nullable<BaseTexture>;
  39035. /**
  39036. * Gets wether the color grading effect is enabled.
  39037. */
  39038. /**
  39039. * Gets wether the color grading effect is enabled.
  39040. */
  39041. colorGradingEnabled: boolean;
  39042. /**
  39043. * Gets exposure used in the effect.
  39044. */
  39045. /**
  39046. * Sets exposure used in the effect.
  39047. */
  39048. exposure: number;
  39049. /**
  39050. * Gets wether tonemapping is enabled or not.
  39051. */
  39052. /**
  39053. * Sets wether tonemapping is enabled or not
  39054. */
  39055. toneMappingEnabled: boolean;
  39056. /**
  39057. * Gets the type of tone mapping effect.
  39058. */
  39059. /**
  39060. * Sets the type of tone mapping effect.
  39061. */
  39062. toneMappingType: number;
  39063. /**
  39064. * Gets contrast used in the effect.
  39065. */
  39066. /**
  39067. * Sets contrast used in the effect.
  39068. */
  39069. contrast: number;
  39070. /**
  39071. * Gets Vignette stretch size.
  39072. */
  39073. /**
  39074. * Sets Vignette stretch size.
  39075. */
  39076. vignetteStretch: number;
  39077. /**
  39078. * Gets Vignette centre X Offset.
  39079. */
  39080. /**
  39081. * Sets Vignette centre X Offset.
  39082. */
  39083. vignetteCentreX: number;
  39084. /**
  39085. * Gets Vignette centre Y Offset.
  39086. */
  39087. /**
  39088. * Sets Vignette centre Y Offset.
  39089. */
  39090. vignetteCentreY: number;
  39091. /**
  39092. * Gets Vignette weight or intensity of the vignette effect.
  39093. */
  39094. /**
  39095. * Sets Vignette weight or intensity of the vignette effect.
  39096. */
  39097. vignetteWeight: number;
  39098. /**
  39099. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39100. * if vignetteEnabled is set to true.
  39101. */
  39102. /**
  39103. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39104. * if vignetteEnabled is set to true.
  39105. */
  39106. vignetteColor: Color4;
  39107. /**
  39108. * Gets Camera field of view used by the Vignette effect.
  39109. */
  39110. /**
  39111. * Sets Camera field of view used by the Vignette effect.
  39112. */
  39113. vignetteCameraFov: number;
  39114. /**
  39115. * Gets the vignette blend mode allowing different kind of effect.
  39116. */
  39117. /**
  39118. * Sets the vignette blend mode allowing different kind of effect.
  39119. */
  39120. vignetteBlendMode: number;
  39121. /**
  39122. * Gets wether the vignette effect is enabled.
  39123. */
  39124. /**
  39125. * Sets wether the vignette effect is enabled.
  39126. */
  39127. vignetteEnabled: boolean;
  39128. private _fromLinearSpace;
  39129. /**
  39130. * Gets wether the input of the processing is in Gamma or Linear Space.
  39131. */
  39132. /**
  39133. * Sets wether the input of the processing is in Gamma or Linear Space.
  39134. */
  39135. fromLinearSpace: boolean;
  39136. /**
  39137. * Defines cache preventing GC.
  39138. */
  39139. private _defines;
  39140. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39141. /**
  39142. * "ImageProcessingPostProcess"
  39143. * @returns "ImageProcessingPostProcess"
  39144. */
  39145. getClassName(): string;
  39146. protected _updateParameters(): void;
  39147. dispose(camera?: Camera): void;
  39148. }
  39149. }
  39150. declare module BABYLON {
  39151. /**
  39152. * Class containing static functions to help procedurally build meshes
  39153. */
  39154. export class GroundBuilder {
  39155. /**
  39156. * Creates a ground mesh
  39157. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39158. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39160. * @param name defines the name of the mesh
  39161. * @param options defines the options used to create the mesh
  39162. * @param scene defines the hosting scene
  39163. * @returns the ground mesh
  39164. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39165. */
  39166. static CreateGround(name: string, options: {
  39167. width?: number;
  39168. height?: number;
  39169. subdivisions?: number;
  39170. subdivisionsX?: number;
  39171. subdivisionsY?: number;
  39172. updatable?: boolean;
  39173. }, scene: any): Mesh;
  39174. /**
  39175. * Creates a tiled ground mesh
  39176. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39177. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39178. * * 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
  39179. * * 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
  39180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39181. * @param name defines the name of the mesh
  39182. * @param options defines the options used to create the mesh
  39183. * @param scene defines the hosting scene
  39184. * @returns the tiled ground mesh
  39185. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39186. */
  39187. static CreateTiledGround(name: string, options: {
  39188. xmin: number;
  39189. zmin: number;
  39190. xmax: number;
  39191. zmax: number;
  39192. subdivisions?: {
  39193. w: number;
  39194. h: number;
  39195. };
  39196. precision?: {
  39197. w: number;
  39198. h: number;
  39199. };
  39200. updatable?: boolean;
  39201. }, scene?: Nullable<Scene>): Mesh;
  39202. /**
  39203. * Creates a ground mesh from a height map
  39204. * * The parameter `url` sets the URL of the height map image resource.
  39205. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39206. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39207. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39208. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39209. * * 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.
  39210. * * 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).
  39211. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39213. * @param name defines the name of the mesh
  39214. * @param url defines the url to the height map
  39215. * @param options defines the options used to create the mesh
  39216. * @param scene defines the hosting scene
  39217. * @returns the ground mesh
  39218. * @see https://doc.babylonjs.com/babylon101/height_map
  39219. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39220. */
  39221. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39222. width?: number;
  39223. height?: number;
  39224. subdivisions?: number;
  39225. minHeight?: number;
  39226. maxHeight?: number;
  39227. colorFilter?: Color3;
  39228. alphaFilter?: number;
  39229. updatable?: boolean;
  39230. onReady?: (mesh: GroundMesh) => void;
  39231. }, scene?: Nullable<Scene>): GroundMesh;
  39232. }
  39233. }
  39234. declare module BABYLON {
  39235. /**
  39236. * Class containing static functions to help procedurally build meshes
  39237. */
  39238. export class TorusBuilder {
  39239. /**
  39240. * Creates a torus mesh
  39241. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39242. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39243. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39245. * * 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
  39246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39247. * @param name defines the name of the mesh
  39248. * @param options defines the options used to create the mesh
  39249. * @param scene defines the hosting scene
  39250. * @returns the torus mesh
  39251. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39252. */
  39253. static CreateTorus(name: string, options: {
  39254. diameter?: number;
  39255. thickness?: number;
  39256. tessellation?: number;
  39257. updatable?: boolean;
  39258. sideOrientation?: number;
  39259. frontUVs?: Vector4;
  39260. backUVs?: Vector4;
  39261. }, scene: any): Mesh;
  39262. }
  39263. }
  39264. declare module BABYLON {
  39265. /**
  39266. * Class containing static functions to help procedurally build meshes
  39267. */
  39268. export class CylinderBuilder {
  39269. /**
  39270. * Creates a cylinder or a cone mesh
  39271. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39272. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39273. * * 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.
  39274. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39275. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39276. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39277. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39278. * * 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).
  39279. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39280. * * 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).
  39281. * * 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
  39282. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39283. * * 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
  39284. * * 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.
  39285. * * If `enclose` is false, a ring surface is one element.
  39286. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39287. * * 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
  39288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39289. * * 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
  39290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39291. * @param name defines the name of the mesh
  39292. * @param options defines the options used to create the mesh
  39293. * @param scene defines the hosting scene
  39294. * @returns the cylinder mesh
  39295. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39296. */
  39297. static CreateCylinder(name: string, options: {
  39298. height?: number;
  39299. diameterTop?: number;
  39300. diameterBottom?: number;
  39301. diameter?: number;
  39302. tessellation?: number;
  39303. subdivisions?: number;
  39304. arc?: number;
  39305. faceColors?: Color4[];
  39306. faceUV?: Vector4[];
  39307. updatable?: boolean;
  39308. hasRings?: boolean;
  39309. enclose?: boolean;
  39310. cap?: number;
  39311. sideOrientation?: number;
  39312. frontUVs?: Vector4;
  39313. backUVs?: Vector4;
  39314. }, scene: any): Mesh;
  39315. }
  39316. }
  39317. declare module BABYLON {
  39318. /**
  39319. * Options to modify the vr teleportation behavior.
  39320. */
  39321. export interface VRTeleportationOptions {
  39322. /**
  39323. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39324. */
  39325. floorMeshName?: string;
  39326. /**
  39327. * A list of meshes to be used as the teleportation floor. (default: empty)
  39328. */
  39329. floorMeshes?: Mesh[];
  39330. }
  39331. /**
  39332. * Options to modify the vr experience helper's behavior.
  39333. */
  39334. export interface VRExperienceHelperOptions extends WebVROptions {
  39335. /**
  39336. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39337. */
  39338. createDeviceOrientationCamera?: boolean;
  39339. /**
  39340. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39341. */
  39342. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39343. /**
  39344. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39345. */
  39346. laserToggle?: boolean;
  39347. /**
  39348. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39349. */
  39350. floorMeshes?: Mesh[];
  39351. /**
  39352. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39353. */
  39354. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39355. }
  39356. /**
  39357. * Event containing information after VR has been entered
  39358. */
  39359. export class OnAfterEnteringVRObservableEvent {
  39360. /**
  39361. * If entering vr was successful
  39362. */
  39363. success: boolean;
  39364. }
  39365. /**
  39366. * Helps to quickly add VR support to an existing scene.
  39367. * See http://doc.babylonjs.com/how_to/webvr_helper
  39368. */
  39369. export class VRExperienceHelper {
  39370. /** Options to modify the vr experience helper's behavior. */
  39371. webVROptions: VRExperienceHelperOptions;
  39372. private _scene;
  39373. private _position;
  39374. private _btnVR;
  39375. private _btnVRDisplayed;
  39376. private _webVRsupported;
  39377. private _webVRready;
  39378. private _webVRrequesting;
  39379. private _webVRpresenting;
  39380. private _hasEnteredVR;
  39381. private _fullscreenVRpresenting;
  39382. private _canvas;
  39383. private _webVRCamera;
  39384. private _vrDeviceOrientationCamera;
  39385. private _deviceOrientationCamera;
  39386. private _existingCamera;
  39387. private _onKeyDown;
  39388. private _onVrDisplayPresentChange;
  39389. private _onVRDisplayChanged;
  39390. private _onVRRequestPresentStart;
  39391. private _onVRRequestPresentComplete;
  39392. /**
  39393. * Observable raised right before entering VR.
  39394. */
  39395. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39396. /**
  39397. * Observable raised when entering VR has completed.
  39398. */
  39399. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39400. /**
  39401. * Observable raised when exiting VR.
  39402. */
  39403. onExitingVRObservable: Observable<VRExperienceHelper>;
  39404. /**
  39405. * Observable raised when controller mesh is loaded.
  39406. */
  39407. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39408. /** Return this.onEnteringVRObservable
  39409. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39410. */
  39411. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39412. /** Return this.onExitingVRObservable
  39413. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39414. */
  39415. readonly onExitingVR: Observable<VRExperienceHelper>;
  39416. /** Return this.onControllerMeshLoadedObservable
  39417. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39418. */
  39419. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39420. private _rayLength;
  39421. private _useCustomVRButton;
  39422. private _teleportationRequested;
  39423. private _teleportActive;
  39424. private _floorMeshName;
  39425. private _floorMeshesCollection;
  39426. private _rotationAllowed;
  39427. private _teleportBackwardsVector;
  39428. private _teleportationTarget;
  39429. private _isDefaultTeleportationTarget;
  39430. private _postProcessMove;
  39431. private _teleportationFillColor;
  39432. private _teleportationBorderColor;
  39433. private _rotationAngle;
  39434. private _haloCenter;
  39435. private _cameraGazer;
  39436. private _padSensibilityUp;
  39437. private _padSensibilityDown;
  39438. private _leftController;
  39439. private _rightController;
  39440. /**
  39441. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39442. */
  39443. onNewMeshSelected: Observable<AbstractMesh>;
  39444. /**
  39445. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39446. */
  39447. onNewMeshPicked: Observable<PickingInfo>;
  39448. private _circleEase;
  39449. /**
  39450. * Observable raised before camera teleportation
  39451. */
  39452. onBeforeCameraTeleport: Observable<Vector3>;
  39453. /**
  39454. * Observable raised after camera teleportation
  39455. */
  39456. onAfterCameraTeleport: Observable<Vector3>;
  39457. /**
  39458. * Observable raised when current selected mesh gets unselected
  39459. */
  39460. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39461. private _raySelectionPredicate;
  39462. /**
  39463. * To be optionaly changed by user to define custom ray selection
  39464. */
  39465. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39466. /**
  39467. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39468. */
  39469. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39470. /**
  39471. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39472. */
  39473. teleportationEnabled: boolean;
  39474. private _defaultHeight;
  39475. private _teleportationInitialized;
  39476. private _interactionsEnabled;
  39477. private _interactionsRequested;
  39478. private _displayGaze;
  39479. private _displayLaserPointer;
  39480. /**
  39481. * The mesh used to display where the user is going to teleport.
  39482. */
  39483. /**
  39484. * Sets the mesh to be used to display where the user is going to teleport.
  39485. */
  39486. teleportationTarget: Mesh;
  39487. /**
  39488. * 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
  39489. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39490. * See http://doc.babylonjs.com/resources/baking_transformations
  39491. */
  39492. gazeTrackerMesh: Mesh;
  39493. /**
  39494. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39495. */
  39496. updateGazeTrackerScale: boolean;
  39497. /**
  39498. * If the gaze trackers color should be updated when selecting meshes
  39499. */
  39500. updateGazeTrackerColor: boolean;
  39501. /**
  39502. * The gaze tracking mesh corresponding to the left controller
  39503. */
  39504. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39505. /**
  39506. * The gaze tracking mesh corresponding to the right controller
  39507. */
  39508. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39509. /**
  39510. * If the ray of the gaze should be displayed.
  39511. */
  39512. /**
  39513. * Sets if the ray of the gaze should be displayed.
  39514. */
  39515. displayGaze: boolean;
  39516. /**
  39517. * If the ray of the LaserPointer should be displayed.
  39518. */
  39519. /**
  39520. * Sets if the ray of the LaserPointer should be displayed.
  39521. */
  39522. displayLaserPointer: boolean;
  39523. /**
  39524. * The deviceOrientationCamera used as the camera when not in VR.
  39525. */
  39526. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39527. /**
  39528. * Based on the current WebVR support, returns the current VR camera used.
  39529. */
  39530. readonly currentVRCamera: Nullable<Camera>;
  39531. /**
  39532. * The webVRCamera which is used when in VR.
  39533. */
  39534. readonly webVRCamera: WebVRFreeCamera;
  39535. /**
  39536. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39537. */
  39538. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39539. private readonly _teleportationRequestInitiated;
  39540. /**
  39541. * Defines wether or not Pointer lock should be requested when switching to
  39542. * full screen.
  39543. */
  39544. requestPointerLockOnFullScreen: boolean;
  39545. /**
  39546. * Instantiates a VRExperienceHelper.
  39547. * Helps to quickly add VR support to an existing scene.
  39548. * @param scene The scene the VRExperienceHelper belongs to.
  39549. * @param webVROptions Options to modify the vr experience helper's behavior.
  39550. */
  39551. constructor(scene: Scene,
  39552. /** Options to modify the vr experience helper's behavior. */
  39553. webVROptions?: VRExperienceHelperOptions);
  39554. private _onDefaultMeshLoaded;
  39555. private _onResize;
  39556. private _onFullscreenChange;
  39557. /**
  39558. * Gets a value indicating if we are currently in VR mode.
  39559. */
  39560. readonly isInVRMode: boolean;
  39561. private onVrDisplayPresentChange;
  39562. private onVRDisplayChanged;
  39563. private moveButtonToBottomRight;
  39564. private displayVRButton;
  39565. private updateButtonVisibility;
  39566. private _cachedAngularSensibility;
  39567. /**
  39568. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39569. * Otherwise, will use the fullscreen API.
  39570. */
  39571. enterVR(): void;
  39572. /**
  39573. * Attempt to exit VR, or fullscreen.
  39574. */
  39575. exitVR(): void;
  39576. /**
  39577. * The position of the vr experience helper.
  39578. */
  39579. /**
  39580. * Sets the position of the vr experience helper.
  39581. */
  39582. position: Vector3;
  39583. /**
  39584. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39585. */
  39586. enableInteractions(): void;
  39587. private readonly _noControllerIsActive;
  39588. private beforeRender;
  39589. private _isTeleportationFloor;
  39590. /**
  39591. * Adds a floor mesh to be used for teleportation.
  39592. * @param floorMesh the mesh to be used for teleportation.
  39593. */
  39594. addFloorMesh(floorMesh: Mesh): void;
  39595. /**
  39596. * Removes a floor mesh from being used for teleportation.
  39597. * @param floorMesh the mesh to be removed.
  39598. */
  39599. removeFloorMesh(floorMesh: Mesh): void;
  39600. /**
  39601. * Enables interactions and teleportation using the VR controllers and gaze.
  39602. * @param vrTeleportationOptions options to modify teleportation behavior.
  39603. */
  39604. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39605. private _onNewGamepadConnected;
  39606. private _tryEnableInteractionOnController;
  39607. private _onNewGamepadDisconnected;
  39608. private _enableInteractionOnController;
  39609. private _checkTeleportWithRay;
  39610. private _checkRotate;
  39611. private _checkTeleportBackwards;
  39612. private _enableTeleportationOnController;
  39613. private _createTeleportationCircles;
  39614. private _displayTeleportationTarget;
  39615. private _hideTeleportationTarget;
  39616. private _rotateCamera;
  39617. private _moveTeleportationSelectorTo;
  39618. private _workingVector;
  39619. private _workingQuaternion;
  39620. private _workingMatrix;
  39621. /**
  39622. * Teleports the users feet to the desired location
  39623. * @param location The location where the user's feet should be placed
  39624. */
  39625. teleportCamera(location: Vector3): void;
  39626. private _convertNormalToDirectionOfRay;
  39627. private _castRayAndSelectObject;
  39628. private _notifySelectedMeshUnselected;
  39629. /**
  39630. * Sets the color of the laser ray from the vr controllers.
  39631. * @param color new color for the ray.
  39632. */
  39633. changeLaserColor(color: Color3): void;
  39634. /**
  39635. * Sets the color of the ray from the vr headsets gaze.
  39636. * @param color new color for the ray.
  39637. */
  39638. changeGazeColor(color: Color3): void;
  39639. /**
  39640. * Exits VR and disposes of the vr experience helper
  39641. */
  39642. dispose(): void;
  39643. /**
  39644. * Gets the name of the VRExperienceHelper class
  39645. * @returns "VRExperienceHelper"
  39646. */
  39647. getClassName(): string;
  39648. }
  39649. }
  39650. declare module BABYLON {
  39651. /**
  39652. * Manages an XRSession
  39653. * @see https://doc.babylonjs.com/how_to/webxr
  39654. */
  39655. export class WebXRSessionManager implements IDisposable {
  39656. private scene;
  39657. /**
  39658. * Fires every time a new xrFrame arrives which can be used to update the camera
  39659. */
  39660. onXRFrameObservable: Observable<any>;
  39661. /**
  39662. * Fires when the xr session is ended either by the device or manually done
  39663. */
  39664. onXRSessionEnded: Observable<any>;
  39665. /** @hidden */ private _xrSession: XRSession;
  39666. /** @hidden */ private _frameOfReference: XRFrameOfReference;
  39667. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39668. /** @hidden */ private _currentXRFrame: Nullable<XRFrame>;
  39669. private _xrNavigator;
  39670. private _xrDevice;
  39671. private _tmpMatrix;
  39672. /**
  39673. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39674. * @param scene The scene which the session should be created for
  39675. */
  39676. constructor(scene: Scene);
  39677. /**
  39678. * Initializes the manager
  39679. * After initialization enterXR can be called to start an XR session
  39680. * @returns Promise which resolves after it is initialized
  39681. */
  39682. initializeAsync(): Promise<void>;
  39683. /**
  39684. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39685. * @param sessionCreationOptions xr options to create the session with
  39686. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39687. * @returns Promise which resolves after it enters XR
  39688. */
  39689. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39690. /**
  39691. * Stops the xrSession and restores the renderloop
  39692. * @returns Promise which resolves after it exits XR
  39693. */
  39694. exitXRAsync(): Promise<void>;
  39695. /**
  39696. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39697. * @param ray ray to cast into the environment
  39698. * @returns Promise which resolves with a collision point in the environment if it exists
  39699. */
  39700. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39701. /**
  39702. * Checks if a session would be supported for the creation options specified
  39703. * @param options creation options to check if they are supported
  39704. * @returns true if supported
  39705. */
  39706. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39707. /**
  39708. * @hidden
  39709. * Converts the render layer of xrSession to a render target
  39710. * @param session session to create render target for
  39711. * @param scene scene the new render target should be created for
  39712. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39713. /**
  39714. * Disposes of the session manager
  39715. */
  39716. dispose(): void;
  39717. }
  39718. }
  39719. declare module BABYLON {
  39720. /**
  39721. * WebXR Camera which holds the views for the xrSession
  39722. * @see https://doc.babylonjs.com/how_to/webxr
  39723. */
  39724. export class WebXRCamera extends FreeCamera {
  39725. private static _TmpMatrix;
  39726. /**
  39727. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39728. * @param name the name of the camera
  39729. * @param scene the scene to add the camera to
  39730. */
  39731. constructor(name: string, scene: Scene);
  39732. private _updateNumberOfRigCameras;
  39733. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  39734. /**
  39735. * Updates the cameras position from the current pose information of the XR session
  39736. * @param xrSessionManager the session containing pose information
  39737. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39738. */
  39739. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39740. }
  39741. }
  39742. declare module BABYLON {
  39743. /**
  39744. * States of the webXR experience
  39745. */
  39746. export enum WebXRState {
  39747. /**
  39748. * Transitioning to being in XR mode
  39749. */
  39750. ENTERING_XR = 0,
  39751. /**
  39752. * Transitioning to non XR mode
  39753. */
  39754. EXITING_XR = 1,
  39755. /**
  39756. * In XR mode and presenting
  39757. */
  39758. IN_XR = 2,
  39759. /**
  39760. * Not entered XR mode
  39761. */
  39762. NOT_IN_XR = 3
  39763. }
  39764. /**
  39765. * Helper class used to enable XR
  39766. * @see https://doc.babylonjs.com/how_to/webxr
  39767. */
  39768. export class WebXRExperienceHelper implements IDisposable {
  39769. private scene;
  39770. /**
  39771. * 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
  39772. */
  39773. container: AbstractMesh;
  39774. /**
  39775. * Camera used to render xr content
  39776. */
  39777. camera: WebXRCamera;
  39778. /**
  39779. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39780. */
  39781. state: WebXRState;
  39782. private _setState;
  39783. private static _TmpVector;
  39784. /**
  39785. * Fires when the state of the experience helper has changed
  39786. */
  39787. onStateChangedObservable: Observable<WebXRState>;
  39788. /** @hidden */ private _sessionManager: WebXRSessionManager;
  39789. private _nonVRCamera;
  39790. private _originalSceneAutoClear;
  39791. private _supported;
  39792. /**
  39793. * Creates the experience helper
  39794. * @param scene the scene to attach the experience helper to
  39795. * @returns a promise for the experience helper
  39796. */
  39797. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39798. /**
  39799. * Creates a WebXRExperienceHelper
  39800. * @param scene The scene the helper should be created in
  39801. */
  39802. private constructor();
  39803. /**
  39804. * Exits XR mode and returns the scene to its original state
  39805. * @returns promise that resolves after xr mode has exited
  39806. */
  39807. exitXRAsync(): Promise<void>;
  39808. /**
  39809. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39810. * @param sessionCreationOptions options for the XR session
  39811. * @param frameOfReference frame of reference of the XR session
  39812. * @returns promise that resolves after xr mode has entered
  39813. */
  39814. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39815. /**
  39816. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39817. * @param ray ray to cast into the environment
  39818. * @returns Promise which resolves with a collision point in the environment if it exists
  39819. */
  39820. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39821. /**
  39822. * Updates the global position of the camera by moving the camera's container
  39823. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39824. * @param position The desired global position of the camera
  39825. */
  39826. setPositionOfCameraUsingContainer(position: Vector3): void;
  39827. /**
  39828. * Rotates the xr camera by rotating the camera's container around the camera's position
  39829. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39830. * @param rotation the desired quaternion rotation to apply to the camera
  39831. */
  39832. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39833. /**
  39834. * Checks if the creation options are supported by the xr session
  39835. * @param options creation options
  39836. * @returns true if supported
  39837. */
  39838. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39839. /**
  39840. * Disposes of the experience helper
  39841. */
  39842. dispose(): void;
  39843. }
  39844. }
  39845. declare module BABYLON {
  39846. /**
  39847. * Button which can be used to enter a different mode of XR
  39848. */
  39849. export class WebXREnterExitUIButton {
  39850. /** button element */
  39851. element: HTMLElement;
  39852. /** XR initialization options for the button */
  39853. initializationOptions: XRSessionCreationOptions;
  39854. /**
  39855. * Creates a WebXREnterExitUIButton
  39856. * @param element button element
  39857. * @param initializationOptions XR initialization options for the button
  39858. */
  39859. constructor(
  39860. /** button element */
  39861. element: HTMLElement,
  39862. /** XR initialization options for the button */
  39863. initializationOptions: XRSessionCreationOptions);
  39864. /**
  39865. * Overwritable function which can be used to update the button's visuals when the state changes
  39866. * @param activeButton the current active button in the UI
  39867. */
  39868. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39869. }
  39870. /**
  39871. * Options to create the webXR UI
  39872. */
  39873. export class WebXREnterExitUIOptions {
  39874. /**
  39875. * Context to enter xr with
  39876. */
  39877. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39878. /**
  39879. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39880. */
  39881. customButtons?: Array<WebXREnterExitUIButton>;
  39882. }
  39883. /**
  39884. * UI to allow the user to enter/exit XR mode
  39885. */
  39886. export class WebXREnterExitUI implements IDisposable {
  39887. private scene;
  39888. private _overlay;
  39889. private _buttons;
  39890. private _activeButton;
  39891. /**
  39892. * Fired every time the active button is changed.
  39893. *
  39894. * When xr is entered via a button that launches xr that button will be the callback parameter
  39895. *
  39896. * When exiting xr the callback parameter will be null)
  39897. */
  39898. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39899. /**
  39900. * Creates UI to allow the user to enter/exit XR mode
  39901. * @param scene the scene to add the ui to
  39902. * @param helper the xr experience helper to enter/exit xr with
  39903. * @param options options to configure the UI
  39904. * @returns the created ui
  39905. */
  39906. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39907. private constructor();
  39908. private _updateButtons;
  39909. /**
  39910. * Disposes of the object
  39911. */
  39912. dispose(): void;
  39913. }
  39914. }
  39915. declare module BABYLON {
  39916. /**
  39917. * Represents an XR input
  39918. */
  39919. export class WebXRController {
  39920. /**
  39921. * 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
  39922. */
  39923. grip?: AbstractMesh;
  39924. /**
  39925. * Pointer which can be used to select objects or attach a visible laser to
  39926. */
  39927. pointer: AbstractMesh;
  39928. /**
  39929. * Creates the controller
  39930. * @see https://doc.babylonjs.com/how_to/webxr
  39931. * @param scene the scene which the controller should be associated to
  39932. */
  39933. constructor(scene: Scene);
  39934. /**
  39935. * Disposes of the object
  39936. */
  39937. dispose(): void;
  39938. }
  39939. /**
  39940. * XR input used to track XR inputs such as controllers/rays
  39941. */
  39942. export class WebXRInput implements IDisposable {
  39943. private helper;
  39944. /**
  39945. * XR controllers being tracked
  39946. */
  39947. controllers: Array<WebXRController>;
  39948. private _tmpMatrix;
  39949. private _frameObserver;
  39950. /**
  39951. * Initializes the WebXRInput
  39952. * @param helper experience helper which the input should be created for
  39953. */
  39954. constructor(helper: WebXRExperienceHelper);
  39955. /**
  39956. * Disposes of the object
  39957. */
  39958. dispose(): void;
  39959. }
  39960. }
  39961. declare module BABYLON {
  39962. /**
  39963. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39964. */
  39965. export class WebXRManagedOutputCanvas implements IDisposable {
  39966. private _canvas;
  39967. /**
  39968. * xrpresent context of the canvas which can be used to display/mirror xr content
  39969. */
  39970. canvasContext: Nullable<WebGLRenderingContext>;
  39971. /**
  39972. * Initializes the canvas to be added/removed upon entering/exiting xr
  39973. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39974. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39975. */
  39976. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39977. /**
  39978. * Disposes of the object
  39979. */
  39980. dispose(): void;
  39981. private _setManagedOutputCanvas;
  39982. private _addCanvas;
  39983. private _removeCanvas;
  39984. }
  39985. }
  39986. declare module BABYLON {
  39987. /**
  39988. * Contains an array of blocks representing the octree
  39989. */
  39990. export interface IOctreeContainer<T> {
  39991. /**
  39992. * Blocks within the octree
  39993. */
  39994. blocks: Array<OctreeBlock<T>>;
  39995. }
  39996. /**
  39997. * Class used to store a cell in an octree
  39998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39999. */
  40000. export class OctreeBlock<T> {
  40001. /**
  40002. * Gets the content of the current block
  40003. */
  40004. entries: T[];
  40005. /**
  40006. * Gets the list of block children
  40007. */
  40008. blocks: Array<OctreeBlock<T>>;
  40009. private _depth;
  40010. private _maxDepth;
  40011. private _capacity;
  40012. private _minPoint;
  40013. private _maxPoint;
  40014. private _boundingVectors;
  40015. private _creationFunc;
  40016. /**
  40017. * Creates a new block
  40018. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40019. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40020. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40021. * @param depth defines the current depth of this block in the octree
  40022. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40023. * @param creationFunc defines a callback to call when an element is added to the block
  40024. */
  40025. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40026. /**
  40027. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40028. */
  40029. readonly capacity: number;
  40030. /**
  40031. * Gets the minimum vector (in world space) of the block's bounding box
  40032. */
  40033. readonly minPoint: Vector3;
  40034. /**
  40035. * Gets the maximum vector (in world space) of the block's bounding box
  40036. */
  40037. readonly maxPoint: Vector3;
  40038. /**
  40039. * Add a new element to this block
  40040. * @param entry defines the element to add
  40041. */
  40042. addEntry(entry: T): void;
  40043. /**
  40044. * Remove an element from this block
  40045. * @param entry defines the element to remove
  40046. */
  40047. removeEntry(entry: T): void;
  40048. /**
  40049. * Add an array of elements to this block
  40050. * @param entries defines the array of elements to add
  40051. */
  40052. addEntries(entries: T[]): void;
  40053. /**
  40054. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40055. * @param frustumPlanes defines the frustum planes to test
  40056. * @param selection defines the array to store current content if selection is positive
  40057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40058. */
  40059. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40060. /**
  40061. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40062. * @param sphereCenter defines the bounding sphere center
  40063. * @param sphereRadius defines the bounding sphere radius
  40064. * @param selection defines the array to store current content if selection is positive
  40065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40066. */
  40067. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40068. /**
  40069. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40070. * @param ray defines the ray to test with
  40071. * @param selection defines the array to store current content if selection is positive
  40072. */
  40073. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40074. /**
  40075. * Subdivide the content into child blocks (this block will then be empty)
  40076. */
  40077. createInnerBlocks(): void;
  40078. /**
  40079. * @hidden
  40080. */ 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;
  40081. }
  40082. }
  40083. declare module BABYLON {
  40084. /**
  40085. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40086. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40087. */
  40088. export class Octree<T> {
  40089. /** 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.) */
  40090. maxDepth: number;
  40091. /**
  40092. * Blocks within the octree containing objects
  40093. */
  40094. blocks: Array<OctreeBlock<T>>;
  40095. /**
  40096. * Content stored in the octree
  40097. */
  40098. dynamicContent: T[];
  40099. private _maxBlockCapacity;
  40100. private _selectionContent;
  40101. private _creationFunc;
  40102. /**
  40103. * Creates a octree
  40104. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40105. * @param creationFunc function to be used to instatiate the octree
  40106. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40107. * @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.)
  40108. */
  40109. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40110. /** 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.) */
  40111. maxDepth?: number);
  40112. /**
  40113. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40114. * @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);
  40115. * @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);
  40116. * @param entries meshes to be added to the octree blocks
  40117. */
  40118. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40119. /**
  40120. * Adds a mesh to the octree
  40121. * @param entry Mesh to add to the octree
  40122. */
  40123. addMesh(entry: T): void;
  40124. /**
  40125. * Remove an element from the octree
  40126. * @param entry defines the element to remove
  40127. */
  40128. removeMesh(entry: T): void;
  40129. /**
  40130. * Selects an array of meshes within the frustum
  40131. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40132. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40133. * @returns array of meshes within the frustum
  40134. */
  40135. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40136. /**
  40137. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40138. * @param sphereCenter defines the bounding sphere center
  40139. * @param sphereRadius defines the bounding sphere radius
  40140. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40141. * @returns an array of objects that intersect the sphere
  40142. */
  40143. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40144. /**
  40145. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40146. * @param ray defines the ray to test with
  40147. * @returns array of intersected objects
  40148. */
  40149. intersectsRay(ray: Ray): SmartArray<T>;
  40150. /**
  40151. * Adds a mesh into the octree block if it intersects the block
  40152. */
  40153. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40154. /**
  40155. * Adds a submesh into the octree block if it intersects the block
  40156. */
  40157. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40158. }
  40159. }
  40160. declare module BABYLON {
  40161. interface Scene {
  40162. /**
  40163. * @hidden
  40164. * Backing Filed
  40165. */ private _selectionOctree: Octree<AbstractMesh>;
  40166. /**
  40167. * Gets the octree used to boost mesh selection (picking)
  40168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40169. */
  40170. selectionOctree: Octree<AbstractMesh>;
  40171. /**
  40172. * Creates or updates the octree used to boost selection (picking)
  40173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40174. * @param maxCapacity defines the maximum capacity per leaf
  40175. * @param maxDepth defines the maximum depth of the octree
  40176. * @returns an octree of AbstractMesh
  40177. */
  40178. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40179. }
  40180. interface AbstractMesh {
  40181. /**
  40182. * @hidden
  40183. * Backing Field
  40184. */ private _submeshesOctree: Octree<SubMesh>;
  40185. /**
  40186. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40187. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40188. * @param maxCapacity defines the maximum size of each block (64 by default)
  40189. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40190. * @returns the new octree
  40191. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40193. */
  40194. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40195. }
  40196. /**
  40197. * Defines the octree scene component responsible to manage any octrees
  40198. * in a given scene.
  40199. */
  40200. export class OctreeSceneComponent {
  40201. /**
  40202. * The component name help to identify the component in the list of scene components.
  40203. */
  40204. readonly name: string;
  40205. /**
  40206. * The scene the component belongs to.
  40207. */
  40208. scene: Scene;
  40209. /**
  40210. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40211. */
  40212. readonly checksIsEnabled: boolean;
  40213. /**
  40214. * Creates a new instance of the component for the given scene
  40215. * @param scene Defines the scene to register the component in
  40216. */
  40217. constructor(scene: Scene);
  40218. /**
  40219. * Registers the component in a given scene
  40220. */
  40221. register(): void;
  40222. /**
  40223. * Return the list of active meshes
  40224. * @returns the list of active meshes
  40225. */
  40226. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40227. /**
  40228. * Return the list of active sub meshes
  40229. * @param mesh The mesh to get the candidates sub meshes from
  40230. * @returns the list of active sub meshes
  40231. */
  40232. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40233. private _tempRay;
  40234. /**
  40235. * Return the list of sub meshes intersecting with a given local ray
  40236. * @param mesh defines the mesh to find the submesh for
  40237. * @param localRay defines the ray in local space
  40238. * @returns the list of intersecting sub meshes
  40239. */
  40240. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40241. /**
  40242. * Return the list of sub meshes colliding with a collider
  40243. * @param mesh defines the mesh to find the submesh for
  40244. * @param collider defines the collider to evaluate the collision against
  40245. * @returns the list of colliding sub meshes
  40246. */
  40247. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40248. /**
  40249. * Rebuilds the elements related to this component in case of
  40250. * context lost for instance.
  40251. */
  40252. rebuild(): void;
  40253. /**
  40254. * Disposes the component and the associated ressources.
  40255. */
  40256. dispose(): void;
  40257. }
  40258. }
  40259. declare module BABYLON {
  40260. /**
  40261. * Renders a layer on top of an existing scene
  40262. */
  40263. export class UtilityLayerRenderer implements IDisposable {
  40264. /** the original scene that will be rendered on top of */
  40265. originalScene: Scene;
  40266. private _pointerCaptures;
  40267. private _lastPointerEvents;
  40268. private static _DefaultUtilityLayer;
  40269. private static _DefaultKeepDepthUtilityLayer;
  40270. private _sharedGizmoLight;
  40271. private _renderCamera;
  40272. /**
  40273. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  40274. * @returns the camera that is used when rendering the utility layer
  40275. */
  40276. getRenderCamera(): Nullable<Camera>;
  40277. /**
  40278. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  40279. * @param cam the camera that should be used when rendering the utility layer
  40280. */
  40281. setRenderCamera(cam: Nullable<Camera>): void;
  40282. /**
  40283. * @hidden
  40284. * Light which used by gizmos to get light shading
  40285. */ private _getSharedGizmoLight(): HemisphericLight;
  40286. /**
  40287. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40288. */
  40289. pickUtilitySceneFirst: boolean;
  40290. /**
  40291. * 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)
  40292. */
  40293. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40294. /**
  40295. * 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)
  40296. */
  40297. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40298. /**
  40299. * The scene that is rendered on top of the original scene
  40300. */
  40301. utilityLayerScene: Scene;
  40302. /**
  40303. * If the utility layer should automatically be rendered on top of existing scene
  40304. */
  40305. shouldRender: boolean;
  40306. /**
  40307. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40308. */
  40309. onlyCheckPointerDownEvents: boolean;
  40310. /**
  40311. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40312. */
  40313. processAllEvents: boolean;
  40314. /**
  40315. * Observable raised when the pointer move from the utility layer scene to the main scene
  40316. */
  40317. onPointerOutObservable: Observable<number>;
  40318. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40319. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40320. private _afterRenderObserver;
  40321. private _sceneDisposeObserver;
  40322. private _originalPointerObserver;
  40323. /**
  40324. * Instantiates a UtilityLayerRenderer
  40325. * @param originalScene the original scene that will be rendered on top of
  40326. * @param handleEvents boolean indicating if the utility layer should handle events
  40327. */
  40328. constructor(
  40329. /** the original scene that will be rendered on top of */
  40330. originalScene: Scene, handleEvents?: boolean);
  40331. private _notifyObservers;
  40332. /**
  40333. * Renders the utility layers scene on top of the original scene
  40334. */
  40335. render(): void;
  40336. /**
  40337. * Disposes of the renderer
  40338. */
  40339. dispose(): void;
  40340. private _updateCamera;
  40341. }
  40342. }
  40343. declare module BABYLON {
  40344. /**
  40345. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40346. */
  40347. export class Gizmo implements IDisposable {
  40348. /** The utility layer the gizmo will be added to */
  40349. gizmoLayer: UtilityLayerRenderer;
  40350. /**
  40351. * The root mesh of the gizmo
  40352. */ private _rootMesh: Mesh;
  40353. private _attachedMesh;
  40354. /**
  40355. * Ratio for the scale of the gizmo (Default: 1)
  40356. */
  40357. scaleRatio: number;
  40358. /**
  40359. * If a custom mesh has been set (Default: false)
  40360. */
  40361. protected _customMeshSet: boolean;
  40362. /**
  40363. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40364. * * When set, interactions will be enabled
  40365. */
  40366. attachedMesh: Nullable<AbstractMesh>;
  40367. /**
  40368. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40369. * @param mesh The mesh to replace the default mesh of the gizmo
  40370. */
  40371. setCustomMesh(mesh: Mesh): void;
  40372. /**
  40373. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40374. */
  40375. updateGizmoRotationToMatchAttachedMesh: boolean;
  40376. /**
  40377. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40378. */
  40379. updateGizmoPositionToMatchAttachedMesh: boolean;
  40380. /**
  40381. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40382. */
  40383. protected _updateScale: boolean;
  40384. protected _interactionsEnabled: boolean;
  40385. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40386. private _beforeRenderObserver;
  40387. private _tempVector;
  40388. /**
  40389. * Creates a gizmo
  40390. * @param gizmoLayer The utility layer the gizmo will be added to
  40391. */
  40392. constructor(
  40393. /** The utility layer the gizmo will be added to */
  40394. gizmoLayer?: UtilityLayerRenderer);
  40395. /**
  40396. * Updates the gizmo to match the attached mesh's position/rotation
  40397. */
  40398. protected _update(): void;
  40399. /**
  40400. * Disposes of the gizmo
  40401. */
  40402. dispose(): void;
  40403. }
  40404. }
  40405. declare module BABYLON {
  40406. /**
  40407. * Single plane drag gizmo
  40408. */
  40409. export class PlaneDragGizmo extends Gizmo {
  40410. /**
  40411. * Drag behavior responsible for the gizmos dragging interactions
  40412. */
  40413. dragBehavior: PointerDragBehavior;
  40414. private _pointerObserver;
  40415. /**
  40416. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40417. */
  40418. snapDistance: number;
  40419. /**
  40420. * Event that fires each time the gizmo snaps to a new location.
  40421. * * snapDistance is the the change in distance
  40422. */
  40423. onSnapObservable: Observable<{
  40424. snapDistance: number;
  40425. }>;
  40426. private _plane;
  40427. private _coloredMaterial;
  40428. private _hoverMaterial;
  40429. private _isEnabled;
  40430. private _parent;
  40431. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  40432. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40433. /**
  40434. * Creates a PlaneDragGizmo
  40435. * @param gizmoLayer The utility layer the gizmo will be added to
  40436. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  40437. * @param color The color of the gizmo
  40438. */
  40439. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  40440. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40441. /**
  40442. * If the gizmo is enabled
  40443. */
  40444. isEnabled: boolean;
  40445. /**
  40446. * Disposes of the gizmo
  40447. */
  40448. dispose(): void;
  40449. }
  40450. }
  40451. declare module BABYLON {
  40452. /**
  40453. * Gizmo that enables dragging a mesh along 3 axis
  40454. */
  40455. export class PositionGizmo extends Gizmo {
  40456. /**
  40457. * Internal gizmo used for interactions on the x axis
  40458. */
  40459. xGizmo: AxisDragGizmo;
  40460. /**
  40461. * Internal gizmo used for interactions on the y axis
  40462. */
  40463. yGizmo: AxisDragGizmo;
  40464. /**
  40465. * Internal gizmo used for interactions on the z axis
  40466. */
  40467. zGizmo: AxisDragGizmo;
  40468. /**
  40469. * Internal gizmo used for interactions on the yz plane
  40470. */
  40471. xPlaneGizmo: PlaneDragGizmo;
  40472. /**
  40473. * Internal gizmo used for interactions on the xz plane
  40474. */
  40475. yPlaneGizmo: PlaneDragGizmo;
  40476. /**
  40477. * Internal gizmo used for interactions on the xy plane
  40478. */
  40479. zPlaneGizmo: PlaneDragGizmo;
  40480. /**
  40481. * private variables
  40482. */
  40483. private _meshAttached;
  40484. private _updateGizmoRotationToMatchAttachedMesh;
  40485. private _snapDistance;
  40486. private _scaleRatio;
  40487. /** Fires an event when any of it's sub gizmos are dragged */
  40488. onDragStartObservable: Observable<unknown>;
  40489. /** Fires an event when any of it's sub gizmos are released from dragging */
  40490. onDragEndObservable: Observable<unknown>;
  40491. /**
  40492. * If set to true, planar drag is enabled
  40493. */
  40494. private _planarGizmoEnabled;
  40495. attachedMesh: Nullable<AbstractMesh>;
  40496. /**
  40497. * Creates a PositionGizmo
  40498. * @param gizmoLayer The utility layer the gizmo will be added to
  40499. */
  40500. constructor(gizmoLayer?: UtilityLayerRenderer);
  40501. /**
  40502. * If the planar drag gizmo is enabled
  40503. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  40504. */
  40505. planarGizmoEnabled: boolean;
  40506. updateGizmoRotationToMatchAttachedMesh: boolean;
  40507. /**
  40508. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40509. */
  40510. snapDistance: number;
  40511. /**
  40512. * Ratio for the scale of the gizmo (Default: 1)
  40513. */
  40514. scaleRatio: number;
  40515. /**
  40516. * Disposes of the gizmo
  40517. */
  40518. dispose(): void;
  40519. /**
  40520. * CustomMeshes are not supported by this gizmo
  40521. * @param mesh The mesh to replace the default mesh of the gizmo
  40522. */
  40523. setCustomMesh(mesh: Mesh): void;
  40524. }
  40525. }
  40526. declare module BABYLON {
  40527. /**
  40528. * Single axis drag gizmo
  40529. */
  40530. export class AxisDragGizmo extends Gizmo {
  40531. /**
  40532. * Drag behavior responsible for the gizmos dragging interactions
  40533. */
  40534. dragBehavior: PointerDragBehavior;
  40535. private _pointerObserver;
  40536. /**
  40537. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40538. */
  40539. snapDistance: number;
  40540. /**
  40541. * Event that fires each time the gizmo snaps to a new location.
  40542. * * snapDistance is the the change in distance
  40543. */
  40544. onSnapObservable: Observable<{
  40545. snapDistance: number;
  40546. }>;
  40547. private _isEnabled;
  40548. private _parent;
  40549. private _arrow;
  40550. private _coloredMaterial;
  40551. private _hoverMaterial;
  40552. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40553. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40554. /**
  40555. * Creates an AxisDragGizmo
  40556. * @param gizmoLayer The utility layer the gizmo will be added to
  40557. * @param dragAxis The axis which the gizmo will be able to drag on
  40558. * @param color The color of the gizmo
  40559. */
  40560. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  40561. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40562. /**
  40563. * If the gizmo is enabled
  40564. */
  40565. isEnabled: boolean;
  40566. /**
  40567. * Disposes of the gizmo
  40568. */
  40569. dispose(): void;
  40570. }
  40571. }
  40572. declare module BABYLON.Debug {
  40573. /**
  40574. * The Axes viewer will show 3 axes in a specific point in space
  40575. */
  40576. export class AxesViewer {
  40577. private _xAxis;
  40578. private _yAxis;
  40579. private _zAxis;
  40580. private _scaleLinesFactor;
  40581. private _instanced;
  40582. /**
  40583. * Gets the hosting scene
  40584. */
  40585. scene: Scene;
  40586. /**
  40587. * Gets or sets a number used to scale line length
  40588. */
  40589. scaleLines: number;
  40590. /** Gets the node hierarchy used to render x-axis */
  40591. readonly xAxis: TransformNode;
  40592. /** Gets the node hierarchy used to render y-axis */
  40593. readonly yAxis: TransformNode;
  40594. /** Gets the node hierarchy used to render z-axis */
  40595. readonly zAxis: TransformNode;
  40596. /**
  40597. * Creates a new AxesViewer
  40598. * @param scene defines the hosting scene
  40599. * @param scaleLines defines a number used to scale line length (1 by default)
  40600. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40601. * @param xAxis defines the node hierarchy used to render the x-axis
  40602. * @param yAxis defines the node hierarchy used to render the y-axis
  40603. * @param zAxis defines the node hierarchy used to render the z-axis
  40604. */
  40605. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40606. /**
  40607. * Force the viewer to update
  40608. * @param position defines the position of the viewer
  40609. * @param xaxis defines the x axis of the viewer
  40610. * @param yaxis defines the y axis of the viewer
  40611. * @param zaxis defines the z axis of the viewer
  40612. */
  40613. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40614. /**
  40615. * Creates an instance of this axes viewer.
  40616. * @returns a new axes viewer with instanced meshes
  40617. */
  40618. createInstance(): AxesViewer;
  40619. /** Releases resources */
  40620. dispose(): void;
  40621. private static _SetRenderingGroupId;
  40622. }
  40623. }
  40624. declare module BABYLON.Debug {
  40625. /**
  40626. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40627. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40628. */
  40629. export class BoneAxesViewer extends AxesViewer {
  40630. /**
  40631. * Gets or sets the target mesh where to display the axes viewer
  40632. */
  40633. mesh: Nullable<Mesh>;
  40634. /**
  40635. * Gets or sets the target bone where to display the axes viewer
  40636. */
  40637. bone: Nullable<Bone>;
  40638. /** Gets current position */
  40639. pos: Vector3;
  40640. /** Gets direction of X axis */
  40641. xaxis: Vector3;
  40642. /** Gets direction of Y axis */
  40643. yaxis: Vector3;
  40644. /** Gets direction of Z axis */
  40645. zaxis: Vector3;
  40646. /**
  40647. * Creates a new BoneAxesViewer
  40648. * @param scene defines the hosting scene
  40649. * @param bone defines the target bone
  40650. * @param mesh defines the target mesh
  40651. * @param scaleLines defines a scaling factor for line length (1 by default)
  40652. */
  40653. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40654. /**
  40655. * Force the viewer to update
  40656. */
  40657. update(): void;
  40658. /** Releases resources */
  40659. dispose(): void;
  40660. }
  40661. }
  40662. declare module BABYLON {
  40663. /**
  40664. * Interface used to define scene explorer extensibility option
  40665. */
  40666. export interface IExplorerExtensibilityOption {
  40667. /**
  40668. * Define the option label
  40669. */
  40670. label: string;
  40671. /**
  40672. * Defines the action to execute on click
  40673. */
  40674. action: (entity: any) => void;
  40675. }
  40676. /**
  40677. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40678. */
  40679. export interface IExplorerExtensibilityGroup {
  40680. /**
  40681. * Defines a predicate to test if a given type mut be extended
  40682. */
  40683. predicate: (entity: any) => boolean;
  40684. /**
  40685. * Gets the list of options added to a type
  40686. */
  40687. entries: IExplorerExtensibilityOption[];
  40688. }
  40689. /**
  40690. * Interface used to define the options to use to create the Inspector
  40691. */
  40692. export interface IInspectorOptions {
  40693. /**
  40694. * Display in overlay mode (default: false)
  40695. */
  40696. overlay?: boolean;
  40697. /**
  40698. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40699. */
  40700. globalRoot?: HTMLElement;
  40701. /**
  40702. * Display the Scene explorer
  40703. */
  40704. showExplorer?: boolean;
  40705. /**
  40706. * Display the property inspector
  40707. */
  40708. showInspector?: boolean;
  40709. /**
  40710. * Display in embed mode (both panes on the right)
  40711. */
  40712. embedMode?: boolean;
  40713. /**
  40714. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40715. */
  40716. handleResize?: boolean;
  40717. /**
  40718. * Allow the panes to popup (default: true)
  40719. */
  40720. enablePopup?: boolean;
  40721. /**
  40722. * Allow the panes to be closed by users (default: true)
  40723. */
  40724. enableClose?: boolean;
  40725. /**
  40726. * Optional list of extensibility entries
  40727. */
  40728. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40729. /**
  40730. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40731. */
  40732. inspectorURL?: string;
  40733. }
  40734. interface Scene {
  40735. /**
  40736. * @hidden
  40737. * Backing field
  40738. */ private _debugLayer: DebugLayer;
  40739. /**
  40740. * Gets the debug layer (aka Inspector) associated with the scene
  40741. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40742. */
  40743. debugLayer: DebugLayer;
  40744. }
  40745. /**
  40746. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40747. * what is happening in your scene
  40748. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40749. */
  40750. export class DebugLayer {
  40751. /**
  40752. * Define the url to get the inspector script from.
  40753. * By default it uses the babylonjs CDN.
  40754. * @ignoreNaming
  40755. */
  40756. static InspectorURL: string;
  40757. private _scene;
  40758. private BJSINSPECTOR;
  40759. /**
  40760. * Observable triggered when a property is changed through the inspector.
  40761. */
  40762. onPropertyChangedObservable: Observable<{
  40763. object: any;
  40764. property: string;
  40765. value: any;
  40766. initialValue: any;
  40767. }>;
  40768. /**
  40769. * Instantiates a new debug layer.
  40770. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40771. * what is happening in your scene
  40772. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40773. * @param scene Defines the scene to inspect
  40774. */
  40775. constructor(scene: Scene);
  40776. /** Creates the inspector window. */
  40777. private _createInspector;
  40778. /**
  40779. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40780. * @param entity defines the entity to select
  40781. * @param lineContainerTitle defines the specific block to highlight
  40782. */
  40783. select(entity: any, lineContainerTitle?: string): void;
  40784. /** Get the inspector from bundle or global */
  40785. private _getGlobalInspector;
  40786. /**
  40787. * Get if the inspector is visible or not.
  40788. * @returns true if visible otherwise, false
  40789. */
  40790. isVisible(): boolean;
  40791. /**
  40792. * Hide the inspector and close its window.
  40793. */
  40794. hide(): void;
  40795. /**
  40796. * Launch the debugLayer.
  40797. * @param config Define the configuration of the inspector
  40798. * @return a promise fulfilled when the debug layer is visible
  40799. */
  40800. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40801. }
  40802. }
  40803. declare module BABYLON {
  40804. /**
  40805. * Class containing static functions to help procedurally build meshes
  40806. */
  40807. export class BoxBuilder {
  40808. /**
  40809. * Creates a box mesh
  40810. * * The parameter `size` sets the size (float) of each box side (default 1)
  40811. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40812. * * 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)
  40813. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40815. * * 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
  40816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40817. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40818. * @param name defines the name of the mesh
  40819. * @param options defines the options used to create the mesh
  40820. * @param scene defines the hosting scene
  40821. * @returns the box mesh
  40822. */
  40823. static CreateBox(name: string, options: {
  40824. size?: number;
  40825. width?: number;
  40826. height?: number;
  40827. depth?: number;
  40828. faceUV?: Vector4[];
  40829. faceColors?: Color4[];
  40830. sideOrientation?: number;
  40831. frontUVs?: Vector4;
  40832. backUVs?: Vector4;
  40833. wrap?: boolean;
  40834. topBaseAt?: number;
  40835. bottomBaseAt?: number;
  40836. updatable?: boolean;
  40837. }, scene?: Nullable<Scene>): Mesh;
  40838. }
  40839. }
  40840. declare module BABYLON {
  40841. /**
  40842. * Class containing static functions to help procedurally build meshes
  40843. */
  40844. export class SphereBuilder {
  40845. /**
  40846. * Creates a sphere mesh
  40847. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40848. * * 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`)
  40849. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40850. * * 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
  40851. * * 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)
  40852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40853. * * 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
  40854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40855. * @param name defines the name of the mesh
  40856. * @param options defines the options used to create the mesh
  40857. * @param scene defines the hosting scene
  40858. * @returns the sphere mesh
  40859. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40860. */
  40861. static CreateSphere(name: string, options: {
  40862. segments?: number;
  40863. diameter?: number;
  40864. diameterX?: number;
  40865. diameterY?: number;
  40866. diameterZ?: number;
  40867. arc?: number;
  40868. slice?: number;
  40869. sideOrientation?: number;
  40870. frontUVs?: Vector4;
  40871. backUVs?: Vector4;
  40872. updatable?: boolean;
  40873. }, scene: any): Mesh;
  40874. }
  40875. }
  40876. declare module BABYLON.Debug {
  40877. /**
  40878. * Used to show the physics impostor around the specific mesh
  40879. */
  40880. export class PhysicsViewer {
  40881. /** @hidden */
  40882. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40883. /** @hidden */
  40884. protected _meshes: Array<Nullable<AbstractMesh>>;
  40885. /** @hidden */
  40886. protected _scene: Nullable<Scene>;
  40887. /** @hidden */
  40888. protected _numMeshes: number;
  40889. /** @hidden */
  40890. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40891. private _renderFunction;
  40892. private _utilityLayer;
  40893. private _debugBoxMesh;
  40894. private _debugSphereMesh;
  40895. private _debugCylinderMesh;
  40896. private _debugMaterial;
  40897. private _debugMeshMeshes;
  40898. /**
  40899. * Creates a new PhysicsViewer
  40900. * @param scene defines the hosting scene
  40901. */
  40902. constructor(scene: Scene);
  40903. /** @hidden */
  40904. protected _updateDebugMeshes(): void;
  40905. /**
  40906. * Renders a specified physic impostor
  40907. * @param impostor defines the impostor to render
  40908. * @param targetMesh defines the mesh represented by the impostor
  40909. * @returns the new debug mesh used to render the impostor
  40910. */
  40911. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40912. /**
  40913. * Hides a specified physic impostor
  40914. * @param impostor defines the impostor to hide
  40915. */
  40916. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40917. private _getDebugMaterial;
  40918. private _getDebugBoxMesh;
  40919. private _getDebugSphereMesh;
  40920. private _getDebugCylinderMesh;
  40921. private _getDebugMeshMesh;
  40922. private _getDebugMesh;
  40923. /** Releases all resources */
  40924. dispose(): void;
  40925. }
  40926. }
  40927. declare module BABYLON {
  40928. /**
  40929. * Class containing static functions to help procedurally build meshes
  40930. */
  40931. export class LinesBuilder {
  40932. /**
  40933. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40934. * * 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
  40935. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40936. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40937. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40938. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40939. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40940. * * 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
  40941. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40944. * @param name defines the name of the new line system
  40945. * @param options defines the options used to create the line system
  40946. * @param scene defines the hosting scene
  40947. * @returns a new line system mesh
  40948. */
  40949. static CreateLineSystem(name: string, options: {
  40950. lines: Vector3[][];
  40951. updatable?: boolean;
  40952. instance?: Nullable<LinesMesh>;
  40953. colors?: Nullable<Color4[][]>;
  40954. useVertexAlpha?: boolean;
  40955. }, scene: Nullable<Scene>): LinesMesh;
  40956. /**
  40957. * Creates a line mesh
  40958. * 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
  40959. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40960. * * The parameter `points` is an array successive Vector3
  40961. * * 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
  40962. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40963. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40964. * * When updating an instance, remember that only point positions can change, not the number of points
  40965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40967. * @param name defines the name of the new line system
  40968. * @param options defines the options used to create the line system
  40969. * @param scene defines the hosting scene
  40970. * @returns a new line mesh
  40971. */
  40972. static CreateLines(name: string, options: {
  40973. points: Vector3[];
  40974. updatable?: boolean;
  40975. instance?: Nullable<LinesMesh>;
  40976. colors?: Color4[];
  40977. useVertexAlpha?: boolean;
  40978. }, scene?: Nullable<Scene>): LinesMesh;
  40979. /**
  40980. * Creates a dashed line mesh
  40981. * * 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
  40982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40983. * * The parameter `points` is an array successive Vector3
  40984. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40985. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40986. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40987. * * 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
  40988. * * When updating an instance, remember that only point positions can change, not the number of points
  40989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40990. * @param name defines the name of the mesh
  40991. * @param options defines the options used to create the mesh
  40992. * @param scene defines the hosting scene
  40993. * @returns the dashed line mesh
  40994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40995. */
  40996. static CreateDashedLines(name: string, options: {
  40997. points: Vector3[];
  40998. dashSize?: number;
  40999. gapSize?: number;
  41000. dashNb?: number;
  41001. updatable?: boolean;
  41002. instance?: LinesMesh;
  41003. }, scene?: Nullable<Scene>): LinesMesh;
  41004. }
  41005. }
  41006. declare module BABYLON {
  41007. /**
  41008. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41009. * in order to better appreciate the issue one might have.
  41010. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41011. */
  41012. export class RayHelper {
  41013. /**
  41014. * Defines the ray we are currently tryin to visualize.
  41015. */
  41016. ray: Nullable<Ray>;
  41017. private _renderPoints;
  41018. private _renderLine;
  41019. private _renderFunction;
  41020. private _scene;
  41021. private _updateToMeshFunction;
  41022. private _attachedToMesh;
  41023. private _meshSpaceDirection;
  41024. private _meshSpaceOrigin;
  41025. /**
  41026. * Helper function to create a colored helper in a scene in one line.
  41027. * @param ray Defines the ray we are currently tryin to visualize
  41028. * @param scene Defines the scene the ray is used in
  41029. * @param color Defines the color we want to see the ray in
  41030. * @returns The newly created ray helper.
  41031. */
  41032. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41033. /**
  41034. * Instantiate a new ray helper.
  41035. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41036. * in order to better appreciate the issue one might have.
  41037. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41038. * @param ray Defines the ray we are currently tryin to visualize
  41039. */
  41040. constructor(ray: Ray);
  41041. /**
  41042. * Shows the ray we are willing to debug.
  41043. * @param scene Defines the scene the ray needs to be rendered in
  41044. * @param color Defines the color the ray needs to be rendered in
  41045. */
  41046. show(scene: Scene, color?: Color3): void;
  41047. /**
  41048. * Hides the ray we are debugging.
  41049. */
  41050. hide(): void;
  41051. private _render;
  41052. /**
  41053. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41054. * @param mesh Defines the mesh we want the helper attached to
  41055. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41056. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41057. * @param length Defines the length of the ray
  41058. */
  41059. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41060. /**
  41061. * Detach the ray helper from the mesh it has previously been attached to.
  41062. */
  41063. detachFromMesh(): void;
  41064. private _updateToMesh;
  41065. /**
  41066. * Dispose the helper and release its associated resources.
  41067. */
  41068. dispose(): void;
  41069. }
  41070. }
  41071. declare module BABYLON.Debug {
  41072. /**
  41073. * Class used to render a debug view of a given skeleton
  41074. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41075. */
  41076. export class SkeletonViewer {
  41077. /** defines the skeleton to render */
  41078. skeleton: Skeleton;
  41079. /** defines the mesh attached to the skeleton */
  41080. mesh: AbstractMesh;
  41081. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41082. autoUpdateBonesMatrices: boolean;
  41083. /** defines the rendering group id to use with the viewer */
  41084. renderingGroupId: number;
  41085. /** Gets or sets the color used to render the skeleton */
  41086. color: Color3;
  41087. private _scene;
  41088. private _debugLines;
  41089. private _debugMesh;
  41090. private _isEnabled;
  41091. private _renderFunction;
  41092. private _utilityLayer;
  41093. /**
  41094. * Returns the mesh used to render the bones
  41095. */
  41096. readonly debugMesh: Nullable<LinesMesh>;
  41097. /**
  41098. * Creates a new SkeletonViewer
  41099. * @param skeleton defines the skeleton to render
  41100. * @param mesh defines the mesh attached to the skeleton
  41101. * @param scene defines the hosting scene
  41102. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41103. * @param renderingGroupId defines the rendering group id to use with the viewer
  41104. */
  41105. constructor(
  41106. /** defines the skeleton to render */
  41107. skeleton: Skeleton,
  41108. /** defines the mesh attached to the skeleton */
  41109. mesh: AbstractMesh, scene: Scene,
  41110. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41111. autoUpdateBonesMatrices?: boolean,
  41112. /** defines the rendering group id to use with the viewer */
  41113. renderingGroupId?: number);
  41114. /** Gets or sets a boolean indicating if the viewer is enabled */
  41115. isEnabled: boolean;
  41116. private _getBonePosition;
  41117. private _getLinesForBonesWithLength;
  41118. private _getLinesForBonesNoLength;
  41119. /** Update the viewer to sync with current skeleton state */
  41120. update(): void;
  41121. /** Release associated resources */
  41122. dispose(): void;
  41123. }
  41124. }
  41125. declare module BABYLON {
  41126. /**
  41127. * Options to create the null engine
  41128. */
  41129. export class NullEngineOptions {
  41130. /**
  41131. * Render width (Default: 512)
  41132. */
  41133. renderWidth: number;
  41134. /**
  41135. * Render height (Default: 256)
  41136. */
  41137. renderHeight: number;
  41138. /**
  41139. * Texture size (Default: 512)
  41140. */
  41141. textureSize: number;
  41142. /**
  41143. * If delta time between frames should be constant
  41144. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41145. */
  41146. deterministicLockstep: boolean;
  41147. /**
  41148. * Maximum about of steps between frames (Default: 4)
  41149. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41150. */
  41151. lockstepMaxSteps: number;
  41152. }
  41153. /**
  41154. * The null engine class provides support for headless version of babylon.js.
  41155. * This can be used in server side scenario or for testing purposes
  41156. */
  41157. export class NullEngine extends Engine {
  41158. private _options;
  41159. /**
  41160. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41161. */
  41162. isDeterministicLockStep(): boolean;
  41163. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41164. getLockstepMaxSteps(): number;
  41165. /**
  41166. * Sets hardware scaling, used to save performance if needed
  41167. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41168. */
  41169. getHardwareScalingLevel(): number;
  41170. constructor(options?: NullEngineOptions);
  41171. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41172. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41173. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41174. getRenderWidth(useScreen?: boolean): number;
  41175. getRenderHeight(useScreen?: boolean): number;
  41176. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41177. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41178. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41179. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41180. bindSamplers(effect: Effect): void;
  41181. enableEffect(effect: Effect): void;
  41182. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41183. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41184. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41185. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41186. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41187. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41188. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41189. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41190. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41191. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41192. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41193. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41194. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41195. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41196. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41197. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41198. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41199. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41200. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41201. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41202. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41203. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41204. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41205. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41206. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41207. bindBuffers(vertexBuffers: {
  41208. [key: string]: VertexBuffer;
  41209. }, indexBuffer: DataBuffer, effect: Effect): void;
  41210. wipeCaches(bruteForce?: boolean): void;
  41211. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41212. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41213. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41214. /** @hidden */ private _createTexture(): WebGLTexture;
  41215. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  41216. 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;
  41217. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41218. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41219. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41220. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41221. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41222. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41223. areAllEffectsReady(): boolean;
  41224. /**
  41225. * @hidden
  41226. * Get the current error code of the webGL context
  41227. * @returns the error code
  41228. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41229. */
  41230. getError(): number;
  41231. /** @hidden */ private _getUnpackAlignement(): number;
  41232. /** @hidden */ private _unpackFlipY(value: boolean): void;
  41233. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41234. /**
  41235. * Updates a dynamic vertex buffer.
  41236. * @param vertexBuffer the vertex buffer to update
  41237. * @param data the data used to update the vertex buffer
  41238. * @param byteOffset the byte offset of the data (optional)
  41239. * @param byteLength the byte length of the data (optional)
  41240. */
  41241. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41242. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  41243. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  41244. releaseEffects(): void;
  41245. displayLoadingUI(): void;
  41246. hideLoadingUI(): void;
  41247. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41248. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41249. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41250. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41251. }
  41252. }
  41253. declare module BABYLON {
  41254. /** @hidden */
  41255. export class _OcclusionDataStorage {
  41256. /** @hidden */
  41257. occlusionInternalRetryCounter: number;
  41258. /** @hidden */
  41259. isOcclusionQueryInProgress: boolean;
  41260. /** @hidden */
  41261. isOccluded: boolean;
  41262. /** @hidden */
  41263. occlusionRetryCount: number;
  41264. /** @hidden */
  41265. occlusionType: number;
  41266. /** @hidden */
  41267. occlusionQueryAlgorithmType: number;
  41268. }
  41269. interface Engine {
  41270. /**
  41271. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41272. * @return the new query
  41273. */
  41274. createQuery(): WebGLQuery;
  41275. /**
  41276. * Delete and release a webGL query
  41277. * @param query defines the query to delete
  41278. * @return the current engine
  41279. */
  41280. deleteQuery(query: WebGLQuery): Engine;
  41281. /**
  41282. * Check if a given query has resolved and got its value
  41283. * @param query defines the query to check
  41284. * @returns true if the query got its value
  41285. */
  41286. isQueryResultAvailable(query: WebGLQuery): boolean;
  41287. /**
  41288. * Gets the value of a given query
  41289. * @param query defines the query to check
  41290. * @returns the value of the query
  41291. */
  41292. getQueryResult(query: WebGLQuery): number;
  41293. /**
  41294. * Initiates an occlusion query
  41295. * @param algorithmType defines the algorithm to use
  41296. * @param query defines the query to use
  41297. * @returns the current engine
  41298. * @see http://doc.babylonjs.com/features/occlusionquery
  41299. */
  41300. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41301. /**
  41302. * Ends an occlusion query
  41303. * @see http://doc.babylonjs.com/features/occlusionquery
  41304. * @param algorithmType defines the algorithm to use
  41305. * @returns the current engine
  41306. */
  41307. endOcclusionQuery(algorithmType: number): Engine;
  41308. /**
  41309. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41310. * Please note that only one query can be issued at a time
  41311. * @returns a time token used to track the time span
  41312. */
  41313. startTimeQuery(): Nullable<_TimeToken>;
  41314. /**
  41315. * Ends a time query
  41316. * @param token defines the token used to measure the time span
  41317. * @returns the time spent (in ns)
  41318. */
  41319. endTimeQuery(token: _TimeToken): int;
  41320. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  41321. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  41322. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  41323. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  41324. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  41325. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  41326. }
  41327. interface AbstractMesh {
  41328. /**
  41329. * Backing filed
  41330. * @hidden
  41331. */ private __occlusionDataStorage: _OcclusionDataStorage;
  41332. /**
  41333. * Access property
  41334. * @hidden
  41335. */ private _occlusionDataStorage: _OcclusionDataStorage;
  41336. /**
  41337. * 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.
  41338. * The default value is -1 which means don't break the query and wait till the result
  41339. * @see http://doc.babylonjs.com/features/occlusionquery
  41340. */
  41341. occlusionRetryCount: number;
  41342. /**
  41343. * 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:
  41344. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41345. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41346. * * 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.
  41347. * @see http://doc.babylonjs.com/features/occlusionquery
  41348. */
  41349. occlusionType: number;
  41350. /**
  41351. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41352. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41353. * * 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.
  41354. * @see http://doc.babylonjs.com/features/occlusionquery
  41355. */
  41356. occlusionQueryAlgorithmType: number;
  41357. /**
  41358. * 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
  41359. * @see http://doc.babylonjs.com/features/occlusionquery
  41360. */
  41361. isOccluded: boolean;
  41362. /**
  41363. * Flag to check the progress status of the query
  41364. * @see http://doc.babylonjs.com/features/occlusionquery
  41365. */
  41366. isOcclusionQueryInProgress: boolean;
  41367. }
  41368. }
  41369. declare module BABYLON {
  41370. /** @hidden */
  41371. export var _forceTransformFeedbackToBundle: boolean;
  41372. interface Engine {
  41373. /**
  41374. * Creates a webGL transform feedback object
  41375. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41376. * @returns the webGL transform feedback object
  41377. */
  41378. createTransformFeedback(): WebGLTransformFeedback;
  41379. /**
  41380. * Delete a webGL transform feedback object
  41381. * @param value defines the webGL transform feedback object to delete
  41382. */
  41383. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41384. /**
  41385. * Bind a webGL transform feedback object to the webgl context
  41386. * @param value defines the webGL transform feedback object to bind
  41387. */
  41388. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41389. /**
  41390. * Begins a transform feedback operation
  41391. * @param usePoints defines if points or triangles must be used
  41392. */
  41393. beginTransformFeedback(usePoints: boolean): void;
  41394. /**
  41395. * Ends a transform feedback operation
  41396. */
  41397. endTransformFeedback(): void;
  41398. /**
  41399. * Specify the varyings to use with transform feedback
  41400. * @param program defines the associated webGL program
  41401. * @param value defines the list of strings representing the varying names
  41402. */
  41403. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41404. /**
  41405. * Bind a webGL buffer for a transform feedback operation
  41406. * @param value defines the webGL buffer to bind
  41407. */
  41408. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41409. }
  41410. }
  41411. declare module BABYLON {
  41412. /**
  41413. * Creation options of the multi render target texture.
  41414. */
  41415. export interface IMultiRenderTargetOptions {
  41416. /**
  41417. * Define if the texture needs to create mip maps after render.
  41418. */
  41419. generateMipMaps?: boolean;
  41420. /**
  41421. * Define the types of all the draw buffers we want to create
  41422. */
  41423. types?: number[];
  41424. /**
  41425. * Define the sampling modes of all the draw buffers we want to create
  41426. */
  41427. samplingModes?: number[];
  41428. /**
  41429. * Define if a depth buffer is required
  41430. */
  41431. generateDepthBuffer?: boolean;
  41432. /**
  41433. * Define if a stencil buffer is required
  41434. */
  41435. generateStencilBuffer?: boolean;
  41436. /**
  41437. * Define if a depth texture is required instead of a depth buffer
  41438. */
  41439. generateDepthTexture?: boolean;
  41440. /**
  41441. * Define the number of desired draw buffers
  41442. */
  41443. textureCount?: number;
  41444. /**
  41445. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41446. */
  41447. doNotChangeAspectRatio?: boolean;
  41448. /**
  41449. * Define the default type of the buffers we are creating
  41450. */
  41451. defaultType?: number;
  41452. }
  41453. /**
  41454. * A multi render target, like a render target provides the ability to render to a texture.
  41455. * Unlike the render target, it can render to several draw buffers in one draw.
  41456. * This is specially interesting in deferred rendering or for any effects requiring more than
  41457. * just one color from a single pass.
  41458. */
  41459. export class MultiRenderTarget extends RenderTargetTexture {
  41460. private _internalTextures;
  41461. private _textures;
  41462. private _multiRenderTargetOptions;
  41463. /**
  41464. * Get if draw buffers are currently supported by the used hardware and browser.
  41465. */
  41466. readonly isSupported: boolean;
  41467. /**
  41468. * Get the list of textures generated by the multi render target.
  41469. */
  41470. readonly textures: Texture[];
  41471. /**
  41472. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41473. */
  41474. readonly depthTexture: Texture;
  41475. /**
  41476. * Set the wrapping mode on U of all the textures we are rendering to.
  41477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41478. */
  41479. wrapU: number;
  41480. /**
  41481. * Set the wrapping mode on V of all the textures we are rendering to.
  41482. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41483. */
  41484. wrapV: number;
  41485. /**
  41486. * Instantiate a new multi render target texture.
  41487. * A multi render target, like a render target provides the ability to render to a texture.
  41488. * Unlike the render target, it can render to several draw buffers in one draw.
  41489. * This is specially interesting in deferred rendering or for any effects requiring more than
  41490. * just one color from a single pass.
  41491. * @param name Define the name of the texture
  41492. * @param size Define the size of the buffers to render to
  41493. * @param count Define the number of target we are rendering into
  41494. * @param scene Define the scene the texture belongs to
  41495. * @param options Define the options used to create the multi render target
  41496. */
  41497. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41498. /** @hidden */ private _rebuild(): void;
  41499. private _createInternalTextures;
  41500. private _createTextures;
  41501. /**
  41502. * Define the number of samples used if MSAA is enabled.
  41503. */
  41504. samples: number;
  41505. /**
  41506. * Resize all the textures in the multi render target.
  41507. * Be carrefull as it will recreate all the data in the new texture.
  41508. * @param size Define the new size
  41509. */
  41510. resize(size: any): void;
  41511. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41512. /**
  41513. * Dispose the render targets and their associated resources
  41514. */
  41515. dispose(): void;
  41516. /**
  41517. * Release all the underlying texture used as draw buffers.
  41518. */
  41519. releaseInternalTextures(): void;
  41520. }
  41521. }
  41522. declare module BABYLON {
  41523. interface Engine {
  41524. /**
  41525. * Unbind a list of render target textures from the webGL context
  41526. * This is used only when drawBuffer extension or webGL2 are active
  41527. * @param textures defines the render target textures to unbind
  41528. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41529. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41530. */
  41531. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41532. /**
  41533. * Create a multi render target texture
  41534. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41535. * @param size defines the size of the texture
  41536. * @param options defines the creation options
  41537. * @returns the cube texture as an InternalTexture
  41538. */
  41539. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41540. /**
  41541. * Update the sample count for a given multiple render target texture
  41542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41543. * @param textures defines the textures to update
  41544. * @param samples defines the sample count to set
  41545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41546. */
  41547. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41548. }
  41549. }
  41550. declare module BABYLON {
  41551. /**
  41552. * Gather the list of clipboard event types as constants.
  41553. */
  41554. export class ClipboardEventTypes {
  41555. /**
  41556. * The clipboard event is fired when a copy command is active (pressed).
  41557. */
  41558. static readonly COPY: number;
  41559. /**
  41560. * The clipboard event is fired when a cut command is active (pressed).
  41561. */
  41562. static readonly CUT: number;
  41563. /**
  41564. * The clipboard event is fired when a paste command is active (pressed).
  41565. */
  41566. static readonly PASTE: number;
  41567. }
  41568. /**
  41569. * This class is used to store clipboard related info for the onClipboardObservable event.
  41570. */
  41571. export class ClipboardInfo {
  41572. /**
  41573. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41574. */
  41575. type: number;
  41576. /**
  41577. * Defines the related dom event
  41578. */
  41579. event: ClipboardEvent;
  41580. /**
  41581. *Creates an instance of ClipboardInfo.
  41582. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41583. * @param event Defines the related dom event
  41584. */
  41585. constructor(
  41586. /**
  41587. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41588. */
  41589. type: number,
  41590. /**
  41591. * Defines the related dom event
  41592. */
  41593. event: ClipboardEvent);
  41594. /**
  41595. * Get the clipboard event's type from the keycode.
  41596. * @param keyCode Defines the keyCode for the current keyboard event.
  41597. * @return {number}
  41598. */
  41599. static GetTypeFromCharacter(keyCode: number): number;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Class used to represent data loading progression
  41605. */
  41606. export class SceneLoaderProgressEvent {
  41607. /** defines if data length to load can be evaluated */
  41608. readonly lengthComputable: boolean;
  41609. /** defines the loaded data length */
  41610. readonly loaded: number;
  41611. /** defines the data length to load */
  41612. readonly total: number;
  41613. /**
  41614. * Create a new progress event
  41615. * @param lengthComputable defines if data length to load can be evaluated
  41616. * @param loaded defines the loaded data length
  41617. * @param total defines the data length to load
  41618. */
  41619. constructor(
  41620. /** defines if data length to load can be evaluated */
  41621. lengthComputable: boolean,
  41622. /** defines the loaded data length */
  41623. loaded: number,
  41624. /** defines the data length to load */
  41625. total: number);
  41626. /**
  41627. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41628. * @param event defines the source event
  41629. * @returns a new SceneLoaderProgressEvent
  41630. */
  41631. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41632. }
  41633. /**
  41634. * Interface used by SceneLoader plugins to define supported file extensions
  41635. */
  41636. export interface ISceneLoaderPluginExtensions {
  41637. /**
  41638. * Defines the list of supported extensions
  41639. */
  41640. [extension: string]: {
  41641. isBinary: boolean;
  41642. };
  41643. }
  41644. /**
  41645. * Interface used by SceneLoader plugin factory
  41646. */
  41647. export interface ISceneLoaderPluginFactory {
  41648. /**
  41649. * Defines the name of the factory
  41650. */
  41651. name: string;
  41652. /**
  41653. * Function called to create a new plugin
  41654. * @return the new plugin
  41655. */
  41656. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41657. /**
  41658. * Boolean indicating if the plugin can direct load specific data
  41659. */
  41660. canDirectLoad?: (data: string) => boolean;
  41661. }
  41662. /**
  41663. * Interface used to define a SceneLoader plugin
  41664. */
  41665. export interface ISceneLoaderPlugin {
  41666. /**
  41667. * The friendly name of this plugin.
  41668. */
  41669. name: string;
  41670. /**
  41671. * The file extensions supported by this plugin.
  41672. */
  41673. extensions: string | ISceneLoaderPluginExtensions;
  41674. /**
  41675. * Import meshes into a scene.
  41676. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41677. * @param scene The scene to import into
  41678. * @param data The data to import
  41679. * @param rootUrl The root url for scene and resources
  41680. * @param meshes The meshes array to import into
  41681. * @param particleSystems The particle systems array to import into
  41682. * @param skeletons The skeletons array to import into
  41683. * @param onError The callback when import fails
  41684. * @returns True if successful or false otherwise
  41685. */
  41686. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41687. /**
  41688. * Load into a scene.
  41689. * @param scene The scene to load into
  41690. * @param data The data to import
  41691. * @param rootUrl The root url for scene and resources
  41692. * @param onError The callback when import fails
  41693. * @returns true if successful or false otherwise
  41694. */
  41695. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41696. /**
  41697. * The callback that returns true if the data can be directly loaded.
  41698. */
  41699. canDirectLoad?: (data: string) => boolean;
  41700. /**
  41701. * The callback that allows custom handling of the root url based on the response url.
  41702. */
  41703. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41704. /**
  41705. * Load into an asset container.
  41706. * @param scene The scene to load into
  41707. * @param data The data to import
  41708. * @param rootUrl The root url for scene and resources
  41709. * @param onError The callback when import fails
  41710. * @returns The loaded asset container
  41711. */
  41712. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41713. }
  41714. /**
  41715. * Interface used to define an async SceneLoader plugin
  41716. */
  41717. export interface ISceneLoaderPluginAsync {
  41718. /**
  41719. * The friendly name of this plugin.
  41720. */
  41721. name: string;
  41722. /**
  41723. * The file extensions supported by this plugin.
  41724. */
  41725. extensions: string | ISceneLoaderPluginExtensions;
  41726. /**
  41727. * Import meshes into a scene.
  41728. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41729. * @param scene The scene to import into
  41730. * @param data The data to import
  41731. * @param rootUrl The root url for scene and resources
  41732. * @param onProgress The callback when the load progresses
  41733. * @param fileName Defines the name of the file to load
  41734. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41735. */
  41736. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41737. meshes: AbstractMesh[];
  41738. particleSystems: IParticleSystem[];
  41739. skeletons: Skeleton[];
  41740. animationGroups: AnimationGroup[];
  41741. }>;
  41742. /**
  41743. * Load into a scene.
  41744. * @param scene The scene to load into
  41745. * @param data The data to import
  41746. * @param rootUrl The root url for scene and resources
  41747. * @param onProgress The callback when the load progresses
  41748. * @param fileName Defines the name of the file to load
  41749. * @returns Nothing
  41750. */
  41751. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41752. /**
  41753. * The callback that returns true if the data can be directly loaded.
  41754. */
  41755. canDirectLoad?: (data: string) => boolean;
  41756. /**
  41757. * The callback that allows custom handling of the root url based on the response url.
  41758. */
  41759. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41760. /**
  41761. * Load into an asset container.
  41762. * @param scene The scene to load into
  41763. * @param data The data to import
  41764. * @param rootUrl The root url for scene and resources
  41765. * @param onProgress The callback when the load progresses
  41766. * @param fileName Defines the name of the file to load
  41767. * @returns The loaded asset container
  41768. */
  41769. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41770. }
  41771. /**
  41772. * Class used to load scene from various file formats using registered plugins
  41773. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41774. */
  41775. export class SceneLoader {
  41776. /**
  41777. * No logging while loading
  41778. */
  41779. static readonly NO_LOGGING: number;
  41780. /**
  41781. * Minimal logging while loading
  41782. */
  41783. static readonly MINIMAL_LOGGING: number;
  41784. /**
  41785. * Summary logging while loading
  41786. */
  41787. static readonly SUMMARY_LOGGING: number;
  41788. /**
  41789. * Detailled logging while loading
  41790. */
  41791. static readonly DETAILED_LOGGING: number;
  41792. /**
  41793. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41794. */
  41795. static ForceFullSceneLoadingForIncremental: boolean;
  41796. /**
  41797. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41798. */
  41799. static ShowLoadingScreen: boolean;
  41800. /**
  41801. * Defines the current logging level (while loading the scene)
  41802. * @ignorenaming
  41803. */
  41804. static loggingLevel: number;
  41805. /**
  41806. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41807. */
  41808. static CleanBoneMatrixWeights: boolean;
  41809. /**
  41810. * Event raised when a plugin is used to load a scene
  41811. */
  41812. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41813. private static _registeredPlugins;
  41814. private static _getDefaultPlugin;
  41815. private static _getPluginForExtension;
  41816. private static _getPluginForDirectLoad;
  41817. private static _getPluginForFilename;
  41818. private static _getDirectLoad;
  41819. private static _loadData;
  41820. private static _getFileInfo;
  41821. /**
  41822. * Gets a plugin that can load the given extension
  41823. * @param extension defines the extension to load
  41824. * @returns a plugin or null if none works
  41825. */
  41826. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41827. /**
  41828. * Gets a boolean indicating that the given extension can be loaded
  41829. * @param extension defines the extension to load
  41830. * @returns true if the extension is supported
  41831. */
  41832. static IsPluginForExtensionAvailable(extension: string): boolean;
  41833. /**
  41834. * Adds a new plugin to the list of registered plugins
  41835. * @param plugin defines the plugin to add
  41836. */
  41837. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41838. /**
  41839. * Import meshes into a scene
  41840. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41841. * @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)
  41842. * @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)
  41843. * @param scene the instance of BABYLON.Scene to append to
  41844. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41845. * @param onProgress a callback with a progress event for each file being loaded
  41846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41847. * @param pluginExtension the extension used to determine the plugin
  41848. * @returns The loaded plugin
  41849. */
  41850. 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>;
  41851. /**
  41852. * Import meshes into a scene
  41853. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41854. * @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)
  41855. * @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)
  41856. * @param scene the instance of BABYLON.Scene to append to
  41857. * @param onProgress a callback with a progress event for each file being loaded
  41858. * @param pluginExtension the extension used to determine the plugin
  41859. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41860. */
  41861. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41862. meshes: AbstractMesh[];
  41863. particleSystems: IParticleSystem[];
  41864. skeletons: Skeleton[];
  41865. animationGroups: AnimationGroup[];
  41866. }>;
  41867. /**
  41868. * Load a scene
  41869. * @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)
  41870. * @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)
  41871. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41872. * @param onSuccess a callback with the scene when import succeeds
  41873. * @param onProgress a callback with a progress event for each file being loaded
  41874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41875. * @param pluginExtension the extension used to determine the plugin
  41876. * @returns The loaded plugin
  41877. */
  41878. 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>;
  41879. /**
  41880. * Load a scene
  41881. * @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)
  41882. * @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)
  41883. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41884. * @param onProgress a callback with a progress event for each file being loaded
  41885. * @param pluginExtension the extension used to determine the plugin
  41886. * @returns The loaded scene
  41887. */
  41888. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41889. /**
  41890. * Append a scene
  41891. * @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)
  41892. * @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)
  41893. * @param scene is the instance of BABYLON.Scene to append to
  41894. * @param onSuccess a callback with the scene when import succeeds
  41895. * @param onProgress a callback with a progress event for each file being loaded
  41896. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41897. * @param pluginExtension the extension used to determine the plugin
  41898. * @returns The loaded plugin
  41899. */
  41900. 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>;
  41901. /**
  41902. * Append a scene
  41903. * @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)
  41904. * @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)
  41905. * @param scene is the instance of BABYLON.Scene to append to
  41906. * @param onProgress a callback with a progress event for each file being loaded
  41907. * @param pluginExtension the extension used to determine the plugin
  41908. * @returns The given scene
  41909. */
  41910. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41911. /**
  41912. * Load a scene into an asset container
  41913. * @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)
  41914. * @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)
  41915. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41916. * @param onSuccess a callback with the scene when import succeeds
  41917. * @param onProgress a callback with a progress event for each file being loaded
  41918. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41919. * @param pluginExtension the extension used to determine the plugin
  41920. * @returns The loaded plugin
  41921. */
  41922. 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>;
  41923. /**
  41924. * Load a scene into an asset container
  41925. * @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)
  41926. * @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)
  41927. * @param scene is the instance of Scene to append to
  41928. * @param onProgress a callback with a progress event for each file being loaded
  41929. * @param pluginExtension the extension used to determine the plugin
  41930. * @returns The loaded asset container
  41931. */
  41932. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41933. }
  41934. }
  41935. declare module BABYLON {
  41936. /**
  41937. * Google Daydream controller
  41938. */
  41939. export class DaydreamController extends WebVRController {
  41940. /**
  41941. * Base Url for the controller model.
  41942. */
  41943. static MODEL_BASE_URL: string;
  41944. /**
  41945. * File name for the controller model.
  41946. */
  41947. static MODEL_FILENAME: string;
  41948. /**
  41949. * Gamepad Id prefix used to identify Daydream Controller.
  41950. */
  41951. static readonly GAMEPAD_ID_PREFIX: string;
  41952. /**
  41953. * Creates a new DaydreamController from a gamepad
  41954. * @param vrGamepad the gamepad that the controller should be created from
  41955. */
  41956. constructor(vrGamepad: any);
  41957. /**
  41958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41959. * @param scene scene in which to add meshes
  41960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41961. */
  41962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41963. /**
  41964. * Called once for each button that changed state since the last frame
  41965. * @param buttonIdx Which button index changed
  41966. * @param state New state of the button
  41967. * @param changes Which properties on the state changed since last frame
  41968. */
  41969. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41970. }
  41971. }
  41972. declare module BABYLON {
  41973. /**
  41974. * Gear VR Controller
  41975. */
  41976. export class GearVRController extends WebVRController {
  41977. /**
  41978. * Base Url for the controller model.
  41979. */
  41980. static MODEL_BASE_URL: string;
  41981. /**
  41982. * File name for the controller model.
  41983. */
  41984. static MODEL_FILENAME: string;
  41985. /**
  41986. * Gamepad Id prefix used to identify this controller.
  41987. */
  41988. static readonly GAMEPAD_ID_PREFIX: string;
  41989. private readonly _buttonIndexToObservableNameMap;
  41990. /**
  41991. * Creates a new GearVRController from a gamepad
  41992. * @param vrGamepad the gamepad that the controller should be created from
  41993. */
  41994. constructor(vrGamepad: any);
  41995. /**
  41996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41997. * @param scene scene in which to add meshes
  41998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41999. */
  42000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42001. /**
  42002. * Called once for each button that changed state since the last frame
  42003. * @param buttonIdx Which button index changed
  42004. * @param state New state of the button
  42005. * @param changes Which properties on the state changed since last frame
  42006. */
  42007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42008. }
  42009. }
  42010. declare module BABYLON {
  42011. /**
  42012. * Generic Controller
  42013. */
  42014. export class GenericController extends WebVRController {
  42015. /**
  42016. * Base Url for the controller model.
  42017. */
  42018. static readonly MODEL_BASE_URL: string;
  42019. /**
  42020. * File name for the controller model.
  42021. */
  42022. static readonly MODEL_FILENAME: string;
  42023. /**
  42024. * Creates a new GenericController from a gamepad
  42025. * @param vrGamepad the gamepad that the controller should be created from
  42026. */
  42027. constructor(vrGamepad: any);
  42028. /**
  42029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42030. * @param scene scene in which to add meshes
  42031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42032. */
  42033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42034. /**
  42035. * Called once for each button that changed state since the last frame
  42036. * @param buttonIdx Which button index changed
  42037. * @param state New state of the button
  42038. * @param changes Which properties on the state changed since last frame
  42039. */
  42040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42041. }
  42042. }
  42043. declare module BABYLON {
  42044. /**
  42045. * Oculus Touch Controller
  42046. */
  42047. export class OculusTouchController extends WebVRController {
  42048. /**
  42049. * Base Url for the controller model.
  42050. */
  42051. static MODEL_BASE_URL: string;
  42052. /**
  42053. * File name for the left controller model.
  42054. */
  42055. static MODEL_LEFT_FILENAME: string;
  42056. /**
  42057. * File name for the right controller model.
  42058. */
  42059. static MODEL_RIGHT_FILENAME: string;
  42060. /**
  42061. * Fired when the secondary trigger on this controller is modified
  42062. */
  42063. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42064. /**
  42065. * Fired when the thumb rest on this controller is modified
  42066. */
  42067. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42068. /**
  42069. * Creates a new OculusTouchController from a gamepad
  42070. * @param vrGamepad the gamepad that the controller should be created from
  42071. */
  42072. constructor(vrGamepad: any);
  42073. /**
  42074. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42075. * @param scene scene in which to add meshes
  42076. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42077. */
  42078. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42079. /**
  42080. * Fired when the A button on this controller is modified
  42081. */
  42082. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42083. /**
  42084. * Fired when the B button on this controller is modified
  42085. */
  42086. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42087. /**
  42088. * Fired when the X button on this controller is modified
  42089. */
  42090. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42091. /**
  42092. * Fired when the Y button on this controller is modified
  42093. */
  42094. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42095. /**
  42096. * Called once for each button that changed state since the last frame
  42097. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42098. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42099. * 2) secondary trigger (same)
  42100. * 3) A (right) X (left), touch, pressed = value
  42101. * 4) B / Y
  42102. * 5) thumb rest
  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. * Vive Controller
  42113. */
  42114. export class ViveController extends WebVRController {
  42115. /**
  42116. * Base Url for the controller model.
  42117. */
  42118. static MODEL_BASE_URL: string;
  42119. /**
  42120. * File name for the controller model.
  42121. */
  42122. static MODEL_FILENAME: string;
  42123. /**
  42124. * Creates a new ViveController 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. * Fired when the left button on this controller is modified
  42136. */
  42137. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42138. /**
  42139. * Fired when the right button on this controller is modified
  42140. */
  42141. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42142. /**
  42143. * Fired when the menu button on this controller is modified
  42144. */
  42145. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42146. /**
  42147. * Called once for each button that changed state since the last frame
  42148. * Vive mapping:
  42149. * 0: touchpad
  42150. * 1: trigger
  42151. * 2: left AND right buttons
  42152. * 3: menu button
  42153. * @param buttonIdx Which button index changed
  42154. * @param state New state of the button
  42155. * @param changes Which properties on the state changed since last frame
  42156. */
  42157. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42158. }
  42159. }
  42160. declare module BABYLON {
  42161. /**
  42162. * Defines the WindowsMotionController object that the state of the windows motion controller
  42163. */
  42164. export class WindowsMotionController extends WebVRController {
  42165. /**
  42166. * The base url used to load the left and right controller models
  42167. */
  42168. static MODEL_BASE_URL: string;
  42169. /**
  42170. * The name of the left controller model file
  42171. */
  42172. static MODEL_LEFT_FILENAME: string;
  42173. /**
  42174. * The name of the right controller model file
  42175. */
  42176. static MODEL_RIGHT_FILENAME: string;
  42177. /**
  42178. * The controller name prefix for this controller type
  42179. */
  42180. static readonly GAMEPAD_ID_PREFIX: string;
  42181. /**
  42182. * The controller id pattern for this controller type
  42183. */
  42184. private static readonly GAMEPAD_ID_PATTERN;
  42185. private _loadedMeshInfo;
  42186. private readonly _mapping;
  42187. /**
  42188. * Fired when the trackpad on this controller is clicked
  42189. */
  42190. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42191. /**
  42192. * Fired when the trackpad on this controller is modified
  42193. */
  42194. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42195. /**
  42196. * The current x and y values of this controller's trackpad
  42197. */
  42198. trackpad: StickValues;
  42199. /**
  42200. * Creates a new WindowsMotionController from a gamepad
  42201. * @param vrGamepad the gamepad that the controller should be created from
  42202. */
  42203. constructor(vrGamepad: any);
  42204. /**
  42205. * Fired when the trigger on this controller is modified
  42206. */
  42207. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42208. /**
  42209. * Fired when the menu button on this controller is modified
  42210. */
  42211. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42212. /**
  42213. * Fired when the grip button on this controller is modified
  42214. */
  42215. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42216. /**
  42217. * Fired when the thumbstick button on this controller is modified
  42218. */
  42219. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42220. /**
  42221. * Fired when the touchpad button on this controller is modified
  42222. */
  42223. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42224. /**
  42225. * Fired when the touchpad values on this controller are modified
  42226. */
  42227. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42228. private _updateTrackpad;
  42229. /**
  42230. * Called once per frame by the engine.
  42231. */
  42232. update(): void;
  42233. /**
  42234. * Called once for each button that changed state since the last frame
  42235. * @param buttonIdx Which button index changed
  42236. * @param state New state of the button
  42237. * @param changes Which properties on the state changed since last frame
  42238. */
  42239. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42240. /**
  42241. * Moves the buttons on the controller mesh based on their current state
  42242. * @param buttonName the name of the button to move
  42243. * @param buttonValue the value of the button which determines the buttons new position
  42244. */
  42245. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42246. /**
  42247. * Moves the axis on the controller mesh based on its current state
  42248. * @param axis the index of the axis
  42249. * @param axisValue the value of the axis which determines the meshes new position
  42250. * @hidden
  42251. */
  42252. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42253. /**
  42254. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42255. * @param scene scene in which to add meshes
  42256. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42257. */
  42258. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42259. /**
  42260. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42261. * can be transformed by button presses and axes values, based on this._mapping.
  42262. *
  42263. * @param scene scene in which the meshes exist
  42264. * @param meshes list of meshes that make up the controller model to process
  42265. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42266. */
  42267. private processModel;
  42268. private createMeshInfo;
  42269. /**
  42270. * Gets the ray of the controller in the direction the controller is pointing
  42271. * @param length the length the resulting ray should be
  42272. * @returns a ray in the direction the controller is pointing
  42273. */
  42274. getForwardRay(length?: number): Ray;
  42275. /**
  42276. * Disposes of the controller
  42277. */
  42278. dispose(): void;
  42279. }
  42280. }
  42281. declare module BABYLON {
  42282. /**
  42283. * Class containing static functions to help procedurally build meshes
  42284. */
  42285. export class PolyhedronBuilder {
  42286. /**
  42287. * Creates a polyhedron mesh
  42288. * * 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
  42289. * * The parameter `size` (positive float, default 1) sets the polygon size
  42290. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42291. * * 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`
  42292. * * 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
  42293. * * 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)`)
  42294. * * 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
  42295. * * 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
  42296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42297. * * 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
  42298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42299. * @param name defines the name of the mesh
  42300. * @param options defines the options used to create the mesh
  42301. * @param scene defines the hosting scene
  42302. * @returns the polyhedron mesh
  42303. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42304. */
  42305. static CreatePolyhedron(name: string, options: {
  42306. type?: number;
  42307. size?: number;
  42308. sizeX?: number;
  42309. sizeY?: number;
  42310. sizeZ?: number;
  42311. custom?: any;
  42312. faceUV?: Vector4[];
  42313. faceColors?: Color4[];
  42314. flat?: boolean;
  42315. updatable?: boolean;
  42316. sideOrientation?: number;
  42317. frontUVs?: Vector4;
  42318. backUVs?: Vector4;
  42319. }, scene?: Nullable<Scene>): Mesh;
  42320. }
  42321. }
  42322. declare module BABYLON {
  42323. /**
  42324. * Gizmo that enables scaling a mesh along 3 axis
  42325. */
  42326. export class ScaleGizmo extends Gizmo {
  42327. /**
  42328. * Internal gizmo used for interactions on the x axis
  42329. */
  42330. xGizmo: AxisScaleGizmo;
  42331. /**
  42332. * Internal gizmo used for interactions on the y axis
  42333. */
  42334. yGizmo: AxisScaleGizmo;
  42335. /**
  42336. * Internal gizmo used for interactions on the z axis
  42337. */
  42338. zGizmo: AxisScaleGizmo;
  42339. /**
  42340. * Internal gizmo used to scale all axis equally
  42341. */
  42342. uniformScaleGizmo: AxisScaleGizmo;
  42343. private _meshAttached;
  42344. private _updateGizmoRotationToMatchAttachedMesh;
  42345. private _snapDistance;
  42346. private _scaleRatio;
  42347. private _uniformScalingMesh;
  42348. private _octahedron;
  42349. /** Fires an event when any of it's sub gizmos are dragged */
  42350. onDragStartObservable: Observable<unknown>;
  42351. /** Fires an event when any of it's sub gizmos are released from dragging */
  42352. onDragEndObservable: Observable<unknown>;
  42353. attachedMesh: Nullable<AbstractMesh>;
  42354. /**
  42355. * Creates a ScaleGizmo
  42356. * @param gizmoLayer The utility layer the gizmo will be added to
  42357. */
  42358. constructor(gizmoLayer?: UtilityLayerRenderer);
  42359. updateGizmoRotationToMatchAttachedMesh: boolean;
  42360. /**
  42361. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42362. */
  42363. snapDistance: number;
  42364. /**
  42365. * Ratio for the scale of the gizmo (Default: 1)
  42366. */
  42367. scaleRatio: number;
  42368. /**
  42369. * Disposes of the gizmo
  42370. */
  42371. dispose(): void;
  42372. }
  42373. }
  42374. declare module BABYLON {
  42375. /**
  42376. * Single axis scale gizmo
  42377. */
  42378. export class AxisScaleGizmo extends Gizmo {
  42379. /**
  42380. * Drag behavior responsible for the gizmos dragging interactions
  42381. */
  42382. dragBehavior: PointerDragBehavior;
  42383. private _pointerObserver;
  42384. /**
  42385. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42386. */
  42387. snapDistance: number;
  42388. /**
  42389. * Event that fires each time the gizmo snaps to a new location.
  42390. * * snapDistance is the the change in distance
  42391. */
  42392. onSnapObservable: Observable<{
  42393. snapDistance: number;
  42394. }>;
  42395. /**
  42396. * If the scaling operation should be done on all axis (default: false)
  42397. */
  42398. uniformScaling: boolean;
  42399. private _isEnabled;
  42400. private _parent;
  42401. private _arrow;
  42402. private _coloredMaterial;
  42403. private _hoverMaterial;
  42404. /**
  42405. * Creates an AxisScaleGizmo
  42406. * @param gizmoLayer The utility layer the gizmo will be added to
  42407. * @param dragAxis The axis which the gizmo will be able to scale on
  42408. * @param color The color of the gizmo
  42409. */
  42410. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  42411. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42412. /**
  42413. * If the gizmo is enabled
  42414. */
  42415. isEnabled: boolean;
  42416. /**
  42417. * Disposes of the gizmo
  42418. */
  42419. dispose(): void;
  42420. /**
  42421. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42422. * @param mesh The mesh to replace the default mesh of the gizmo
  42423. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42424. */
  42425. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42426. }
  42427. }
  42428. declare module BABYLON {
  42429. /**
  42430. * Bounding box gizmo
  42431. */
  42432. export class BoundingBoxGizmo extends Gizmo {
  42433. private _lineBoundingBox;
  42434. private _rotateSpheresParent;
  42435. private _scaleBoxesParent;
  42436. private _boundingDimensions;
  42437. private _renderObserver;
  42438. private _pointerObserver;
  42439. private _scaleDragSpeed;
  42440. private _tmpQuaternion;
  42441. private _tmpVector;
  42442. private _tmpRotationMatrix;
  42443. /**
  42444. * 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)
  42445. */
  42446. ignoreChildren: boolean;
  42447. /**
  42448. * 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)
  42449. */
  42450. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42451. /**
  42452. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42453. */
  42454. rotationSphereSize: number;
  42455. /**
  42456. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42457. */
  42458. scaleBoxSize: number;
  42459. /**
  42460. * 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)
  42461. */
  42462. fixedDragMeshScreenSize: boolean;
  42463. /**
  42464. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42465. */
  42466. fixedDragMeshScreenSizeDistanceFactor: number;
  42467. /**
  42468. * Fired when a rotation sphere or scale box is dragged
  42469. */
  42470. onDragStartObservable: Observable<{}>;
  42471. /**
  42472. * Fired when a scale box is dragged
  42473. */
  42474. onScaleBoxDragObservable: Observable<{}>;
  42475. /**
  42476. * Fired when a scale box drag is ended
  42477. */
  42478. onScaleBoxDragEndObservable: Observable<{}>;
  42479. /**
  42480. * Fired when a rotation sphere is dragged
  42481. */
  42482. onRotationSphereDragObservable: Observable<{}>;
  42483. /**
  42484. * Fired when a rotation sphere drag is ended
  42485. */
  42486. onRotationSphereDragEndObservable: Observable<{}>;
  42487. /**
  42488. * 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)
  42489. */
  42490. scalePivot: Nullable<Vector3>;
  42491. /**
  42492. * Mesh used as a pivot to rotate the attached mesh
  42493. */
  42494. private _anchorMesh;
  42495. private _existingMeshScale;
  42496. private _dragMesh;
  42497. private pointerDragBehavior;
  42498. private coloredMaterial;
  42499. private hoverColoredMaterial;
  42500. /**
  42501. * Sets the color of the bounding box gizmo
  42502. * @param color the color to set
  42503. */
  42504. setColor(color: Color3): void;
  42505. /**
  42506. * Creates an BoundingBoxGizmo
  42507. * @param gizmoLayer The utility layer the gizmo will be added to
  42508. * @param color The color of the gizmo
  42509. */
  42510. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42511. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42512. private _selectNode;
  42513. /**
  42514. * Updates the bounding box information for the Gizmo
  42515. */
  42516. updateBoundingBox(): void;
  42517. private _updateRotationSpheres;
  42518. private _updateScaleBoxes;
  42519. /**
  42520. * Enables rotation on the specified axis and disables rotation on the others
  42521. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42522. */
  42523. setEnabledRotationAxis(axis: string): void;
  42524. /**
  42525. * Enables/disables scaling
  42526. * @param enable if scaling should be enabled
  42527. */
  42528. setEnabledScaling(enable: boolean): void;
  42529. private _updateDummy;
  42530. /**
  42531. * Enables a pointer drag behavior on the bounding box of the gizmo
  42532. */
  42533. enableDragBehavior(): void;
  42534. /**
  42535. * Disposes of the gizmo
  42536. */
  42537. dispose(): void;
  42538. /**
  42539. * 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)
  42540. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42541. * @returns the bounding box mesh with the passed in mesh as a child
  42542. */
  42543. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42544. /**
  42545. * CustomMeshes are not supported by this gizmo
  42546. * @param mesh The mesh to replace the default mesh of the gizmo
  42547. */
  42548. setCustomMesh(mesh: Mesh): void;
  42549. }
  42550. }
  42551. declare module BABYLON {
  42552. /**
  42553. * Single plane rotation gizmo
  42554. */
  42555. export class PlaneRotationGizmo extends Gizmo {
  42556. /**
  42557. * Drag behavior responsible for the gizmos dragging interactions
  42558. */
  42559. dragBehavior: PointerDragBehavior;
  42560. private _pointerObserver;
  42561. /**
  42562. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42563. */
  42564. snapDistance: number;
  42565. /**
  42566. * Event that fires each time the gizmo snaps to a new location.
  42567. * * snapDistance is the the change in distance
  42568. */
  42569. onSnapObservable: Observable<{
  42570. snapDistance: number;
  42571. }>;
  42572. private _isEnabled;
  42573. private _parent;
  42574. /**
  42575. * Creates a PlaneRotationGizmo
  42576. * @param gizmoLayer The utility layer the gizmo will be added to
  42577. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42578. * @param color The color of the gizmo
  42579. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42580. */
  42581. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  42582. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42583. /**
  42584. * If the gizmo is enabled
  42585. */
  42586. isEnabled: boolean;
  42587. /**
  42588. * Disposes of the gizmo
  42589. */
  42590. dispose(): void;
  42591. }
  42592. }
  42593. declare module BABYLON {
  42594. /**
  42595. * Gizmo that enables rotating a mesh along 3 axis
  42596. */
  42597. export class RotationGizmo extends Gizmo {
  42598. /**
  42599. * Internal gizmo used for interactions on the x axis
  42600. */
  42601. xGizmo: PlaneRotationGizmo;
  42602. /**
  42603. * Internal gizmo used for interactions on the y axis
  42604. */
  42605. yGizmo: PlaneRotationGizmo;
  42606. /**
  42607. * Internal gizmo used for interactions on the z axis
  42608. */
  42609. zGizmo: PlaneRotationGizmo;
  42610. /** Fires an event when any of it's sub gizmos are dragged */
  42611. onDragStartObservable: Observable<unknown>;
  42612. /** Fires an event when any of it's sub gizmos are released from dragging */
  42613. onDragEndObservable: Observable<unknown>;
  42614. private _meshAttached;
  42615. attachedMesh: Nullable<AbstractMesh>;
  42616. /**
  42617. * Creates a RotationGizmo
  42618. * @param gizmoLayer The utility layer the gizmo will be added to
  42619. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42620. */
  42621. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42622. updateGizmoRotationToMatchAttachedMesh: boolean;
  42623. /**
  42624. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42625. */
  42626. snapDistance: number;
  42627. /**
  42628. * Ratio for the scale of the gizmo (Default: 1)
  42629. */
  42630. scaleRatio: number;
  42631. /**
  42632. * Disposes of the gizmo
  42633. */
  42634. dispose(): void;
  42635. /**
  42636. * CustomMeshes are not supported by this gizmo
  42637. * @param mesh The mesh to replace the default mesh of the gizmo
  42638. */
  42639. setCustomMesh(mesh: Mesh): void;
  42640. }
  42641. }
  42642. declare module BABYLON {
  42643. /**
  42644. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42645. */
  42646. export class GizmoManager implements IDisposable {
  42647. private scene;
  42648. /**
  42649. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42650. */
  42651. gizmos: {
  42652. positionGizmo: Nullable<PositionGizmo>;
  42653. rotationGizmo: Nullable<RotationGizmo>;
  42654. scaleGizmo: Nullable<ScaleGizmo>;
  42655. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42656. };
  42657. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42658. clearGizmoOnEmptyPointerEvent: boolean;
  42659. /** Fires an event when the manager is attached to a mesh */
  42660. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42661. private _gizmosEnabled;
  42662. private _pointerObserver;
  42663. private _attachedMesh;
  42664. private _boundingBoxColor;
  42665. private _defaultUtilityLayer;
  42666. private _defaultKeepDepthUtilityLayer;
  42667. /**
  42668. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42669. */
  42670. boundingBoxDragBehavior: SixDofDragBehavior;
  42671. /**
  42672. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42673. */
  42674. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42675. /**
  42676. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42677. */
  42678. usePointerToAttachGizmos: boolean;
  42679. /**
  42680. * Utility layer that the bounding box gizmo belongs to
  42681. */
  42682. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  42683. /**
  42684. * Utility layer that all gizmos besides bounding box belong to
  42685. */
  42686. readonly utilityLayer: UtilityLayerRenderer;
  42687. /**
  42688. * Instatiates a gizmo manager
  42689. * @param scene the scene to overlay the gizmos on top of
  42690. */
  42691. constructor(scene: Scene);
  42692. /**
  42693. * Attaches a set of gizmos to the specified mesh
  42694. * @param mesh The mesh the gizmo's should be attached to
  42695. */
  42696. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42697. /**
  42698. * If the position gizmo is enabled
  42699. */
  42700. positionGizmoEnabled: boolean;
  42701. /**
  42702. * If the rotation gizmo is enabled
  42703. */
  42704. rotationGizmoEnabled: boolean;
  42705. /**
  42706. * If the scale gizmo is enabled
  42707. */
  42708. scaleGizmoEnabled: boolean;
  42709. /**
  42710. * If the boundingBox gizmo is enabled
  42711. */
  42712. boundingBoxGizmoEnabled: boolean;
  42713. /**
  42714. * Disposes of the gizmo manager
  42715. */
  42716. dispose(): void;
  42717. }
  42718. }
  42719. declare module BABYLON {
  42720. /**
  42721. * A directional light is defined by a direction (what a surprise!).
  42722. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42723. * 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.
  42724. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42725. */
  42726. export class DirectionalLight extends ShadowLight {
  42727. private _shadowFrustumSize;
  42728. /**
  42729. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42730. */
  42731. /**
  42732. * Specifies a fix frustum size for the shadow generation.
  42733. */
  42734. shadowFrustumSize: number;
  42735. private _shadowOrthoScale;
  42736. /**
  42737. * Gets the shadow projection scale against the optimal computed one.
  42738. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42739. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42740. */
  42741. /**
  42742. * Sets the shadow projection scale against the optimal computed one.
  42743. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42744. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42745. */
  42746. shadowOrthoScale: number;
  42747. /**
  42748. * Automatically compute the projection matrix to best fit (including all the casters)
  42749. * on each frame.
  42750. */
  42751. autoUpdateExtends: boolean;
  42752. private _orthoLeft;
  42753. private _orthoRight;
  42754. private _orthoTop;
  42755. private _orthoBottom;
  42756. /**
  42757. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42758. * The directional light is emitted from everywhere in the given direction.
  42759. * It can cast shadows.
  42760. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42761. * @param name The friendly name of the light
  42762. * @param direction The direction of the light
  42763. * @param scene The scene the light belongs to
  42764. */
  42765. constructor(name: string, direction: Vector3, scene: Scene);
  42766. /**
  42767. * Returns the string "DirectionalLight".
  42768. * @return The class name
  42769. */
  42770. getClassName(): string;
  42771. /**
  42772. * Returns the integer 1.
  42773. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42774. */
  42775. getTypeID(): number;
  42776. /**
  42777. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42778. * Returns the DirectionalLight Shadow projection matrix.
  42779. */
  42780. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42781. /**
  42782. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42783. * Returns the DirectionalLight Shadow projection matrix.
  42784. */
  42785. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42786. /**
  42787. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42788. * Returns the DirectionalLight Shadow projection matrix.
  42789. */
  42790. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42791. protected _buildUniformLayout(): void;
  42792. /**
  42793. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42794. * @param effect The effect to update
  42795. * @param lightIndex The index of the light in the effect to update
  42796. * @returns The directional light
  42797. */
  42798. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42799. /**
  42800. * Gets the minZ used for shadow according to both the scene and the light.
  42801. *
  42802. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42803. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42804. * @param activeCamera The camera we are returning the min for
  42805. * @returns the depth min z
  42806. */
  42807. getDepthMinZ(activeCamera: Camera): number;
  42808. /**
  42809. * Gets the maxZ used for shadow according to both the scene and the light.
  42810. *
  42811. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42812. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42813. * @param activeCamera The camera we are returning the max for
  42814. * @returns the depth max z
  42815. */
  42816. getDepthMaxZ(activeCamera: Camera): number;
  42817. /**
  42818. * Prepares the list of defines specific to the light type.
  42819. * @param defines the list of defines
  42820. * @param lightIndex defines the index of the light for the effect
  42821. */
  42822. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42823. }
  42824. }
  42825. declare module BABYLON {
  42826. /**
  42827. * Class containing static functions to help procedurally build meshes
  42828. */
  42829. export class HemisphereBuilder {
  42830. /**
  42831. * Creates a hemisphere mesh
  42832. * @param name defines the name of the mesh
  42833. * @param options defines the options used to create the mesh
  42834. * @param scene defines the hosting scene
  42835. * @returns the hemisphere mesh
  42836. */
  42837. static CreateHemisphere(name: string, options: {
  42838. segments?: number;
  42839. diameter?: number;
  42840. sideOrientation?: number;
  42841. }, scene: any): Mesh;
  42842. }
  42843. }
  42844. declare module BABYLON {
  42845. /**
  42846. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42847. * These values define a cone of light starting from the position, emitting toward the direction.
  42848. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42849. * and the exponent defines the speed of the decay of the light with distance (reach).
  42850. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42851. */
  42852. export class SpotLight extends ShadowLight {
  42853. private _angle;
  42854. private _innerAngle;
  42855. private _cosHalfAngle;
  42856. private _lightAngleScale;
  42857. private _lightAngleOffset;
  42858. /**
  42859. * Gets the cone angle of the spot light in Radians.
  42860. */
  42861. /**
  42862. * Sets the cone angle of the spot light in Radians.
  42863. */
  42864. angle: number;
  42865. /**
  42866. * Only used in gltf falloff mode, this defines the angle where
  42867. * the directional falloff will start before cutting at angle which could be seen
  42868. * as outer angle.
  42869. */
  42870. /**
  42871. * Only used in gltf falloff mode, this defines the angle where
  42872. * the directional falloff will start before cutting at angle which could be seen
  42873. * as outer angle.
  42874. */
  42875. innerAngle: number;
  42876. private _shadowAngleScale;
  42877. /**
  42878. * Allows scaling the angle of the light for shadow generation only.
  42879. */
  42880. /**
  42881. * Allows scaling the angle of the light for shadow generation only.
  42882. */
  42883. shadowAngleScale: number;
  42884. /**
  42885. * The light decay speed with the distance from the emission spot.
  42886. */
  42887. exponent: number;
  42888. private _projectionTextureMatrix;
  42889. /**
  42890. * Allows reading the projecton texture
  42891. */
  42892. readonly projectionTextureMatrix: Matrix;
  42893. protected _projectionTextureLightNear: number;
  42894. /**
  42895. * Gets the near clip of the Spotlight for texture projection.
  42896. */
  42897. /**
  42898. * Sets the near clip of the Spotlight for texture projection.
  42899. */
  42900. projectionTextureLightNear: number;
  42901. protected _projectionTextureLightFar: number;
  42902. /**
  42903. * Gets the far clip of the Spotlight for texture projection.
  42904. */
  42905. /**
  42906. * Sets the far clip of the Spotlight for texture projection.
  42907. */
  42908. projectionTextureLightFar: number;
  42909. protected _projectionTextureUpDirection: Vector3;
  42910. /**
  42911. * Gets the Up vector of the Spotlight for texture projection.
  42912. */
  42913. /**
  42914. * Sets the Up vector of the Spotlight for texture projection.
  42915. */
  42916. projectionTextureUpDirection: Vector3;
  42917. private _projectionTexture;
  42918. /**
  42919. * Gets the projection texture of the light.
  42920. */
  42921. /**
  42922. * Sets the projection texture of the light.
  42923. */
  42924. projectionTexture: Nullable<BaseTexture>;
  42925. private _projectionTextureViewLightDirty;
  42926. private _projectionTextureProjectionLightDirty;
  42927. private _projectionTextureDirty;
  42928. private _projectionTextureViewTargetVector;
  42929. private _projectionTextureViewLightMatrix;
  42930. private _projectionTextureProjectionLightMatrix;
  42931. private _projectionTextureScalingMatrix;
  42932. /**
  42933. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42934. * It can cast shadows.
  42935. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42936. * @param name The light friendly name
  42937. * @param position The position of the spot light in the scene
  42938. * @param direction The direction of the light in the scene
  42939. * @param angle The cone angle of the light in Radians
  42940. * @param exponent The light decay speed with the distance from the emission spot
  42941. * @param scene The scene the lights belongs to
  42942. */
  42943. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42944. /**
  42945. * Returns the string "SpotLight".
  42946. * @returns the class name
  42947. */
  42948. getClassName(): string;
  42949. /**
  42950. * Returns the integer 2.
  42951. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42952. */
  42953. getTypeID(): number;
  42954. /**
  42955. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42956. */
  42957. protected _setDirection(value: Vector3): void;
  42958. /**
  42959. * Overrides the position setter to recompute the projection texture view light Matrix.
  42960. */
  42961. protected _setPosition(value: Vector3): void;
  42962. /**
  42963. * 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.
  42964. * Returns the SpotLight.
  42965. */
  42966. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42967. protected _computeProjectionTextureViewLightMatrix(): void;
  42968. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42969. /**
  42970. * Main function for light texture projection matrix computing.
  42971. */
  42972. protected _computeProjectionTextureMatrix(): void;
  42973. protected _buildUniformLayout(): void;
  42974. private _computeAngleValues;
  42975. /**
  42976. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42977. * @param effect The effect to update
  42978. * @param lightIndex The index of the light in the effect to update
  42979. * @returns The spot light
  42980. */
  42981. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42982. /**
  42983. * Disposes the light and the associated resources.
  42984. */
  42985. dispose(): void;
  42986. /**
  42987. * Prepares the list of defines specific to the light type.
  42988. * @param defines the list of defines
  42989. * @param lightIndex defines the index of the light for the effect
  42990. */
  42991. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42992. }
  42993. }
  42994. declare module BABYLON {
  42995. /**
  42996. * Gizmo that enables viewing a light
  42997. */
  42998. export class LightGizmo extends Gizmo {
  42999. private _lightMesh;
  43000. private _material;
  43001. private cachedPosition;
  43002. private cachedForward;
  43003. /**
  43004. * Creates a LightGizmo
  43005. * @param gizmoLayer The utility layer the gizmo will be added to
  43006. */
  43007. constructor(gizmoLayer?: UtilityLayerRenderer);
  43008. private _light;
  43009. /**
  43010. * The light that the gizmo is attached to
  43011. */
  43012. light: Nullable<Light>;
  43013. /**
  43014. * @hidden
  43015. * Updates the gizmo to match the attached mesh's position/rotation
  43016. */
  43017. protected _update(): void;
  43018. private static _Scale;
  43019. /**
  43020. * Creates the lines for a light mesh
  43021. */
  43022. private static _createLightLines;
  43023. /**
  43024. * Disposes of the light gizmo
  43025. */
  43026. dispose(): void;
  43027. private static _CreateHemisphericLightMesh;
  43028. private static _CreatePointLightMesh;
  43029. private static _CreateSpotLightMesh;
  43030. private static _CreateDirectionalLightMesh;
  43031. }
  43032. }
  43033. declare module BABYLON {
  43034. /** @hidden */
  43035. export var backgroundFragmentDeclaration: {
  43036. name: string;
  43037. shader: string;
  43038. };
  43039. }
  43040. declare module BABYLON {
  43041. /** @hidden */
  43042. export var backgroundUboDeclaration: {
  43043. name: string;
  43044. shader: string;
  43045. };
  43046. }
  43047. declare module BABYLON {
  43048. /** @hidden */
  43049. export var backgroundPixelShader: {
  43050. name: string;
  43051. shader: string;
  43052. };
  43053. }
  43054. declare module BABYLON {
  43055. /** @hidden */
  43056. export var backgroundVertexDeclaration: {
  43057. name: string;
  43058. shader: string;
  43059. };
  43060. }
  43061. declare module BABYLON {
  43062. /** @hidden */
  43063. export var backgroundVertexShader: {
  43064. name: string;
  43065. shader: string;
  43066. };
  43067. }
  43068. declare module BABYLON {
  43069. /**
  43070. * Background material used to create an efficient environement around your scene.
  43071. */
  43072. export class BackgroundMaterial extends PushMaterial {
  43073. /**
  43074. * Standard reflectance value at parallel view angle.
  43075. */
  43076. static StandardReflectance0: number;
  43077. /**
  43078. * Standard reflectance value at grazing angle.
  43079. */
  43080. static StandardReflectance90: number;
  43081. protected _primaryColor: Color3;
  43082. /**
  43083. * Key light Color (multiply against the environement texture)
  43084. */
  43085. primaryColor: Color3;
  43086. protected __perceptualColor: Nullable<Color3>;
  43087. /**
  43088. * Experimental Internal Use Only.
  43089. *
  43090. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43091. * This acts as a helper to set the primary color to a more "human friendly" value.
  43092. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43093. * output color as close as possible from the chosen value.
  43094. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43095. * part of lighting setup.)
  43096. */ private _perceptualColor: Nullable<Color3>;
  43097. protected _primaryColorShadowLevel: float;
  43098. /**
  43099. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43100. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43101. */
  43102. primaryColorShadowLevel: float;
  43103. protected _primaryColorHighlightLevel: float;
  43104. /**
  43105. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43106. * The primary color is used at the level chosen to define what the white area would look.
  43107. */
  43108. primaryColorHighlightLevel: float;
  43109. protected _reflectionTexture: Nullable<BaseTexture>;
  43110. /**
  43111. * Reflection Texture used in the material.
  43112. * Should be author in a specific way for the best result (refer to the documentation).
  43113. */
  43114. reflectionTexture: Nullable<BaseTexture>;
  43115. protected _reflectionBlur: float;
  43116. /**
  43117. * Reflection Texture level of blur.
  43118. *
  43119. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43120. * texture twice.
  43121. */
  43122. reflectionBlur: float;
  43123. protected _diffuseTexture: Nullable<BaseTexture>;
  43124. /**
  43125. * Diffuse Texture used in the material.
  43126. * Should be author in a specific way for the best result (refer to the documentation).
  43127. */
  43128. diffuseTexture: Nullable<BaseTexture>;
  43129. protected _shadowLights: Nullable<IShadowLight[]>;
  43130. /**
  43131. * Specify the list of lights casting shadow on the material.
  43132. * All scene shadow lights will be included if null.
  43133. */
  43134. shadowLights: Nullable<IShadowLight[]>;
  43135. protected _shadowLevel: float;
  43136. /**
  43137. * Helps adjusting the shadow to a softer level if required.
  43138. * 0 means black shadows and 1 means no shadows.
  43139. */
  43140. shadowLevel: float;
  43141. protected _sceneCenter: Vector3;
  43142. /**
  43143. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43144. * It is usually zero but might be interesting to modify according to your setup.
  43145. */
  43146. sceneCenter: Vector3;
  43147. protected _opacityFresnel: boolean;
  43148. /**
  43149. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43150. * This helps ensuring a nice transition when the camera goes under the ground.
  43151. */
  43152. opacityFresnel: boolean;
  43153. protected _reflectionFresnel: boolean;
  43154. /**
  43155. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43156. * This helps adding a mirror texture on the ground.
  43157. */
  43158. reflectionFresnel: boolean;
  43159. protected _reflectionFalloffDistance: number;
  43160. /**
  43161. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43162. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43163. */
  43164. reflectionFalloffDistance: number;
  43165. protected _reflectionAmount: number;
  43166. /**
  43167. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43168. */
  43169. reflectionAmount: number;
  43170. protected _reflectionReflectance0: number;
  43171. /**
  43172. * This specifies the weight of the reflection at grazing angle.
  43173. */
  43174. reflectionReflectance0: number;
  43175. protected _reflectionReflectance90: number;
  43176. /**
  43177. * This specifies the weight of the reflection at a perpendicular point of view.
  43178. */
  43179. reflectionReflectance90: number;
  43180. /**
  43181. * Sets the reflection reflectance fresnel values according to the default standard
  43182. * empirically know to work well :-)
  43183. */
  43184. reflectionStandardFresnelWeight: number;
  43185. protected _useRGBColor: boolean;
  43186. /**
  43187. * Helps to directly use the maps channels instead of their level.
  43188. */
  43189. useRGBColor: boolean;
  43190. protected _enableNoise: boolean;
  43191. /**
  43192. * This helps reducing the banding effect that could occur on the background.
  43193. */
  43194. enableNoise: boolean;
  43195. /**
  43196. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43197. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43198. * Recommended to be keep at 1.0 except for special cases.
  43199. */
  43200. fovMultiplier: number;
  43201. private _fovMultiplier;
  43202. /**
  43203. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43204. */
  43205. useEquirectangularFOV: boolean;
  43206. private _maxSimultaneousLights;
  43207. /**
  43208. * Number of Simultaneous lights allowed on the material.
  43209. */
  43210. maxSimultaneousLights: int;
  43211. /**
  43212. * Default configuration related to image processing available in the Background Material.
  43213. */
  43214. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43215. /**
  43216. * Keep track of the image processing observer to allow dispose and replace.
  43217. */
  43218. private _imageProcessingObserver;
  43219. /**
  43220. * Attaches a new image processing configuration to the PBR Material.
  43221. * @param configuration (if null the scene configuration will be use)
  43222. */
  43223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43224. /**
  43225. * Gets the image processing configuration used either in this material.
  43226. */
  43227. /**
  43228. * Sets the Default image processing configuration used either in the this material.
  43229. *
  43230. * If sets to null, the scene one is in use.
  43231. */
  43232. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43233. /**
  43234. * Gets wether the color curves effect is enabled.
  43235. */
  43236. /**
  43237. * Sets wether the color curves effect is enabled.
  43238. */
  43239. cameraColorCurvesEnabled: boolean;
  43240. /**
  43241. * Gets wether the color grading effect is enabled.
  43242. */
  43243. /**
  43244. * Gets wether the color grading effect is enabled.
  43245. */
  43246. cameraColorGradingEnabled: boolean;
  43247. /**
  43248. * Gets wether tonemapping is enabled or not.
  43249. */
  43250. /**
  43251. * Sets wether tonemapping is enabled or not
  43252. */
  43253. cameraToneMappingEnabled: boolean;
  43254. /**
  43255. * The camera exposure used on this material.
  43256. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43257. * This corresponds to a photographic exposure.
  43258. */
  43259. /**
  43260. * The camera exposure used on this material.
  43261. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43262. * This corresponds to a photographic exposure.
  43263. */
  43264. cameraExposure: float;
  43265. /**
  43266. * Gets The camera contrast used on this material.
  43267. */
  43268. /**
  43269. * Sets The camera contrast used on this material.
  43270. */
  43271. cameraContrast: float;
  43272. /**
  43273. * Gets the Color Grading 2D Lookup Texture.
  43274. */
  43275. /**
  43276. * Sets the Color Grading 2D Lookup Texture.
  43277. */
  43278. cameraColorGradingTexture: Nullable<BaseTexture>;
  43279. /**
  43280. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43281. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43282. * 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;
  43283. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43284. */
  43285. /**
  43286. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43287. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43288. * 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;
  43289. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43290. */
  43291. cameraColorCurves: Nullable<ColorCurves>;
  43292. /**
  43293. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43294. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43295. */
  43296. switchToBGR: boolean;
  43297. private _renderTargets;
  43298. private _reflectionControls;
  43299. private _white;
  43300. private _primaryShadowColor;
  43301. private _primaryHighlightColor;
  43302. /**
  43303. * Instantiates a Background Material in the given scene
  43304. * @param name The friendly name of the material
  43305. * @param scene The scene to add the material to
  43306. */
  43307. constructor(name: string, scene: Scene);
  43308. /**
  43309. * Gets a boolean indicating that current material needs to register RTT
  43310. */
  43311. readonly hasRenderTargetTextures: boolean;
  43312. /**
  43313. * The entire material has been created in order to prevent overdraw.
  43314. * @returns false
  43315. */
  43316. needAlphaTesting(): boolean;
  43317. /**
  43318. * The entire material has been created in order to prevent overdraw.
  43319. * @returns true if blending is enable
  43320. */
  43321. needAlphaBlending(): boolean;
  43322. /**
  43323. * Checks wether the material is ready to be rendered for a given mesh.
  43324. * @param mesh The mesh to render
  43325. * @param subMesh The submesh to check against
  43326. * @param useInstances Specify wether or not the material is used with instances
  43327. * @returns true if all the dependencies are ready (Textures, Effects...)
  43328. */
  43329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43330. /**
  43331. * Compute the primary color according to the chosen perceptual color.
  43332. */
  43333. private _computePrimaryColorFromPerceptualColor;
  43334. /**
  43335. * Compute the highlights and shadow colors according to their chosen levels.
  43336. */
  43337. private _computePrimaryColors;
  43338. /**
  43339. * Build the uniform buffer used in the material.
  43340. */
  43341. buildUniformLayout(): void;
  43342. /**
  43343. * Unbind the material.
  43344. */
  43345. unbind(): void;
  43346. /**
  43347. * Bind only the world matrix to the material.
  43348. * @param world The world matrix to bind.
  43349. */
  43350. bindOnlyWorldMatrix(world: Matrix): void;
  43351. /**
  43352. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43353. * @param world The world matrix to bind.
  43354. * @param subMesh The submesh to bind for.
  43355. */
  43356. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43357. /**
  43358. * Dispose the material.
  43359. * @param forceDisposeEffect Force disposal of the associated effect.
  43360. * @param forceDisposeTextures Force disposal of the associated textures.
  43361. */
  43362. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43363. /**
  43364. * Clones the material.
  43365. * @param name The cloned name.
  43366. * @returns The cloned material.
  43367. */
  43368. clone(name: string): BackgroundMaterial;
  43369. /**
  43370. * Serializes the current material to its JSON representation.
  43371. * @returns The JSON representation.
  43372. */
  43373. serialize(): any;
  43374. /**
  43375. * Gets the class name of the material
  43376. * @returns "BackgroundMaterial"
  43377. */
  43378. getClassName(): string;
  43379. /**
  43380. * Parse a JSON input to create back a background material.
  43381. * @param source The JSON data to parse
  43382. * @param scene The scene to create the parsed material in
  43383. * @param rootUrl The root url of the assets the material depends upon
  43384. * @returns the instantiated BackgroundMaterial.
  43385. */
  43386. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43387. }
  43388. }
  43389. declare module BABYLON {
  43390. /**
  43391. * Represents the different options available during the creation of
  43392. * a Environment helper.
  43393. *
  43394. * This can control the default ground, skybox and image processing setup of your scene.
  43395. */
  43396. export interface IEnvironmentHelperOptions {
  43397. /**
  43398. * Specifies wether or not to create a ground.
  43399. * True by default.
  43400. */
  43401. createGround: boolean;
  43402. /**
  43403. * Specifies the ground size.
  43404. * 15 by default.
  43405. */
  43406. groundSize: number;
  43407. /**
  43408. * The texture used on the ground for the main color.
  43409. * Comes from the BabylonJS CDN by default.
  43410. *
  43411. * Remarks: Can be either a texture or a url.
  43412. */
  43413. groundTexture: string | BaseTexture;
  43414. /**
  43415. * The color mixed in the ground texture by default.
  43416. * BabylonJS clearColor by default.
  43417. */
  43418. groundColor: Color3;
  43419. /**
  43420. * Specifies the ground opacity.
  43421. * 1 by default.
  43422. */
  43423. groundOpacity: number;
  43424. /**
  43425. * Enables the ground to receive shadows.
  43426. * True by default.
  43427. */
  43428. enableGroundShadow: boolean;
  43429. /**
  43430. * Helps preventing the shadow to be fully black on the ground.
  43431. * 0.5 by default.
  43432. */
  43433. groundShadowLevel: number;
  43434. /**
  43435. * Creates a mirror texture attach to the ground.
  43436. * false by default.
  43437. */
  43438. enableGroundMirror: boolean;
  43439. /**
  43440. * Specifies the ground mirror size ratio.
  43441. * 0.3 by default as the default kernel is 64.
  43442. */
  43443. groundMirrorSizeRatio: number;
  43444. /**
  43445. * Specifies the ground mirror blur kernel size.
  43446. * 64 by default.
  43447. */
  43448. groundMirrorBlurKernel: number;
  43449. /**
  43450. * Specifies the ground mirror visibility amount.
  43451. * 1 by default
  43452. */
  43453. groundMirrorAmount: number;
  43454. /**
  43455. * Specifies the ground mirror reflectance weight.
  43456. * This uses the standard weight of the background material to setup the fresnel effect
  43457. * of the mirror.
  43458. * 1 by default.
  43459. */
  43460. groundMirrorFresnelWeight: number;
  43461. /**
  43462. * Specifies the ground mirror Falloff distance.
  43463. * This can helps reducing the size of the reflection.
  43464. * 0 by Default.
  43465. */
  43466. groundMirrorFallOffDistance: number;
  43467. /**
  43468. * Specifies the ground mirror texture type.
  43469. * Unsigned Int by Default.
  43470. */
  43471. groundMirrorTextureType: number;
  43472. /**
  43473. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43474. * the shown objects.
  43475. */
  43476. groundYBias: number;
  43477. /**
  43478. * Specifies wether or not to create a skybox.
  43479. * True by default.
  43480. */
  43481. createSkybox: boolean;
  43482. /**
  43483. * Specifies the skybox size.
  43484. * 20 by default.
  43485. */
  43486. skyboxSize: number;
  43487. /**
  43488. * The texture used on the skybox for the main color.
  43489. * Comes from the BabylonJS CDN by default.
  43490. *
  43491. * Remarks: Can be either a texture or a url.
  43492. */
  43493. skyboxTexture: string | BaseTexture;
  43494. /**
  43495. * The color mixed in the skybox texture by default.
  43496. * BabylonJS clearColor by default.
  43497. */
  43498. skyboxColor: Color3;
  43499. /**
  43500. * The background rotation around the Y axis of the scene.
  43501. * This helps aligning the key lights of your scene with the background.
  43502. * 0 by default.
  43503. */
  43504. backgroundYRotation: number;
  43505. /**
  43506. * Compute automatically the size of the elements to best fit with the scene.
  43507. */
  43508. sizeAuto: boolean;
  43509. /**
  43510. * Default position of the rootMesh if autoSize is not true.
  43511. */
  43512. rootPosition: Vector3;
  43513. /**
  43514. * Sets up the image processing in the scene.
  43515. * true by default.
  43516. */
  43517. setupImageProcessing: boolean;
  43518. /**
  43519. * The texture used as your environment texture in the scene.
  43520. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43521. *
  43522. * Remarks: Can be either a texture or a url.
  43523. */
  43524. environmentTexture: string | BaseTexture;
  43525. /**
  43526. * The value of the exposure to apply to the scene.
  43527. * 0.6 by default if setupImageProcessing is true.
  43528. */
  43529. cameraExposure: number;
  43530. /**
  43531. * The value of the contrast to apply to the scene.
  43532. * 1.6 by default if setupImageProcessing is true.
  43533. */
  43534. cameraContrast: number;
  43535. /**
  43536. * Specifies wether or not tonemapping should be enabled in the scene.
  43537. * true by default if setupImageProcessing is true.
  43538. */
  43539. toneMappingEnabled: boolean;
  43540. }
  43541. /**
  43542. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43543. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43544. * It also helps with the default setup of your imageProcessing configuration.
  43545. */
  43546. export class EnvironmentHelper {
  43547. /**
  43548. * Default ground texture URL.
  43549. */
  43550. private static _groundTextureCDNUrl;
  43551. /**
  43552. * Default skybox texture URL.
  43553. */
  43554. private static _skyboxTextureCDNUrl;
  43555. /**
  43556. * Default environment texture URL.
  43557. */
  43558. private static _environmentTextureCDNUrl;
  43559. /**
  43560. * Creates the default options for the helper.
  43561. */
  43562. private static _getDefaultOptions;
  43563. private _rootMesh;
  43564. /**
  43565. * Gets the root mesh created by the helper.
  43566. */
  43567. readonly rootMesh: Mesh;
  43568. private _skybox;
  43569. /**
  43570. * Gets the skybox created by the helper.
  43571. */
  43572. readonly skybox: Nullable<Mesh>;
  43573. private _skyboxTexture;
  43574. /**
  43575. * Gets the skybox texture created by the helper.
  43576. */
  43577. readonly skyboxTexture: Nullable<BaseTexture>;
  43578. private _skyboxMaterial;
  43579. /**
  43580. * Gets the skybox material created by the helper.
  43581. */
  43582. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43583. private _ground;
  43584. /**
  43585. * Gets the ground mesh created by the helper.
  43586. */
  43587. readonly ground: Nullable<Mesh>;
  43588. private _groundTexture;
  43589. /**
  43590. * Gets the ground texture created by the helper.
  43591. */
  43592. readonly groundTexture: Nullable<BaseTexture>;
  43593. private _groundMirror;
  43594. /**
  43595. * Gets the ground mirror created by the helper.
  43596. */
  43597. readonly groundMirror: Nullable<MirrorTexture>;
  43598. /**
  43599. * Gets the ground mirror render list to helps pushing the meshes
  43600. * you wish in the ground reflection.
  43601. */
  43602. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43603. private _groundMaterial;
  43604. /**
  43605. * Gets the ground material created by the helper.
  43606. */
  43607. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43608. /**
  43609. * Stores the creation options.
  43610. */
  43611. private readonly _scene;
  43612. private _options;
  43613. /**
  43614. * This observable will be notified with any error during the creation of the environment,
  43615. * mainly texture creation errors.
  43616. */
  43617. onErrorObservable: Observable<{
  43618. message?: string;
  43619. exception?: any;
  43620. }>;
  43621. /**
  43622. * constructor
  43623. * @param options Defines the options we want to customize the helper
  43624. * @param scene The scene to add the material to
  43625. */
  43626. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43627. /**
  43628. * Updates the background according to the new options
  43629. * @param options
  43630. */
  43631. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43632. /**
  43633. * Sets the primary color of all the available elements.
  43634. * @param color the main color to affect to the ground and the background
  43635. */
  43636. setMainColor(color: Color3): void;
  43637. /**
  43638. * Setup the image processing according to the specified options.
  43639. */
  43640. private _setupImageProcessing;
  43641. /**
  43642. * Setup the environment texture according to the specified options.
  43643. */
  43644. private _setupEnvironmentTexture;
  43645. /**
  43646. * Setup the background according to the specified options.
  43647. */
  43648. private _setupBackground;
  43649. /**
  43650. * Get the scene sizes according to the setup.
  43651. */
  43652. private _getSceneSize;
  43653. /**
  43654. * Setup the ground according to the specified options.
  43655. */
  43656. private _setupGround;
  43657. /**
  43658. * Setup the ground material according to the specified options.
  43659. */
  43660. private _setupGroundMaterial;
  43661. /**
  43662. * Setup the ground diffuse texture according to the specified options.
  43663. */
  43664. private _setupGroundDiffuseTexture;
  43665. /**
  43666. * Setup the ground mirror texture according to the specified options.
  43667. */
  43668. private _setupGroundMirrorTexture;
  43669. /**
  43670. * Setup the ground to receive the mirror texture.
  43671. */
  43672. private _setupMirrorInGroundMaterial;
  43673. /**
  43674. * Setup the skybox according to the specified options.
  43675. */
  43676. private _setupSkybox;
  43677. /**
  43678. * Setup the skybox material according to the specified options.
  43679. */
  43680. private _setupSkyboxMaterial;
  43681. /**
  43682. * Setup the skybox reflection texture according to the specified options.
  43683. */
  43684. private _setupSkyboxReflectionTexture;
  43685. private _errorHandler;
  43686. /**
  43687. * Dispose all the elements created by the Helper.
  43688. */
  43689. dispose(): void;
  43690. }
  43691. }
  43692. declare module BABYLON {
  43693. /**
  43694. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43695. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43696. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43697. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43698. */
  43699. export class PhotoDome extends TransformNode {
  43700. /**
  43701. * Define the image as a Monoscopic panoramic 360 image.
  43702. */
  43703. static readonly MODE_MONOSCOPIC: number;
  43704. /**
  43705. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43706. */
  43707. static readonly MODE_TOPBOTTOM: number;
  43708. /**
  43709. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43710. */
  43711. static readonly MODE_SIDEBYSIDE: number;
  43712. private _useDirectMapping;
  43713. /**
  43714. * The texture being displayed on the sphere
  43715. */
  43716. protected _photoTexture: Texture;
  43717. /**
  43718. * Gets or sets the texture being displayed on the sphere
  43719. */
  43720. photoTexture: Texture;
  43721. /**
  43722. * Observable raised when an error occured while loading the 360 image
  43723. */
  43724. onLoadErrorObservable: Observable<string>;
  43725. /**
  43726. * The skybox material
  43727. */
  43728. protected _material: BackgroundMaterial;
  43729. /**
  43730. * The surface used for the skybox
  43731. */
  43732. protected _mesh: Mesh;
  43733. /**
  43734. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43735. * Also see the options.resolution property.
  43736. */
  43737. fovMultiplier: number;
  43738. private _imageMode;
  43739. /**
  43740. * Gets or set the current video mode for the video. It can be:
  43741. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  43742. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43743. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43744. */
  43745. imageMode: number;
  43746. /**
  43747. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43748. * @param name Element's name, child elements will append suffixes for their own names.
  43749. * @param urlsOfPhoto defines the url of the photo to display
  43750. * @param options defines an object containing optional or exposed sub element properties
  43751. * @param onError defines a callback called when an error occured while loading the texture
  43752. */
  43753. constructor(name: string, urlOfPhoto: string, options: {
  43754. resolution?: number;
  43755. size?: number;
  43756. useDirectMapping?: boolean;
  43757. faceForward?: boolean;
  43758. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43759. private _onBeforeCameraRenderObserver;
  43760. private _changeImageMode;
  43761. /**
  43762. * Releases resources associated with this node.
  43763. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43764. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43765. */
  43766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43767. }
  43768. }
  43769. declare module BABYLON {
  43770. /** @hidden */
  43771. export var rgbdDecodePixelShader: {
  43772. name: string;
  43773. shader: string;
  43774. };
  43775. }
  43776. declare module BABYLON {
  43777. /**
  43778. * Class used to host texture specific utilities
  43779. */
  43780. export class BRDFTextureTools {
  43781. /**
  43782. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43783. * @param texture the texture to expand.
  43784. */
  43785. private static _ExpandDefaultBRDFTexture;
  43786. /**
  43787. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43788. * @param scene defines the hosting scene
  43789. * @returns the environment BRDF texture
  43790. */
  43791. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43792. private static _environmentBRDFBase64Texture;
  43793. }
  43794. }
  43795. declare module BABYLON {
  43796. /**
  43797. * @hidden
  43798. */
  43799. export interface IMaterialClearCoatDefines {
  43800. CLEARCOAT: boolean;
  43801. CLEARCOAT_DEFAULTIOR: boolean;
  43802. CLEARCOAT_TEXTURE: boolean;
  43803. CLEARCOAT_TEXTUREDIRECTUV: number;
  43804. CLEARCOAT_BUMP: boolean;
  43805. CLEARCOAT_BUMPDIRECTUV: number;
  43806. CLEARCOAT_TINT: boolean;
  43807. CLEARCOAT_TINT_TEXTURE: boolean;
  43808. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43809. /** @hidden */ private _areTexturesDirty: boolean;
  43810. }
  43811. /**
  43812. * Define the code related to the clear coat parameters of the pbr material.
  43813. */
  43814. export class PBRClearCoatConfiguration {
  43815. /**
  43816. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43817. * The default fits with a polyurethane material.
  43818. */
  43819. private static readonly _DefaultIndexOfRefraction;
  43820. private _isEnabled;
  43821. /**
  43822. * Defines if the clear coat is enabled in the material.
  43823. */
  43824. isEnabled: boolean;
  43825. /**
  43826. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43827. */
  43828. intensity: number;
  43829. /**
  43830. * Defines the clear coat layer roughness.
  43831. */
  43832. roughness: number;
  43833. private _indexOfRefraction;
  43834. /**
  43835. * Defines the index of refraction of the clear coat.
  43836. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43837. * The default fits with a polyurethane material.
  43838. * Changing the default value is more performance intensive.
  43839. */
  43840. indexOfRefraction: number;
  43841. private _texture;
  43842. /**
  43843. * Stores the clear coat values in a texture.
  43844. */
  43845. texture: Nullable<BaseTexture>;
  43846. private _bumpTexture;
  43847. /**
  43848. * Define the clear coat specific bump texture.
  43849. */
  43850. bumpTexture: Nullable<BaseTexture>;
  43851. private _isTintEnabled;
  43852. /**
  43853. * Defines if the clear coat tint is enabled in the material.
  43854. */
  43855. isTintEnabled: boolean;
  43856. /**
  43857. * Defines the clear coat tint of the material.
  43858. * This is only use if tint is enabled
  43859. */
  43860. tintColor: Color3;
  43861. /**
  43862. * Defines the distance at which the tint color should be found in the
  43863. * clear coat media.
  43864. * This is only use if tint is enabled
  43865. */
  43866. tintColorAtDistance: number;
  43867. /**
  43868. * Defines the clear coat layer thickness.
  43869. * This is only use if tint is enabled
  43870. */
  43871. tintThickness: number;
  43872. private _tintTexture;
  43873. /**
  43874. * Stores the clear tint values in a texture.
  43875. * rgb is tint
  43876. * a is a thickness factor
  43877. */
  43878. tintTexture: Nullable<BaseTexture>;
  43879. /** @hidden */
  43880. private _internalMarkAllSubMeshesAsTexturesDirty;
  43881. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43882. /**
  43883. * Instantiate a new istance of clear coat configuration.
  43884. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43885. */
  43886. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43887. /**
  43888. * Gets wehter the submesh is ready to be used or not.
  43889. * @param defines the list of "defines" to update.
  43890. * @param scene defines the scene the material belongs to.
  43891. * @param engine defines the engine the material belongs to.
  43892. * @param disableBumpMap defines wether the material disables bump or not.
  43893. * @returns - boolean indicating that the submesh is ready or not.
  43894. */
  43895. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43896. /**
  43897. * Checks to see if a texture is used in the material.
  43898. * @param defines the list of "defines" to update.
  43899. * @param scene defines the scene to the material belongs to.
  43900. */
  43901. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43902. /**
  43903. * Binds the material data.
  43904. * @param uniformBuffer defines the Uniform buffer to fill in.
  43905. * @param scene defines the scene the material belongs to.
  43906. * @param engine defines the engine the material belongs to.
  43907. * @param disableBumpMap defines wether the material disables bump or not.
  43908. * @param isFrozen defines wether the material is frozen or not.
  43909. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43910. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43911. */
  43912. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43913. /**
  43914. * Checks to see if a texture is used in the material.
  43915. * @param texture - Base texture to use.
  43916. * @returns - Boolean specifying if a texture is used in the material.
  43917. */
  43918. hasTexture(texture: BaseTexture): boolean;
  43919. /**
  43920. * Returns an array of the actively used textures.
  43921. * @param activeTextures Array of BaseTextures
  43922. */
  43923. getActiveTextures(activeTextures: BaseTexture[]): void;
  43924. /**
  43925. * Returns the animatable textures.
  43926. * @param animatables Array of animatable textures.
  43927. */
  43928. getAnimatables(animatables: IAnimatable[]): void;
  43929. /**
  43930. * Disposes the resources of the material.
  43931. * @param forceDisposeTextures - Forces the disposal of all textures.
  43932. */
  43933. dispose(forceDisposeTextures?: boolean): void;
  43934. /**
  43935. * Get the current class name of the texture useful for serialization or dynamic coding.
  43936. * @returns "PBRClearCoatConfiguration"
  43937. */
  43938. getClassName(): string;
  43939. /**
  43940. * Add fallbacks to the effect fallbacks list.
  43941. * @param defines defines the Base texture to use.
  43942. * @param fallbacks defines the current fallback list.
  43943. * @param currentRank defines the current fallback rank.
  43944. * @returns the new fallback rank.
  43945. */
  43946. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43947. /**
  43948. * Add the required uniforms to the current list.
  43949. * @param uniforms defines the current uniform list.
  43950. */
  43951. static AddUniforms(uniforms: string[]): void;
  43952. /**
  43953. * Add the required samplers to the current list.
  43954. * @param samplers defines the current sampler list.
  43955. */
  43956. static AddSamplers(samplers: string[]): void;
  43957. /**
  43958. * Add the required uniforms to the current buffer.
  43959. * @param uniformBuffer defines the current uniform buffer.
  43960. */
  43961. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43962. /**
  43963. * Makes a duplicate of the current configuration into another one.
  43964. * @param clearCoatConfiguration define the config where to copy the info
  43965. */
  43966. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43967. /**
  43968. * Serializes this clear coat configuration.
  43969. * @returns - An object with the serialized config.
  43970. */
  43971. serialize(): any;
  43972. /**
  43973. * Parses a anisotropy Configuration from a serialized object.
  43974. * @param source - Serialized object.
  43975. * @param scene Defines the scene we are parsing for
  43976. * @param rootUrl Defines the rootUrl to load from
  43977. */
  43978. parse(source: any, scene: Scene, rootUrl: string): void;
  43979. }
  43980. }
  43981. declare module BABYLON {
  43982. /**
  43983. * @hidden
  43984. */
  43985. export interface IMaterialAnisotropicDefines {
  43986. ANISOTROPIC: boolean;
  43987. ANISOTROPIC_TEXTURE: boolean;
  43988. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43989. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  43990. }
  43991. /**
  43992. * Define the code related to the anisotropic parameters of the pbr material.
  43993. */
  43994. export class PBRAnisotropicConfiguration {
  43995. private _isEnabled;
  43996. /**
  43997. * Defines if the anisotropy is enabled in the material.
  43998. */
  43999. isEnabled: boolean;
  44000. /**
  44001. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44002. */
  44003. intensity: number;
  44004. /**
  44005. * Defines if the effect is along the tangents, bitangents or in between.
  44006. * By default, the effect is "strectching" the highlights along the tangents.
  44007. */
  44008. direction: Vector2;
  44009. private _texture;
  44010. /**
  44011. * Stores the anisotropy values in a texture.
  44012. * rg is direction (like normal from -1 to 1)
  44013. * b is a intensity
  44014. */
  44015. texture: Nullable<BaseTexture>;
  44016. /** @hidden */
  44017. private _internalMarkAllSubMeshesAsTexturesDirty;
  44018. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44019. /**
  44020. * Instantiate a new istance of anisotropy configuration.
  44021. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44022. */
  44023. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44024. /**
  44025. * Specifies that the submesh is ready to be used.
  44026. * @param defines the list of "defines" to update.
  44027. * @param scene defines the scene the material belongs to.
  44028. * @returns - boolean indicating that the submesh is ready or not.
  44029. */
  44030. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44031. /**
  44032. * Checks to see if a texture is used in the material.
  44033. * @param defines the list of "defines" to update.
  44034. * @param mesh the mesh we are preparing the defines for.
  44035. * @param scene defines the scene the material belongs to.
  44036. */
  44037. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44038. /**
  44039. * Binds the material data.
  44040. * @param uniformBuffer defines the Uniform buffer to fill in.
  44041. * @param scene defines the scene the material belongs to.
  44042. * @param isFrozen defines wether the material is frozen or not.
  44043. */
  44044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44045. /**
  44046. * Checks to see if a texture is used in the material.
  44047. * @param texture - Base texture to use.
  44048. * @returns - Boolean specifying if a texture is used in the material.
  44049. */
  44050. hasTexture(texture: BaseTexture): boolean;
  44051. /**
  44052. * Returns an array of the actively used textures.
  44053. * @param activeTextures Array of BaseTextures
  44054. */
  44055. getActiveTextures(activeTextures: BaseTexture[]): void;
  44056. /**
  44057. * Returns the animatable textures.
  44058. * @param animatables Array of animatable textures.
  44059. */
  44060. getAnimatables(animatables: IAnimatable[]): void;
  44061. /**
  44062. * Disposes the resources of the material.
  44063. * @param forceDisposeTextures - Forces the disposal of all textures.
  44064. */
  44065. dispose(forceDisposeTextures?: boolean): void;
  44066. /**
  44067. * Get the current class name of the texture useful for serialization or dynamic coding.
  44068. * @returns "PBRAnisotropicConfiguration"
  44069. */
  44070. getClassName(): string;
  44071. /**
  44072. * Add fallbacks to the effect fallbacks list.
  44073. * @param defines defines the Base texture to use.
  44074. * @param fallbacks defines the current fallback list.
  44075. * @param currentRank defines the current fallback rank.
  44076. * @returns the new fallback rank.
  44077. */
  44078. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44079. /**
  44080. * Add the required uniforms to the current list.
  44081. * @param uniforms defines the current uniform list.
  44082. */
  44083. static AddUniforms(uniforms: string[]): void;
  44084. /**
  44085. * Add the required uniforms to the current buffer.
  44086. * @param uniformBuffer defines the current uniform buffer.
  44087. */
  44088. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44089. /**
  44090. * Add the required samplers to the current list.
  44091. * @param samplers defines the current sampler list.
  44092. */
  44093. static AddSamplers(samplers: string[]): void;
  44094. /**
  44095. * Makes a duplicate of the current configuration into another one.
  44096. * @param anisotropicConfiguration define the config where to copy the info
  44097. */
  44098. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44099. /**
  44100. * Serializes this anisotropy configuration.
  44101. * @returns - An object with the serialized config.
  44102. */
  44103. serialize(): any;
  44104. /**
  44105. * Parses a anisotropy Configuration from a serialized object.
  44106. * @param source - Serialized object.
  44107. * @param scene Defines the scene we are parsing for
  44108. * @param rootUrl Defines the rootUrl to load from
  44109. */
  44110. parse(source: any, scene: Scene, rootUrl: string): void;
  44111. }
  44112. }
  44113. declare module BABYLON {
  44114. /**
  44115. * @hidden
  44116. */
  44117. export interface IMaterialBRDFDefines {
  44118. BRDF_V_HEIGHT_CORRELATED: boolean;
  44119. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44120. SPHERICAL_HARMONICS: boolean;
  44121. /** @hidden */ private _areMiscDirty: boolean;
  44122. }
  44123. /**
  44124. * Define the code related to the BRDF parameters of the pbr material.
  44125. */
  44126. export class PBRBRDFConfiguration {
  44127. /**
  44128. * Default value used for the energy conservation.
  44129. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44130. */
  44131. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44132. /**
  44133. * Default value used for the Smith Visibility Height Correlated mode.
  44134. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44135. */
  44136. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44137. /**
  44138. * Default value used for the IBL diffuse part.
  44139. * This can help switching back to the polynomials mode globally which is a tiny bit
  44140. * less GPU intensive at the drawback of a lower quality.
  44141. */
  44142. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44143. private _useEnergyConservation;
  44144. /**
  44145. * Defines if the material uses energy conservation.
  44146. */
  44147. useEnergyConservation: boolean;
  44148. private _useSmithVisibilityHeightCorrelated;
  44149. /**
  44150. * LEGACY Mode set to false
  44151. * Defines if the material uses height smith correlated visibility term.
  44152. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44153. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44154. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44155. * Not relying on height correlated will also disable energy conservation.
  44156. */
  44157. useSmithVisibilityHeightCorrelated: boolean;
  44158. private _useSphericalHarmonics;
  44159. /**
  44160. * LEGACY Mode set to false
  44161. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44162. * diffuse part of the IBL.
  44163. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44164. * to the ground truth.
  44165. */
  44166. useSphericalHarmonics: boolean;
  44167. /** @hidden */
  44168. private _internalMarkAllSubMeshesAsMiscDirty;
  44169. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  44170. /**
  44171. * Instantiate a new istance of clear coat configuration.
  44172. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44173. */
  44174. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44175. /**
  44176. * Checks to see if a texture is used in the material.
  44177. * @param defines the list of "defines" to update.
  44178. */
  44179. prepareDefines(defines: IMaterialBRDFDefines): void;
  44180. /**
  44181. * Get the current class name of the texture useful for serialization or dynamic coding.
  44182. * @returns "PBRClearCoatConfiguration"
  44183. */
  44184. getClassName(): string;
  44185. /**
  44186. * Makes a duplicate of the current configuration into another one.
  44187. * @param brdfConfiguration define the config where to copy the info
  44188. */
  44189. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44190. /**
  44191. * Serializes this BRDF configuration.
  44192. * @returns - An object with the serialized config.
  44193. */
  44194. serialize(): any;
  44195. /**
  44196. * Parses a anisotropy Configuration from a serialized object.
  44197. * @param source - Serialized object.
  44198. * @param scene Defines the scene we are parsing for
  44199. * @param rootUrl Defines the rootUrl to load from
  44200. */
  44201. parse(source: any, scene: Scene, rootUrl: string): void;
  44202. }
  44203. }
  44204. declare module BABYLON {
  44205. /**
  44206. * @hidden
  44207. */
  44208. export interface IMaterialSheenDefines {
  44209. SHEEN: boolean;
  44210. SHEEN_TEXTURE: boolean;
  44211. SHEEN_TEXTUREDIRECTUV: number;
  44212. SHEEN_LINKWITHALBEDO: boolean;
  44213. /** @hidden */ private _areTexturesDirty: boolean;
  44214. }
  44215. /**
  44216. * Define the code related to the Sheen parameters of the pbr material.
  44217. */
  44218. export class PBRSheenConfiguration {
  44219. private _isEnabled;
  44220. /**
  44221. * Defines if the material uses sheen.
  44222. */
  44223. isEnabled: boolean;
  44224. private _linkSheenWithAlbedo;
  44225. /**
  44226. * Defines if the sheen is linked to the sheen color.
  44227. */
  44228. linkSheenWithAlbedo: boolean;
  44229. /**
  44230. * Defines the sheen intensity.
  44231. */
  44232. intensity: number;
  44233. /**
  44234. * Defines the sheen color.
  44235. */
  44236. color: Color3;
  44237. private _texture;
  44238. /**
  44239. * Stores the sheen tint values in a texture.
  44240. * rgb is tint
  44241. * a is a intensity
  44242. */
  44243. texture: Nullable<BaseTexture>;
  44244. /** @hidden */
  44245. private _internalMarkAllSubMeshesAsTexturesDirty;
  44246. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44247. /**
  44248. * Instantiate a new istance of clear coat configuration.
  44249. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44250. */
  44251. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44252. /**
  44253. * Specifies that the submesh is ready to be used.
  44254. * @param defines the list of "defines" to update.
  44255. * @param scene defines the scene the material belongs to.
  44256. * @returns - boolean indicating that the submesh is ready or not.
  44257. */
  44258. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44259. /**
  44260. * Checks to see if a texture is used in the material.
  44261. * @param defines the list of "defines" to update.
  44262. * @param scene defines the scene the material belongs to.
  44263. */
  44264. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44265. /**
  44266. * Binds the material data.
  44267. * @param uniformBuffer defines the Uniform buffer to fill in.
  44268. * @param scene defines the scene the material belongs to.
  44269. * @param isFrozen defines wether the material is frozen or not.
  44270. */
  44271. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44272. /**
  44273. * Checks to see if a texture is used in the material.
  44274. * @param texture - Base texture to use.
  44275. * @returns - Boolean specifying if a texture is used in the material.
  44276. */
  44277. hasTexture(texture: BaseTexture): boolean;
  44278. /**
  44279. * Returns an array of the actively used textures.
  44280. * @param activeTextures Array of BaseTextures
  44281. */
  44282. getActiveTextures(activeTextures: BaseTexture[]): void;
  44283. /**
  44284. * Returns the animatable textures.
  44285. * @param animatables Array of animatable textures.
  44286. */
  44287. getAnimatables(animatables: IAnimatable[]): void;
  44288. /**
  44289. * Disposes the resources of the material.
  44290. * @param forceDisposeTextures - Forces the disposal of all textures.
  44291. */
  44292. dispose(forceDisposeTextures?: boolean): void;
  44293. /**
  44294. * Get the current class name of the texture useful for serialization or dynamic coding.
  44295. * @returns "PBRSheenConfiguration"
  44296. */
  44297. getClassName(): string;
  44298. /**
  44299. * Add fallbacks to the effect fallbacks list.
  44300. * @param defines defines the Base texture to use.
  44301. * @param fallbacks defines the current fallback list.
  44302. * @param currentRank defines the current fallback rank.
  44303. * @returns the new fallback rank.
  44304. */
  44305. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44306. /**
  44307. * Add the required uniforms to the current list.
  44308. * @param uniforms defines the current uniform list.
  44309. */
  44310. static AddUniforms(uniforms: string[]): void;
  44311. /**
  44312. * Add the required uniforms to the current buffer.
  44313. * @param uniformBuffer defines the current uniform buffer.
  44314. */
  44315. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44316. /**
  44317. * Add the required samplers to the current list.
  44318. * @param samplers defines the current sampler list.
  44319. */
  44320. static AddSamplers(samplers: string[]): void;
  44321. /**
  44322. * Makes a duplicate of the current configuration into another one.
  44323. * @param sheenConfiguration define the config where to copy the info
  44324. */
  44325. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44326. /**
  44327. * Serializes this BRDF configuration.
  44328. * @returns - An object with the serialized config.
  44329. */
  44330. serialize(): any;
  44331. /**
  44332. * Parses a anisotropy Configuration from a serialized object.
  44333. * @param source - Serialized object.
  44334. * @param scene Defines the scene we are parsing for
  44335. * @param rootUrl Defines the rootUrl to load from
  44336. */
  44337. parse(source: any, scene: Scene, rootUrl: string): void;
  44338. }
  44339. }
  44340. declare module BABYLON {
  44341. /**
  44342. * @hidden
  44343. */
  44344. export interface IMaterialSubSurfaceDefines {
  44345. SUBSURFACE: boolean;
  44346. SS_REFRACTION: boolean;
  44347. SS_TRANSLUCENCY: boolean;
  44348. SS_SCATERRING: boolean;
  44349. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44350. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44351. SS_REFRACTIONMAP_3D: boolean;
  44352. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44353. SS_LODINREFRACTIONALPHA: boolean;
  44354. SS_GAMMAREFRACTION: boolean;
  44355. SS_RGBDREFRACTION: boolean;
  44356. SS_LINEARSPECULARREFRACTION: boolean;
  44357. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44358. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44359. /** @hidden */ private _areTexturesDirty: boolean;
  44360. }
  44361. /**
  44362. * Define the code related to the sub surface parameters of the pbr material.
  44363. */
  44364. export class PBRSubSurfaceConfiguration {
  44365. private _isRefractionEnabled;
  44366. /**
  44367. * Defines if the refraction is enabled in the material.
  44368. */
  44369. isRefractionEnabled: boolean;
  44370. private _isTranslucencyEnabled;
  44371. /**
  44372. * Defines if the translucency is enabled in the material.
  44373. */
  44374. isTranslucencyEnabled: boolean;
  44375. private _isScatteringEnabled;
  44376. /**
  44377. * Defines the refraction intensity of the material.
  44378. * The refraction when enabled replaces the Diffuse part of the material.
  44379. * The intensity helps transitionning between diffuse and refraction.
  44380. */
  44381. refractionIntensity: number;
  44382. /**
  44383. * Defines the translucency intensity of the material.
  44384. * When translucency has been enabled, this defines how much of the "translucency"
  44385. * is addded to the diffuse part of the material.
  44386. */
  44387. translucencyIntensity: number;
  44388. /**
  44389. * Defines the scattering intensity of the material.
  44390. * When scattering has been enabled, this defines how much of the "scattered light"
  44391. * is addded to the diffuse part of the material.
  44392. */
  44393. scatteringIntensity: number;
  44394. private _thicknessTexture;
  44395. /**
  44396. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44397. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44398. * 0 would mean minimumThickness
  44399. * 1 would mean maximumThickness
  44400. * The other channels might be use as a mask to vary the different effects intensity.
  44401. */
  44402. thicknessTexture: Nullable<BaseTexture>;
  44403. private _refractionTexture;
  44404. /**
  44405. * Defines the texture to use for refraction.
  44406. */
  44407. refractionTexture: Nullable<BaseTexture>;
  44408. private _indexOfRefraction;
  44409. /**
  44410. * Defines the index of refraction used in the material.
  44411. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44412. */
  44413. indexOfRefraction: number;
  44414. private _invertRefractionY;
  44415. /**
  44416. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44417. */
  44418. invertRefractionY: boolean;
  44419. private _linkRefractionWithTransparency;
  44420. /**
  44421. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44422. * Materials half opaque for instance using refraction could benefit from this control.
  44423. */
  44424. linkRefractionWithTransparency: boolean;
  44425. /**
  44426. * Defines the minimum thickness stored in the thickness map.
  44427. * If no thickness map is defined, this value will be used to simulate thickness.
  44428. */
  44429. minimumThickness: number;
  44430. /**
  44431. * Defines the maximum thickness stored in the thickness map.
  44432. */
  44433. maximumThickness: number;
  44434. /**
  44435. * Defines the volume tint of the material.
  44436. * This is used for both translucency and scattering.
  44437. */
  44438. tintColor: Color3;
  44439. /**
  44440. * Defines the distance at which the tint color should be found in the media.
  44441. * This is used for refraction only.
  44442. */
  44443. tintColorAtDistance: number;
  44444. /**
  44445. * Defines how far each channel transmit through the media.
  44446. * It is defined as a color to simplify it selection.
  44447. */
  44448. diffusionDistance: Color3;
  44449. private _useMaskFromThicknessTexture;
  44450. /**
  44451. * Stores the intensity of the different subsurface effects in the thickness texture.
  44452. * * the green channel is the translucency intensity.
  44453. * * the blue channel is the scattering intensity.
  44454. * * the alpha channel is the refraction intensity.
  44455. */
  44456. useMaskFromThicknessTexture: boolean;
  44457. /** @hidden */
  44458. private _internalMarkAllSubMeshesAsTexturesDirty;
  44459. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44460. /**
  44461. * Instantiate a new istance of sub surface configuration.
  44462. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44463. */
  44464. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44465. /**
  44466. * Gets wehter the submesh is ready to be used or not.
  44467. * @param defines the list of "defines" to update.
  44468. * @param scene defines the scene the material belongs to.
  44469. * @returns - boolean indicating that the submesh is ready or not.
  44470. */
  44471. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44472. /**
  44473. * Checks to see if a texture is used in the material.
  44474. * @param defines the list of "defines" to update.
  44475. * @param scene defines the scene to the material belongs to.
  44476. */
  44477. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44478. /**
  44479. * Binds the material data.
  44480. * @param uniformBuffer defines the Uniform buffer to fill in.
  44481. * @param scene defines the scene the material belongs to.
  44482. * @param engine defines the engine the material belongs to.
  44483. * @param isFrozen defines wether the material is frozen or not.
  44484. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44485. */
  44486. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44487. /**
  44488. * Unbinds the material from the mesh.
  44489. * @param activeEffect defines the effect that should be unbound from.
  44490. * @returns true if unbound, otherwise false
  44491. */
  44492. unbind(activeEffect: Effect): boolean;
  44493. /**
  44494. * Returns the texture used for refraction or null if none is used.
  44495. * @param scene defines the scene the material belongs to.
  44496. * @returns - Refraction texture if present. If no refraction texture and refraction
  44497. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44498. */
  44499. private _getRefractionTexture;
  44500. /**
  44501. * Returns true if alpha blending should be disabled.
  44502. */
  44503. readonly disableAlphaBlending: boolean;
  44504. /**
  44505. * Fills the list of render target textures.
  44506. * @param renderTargets the list of render targets to update
  44507. */
  44508. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44509. /**
  44510. * Checks to see if a texture is used in the material.
  44511. * @param texture - Base texture to use.
  44512. * @returns - Boolean specifying if a texture is used in the material.
  44513. */
  44514. hasTexture(texture: BaseTexture): boolean;
  44515. /**
  44516. * Gets a boolean indicating that current material needs to register RTT
  44517. * @returns true if this uses a render target otherwise false.
  44518. */
  44519. hasRenderTargetTextures(): boolean;
  44520. /**
  44521. * Returns an array of the actively used textures.
  44522. * @param activeTextures Array of BaseTextures
  44523. */
  44524. getActiveTextures(activeTextures: BaseTexture[]): void;
  44525. /**
  44526. * Returns the animatable textures.
  44527. * @param animatables Array of animatable textures.
  44528. */
  44529. getAnimatables(animatables: IAnimatable[]): void;
  44530. /**
  44531. * Disposes the resources of the material.
  44532. * @param forceDisposeTextures - Forces the disposal of all textures.
  44533. */
  44534. dispose(forceDisposeTextures?: boolean): void;
  44535. /**
  44536. * Get the current class name of the texture useful for serialization or dynamic coding.
  44537. * @returns "PBRSubSurfaceConfiguration"
  44538. */
  44539. getClassName(): string;
  44540. /**
  44541. * Add fallbacks to the effect fallbacks list.
  44542. * @param defines defines the Base texture to use.
  44543. * @param fallbacks defines the current fallback list.
  44544. * @param currentRank defines the current fallback rank.
  44545. * @returns the new fallback rank.
  44546. */
  44547. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44548. /**
  44549. * Add the required uniforms to the current list.
  44550. * @param uniforms defines the current uniform list.
  44551. */
  44552. static AddUniforms(uniforms: string[]): void;
  44553. /**
  44554. * Add the required samplers to the current list.
  44555. * @param samplers defines the current sampler list.
  44556. */
  44557. static AddSamplers(samplers: string[]): void;
  44558. /**
  44559. * Add the required uniforms to the current buffer.
  44560. * @param uniformBuffer defines the current uniform buffer.
  44561. */
  44562. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44563. /**
  44564. * Makes a duplicate of the current configuration into another one.
  44565. * @param configuration define the config where to copy the info
  44566. */
  44567. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44568. /**
  44569. * Serializes this Sub Surface configuration.
  44570. * @returns - An object with the serialized config.
  44571. */
  44572. serialize(): any;
  44573. /**
  44574. * Parses a anisotropy Configuration from a serialized object.
  44575. * @param source - Serialized object.
  44576. * @param scene Defines the scene we are parsing for
  44577. * @param rootUrl Defines the rootUrl to load from
  44578. */
  44579. parse(source: any, scene: Scene, rootUrl: string): void;
  44580. }
  44581. }
  44582. declare module BABYLON {
  44583. /** @hidden */
  44584. export var pbrFragmentDeclaration: {
  44585. name: string;
  44586. shader: string;
  44587. };
  44588. }
  44589. declare module BABYLON {
  44590. /** @hidden */
  44591. export var pbrUboDeclaration: {
  44592. name: string;
  44593. shader: string;
  44594. };
  44595. }
  44596. declare module BABYLON {
  44597. /** @hidden */
  44598. export var pbrFragmentExtraDeclaration: {
  44599. name: string;
  44600. shader: string;
  44601. };
  44602. }
  44603. declare module BABYLON {
  44604. /** @hidden */
  44605. export var pbrFragmentSamplersDeclaration: {
  44606. name: string;
  44607. shader: string;
  44608. };
  44609. }
  44610. declare module BABYLON {
  44611. /** @hidden */
  44612. export var pbrHelperFunctions: {
  44613. name: string;
  44614. shader: string;
  44615. };
  44616. }
  44617. declare module BABYLON {
  44618. /** @hidden */
  44619. export var harmonicsFunctions: {
  44620. name: string;
  44621. shader: string;
  44622. };
  44623. }
  44624. declare module BABYLON {
  44625. /** @hidden */
  44626. export var pbrDirectLightingSetupFunctions: {
  44627. name: string;
  44628. shader: string;
  44629. };
  44630. }
  44631. declare module BABYLON {
  44632. /** @hidden */
  44633. export var pbrDirectLightingFalloffFunctions: {
  44634. name: string;
  44635. shader: string;
  44636. };
  44637. }
  44638. declare module BABYLON {
  44639. /** @hidden */
  44640. export var pbrBRDFFunctions: {
  44641. name: string;
  44642. shader: string;
  44643. };
  44644. }
  44645. declare module BABYLON {
  44646. /** @hidden */
  44647. export var pbrDirectLightingFunctions: {
  44648. name: string;
  44649. shader: string;
  44650. };
  44651. }
  44652. declare module BABYLON {
  44653. /** @hidden */
  44654. export var pbrIBLFunctions: {
  44655. name: string;
  44656. shader: string;
  44657. };
  44658. }
  44659. declare module BABYLON {
  44660. /** @hidden */
  44661. export var pbrDebug: {
  44662. name: string;
  44663. shader: string;
  44664. };
  44665. }
  44666. declare module BABYLON {
  44667. /** @hidden */
  44668. export var pbrPixelShader: {
  44669. name: string;
  44670. shader: string;
  44671. };
  44672. }
  44673. declare module BABYLON {
  44674. /** @hidden */
  44675. export var pbrVertexDeclaration: {
  44676. name: string;
  44677. shader: string;
  44678. };
  44679. }
  44680. declare module BABYLON {
  44681. /** @hidden */
  44682. export var pbrVertexShader: {
  44683. name: string;
  44684. shader: string;
  44685. };
  44686. }
  44687. declare module BABYLON {
  44688. /**
  44689. * Manages the defines for the PBR Material.
  44690. * @hidden
  44691. */
  44692. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44693. PBR: boolean;
  44694. MAINUV1: boolean;
  44695. MAINUV2: boolean;
  44696. UV1: boolean;
  44697. UV2: boolean;
  44698. ALBEDO: boolean;
  44699. ALBEDODIRECTUV: number;
  44700. VERTEXCOLOR: boolean;
  44701. AMBIENT: boolean;
  44702. AMBIENTDIRECTUV: number;
  44703. AMBIENTINGRAYSCALE: boolean;
  44704. OPACITY: boolean;
  44705. VERTEXALPHA: boolean;
  44706. OPACITYDIRECTUV: number;
  44707. OPACITYRGB: boolean;
  44708. ALPHATEST: boolean;
  44709. DEPTHPREPASS: boolean;
  44710. ALPHABLEND: boolean;
  44711. ALPHAFROMALBEDO: boolean;
  44712. ALPHATESTVALUE: string;
  44713. SPECULAROVERALPHA: boolean;
  44714. RADIANCEOVERALPHA: boolean;
  44715. ALPHAFRESNEL: boolean;
  44716. LINEARALPHAFRESNEL: boolean;
  44717. PREMULTIPLYALPHA: boolean;
  44718. EMISSIVE: boolean;
  44719. EMISSIVEDIRECTUV: number;
  44720. REFLECTIVITY: boolean;
  44721. REFLECTIVITYDIRECTUV: number;
  44722. SPECULARTERM: boolean;
  44723. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44724. MICROSURFACEAUTOMATIC: boolean;
  44725. LODBASEDMICROSFURACE: boolean;
  44726. MICROSURFACEMAP: boolean;
  44727. MICROSURFACEMAPDIRECTUV: number;
  44728. METALLICWORKFLOW: boolean;
  44729. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44730. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44731. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44732. AOSTOREINMETALMAPRED: boolean;
  44733. ENVIRONMENTBRDF: boolean;
  44734. ENVIRONMENTBRDF_RGBD: boolean;
  44735. NORMAL: boolean;
  44736. TANGENT: boolean;
  44737. BUMP: boolean;
  44738. BUMPDIRECTUV: number;
  44739. OBJECTSPACE_NORMALMAP: boolean;
  44740. PARALLAX: boolean;
  44741. PARALLAXOCCLUSION: boolean;
  44742. NORMALXYSCALE: boolean;
  44743. LIGHTMAP: boolean;
  44744. LIGHTMAPDIRECTUV: number;
  44745. USELIGHTMAPASSHADOWMAP: boolean;
  44746. GAMMALIGHTMAP: boolean;
  44747. REFLECTION: boolean;
  44748. REFLECTIONMAP_3D: boolean;
  44749. REFLECTIONMAP_SPHERICAL: boolean;
  44750. REFLECTIONMAP_PLANAR: boolean;
  44751. REFLECTIONMAP_CUBIC: boolean;
  44752. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44753. REFLECTIONMAP_PROJECTION: boolean;
  44754. REFLECTIONMAP_SKYBOX: boolean;
  44755. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44756. REFLECTIONMAP_EXPLICIT: boolean;
  44757. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44758. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44759. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44760. INVERTCUBICMAP: boolean;
  44761. USESPHERICALFROMREFLECTIONMAP: boolean;
  44762. USEIRRADIANCEMAP: boolean;
  44763. SPHERICAL_HARMONICS: boolean;
  44764. USESPHERICALINVERTEX: boolean;
  44765. REFLECTIONMAP_OPPOSITEZ: boolean;
  44766. LODINREFLECTIONALPHA: boolean;
  44767. GAMMAREFLECTION: boolean;
  44768. RGBDREFLECTION: boolean;
  44769. LINEARSPECULARREFLECTION: boolean;
  44770. RADIANCEOCCLUSION: boolean;
  44771. HORIZONOCCLUSION: boolean;
  44772. INSTANCES: boolean;
  44773. NUM_BONE_INFLUENCERS: number;
  44774. BonesPerMesh: number;
  44775. BONETEXTURE: boolean;
  44776. NONUNIFORMSCALING: boolean;
  44777. MORPHTARGETS: boolean;
  44778. MORPHTARGETS_NORMAL: boolean;
  44779. MORPHTARGETS_TANGENT: boolean;
  44780. MORPHTARGETS_UV: boolean;
  44781. NUM_MORPH_INFLUENCERS: number;
  44782. IMAGEPROCESSING: boolean;
  44783. VIGNETTE: boolean;
  44784. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44785. VIGNETTEBLENDMODEOPAQUE: boolean;
  44786. TONEMAPPING: boolean;
  44787. TONEMAPPING_ACES: boolean;
  44788. CONTRAST: boolean;
  44789. COLORCURVES: boolean;
  44790. COLORGRADING: boolean;
  44791. COLORGRADING3D: boolean;
  44792. SAMPLER3DGREENDEPTH: boolean;
  44793. SAMPLER3DBGRMAP: boolean;
  44794. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44795. EXPOSURE: boolean;
  44796. MULTIVIEW: boolean;
  44797. USEPHYSICALLIGHTFALLOFF: boolean;
  44798. USEGLTFLIGHTFALLOFF: boolean;
  44799. TWOSIDEDLIGHTING: boolean;
  44800. SHADOWFLOAT: boolean;
  44801. CLIPPLANE: boolean;
  44802. CLIPPLANE2: boolean;
  44803. CLIPPLANE3: boolean;
  44804. CLIPPLANE4: boolean;
  44805. POINTSIZE: boolean;
  44806. FOG: boolean;
  44807. LOGARITHMICDEPTH: boolean;
  44808. FORCENORMALFORWARD: boolean;
  44809. SPECULARAA: boolean;
  44810. CLEARCOAT: boolean;
  44811. CLEARCOAT_DEFAULTIOR: boolean;
  44812. CLEARCOAT_TEXTURE: boolean;
  44813. CLEARCOAT_TEXTUREDIRECTUV: number;
  44814. CLEARCOAT_BUMP: boolean;
  44815. CLEARCOAT_BUMPDIRECTUV: number;
  44816. CLEARCOAT_TINT: boolean;
  44817. CLEARCOAT_TINT_TEXTURE: boolean;
  44818. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44819. ANISOTROPIC: boolean;
  44820. ANISOTROPIC_TEXTURE: boolean;
  44821. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44822. BRDF_V_HEIGHT_CORRELATED: boolean;
  44823. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44824. SHEEN: boolean;
  44825. SHEEN_TEXTURE: boolean;
  44826. SHEEN_TEXTUREDIRECTUV: number;
  44827. SHEEN_LINKWITHALBEDO: boolean;
  44828. SUBSURFACE: boolean;
  44829. SS_REFRACTION: boolean;
  44830. SS_TRANSLUCENCY: boolean;
  44831. SS_SCATERRING: boolean;
  44832. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44833. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44834. SS_REFRACTIONMAP_3D: boolean;
  44835. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44836. SS_LODINREFRACTIONALPHA: boolean;
  44837. SS_GAMMAREFRACTION: boolean;
  44838. SS_RGBDREFRACTION: boolean;
  44839. SS_LINEARSPECULARREFRACTION: boolean;
  44840. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44841. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44842. UNLIT: boolean;
  44843. DEBUGMODE: number;
  44844. /**
  44845. * Initializes the PBR Material defines.
  44846. */
  44847. constructor();
  44848. /**
  44849. * Resets the PBR Material defines.
  44850. */
  44851. reset(): void;
  44852. }
  44853. /**
  44854. * The Physically based material base class of BJS.
  44855. *
  44856. * This offers the main features of a standard PBR material.
  44857. * For more information, please refer to the documentation :
  44858. * https://doc.babylonjs.com/how_to/physically_based_rendering
  44859. */
  44860. export abstract class PBRBaseMaterial extends PushMaterial {
  44861. /**
  44862. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44863. */
  44864. static readonly PBRMATERIAL_OPAQUE: number;
  44865. /**
  44866. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44867. */
  44868. static readonly PBRMATERIAL_ALPHATEST: number;
  44869. /**
  44870. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44871. */
  44872. static readonly PBRMATERIAL_ALPHABLEND: number;
  44873. /**
  44874. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44875. * They are also discarded below the alpha cutoff threshold to improve performances.
  44876. */
  44877. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44878. /**
  44879. * Defines the default value of how much AO map is occluding the analytical lights
  44880. * (point spot...).
  44881. */
  44882. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44883. /**
  44884. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44885. */
  44886. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44887. /**
  44888. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44889. * to enhance interoperability with other engines.
  44890. */
  44891. static readonly LIGHTFALLOFF_GLTF: number;
  44892. /**
  44893. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44894. * to enhance interoperability with other materials.
  44895. */
  44896. static readonly LIGHTFALLOFF_STANDARD: number;
  44897. /**
  44898. * Intensity of the direct lights e.g. the four lights available in your scene.
  44899. * This impacts both the direct diffuse and specular highlights.
  44900. */
  44901. protected _directIntensity: number;
  44902. /**
  44903. * Intensity of the emissive part of the material.
  44904. * This helps controlling the emissive effect without modifying the emissive color.
  44905. */
  44906. protected _emissiveIntensity: number;
  44907. /**
  44908. * Intensity of the environment e.g. how much the environment will light the object
  44909. * either through harmonics for rough material or through the refelction for shiny ones.
  44910. */
  44911. protected _environmentIntensity: number;
  44912. /**
  44913. * This is a special control allowing the reduction of the specular highlights coming from the
  44914. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44915. */
  44916. protected _specularIntensity: number;
  44917. /**
  44918. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44919. */
  44920. private _lightingInfos;
  44921. /**
  44922. * Debug Control allowing disabling the bump map on this material.
  44923. */
  44924. protected _disableBumpMap: boolean;
  44925. /**
  44926. * AKA Diffuse Texture in standard nomenclature.
  44927. */
  44928. protected _albedoTexture: Nullable<BaseTexture>;
  44929. /**
  44930. * AKA Occlusion Texture in other nomenclature.
  44931. */
  44932. protected _ambientTexture: Nullable<BaseTexture>;
  44933. /**
  44934. * AKA Occlusion Texture Intensity in other nomenclature.
  44935. */
  44936. protected _ambientTextureStrength: number;
  44937. /**
  44938. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44939. * 1 means it completely occludes it
  44940. * 0 mean it has no impact
  44941. */
  44942. protected _ambientTextureImpactOnAnalyticalLights: number;
  44943. /**
  44944. * Stores the alpha values in a texture.
  44945. */
  44946. protected _opacityTexture: Nullable<BaseTexture>;
  44947. /**
  44948. * Stores the reflection values in a texture.
  44949. */
  44950. protected _reflectionTexture: Nullable<BaseTexture>;
  44951. /**
  44952. * Stores the emissive values in a texture.
  44953. */
  44954. protected _emissiveTexture: Nullable<BaseTexture>;
  44955. /**
  44956. * AKA Specular texture in other nomenclature.
  44957. */
  44958. protected _reflectivityTexture: Nullable<BaseTexture>;
  44959. /**
  44960. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44961. */
  44962. protected _metallicTexture: Nullable<BaseTexture>;
  44963. /**
  44964. * Specifies the metallic scalar of the metallic/roughness workflow.
  44965. * Can also be used to scale the metalness values of the metallic texture.
  44966. */
  44967. protected _metallic: Nullable<number>;
  44968. /**
  44969. * Specifies the roughness scalar of the metallic/roughness workflow.
  44970. * Can also be used to scale the roughness values of the metallic texture.
  44971. */
  44972. protected _roughness: Nullable<number>;
  44973. /**
  44974. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44975. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44976. */
  44977. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44978. /**
  44979. * Stores surface normal data used to displace a mesh in a texture.
  44980. */
  44981. protected _bumpTexture: Nullable<BaseTexture>;
  44982. /**
  44983. * Stores the pre-calculated light information of a mesh in a texture.
  44984. */
  44985. protected _lightmapTexture: Nullable<BaseTexture>;
  44986. /**
  44987. * The color of a material in ambient lighting.
  44988. */
  44989. protected _ambientColor: Color3;
  44990. /**
  44991. * AKA Diffuse Color in other nomenclature.
  44992. */
  44993. protected _albedoColor: Color3;
  44994. /**
  44995. * AKA Specular Color in other nomenclature.
  44996. */
  44997. protected _reflectivityColor: Color3;
  44998. /**
  44999. * The color applied when light is reflected from a material.
  45000. */
  45001. protected _reflectionColor: Color3;
  45002. /**
  45003. * The color applied when light is emitted from a material.
  45004. */
  45005. protected _emissiveColor: Color3;
  45006. /**
  45007. * AKA Glossiness in other nomenclature.
  45008. */
  45009. protected _microSurface: number;
  45010. /**
  45011. * Specifies that the material will use the light map as a show map.
  45012. */
  45013. protected _useLightmapAsShadowmap: boolean;
  45014. /**
  45015. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45016. * makes the reflect vector face the model (under horizon).
  45017. */
  45018. protected _useHorizonOcclusion: boolean;
  45019. /**
  45020. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45021. * too much the area relying on ambient texture to define their ambient occlusion.
  45022. */
  45023. protected _useRadianceOcclusion: boolean;
  45024. /**
  45025. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45026. */
  45027. protected _useAlphaFromAlbedoTexture: boolean;
  45028. /**
  45029. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45030. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45031. */
  45032. protected _useSpecularOverAlpha: boolean;
  45033. /**
  45034. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45035. */
  45036. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45037. /**
  45038. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45039. */
  45040. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45041. /**
  45042. * Specifies if the metallic texture contains the roughness information in its green channel.
  45043. */
  45044. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45045. /**
  45046. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45047. */
  45048. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45049. /**
  45050. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45051. */
  45052. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45053. /**
  45054. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45055. */
  45056. protected _useAmbientInGrayScale: boolean;
  45057. /**
  45058. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45059. * The material will try to infer what glossiness each pixel should be.
  45060. */
  45061. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45062. /**
  45063. * Defines the falloff type used in this material.
  45064. * It by default is Physical.
  45065. */
  45066. protected _lightFalloff: number;
  45067. /**
  45068. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45069. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45070. */
  45071. protected _useRadianceOverAlpha: boolean;
  45072. /**
  45073. * Allows using an object space normal map (instead of tangent space).
  45074. */
  45075. protected _useObjectSpaceNormalMap: boolean;
  45076. /**
  45077. * Allows using the bump map in parallax mode.
  45078. */
  45079. protected _useParallax: boolean;
  45080. /**
  45081. * Allows using the bump map in parallax occlusion mode.
  45082. */
  45083. protected _useParallaxOcclusion: boolean;
  45084. /**
  45085. * Controls the scale bias of the parallax mode.
  45086. */
  45087. protected _parallaxScaleBias: number;
  45088. /**
  45089. * If sets to true, disables all the lights affecting the material.
  45090. */
  45091. protected _disableLighting: boolean;
  45092. /**
  45093. * Number of Simultaneous lights allowed on the material.
  45094. */
  45095. protected _maxSimultaneousLights: number;
  45096. /**
  45097. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45098. */
  45099. protected _invertNormalMapX: boolean;
  45100. /**
  45101. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45102. */
  45103. protected _invertNormalMapY: boolean;
  45104. /**
  45105. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45106. */
  45107. protected _twoSidedLighting: boolean;
  45108. /**
  45109. * Defines the alpha limits in alpha test mode.
  45110. */
  45111. protected _alphaCutOff: number;
  45112. /**
  45113. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45114. */
  45115. protected _forceAlphaTest: boolean;
  45116. /**
  45117. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45118. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45119. */
  45120. protected _useAlphaFresnel: boolean;
  45121. /**
  45122. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45123. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45124. */
  45125. protected _useLinearAlphaFresnel: boolean;
  45126. /**
  45127. * The transparency mode of the material.
  45128. */
  45129. protected _transparencyMode: Nullable<number>;
  45130. /**
  45131. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45132. * from cos thetav and roughness:
  45133. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45134. */
  45135. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45136. /**
  45137. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45138. */
  45139. protected _forceIrradianceInFragment: boolean;
  45140. /**
  45141. * Force normal to face away from face.
  45142. */
  45143. protected _forceNormalForward: boolean;
  45144. /**
  45145. * Enables specular anti aliasing in the PBR shader.
  45146. * It will both interacts on the Geometry for analytical and IBL lighting.
  45147. * It also prefilter the roughness map based on the bump values.
  45148. */
  45149. protected _enableSpecularAntiAliasing: boolean;
  45150. /**
  45151. * Default configuration related to image processing available in the PBR Material.
  45152. */
  45153. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45154. /**
  45155. * Keep track of the image processing observer to allow dispose and replace.
  45156. */
  45157. private _imageProcessingObserver;
  45158. /**
  45159. * Attaches a new image processing configuration to the PBR Material.
  45160. * @param configuration
  45161. */
  45162. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45163. /**
  45164. * Stores the available render targets.
  45165. */
  45166. private _renderTargets;
  45167. /**
  45168. * Sets the global ambient color for the material used in lighting calculations.
  45169. */
  45170. private _globalAmbientColor;
  45171. /**
  45172. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45173. */
  45174. private _useLogarithmicDepth;
  45175. /**
  45176. * If set to true, no lighting calculations will be applied.
  45177. */
  45178. private _unlit;
  45179. private _debugMode;
  45180. /**
  45181. * @hidden
  45182. * This is reserved for the inspector.
  45183. * Defines the material debug mode.
  45184. * It helps seeing only some components of the material while troubleshooting.
  45185. */
  45186. debugMode: number;
  45187. /**
  45188. * @hidden
  45189. * This is reserved for the inspector.
  45190. * Specify from where on screen the debug mode should start.
  45191. * The value goes from -1 (full screen) to 1 (not visible)
  45192. * It helps with side by side comparison against the final render
  45193. * This defaults to -1
  45194. */
  45195. private debugLimit;
  45196. /**
  45197. * @hidden
  45198. * This is reserved for the inspector.
  45199. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45200. * You can use the factor to better multiply the final value.
  45201. */
  45202. private debugFactor;
  45203. /**
  45204. * Defines the clear coat layer parameters for the material.
  45205. */
  45206. readonly clearCoat: PBRClearCoatConfiguration;
  45207. /**
  45208. * Defines the anisotropic parameters for the material.
  45209. */
  45210. readonly anisotropy: PBRAnisotropicConfiguration;
  45211. /**
  45212. * Defines the BRDF parameters for the material.
  45213. */
  45214. readonly brdf: PBRBRDFConfiguration;
  45215. /**
  45216. * Defines the Sheen parameters for the material.
  45217. */
  45218. readonly sheen: PBRSheenConfiguration;
  45219. /**
  45220. * Defines the SubSurface parameters for the material.
  45221. */
  45222. readonly subSurface: PBRSubSurfaceConfiguration;
  45223. /**
  45224. * Custom callback helping to override the default shader used in the material.
  45225. */
  45226. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45227. /**
  45228. * Instantiates a new PBRMaterial instance.
  45229. *
  45230. * @param name The material name
  45231. * @param scene The scene the material will be use in.
  45232. */
  45233. constructor(name: string, scene: Scene);
  45234. /**
  45235. * Gets a boolean indicating that current material needs to register RTT
  45236. */
  45237. readonly hasRenderTargetTextures: boolean;
  45238. /**
  45239. * Gets the name of the material class.
  45240. */
  45241. getClassName(): string;
  45242. /**
  45243. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45244. */
  45245. /**
  45246. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45247. */
  45248. useLogarithmicDepth: boolean;
  45249. /**
  45250. * Gets the current transparency mode.
  45251. */
  45252. /**
  45253. * Sets the transparency mode of the material.
  45254. *
  45255. * | Value | Type | Description |
  45256. * | ----- | ----------------------------------- | ----------- |
  45257. * | 0 | OPAQUE | |
  45258. * | 1 | ALPHATEST | |
  45259. * | 2 | ALPHABLEND | |
  45260. * | 3 | ALPHATESTANDBLEND | |
  45261. *
  45262. */
  45263. transparencyMode: Nullable<number>;
  45264. /**
  45265. * Returns true if alpha blending should be disabled.
  45266. */
  45267. private readonly _disableAlphaBlending;
  45268. /**
  45269. * Specifies whether or not this material should be rendered in alpha blend mode.
  45270. */
  45271. needAlphaBlending(): boolean;
  45272. /**
  45273. * Specifies if the mesh will require alpha blending.
  45274. * @param mesh - BJS mesh.
  45275. */
  45276. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45277. /**
  45278. * Specifies whether or not this material should be rendered in alpha test mode.
  45279. */
  45280. needAlphaTesting(): boolean;
  45281. /**
  45282. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45283. */
  45284. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45285. /**
  45286. * Gets the texture used for the alpha test.
  45287. */
  45288. getAlphaTestTexture(): Nullable<BaseTexture>;
  45289. /**
  45290. * Specifies that the submesh is ready to be used.
  45291. * @param mesh - BJS mesh.
  45292. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45293. * @param useInstances - Specifies that instances should be used.
  45294. * @returns - boolean indicating that the submesh is ready or not.
  45295. */
  45296. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45297. /**
  45298. * Specifies if the material uses metallic roughness workflow.
  45299. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45300. */
  45301. isMetallicWorkflow(): boolean;
  45302. private _prepareEffect;
  45303. private _prepareDefines;
  45304. /**
  45305. * Force shader compilation
  45306. */
  45307. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45308. clipPlane: boolean;
  45309. }>): void;
  45310. /**
  45311. * Initializes the uniform buffer layout for the shader.
  45312. */
  45313. buildUniformLayout(): void;
  45314. /**
  45315. * Unbinds the material from the mesh
  45316. */
  45317. unbind(): void;
  45318. /**
  45319. * Binds the submesh data.
  45320. * @param world - The world matrix.
  45321. * @param mesh - The BJS mesh.
  45322. * @param subMesh - A submesh of the BJS mesh.
  45323. */
  45324. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45325. /**
  45326. * Returns the animatable textures.
  45327. * @returns - Array of animatable textures.
  45328. */
  45329. getAnimatables(): IAnimatable[];
  45330. /**
  45331. * Returns the texture used for reflections.
  45332. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45333. */
  45334. private _getReflectionTexture;
  45335. /**
  45336. * Returns an array of the actively used textures.
  45337. * @returns - Array of BaseTextures
  45338. */
  45339. getActiveTextures(): BaseTexture[];
  45340. /**
  45341. * Checks to see if a texture is used in the material.
  45342. * @param texture - Base texture to use.
  45343. * @returns - Boolean specifying if a texture is used in the material.
  45344. */
  45345. hasTexture(texture: BaseTexture): boolean;
  45346. /**
  45347. * Disposes the resources of the material.
  45348. * @param forceDisposeEffect - Forces the disposal of effects.
  45349. * @param forceDisposeTextures - Forces the disposal of all textures.
  45350. */
  45351. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45352. }
  45353. }
  45354. declare module BABYLON {
  45355. /**
  45356. * The Physically based material of BJS.
  45357. *
  45358. * This offers the main features of a standard PBR material.
  45359. * For more information, please refer to the documentation :
  45360. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45361. */
  45362. export class PBRMaterial extends PBRBaseMaterial {
  45363. /**
  45364. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45365. */
  45366. static readonly PBRMATERIAL_OPAQUE: number;
  45367. /**
  45368. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45369. */
  45370. static readonly PBRMATERIAL_ALPHATEST: number;
  45371. /**
  45372. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45373. */
  45374. static readonly PBRMATERIAL_ALPHABLEND: number;
  45375. /**
  45376. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45377. * They are also discarded below the alpha cutoff threshold to improve performances.
  45378. */
  45379. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45380. /**
  45381. * Defines the default value of how much AO map is occluding the analytical lights
  45382. * (point spot...).
  45383. */
  45384. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45385. /**
  45386. * Intensity of the direct lights e.g. the four lights available in your scene.
  45387. * This impacts both the direct diffuse and specular highlights.
  45388. */
  45389. directIntensity: number;
  45390. /**
  45391. * Intensity of the emissive part of the material.
  45392. * This helps controlling the emissive effect without modifying the emissive color.
  45393. */
  45394. emissiveIntensity: number;
  45395. /**
  45396. * Intensity of the environment e.g. how much the environment will light the object
  45397. * either through harmonics for rough material or through the refelction for shiny ones.
  45398. */
  45399. environmentIntensity: number;
  45400. /**
  45401. * This is a special control allowing the reduction of the specular highlights coming from the
  45402. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45403. */
  45404. specularIntensity: number;
  45405. /**
  45406. * Debug Control allowing disabling the bump map on this material.
  45407. */
  45408. disableBumpMap: boolean;
  45409. /**
  45410. * AKA Diffuse Texture in standard nomenclature.
  45411. */
  45412. albedoTexture: BaseTexture;
  45413. /**
  45414. * AKA Occlusion Texture in other nomenclature.
  45415. */
  45416. ambientTexture: BaseTexture;
  45417. /**
  45418. * AKA Occlusion Texture Intensity in other nomenclature.
  45419. */
  45420. ambientTextureStrength: number;
  45421. /**
  45422. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45423. * 1 means it completely occludes it
  45424. * 0 mean it has no impact
  45425. */
  45426. ambientTextureImpactOnAnalyticalLights: number;
  45427. /**
  45428. * Stores the alpha values in a texture.
  45429. */
  45430. opacityTexture: BaseTexture;
  45431. /**
  45432. * Stores the reflection values in a texture.
  45433. */
  45434. reflectionTexture: Nullable<BaseTexture>;
  45435. /**
  45436. * Stores the emissive values in a texture.
  45437. */
  45438. emissiveTexture: BaseTexture;
  45439. /**
  45440. * AKA Specular texture in other nomenclature.
  45441. */
  45442. reflectivityTexture: BaseTexture;
  45443. /**
  45444. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45445. */
  45446. metallicTexture: BaseTexture;
  45447. /**
  45448. * Specifies the metallic scalar of the metallic/roughness workflow.
  45449. * Can also be used to scale the metalness values of the metallic texture.
  45450. */
  45451. metallic: Nullable<number>;
  45452. /**
  45453. * Specifies the roughness scalar of the metallic/roughness workflow.
  45454. * Can also be used to scale the roughness values of the metallic texture.
  45455. */
  45456. roughness: Nullable<number>;
  45457. /**
  45458. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45459. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45460. */
  45461. microSurfaceTexture: BaseTexture;
  45462. /**
  45463. * Stores surface normal data used to displace a mesh in a texture.
  45464. */
  45465. bumpTexture: BaseTexture;
  45466. /**
  45467. * Stores the pre-calculated light information of a mesh in a texture.
  45468. */
  45469. lightmapTexture: BaseTexture;
  45470. /**
  45471. * Stores the refracted light information in a texture.
  45472. */
  45473. refractionTexture: Nullable<BaseTexture>;
  45474. /**
  45475. * The color of a material in ambient lighting.
  45476. */
  45477. ambientColor: Color3;
  45478. /**
  45479. * AKA Diffuse Color in other nomenclature.
  45480. */
  45481. albedoColor: Color3;
  45482. /**
  45483. * AKA Specular Color in other nomenclature.
  45484. */
  45485. reflectivityColor: Color3;
  45486. /**
  45487. * The color reflected from the material.
  45488. */
  45489. reflectionColor: Color3;
  45490. /**
  45491. * The color emitted from the material.
  45492. */
  45493. emissiveColor: Color3;
  45494. /**
  45495. * AKA Glossiness in other nomenclature.
  45496. */
  45497. microSurface: number;
  45498. /**
  45499. * source material index of refraction (IOR)' / 'destination material IOR.
  45500. */
  45501. indexOfRefraction: number;
  45502. /**
  45503. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45504. */
  45505. invertRefractionY: boolean;
  45506. /**
  45507. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45508. * Materials half opaque for instance using refraction could benefit from this control.
  45509. */
  45510. linkRefractionWithTransparency: boolean;
  45511. /**
  45512. * If true, the light map contains occlusion information instead of lighting info.
  45513. */
  45514. useLightmapAsShadowmap: boolean;
  45515. /**
  45516. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45517. */
  45518. useAlphaFromAlbedoTexture: boolean;
  45519. /**
  45520. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45521. */
  45522. forceAlphaTest: boolean;
  45523. /**
  45524. * Defines the alpha limits in alpha test mode.
  45525. */
  45526. alphaCutOff: number;
  45527. /**
  45528. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45529. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45530. */
  45531. useSpecularOverAlpha: boolean;
  45532. /**
  45533. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45534. */
  45535. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45536. /**
  45537. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45538. */
  45539. useRoughnessFromMetallicTextureAlpha: boolean;
  45540. /**
  45541. * Specifies if the metallic texture contains the roughness information in its green channel.
  45542. */
  45543. useRoughnessFromMetallicTextureGreen: boolean;
  45544. /**
  45545. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45546. */
  45547. useMetallnessFromMetallicTextureBlue: boolean;
  45548. /**
  45549. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45550. */
  45551. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45552. /**
  45553. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45554. */
  45555. useAmbientInGrayScale: boolean;
  45556. /**
  45557. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45558. * The material will try to infer what glossiness each pixel should be.
  45559. */
  45560. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45561. /**
  45562. * BJS is using an harcoded light falloff based on a manually sets up range.
  45563. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45564. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45565. */
  45566. /**
  45567. * BJS is using an harcoded light falloff based on a manually sets up range.
  45568. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45569. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45570. */
  45571. usePhysicalLightFalloff: boolean;
  45572. /**
  45573. * In order to support the falloff compatibility with gltf, a special mode has been added
  45574. * to reproduce the gltf light falloff.
  45575. */
  45576. /**
  45577. * In order to support the falloff compatibility with gltf, a special mode has been added
  45578. * to reproduce the gltf light falloff.
  45579. */
  45580. useGLTFLightFalloff: boolean;
  45581. /**
  45582. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45583. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45584. */
  45585. useRadianceOverAlpha: boolean;
  45586. /**
  45587. * Allows using an object space normal map (instead of tangent space).
  45588. */
  45589. useObjectSpaceNormalMap: boolean;
  45590. /**
  45591. * Allows using the bump map in parallax mode.
  45592. */
  45593. useParallax: boolean;
  45594. /**
  45595. * Allows using the bump map in parallax occlusion mode.
  45596. */
  45597. useParallaxOcclusion: boolean;
  45598. /**
  45599. * Controls the scale bias of the parallax mode.
  45600. */
  45601. parallaxScaleBias: number;
  45602. /**
  45603. * If sets to true, disables all the lights affecting the material.
  45604. */
  45605. disableLighting: boolean;
  45606. /**
  45607. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45608. */
  45609. forceIrradianceInFragment: boolean;
  45610. /**
  45611. * Number of Simultaneous lights allowed on the material.
  45612. */
  45613. maxSimultaneousLights: number;
  45614. /**
  45615. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45616. */
  45617. invertNormalMapX: boolean;
  45618. /**
  45619. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45620. */
  45621. invertNormalMapY: boolean;
  45622. /**
  45623. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45624. */
  45625. twoSidedLighting: boolean;
  45626. /**
  45627. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45628. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45629. */
  45630. useAlphaFresnel: boolean;
  45631. /**
  45632. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45633. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45634. */
  45635. useLinearAlphaFresnel: boolean;
  45636. /**
  45637. * Let user defines the brdf lookup texture used for IBL.
  45638. * A default 8bit version is embedded but you could point at :
  45639. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45640. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45641. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45642. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45643. */
  45644. environmentBRDFTexture: Nullable<BaseTexture>;
  45645. /**
  45646. * Force normal to face away from face.
  45647. */
  45648. forceNormalForward: boolean;
  45649. /**
  45650. * Enables specular anti aliasing in the PBR shader.
  45651. * It will both interacts on the Geometry for analytical and IBL lighting.
  45652. * It also prefilter the roughness map based on the bump values.
  45653. */
  45654. enableSpecularAntiAliasing: boolean;
  45655. /**
  45656. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45657. * makes the reflect vector face the model (under horizon).
  45658. */
  45659. useHorizonOcclusion: boolean;
  45660. /**
  45661. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45662. * too much the area relying on ambient texture to define their ambient occlusion.
  45663. */
  45664. useRadianceOcclusion: boolean;
  45665. /**
  45666. * If set to true, no lighting calculations will be applied.
  45667. */
  45668. unlit: boolean;
  45669. /**
  45670. * Gets the image processing configuration used either in this material.
  45671. */
  45672. /**
  45673. * Sets the Default image processing configuration used either in the this material.
  45674. *
  45675. * If sets to null, the scene one is in use.
  45676. */
  45677. imageProcessingConfiguration: ImageProcessingConfiguration;
  45678. /**
  45679. * Gets wether the color curves effect is enabled.
  45680. */
  45681. /**
  45682. * Sets wether the color curves effect is enabled.
  45683. */
  45684. cameraColorCurvesEnabled: boolean;
  45685. /**
  45686. * Gets wether the color grading effect is enabled.
  45687. */
  45688. /**
  45689. * Gets wether the color grading effect is enabled.
  45690. */
  45691. cameraColorGradingEnabled: boolean;
  45692. /**
  45693. * Gets wether tonemapping is enabled or not.
  45694. */
  45695. /**
  45696. * Sets wether tonemapping is enabled or not
  45697. */
  45698. cameraToneMappingEnabled: boolean;
  45699. /**
  45700. * The camera exposure used on this material.
  45701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45702. * This corresponds to a photographic exposure.
  45703. */
  45704. /**
  45705. * The camera exposure used on this material.
  45706. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45707. * This corresponds to a photographic exposure.
  45708. */
  45709. cameraExposure: number;
  45710. /**
  45711. * Gets The camera contrast used on this material.
  45712. */
  45713. /**
  45714. * Sets The camera contrast used on this material.
  45715. */
  45716. cameraContrast: number;
  45717. /**
  45718. * Gets the Color Grading 2D Lookup Texture.
  45719. */
  45720. /**
  45721. * Sets the Color Grading 2D Lookup Texture.
  45722. */
  45723. cameraColorGradingTexture: Nullable<BaseTexture>;
  45724. /**
  45725. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45726. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45727. * 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;
  45728. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45729. */
  45730. /**
  45731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45733. * 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;
  45734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45735. */
  45736. cameraColorCurves: Nullable<ColorCurves>;
  45737. /**
  45738. * Instantiates a new PBRMaterial instance.
  45739. *
  45740. * @param name The material name
  45741. * @param scene The scene the material will be use in.
  45742. */
  45743. constructor(name: string, scene: Scene);
  45744. /**
  45745. * Returns the name of this material class.
  45746. */
  45747. getClassName(): string;
  45748. /**
  45749. * Makes a duplicate of the current material.
  45750. * @param name - name to use for the new material.
  45751. */
  45752. clone(name: string): PBRMaterial;
  45753. /**
  45754. * Serializes this PBR Material.
  45755. * @returns - An object with the serialized material.
  45756. */
  45757. serialize(): any;
  45758. /**
  45759. * Parses a PBR Material from a serialized object.
  45760. * @param source - Serialized object.
  45761. * @param scene - BJS scene instance.
  45762. * @param rootUrl - url for the scene object
  45763. * @returns - PBRMaterial
  45764. */
  45765. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45766. }
  45767. }
  45768. declare module BABYLON {
  45769. /**
  45770. * Direct draw surface info
  45771. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45772. */
  45773. export interface DDSInfo {
  45774. /**
  45775. * Width of the texture
  45776. */
  45777. width: number;
  45778. /**
  45779. * Width of the texture
  45780. */
  45781. height: number;
  45782. /**
  45783. * Number of Mipmaps for the texture
  45784. * @see https://en.wikipedia.org/wiki/Mipmap
  45785. */
  45786. mipmapCount: number;
  45787. /**
  45788. * If the textures format is a known fourCC format
  45789. * @see https://www.fourcc.org/
  45790. */
  45791. isFourCC: boolean;
  45792. /**
  45793. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45794. */
  45795. isRGB: boolean;
  45796. /**
  45797. * If the texture is a lumincance format
  45798. */
  45799. isLuminance: boolean;
  45800. /**
  45801. * If this is a cube texture
  45802. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45803. */
  45804. isCube: boolean;
  45805. /**
  45806. * If the texture is a compressed format eg. FOURCC_DXT1
  45807. */
  45808. isCompressed: boolean;
  45809. /**
  45810. * The dxgiFormat of the texture
  45811. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45812. */
  45813. dxgiFormat: number;
  45814. /**
  45815. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45816. */
  45817. textureType: number;
  45818. /**
  45819. * Sphericle polynomial created for the dds texture
  45820. */
  45821. sphericalPolynomial?: SphericalPolynomial;
  45822. }
  45823. /**
  45824. * Class used to provide DDS decompression tools
  45825. */
  45826. export class DDSTools {
  45827. /**
  45828. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45829. */
  45830. static StoreLODInAlphaChannel: boolean;
  45831. /**
  45832. * Gets DDS information from an array buffer
  45833. * @param arrayBuffer defines the array buffer to read data from
  45834. * @returns the DDS information
  45835. */
  45836. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45837. private static _FloatView;
  45838. private static _Int32View;
  45839. private static _ToHalfFloat;
  45840. private static _FromHalfFloat;
  45841. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45842. private static _GetHalfFloatRGBAArrayBuffer;
  45843. private static _GetFloatRGBAArrayBuffer;
  45844. private static _GetFloatAsUIntRGBAArrayBuffer;
  45845. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45846. private static _GetRGBAArrayBuffer;
  45847. private static _ExtractLongWordOrder;
  45848. private static _GetRGBArrayBuffer;
  45849. private static _GetLuminanceArrayBuffer;
  45850. /**
  45851. * Uploads DDS Levels to a Babylon Texture
  45852. * @hidden
  45853. */
  45854. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45855. }
  45856. interface Engine {
  45857. /**
  45858. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45859. * @param rootUrl defines the url where the file to load is located
  45860. * @param scene defines the current scene
  45861. * @param lodScale defines scale to apply to the mip map selection
  45862. * @param lodOffset defines offset to apply to the mip map selection
  45863. * @param onLoad defines an optional callback raised when the texture is loaded
  45864. * @param onError defines an optional callback raised if there is an issue to load the texture
  45865. * @param format defines the format of the data
  45866. * @param forcedExtension defines the extension to use to pick the right loader
  45867. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45868. * @returns the cube texture as an InternalTexture
  45869. */
  45870. 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;
  45871. }
  45872. }
  45873. declare module BABYLON {
  45874. /**
  45875. * Implementation of the DDS Texture Loader.
  45876. * @hidden
  45877. */
  45878. export class _DDSTextureLoader implements IInternalTextureLoader {
  45879. /**
  45880. * Defines wether the loader supports cascade loading the different faces.
  45881. */
  45882. readonly supportCascades: boolean;
  45883. /**
  45884. * This returns if the loader support the current file information.
  45885. * @param extension defines the file extension of the file being loaded
  45886. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45887. * @param fallback defines the fallback internal texture if any
  45888. * @param isBase64 defines whether the texture is encoded as a base64
  45889. * @param isBuffer defines whether the texture data are stored as a buffer
  45890. * @returns true if the loader can load the specified file
  45891. */
  45892. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45893. /**
  45894. * Transform the url before loading if required.
  45895. * @param rootUrl the url of the texture
  45896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45897. * @returns the transformed texture
  45898. */
  45899. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45900. /**
  45901. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45902. * @param rootUrl the url of the texture
  45903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45904. * @returns the fallback texture
  45905. */
  45906. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45907. /**
  45908. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45909. * @param data contains the texture data
  45910. * @param texture defines the BabylonJS internal texture
  45911. * @param createPolynomials will be true if polynomials have been requested
  45912. * @param onLoad defines the callback to trigger once the texture is ready
  45913. * @param onError defines the callback to trigger in case of error
  45914. */
  45915. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45916. /**
  45917. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45918. * @param data contains the texture data
  45919. * @param texture defines the BabylonJS internal texture
  45920. * @param callback defines the method to call once ready to upload
  45921. */
  45922. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45923. }
  45924. }
  45925. declare module BABYLON {
  45926. /** @hidden */
  45927. export var rgbdEncodePixelShader: {
  45928. name: string;
  45929. shader: string;
  45930. };
  45931. }
  45932. declare module BABYLON {
  45933. /**
  45934. * Raw texture data and descriptor sufficient for WebGL texture upload
  45935. */
  45936. export interface EnvironmentTextureInfo {
  45937. /**
  45938. * Version of the environment map
  45939. */
  45940. version: number;
  45941. /**
  45942. * Width of image
  45943. */
  45944. width: number;
  45945. /**
  45946. * Irradiance information stored in the file.
  45947. */
  45948. irradiance: any;
  45949. /**
  45950. * Specular information stored in the file.
  45951. */
  45952. specular: any;
  45953. }
  45954. /**
  45955. * Sets of helpers addressing the serialization and deserialization of environment texture
  45956. * stored in a BabylonJS env file.
  45957. * Those files are usually stored as .env files.
  45958. */
  45959. export class EnvironmentTextureTools {
  45960. /**
  45961. * Magic number identifying the env file.
  45962. */
  45963. private static _MagicBytes;
  45964. /**
  45965. * Gets the environment info from an env file.
  45966. * @param data The array buffer containing the .env bytes.
  45967. * @returns the environment file info (the json header) if successfully parsed.
  45968. */
  45969. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45970. /**
  45971. * Creates an environment texture from a loaded cube texture.
  45972. * @param texture defines the cube texture to convert in env file
  45973. * @return a promise containing the environment data if succesfull.
  45974. */
  45975. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45976. /**
  45977. * Creates a JSON representation of the spherical data.
  45978. * @param texture defines the texture containing the polynomials
  45979. * @return the JSON representation of the spherical info
  45980. */
  45981. private static _CreateEnvTextureIrradiance;
  45982. /**
  45983. * Uploads the texture info contained in the env file to the GPU.
  45984. * @param texture defines the internal texture to upload to
  45985. * @param arrayBuffer defines the buffer cotaining the data to load
  45986. * @param info defines the texture info retrieved through the GetEnvInfo method
  45987. * @returns a promise
  45988. */
  45989. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45990. /**
  45991. * Uploads the levels of image data to the GPU.
  45992. * @param texture defines the internal texture to upload to
  45993. * @param imageData defines the array buffer views of image data [mipmap][face]
  45994. * @returns a promise
  45995. */
  45996. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45997. /**
  45998. * Uploads spherical polynomials information to the texture.
  45999. * @param texture defines the texture we are trying to upload the information to
  46000. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46001. */
  46002. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46003. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46004. }
  46005. }
  46006. declare module BABYLON {
  46007. /**
  46008. * Implementation of the ENV Texture Loader.
  46009. * @hidden
  46010. */
  46011. export class _ENVTextureLoader implements IInternalTextureLoader {
  46012. /**
  46013. * Defines wether the loader supports cascade loading the different faces.
  46014. */
  46015. readonly supportCascades: boolean;
  46016. /**
  46017. * This returns if the loader support the current file information.
  46018. * @param extension defines the file extension of the file being loaded
  46019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46020. * @param fallback defines the fallback internal texture if any
  46021. * @param isBase64 defines whether the texture is encoded as a base64
  46022. * @param isBuffer defines whether the texture data are stored as a buffer
  46023. * @returns true if the loader can load the specified file
  46024. */
  46025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46026. /**
  46027. * Transform the url before loading if required.
  46028. * @param rootUrl the url of the texture
  46029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46030. * @returns the transformed texture
  46031. */
  46032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46033. /**
  46034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46035. * @param rootUrl the url of the texture
  46036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46037. * @returns the fallback texture
  46038. */
  46039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46040. /**
  46041. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46042. * @param data contains the texture data
  46043. * @param texture defines the BabylonJS internal texture
  46044. * @param createPolynomials will be true if polynomials have been requested
  46045. * @param onLoad defines the callback to trigger once the texture is ready
  46046. * @param onError defines the callback to trigger in case of error
  46047. */
  46048. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46049. /**
  46050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46051. * @param data contains the texture data
  46052. * @param texture defines the BabylonJS internal texture
  46053. * @param callback defines the method to call once ready to upload
  46054. */
  46055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46056. }
  46057. }
  46058. declare module BABYLON {
  46059. /**
  46060. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46061. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46062. */
  46063. export class KhronosTextureContainer {
  46064. /** contents of the KTX container file */
  46065. arrayBuffer: any;
  46066. private static HEADER_LEN;
  46067. private static COMPRESSED_2D;
  46068. private static COMPRESSED_3D;
  46069. private static TEX_2D;
  46070. private static TEX_3D;
  46071. /**
  46072. * Gets the openGL type
  46073. */
  46074. glType: number;
  46075. /**
  46076. * Gets the openGL type size
  46077. */
  46078. glTypeSize: number;
  46079. /**
  46080. * Gets the openGL format
  46081. */
  46082. glFormat: number;
  46083. /**
  46084. * Gets the openGL internal format
  46085. */
  46086. glInternalFormat: number;
  46087. /**
  46088. * Gets the base internal format
  46089. */
  46090. glBaseInternalFormat: number;
  46091. /**
  46092. * Gets image width in pixel
  46093. */
  46094. pixelWidth: number;
  46095. /**
  46096. * Gets image height in pixel
  46097. */
  46098. pixelHeight: number;
  46099. /**
  46100. * Gets image depth in pixels
  46101. */
  46102. pixelDepth: number;
  46103. /**
  46104. * Gets the number of array elements
  46105. */
  46106. numberOfArrayElements: number;
  46107. /**
  46108. * Gets the number of faces
  46109. */
  46110. numberOfFaces: number;
  46111. /**
  46112. * Gets the number of mipmap levels
  46113. */
  46114. numberOfMipmapLevels: number;
  46115. /**
  46116. * Gets the bytes of key value data
  46117. */
  46118. bytesOfKeyValueData: number;
  46119. /**
  46120. * Gets the load type
  46121. */
  46122. loadType: number;
  46123. /**
  46124. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46125. */
  46126. isInvalid: boolean;
  46127. /**
  46128. * Creates a new KhronosTextureContainer
  46129. * @param arrayBuffer contents of the KTX container file
  46130. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46131. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46132. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46133. */
  46134. constructor(
  46135. /** contents of the KTX container file */
  46136. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46137. /**
  46138. * Uploads KTX content to a Babylon Texture.
  46139. * It is assumed that the texture has already been created & is currently bound
  46140. * @hidden
  46141. */
  46142. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46143. private _upload2DCompressedLevels;
  46144. }
  46145. }
  46146. declare module BABYLON {
  46147. /**
  46148. * Implementation of the KTX Texture Loader.
  46149. * @hidden
  46150. */
  46151. export class _KTXTextureLoader implements IInternalTextureLoader {
  46152. /**
  46153. * Defines wether the loader supports cascade loading the different faces.
  46154. */
  46155. readonly supportCascades: boolean;
  46156. /**
  46157. * This returns if the loader support the current file information.
  46158. * @param extension defines the file extension of the file being loaded
  46159. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46160. * @param fallback defines the fallback internal texture if any
  46161. * @param isBase64 defines whether the texture is encoded as a base64
  46162. * @param isBuffer defines whether the texture data are stored as a buffer
  46163. * @returns true if the loader can load the specified file
  46164. */
  46165. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46166. /**
  46167. * Transform the url before loading if required.
  46168. * @param rootUrl the url of the texture
  46169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46170. * @returns the transformed texture
  46171. */
  46172. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46173. /**
  46174. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46175. * @param rootUrl the url of the texture
  46176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46177. * @returns the fallback texture
  46178. */
  46179. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46180. /**
  46181. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46182. * @param data contains the texture data
  46183. * @param texture defines the BabylonJS internal texture
  46184. * @param createPolynomials will be true if polynomials have been requested
  46185. * @param onLoad defines the callback to trigger once the texture is ready
  46186. * @param onError defines the callback to trigger in case of error
  46187. */
  46188. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46189. /**
  46190. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46191. * @param data contains the texture data
  46192. * @param texture defines the BabylonJS internal texture
  46193. * @param callback defines the method to call once ready to upload
  46194. */
  46195. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46196. }
  46197. }
  46198. declare module BABYLON {
  46199. /** @hidden */
  46200. export var _forceSceneHelpersToBundle: boolean;
  46201. interface Scene {
  46202. /**
  46203. * Creates a default light for the scene.
  46204. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46205. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46206. */
  46207. createDefaultLight(replace?: boolean): void;
  46208. /**
  46209. * Creates a default camera for the scene.
  46210. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46211. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46212. * @param replace has default false, when true replaces the active camera in the scene
  46213. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46214. */
  46215. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46216. /**
  46217. * Creates a default camera and a default light.
  46218. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46219. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46220. * @param replace has the default false, when true replaces the active camera/light in the scene
  46221. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46222. */
  46223. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46224. /**
  46225. * Creates a new sky box
  46226. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46227. * @param environmentTexture defines the texture to use as environment texture
  46228. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46229. * @param scale defines the overall scale of the skybox
  46230. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46231. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46232. * @returns a new mesh holding the sky box
  46233. */
  46234. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46235. /**
  46236. * Creates a new environment
  46237. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46238. * @param options defines the options you can use to configure the environment
  46239. * @returns the new EnvironmentHelper
  46240. */
  46241. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46242. /**
  46243. * Creates a new VREXperienceHelper
  46244. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46245. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46246. * @returns a new VREXperienceHelper
  46247. */
  46248. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46249. /**
  46250. * Creates a new XREXperienceHelper
  46251. * @see http://doc.babylonjs.com/how_to/webxr
  46252. * @returns a promise for a new XREXperienceHelper
  46253. */
  46254. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46255. }
  46256. }
  46257. declare module BABYLON {
  46258. /**
  46259. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46260. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46261. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46262. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46263. */
  46264. export class VideoDome extends TransformNode {
  46265. /**
  46266. * Define the video source as a Monoscopic panoramic 360 video.
  46267. */
  46268. static readonly MODE_MONOSCOPIC: number;
  46269. /**
  46270. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46271. */
  46272. static readonly MODE_TOPBOTTOM: number;
  46273. /**
  46274. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46275. */
  46276. static readonly MODE_SIDEBYSIDE: number;
  46277. private _useDirectMapping;
  46278. /**
  46279. * The video texture being displayed on the sphere
  46280. */
  46281. protected _videoTexture: VideoTexture;
  46282. /**
  46283. * Gets the video texture being displayed on the sphere
  46284. */
  46285. readonly videoTexture: VideoTexture;
  46286. /**
  46287. * The skybox material
  46288. */
  46289. protected _material: BackgroundMaterial;
  46290. /**
  46291. * The surface used for the skybox
  46292. */
  46293. protected _mesh: Mesh;
  46294. /**
  46295. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46296. * Also see the options.resolution property.
  46297. */
  46298. fovMultiplier: number;
  46299. private _videoMode;
  46300. /**
  46301. * Gets or set the current video mode for the video. It can be:
  46302. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46303. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46304. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46305. */
  46306. videoMode: number;
  46307. /**
  46308. * Oberserver used in Stereoscopic VR Mode.
  46309. */
  46310. private _onBeforeCameraRenderObserver;
  46311. /**
  46312. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46313. * @param name Element's name, child elements will append suffixes for their own names.
  46314. * @param urlsOrVideo defines the url(s) or the video element to use
  46315. * @param options An object containing optional or exposed sub element properties
  46316. */
  46317. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46318. resolution?: number;
  46319. clickToPlay?: boolean;
  46320. autoPlay?: boolean;
  46321. loop?: boolean;
  46322. size?: number;
  46323. poster?: string;
  46324. faceForward?: boolean;
  46325. useDirectMapping?: boolean;
  46326. }, scene: Scene);
  46327. private _changeVideoMode;
  46328. /**
  46329. * Releases resources associated with this node.
  46330. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46331. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46332. */
  46333. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46334. }
  46335. }
  46336. declare module BABYLON {
  46337. /**
  46338. * This class can be used to get instrumentation data from a Babylon engine
  46339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46340. */
  46341. export class EngineInstrumentation implements IDisposable {
  46342. /**
  46343. * Define the instrumented engine.
  46344. */
  46345. engine: Engine;
  46346. private _captureGPUFrameTime;
  46347. private _gpuFrameTimeToken;
  46348. private _gpuFrameTime;
  46349. private _captureShaderCompilationTime;
  46350. private _shaderCompilationTime;
  46351. private _onBeginFrameObserver;
  46352. private _onEndFrameObserver;
  46353. private _onBeforeShaderCompilationObserver;
  46354. private _onAfterShaderCompilationObserver;
  46355. /**
  46356. * Gets the perf counter used for GPU frame time
  46357. */
  46358. readonly gpuFrameTimeCounter: PerfCounter;
  46359. /**
  46360. * Gets the GPU frame time capture status
  46361. */
  46362. /**
  46363. * Enable or disable the GPU frame time capture
  46364. */
  46365. captureGPUFrameTime: boolean;
  46366. /**
  46367. * Gets the perf counter used for shader compilation time
  46368. */
  46369. readonly shaderCompilationTimeCounter: PerfCounter;
  46370. /**
  46371. * Gets the shader compilation time capture status
  46372. */
  46373. /**
  46374. * Enable or disable the shader compilation time capture
  46375. */
  46376. captureShaderCompilationTime: boolean;
  46377. /**
  46378. * Instantiates a new engine instrumentation.
  46379. * This class can be used to get instrumentation data from a Babylon engine
  46380. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46381. * @param engine Defines the engine to instrument
  46382. */
  46383. constructor(
  46384. /**
  46385. * Define the instrumented engine.
  46386. */
  46387. engine: Engine);
  46388. /**
  46389. * Dispose and release associated resources.
  46390. */
  46391. dispose(): void;
  46392. }
  46393. }
  46394. declare module BABYLON {
  46395. /**
  46396. * This class can be used to get instrumentation data from a Babylon engine
  46397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46398. */
  46399. export class SceneInstrumentation implements IDisposable {
  46400. /**
  46401. * Defines the scene to instrument
  46402. */
  46403. scene: Scene;
  46404. private _captureActiveMeshesEvaluationTime;
  46405. private _activeMeshesEvaluationTime;
  46406. private _captureRenderTargetsRenderTime;
  46407. private _renderTargetsRenderTime;
  46408. private _captureFrameTime;
  46409. private _frameTime;
  46410. private _captureRenderTime;
  46411. private _renderTime;
  46412. private _captureInterFrameTime;
  46413. private _interFrameTime;
  46414. private _captureParticlesRenderTime;
  46415. private _particlesRenderTime;
  46416. private _captureSpritesRenderTime;
  46417. private _spritesRenderTime;
  46418. private _capturePhysicsTime;
  46419. private _physicsTime;
  46420. private _captureAnimationsTime;
  46421. private _animationsTime;
  46422. private _captureCameraRenderTime;
  46423. private _cameraRenderTime;
  46424. private _onBeforeActiveMeshesEvaluationObserver;
  46425. private _onAfterActiveMeshesEvaluationObserver;
  46426. private _onBeforeRenderTargetsRenderObserver;
  46427. private _onAfterRenderTargetsRenderObserver;
  46428. private _onAfterRenderObserver;
  46429. private _onBeforeDrawPhaseObserver;
  46430. private _onAfterDrawPhaseObserver;
  46431. private _onBeforeAnimationsObserver;
  46432. private _onBeforeParticlesRenderingObserver;
  46433. private _onAfterParticlesRenderingObserver;
  46434. private _onBeforeSpritesRenderingObserver;
  46435. private _onAfterSpritesRenderingObserver;
  46436. private _onBeforePhysicsObserver;
  46437. private _onAfterPhysicsObserver;
  46438. private _onAfterAnimationsObserver;
  46439. private _onBeforeCameraRenderObserver;
  46440. private _onAfterCameraRenderObserver;
  46441. /**
  46442. * Gets the perf counter used for active meshes evaluation time
  46443. */
  46444. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46445. /**
  46446. * Gets the active meshes evaluation time capture status
  46447. */
  46448. /**
  46449. * Enable or disable the active meshes evaluation time capture
  46450. */
  46451. captureActiveMeshesEvaluationTime: boolean;
  46452. /**
  46453. * Gets the perf counter used for render targets render time
  46454. */
  46455. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46456. /**
  46457. * Gets the render targets render time capture status
  46458. */
  46459. /**
  46460. * Enable or disable the render targets render time capture
  46461. */
  46462. captureRenderTargetsRenderTime: boolean;
  46463. /**
  46464. * Gets the perf counter used for particles render time
  46465. */
  46466. readonly particlesRenderTimeCounter: PerfCounter;
  46467. /**
  46468. * Gets the particles render time capture status
  46469. */
  46470. /**
  46471. * Enable or disable the particles render time capture
  46472. */
  46473. captureParticlesRenderTime: boolean;
  46474. /**
  46475. * Gets the perf counter used for sprites render time
  46476. */
  46477. readonly spritesRenderTimeCounter: PerfCounter;
  46478. /**
  46479. * Gets the sprites render time capture status
  46480. */
  46481. /**
  46482. * Enable or disable the sprites render time capture
  46483. */
  46484. captureSpritesRenderTime: boolean;
  46485. /**
  46486. * Gets the perf counter used for physics time
  46487. */
  46488. readonly physicsTimeCounter: PerfCounter;
  46489. /**
  46490. * Gets the physics time capture status
  46491. */
  46492. /**
  46493. * Enable or disable the physics time capture
  46494. */
  46495. capturePhysicsTime: boolean;
  46496. /**
  46497. * Gets the perf counter used for animations time
  46498. */
  46499. readonly animationsTimeCounter: PerfCounter;
  46500. /**
  46501. * Gets the animations time capture status
  46502. */
  46503. /**
  46504. * Enable or disable the animations time capture
  46505. */
  46506. captureAnimationsTime: boolean;
  46507. /**
  46508. * Gets the perf counter used for frame time capture
  46509. */
  46510. readonly frameTimeCounter: PerfCounter;
  46511. /**
  46512. * Gets the frame time capture status
  46513. */
  46514. /**
  46515. * Enable or disable the frame time capture
  46516. */
  46517. captureFrameTime: boolean;
  46518. /**
  46519. * Gets the perf counter used for inter-frames time capture
  46520. */
  46521. readonly interFrameTimeCounter: PerfCounter;
  46522. /**
  46523. * Gets the inter-frames time capture status
  46524. */
  46525. /**
  46526. * Enable or disable the inter-frames time capture
  46527. */
  46528. captureInterFrameTime: boolean;
  46529. /**
  46530. * Gets the perf counter used for render time capture
  46531. */
  46532. readonly renderTimeCounter: PerfCounter;
  46533. /**
  46534. * Gets the render time capture status
  46535. */
  46536. /**
  46537. * Enable or disable the render time capture
  46538. */
  46539. captureRenderTime: boolean;
  46540. /**
  46541. * Gets the perf counter used for camera render time capture
  46542. */
  46543. readonly cameraRenderTimeCounter: PerfCounter;
  46544. /**
  46545. * Gets the camera render time capture status
  46546. */
  46547. /**
  46548. * Enable or disable the camera render time capture
  46549. */
  46550. captureCameraRenderTime: boolean;
  46551. /**
  46552. * Gets the perf counter used for draw calls
  46553. */
  46554. readonly drawCallsCounter: PerfCounter;
  46555. /**
  46556. * Instantiates a new scene instrumentation.
  46557. * This class can be used to get instrumentation data from a Babylon engine
  46558. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46559. * @param scene Defines the scene to instrument
  46560. */
  46561. constructor(
  46562. /**
  46563. * Defines the scene to instrument
  46564. */
  46565. scene: Scene);
  46566. /**
  46567. * Dispose and release associated resources.
  46568. */
  46569. dispose(): void;
  46570. }
  46571. }
  46572. declare module BABYLON {
  46573. /** @hidden */
  46574. export var glowMapGenerationPixelShader: {
  46575. name: string;
  46576. shader: string;
  46577. };
  46578. }
  46579. declare module BABYLON {
  46580. /** @hidden */
  46581. export var glowMapGenerationVertexShader: {
  46582. name: string;
  46583. shader: string;
  46584. };
  46585. }
  46586. declare module BABYLON {
  46587. /**
  46588. * Effect layer options. This helps customizing the behaviour
  46589. * of the effect layer.
  46590. */
  46591. export interface IEffectLayerOptions {
  46592. /**
  46593. * Multiplication factor apply to the canvas size to compute the render target size
  46594. * used to generated the objects (the smaller the faster).
  46595. */
  46596. mainTextureRatio: number;
  46597. /**
  46598. * Enforces a fixed size texture to ensure effect stability across devices.
  46599. */
  46600. mainTextureFixedSize?: number;
  46601. /**
  46602. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46603. */
  46604. alphaBlendingMode: number;
  46605. /**
  46606. * The camera attached to the layer.
  46607. */
  46608. camera: Nullable<Camera>;
  46609. /**
  46610. * The rendering group to draw the layer in.
  46611. */
  46612. renderingGroupId: number;
  46613. }
  46614. /**
  46615. * The effect layer Helps adding post process effect blended with the main pass.
  46616. *
  46617. * This can be for instance use to generate glow or higlight effects on the scene.
  46618. *
  46619. * The effect layer class can not be used directly and is intented to inherited from to be
  46620. * customized per effects.
  46621. */
  46622. export abstract class EffectLayer {
  46623. private _vertexBuffers;
  46624. private _indexBuffer;
  46625. private _cachedDefines;
  46626. private _effectLayerMapGenerationEffect;
  46627. private _effectLayerOptions;
  46628. private _mergeEffect;
  46629. protected _scene: Scene;
  46630. protected _engine: Engine;
  46631. protected _maxSize: number;
  46632. protected _mainTextureDesiredSize: ISize;
  46633. protected _mainTexture: RenderTargetTexture;
  46634. protected _shouldRender: boolean;
  46635. protected _postProcesses: PostProcess[];
  46636. protected _textures: BaseTexture[];
  46637. protected _emissiveTextureAndColor: {
  46638. texture: Nullable<BaseTexture>;
  46639. color: Color4;
  46640. };
  46641. /**
  46642. * The name of the layer
  46643. */
  46644. name: string;
  46645. /**
  46646. * The clear color of the texture used to generate the glow map.
  46647. */
  46648. neutralColor: Color4;
  46649. /**
  46650. * Specifies wether the highlight layer is enabled or not.
  46651. */
  46652. isEnabled: boolean;
  46653. /**
  46654. * Gets the camera attached to the layer.
  46655. */
  46656. readonly camera: Nullable<Camera>;
  46657. /**
  46658. * Gets the rendering group id the layer should render in.
  46659. */
  46660. readonly renderingGroupId: number;
  46661. /**
  46662. * An event triggered when the effect layer has been disposed.
  46663. */
  46664. onDisposeObservable: Observable<EffectLayer>;
  46665. /**
  46666. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46667. */
  46668. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46669. /**
  46670. * An event triggered when the generated texture is being merged in the scene.
  46671. */
  46672. onBeforeComposeObservable: Observable<EffectLayer>;
  46673. /**
  46674. * An event triggered when the generated texture has been merged in the scene.
  46675. */
  46676. onAfterComposeObservable: Observable<EffectLayer>;
  46677. /**
  46678. * An event triggered when the efffect layer changes its size.
  46679. */
  46680. onSizeChangedObservable: Observable<EffectLayer>;
  46681. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46682. /**
  46683. * Instantiates a new effect Layer and references it in the scene.
  46684. * @param name The name of the layer
  46685. * @param scene The scene to use the layer in
  46686. */
  46687. constructor(
  46688. /** The Friendly of the effect in the scene */
  46689. name: string, scene: Scene);
  46690. /**
  46691. * Get the effect name of the layer.
  46692. * @return The effect name
  46693. */
  46694. abstract getEffectName(): string;
  46695. /**
  46696. * Checks for the readiness of the element composing the layer.
  46697. * @param subMesh the mesh to check for
  46698. * @param useInstances specify wether or not to use instances to render the mesh
  46699. * @return true if ready otherwise, false
  46700. */
  46701. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46702. /**
  46703. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46704. * @returns true if the effect requires stencil during the main canvas render pass.
  46705. */
  46706. abstract needStencil(): boolean;
  46707. /**
  46708. * Create the merge effect. This is the shader use to blit the information back
  46709. * to the main canvas at the end of the scene rendering.
  46710. * @returns The effect containing the shader used to merge the effect on the main canvas
  46711. */
  46712. protected abstract _createMergeEffect(): Effect;
  46713. /**
  46714. * Creates the render target textures and post processes used in the effect layer.
  46715. */
  46716. protected abstract _createTextureAndPostProcesses(): void;
  46717. /**
  46718. * Implementation specific of rendering the generating effect on the main canvas.
  46719. * @param effect The effect used to render through
  46720. */
  46721. protected abstract _internalRender(effect: Effect): void;
  46722. /**
  46723. * Sets the required values for both the emissive texture and and the main color.
  46724. */
  46725. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46726. /**
  46727. * Free any resources and references associated to a mesh.
  46728. * Internal use
  46729. * @param mesh The mesh to free.
  46730. */
  46731. abstract _disposeMesh(mesh: Mesh): void;
  46732. /**
  46733. * Serializes this layer (Glow or Highlight for example)
  46734. * @returns a serialized layer object
  46735. */
  46736. abstract serialize?(): any;
  46737. /**
  46738. * Initializes the effect layer with the required options.
  46739. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46740. */
  46741. protected _init(options: Partial<IEffectLayerOptions>): void;
  46742. /**
  46743. * Generates the index buffer of the full screen quad blending to the main canvas.
  46744. */
  46745. private _generateIndexBuffer;
  46746. /**
  46747. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46748. */
  46749. private _generateVertexBuffer;
  46750. /**
  46751. * Sets the main texture desired size which is the closest power of two
  46752. * of the engine canvas size.
  46753. */
  46754. private _setMainTextureSize;
  46755. /**
  46756. * Creates the main texture for the effect layer.
  46757. */
  46758. protected _createMainTexture(): void;
  46759. /**
  46760. * Adds specific effects defines.
  46761. * @param defines The defines to add specifics to.
  46762. */
  46763. protected _addCustomEffectDefines(defines: string[]): void;
  46764. /**
  46765. * Checks for the readiness of the element composing the layer.
  46766. * @param subMesh the mesh to check for
  46767. * @param useInstances specify wether or not to use instances to render the mesh
  46768. * @param emissiveTexture the associated emissive texture used to generate the glow
  46769. * @return true if ready otherwise, false
  46770. */
  46771. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46772. /**
  46773. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46774. */
  46775. render(): void;
  46776. /**
  46777. * Determine if a given mesh will be used in the current effect.
  46778. * @param mesh mesh to test
  46779. * @returns true if the mesh will be used
  46780. */
  46781. hasMesh(mesh: AbstractMesh): boolean;
  46782. /**
  46783. * Returns true if the layer contains information to display, otherwise false.
  46784. * @returns true if the glow layer should be rendered
  46785. */
  46786. shouldRender(): boolean;
  46787. /**
  46788. * Returns true if the mesh should render, otherwise false.
  46789. * @param mesh The mesh to render
  46790. * @returns true if it should render otherwise false
  46791. */
  46792. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46793. /**
  46794. * Returns true if the mesh can be rendered, otherwise false.
  46795. * @param mesh The mesh to render
  46796. * @param material The material used on the mesh
  46797. * @returns true if it can be rendered otherwise false
  46798. */
  46799. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46800. /**
  46801. * Returns true if the mesh should render, otherwise false.
  46802. * @param mesh The mesh to render
  46803. * @returns true if it should render otherwise false
  46804. */
  46805. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46806. /**
  46807. * Renders the submesh passed in parameter to the generation map.
  46808. */
  46809. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46810. /**
  46811. * Rebuild the required buffers.
  46812. * @hidden Internal use only.
  46813. */ private _rebuild(): void;
  46814. /**
  46815. * Dispose only the render target textures and post process.
  46816. */
  46817. private _disposeTextureAndPostProcesses;
  46818. /**
  46819. * Dispose the highlight layer and free resources.
  46820. */
  46821. dispose(): void;
  46822. /**
  46823. * Gets the class name of the effect layer
  46824. * @returns the string with the class name of the effect layer
  46825. */
  46826. getClassName(): string;
  46827. /**
  46828. * Creates an effect layer from parsed effect layer data
  46829. * @param parsedEffectLayer defines effect layer data
  46830. * @param scene defines the current scene
  46831. * @param rootUrl defines the root URL containing the effect layer information
  46832. * @returns a parsed effect Layer
  46833. */
  46834. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46835. }
  46836. }
  46837. declare module BABYLON {
  46838. interface AbstractScene {
  46839. /**
  46840. * The list of effect layers (highlights/glow) added to the scene
  46841. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46842. * @see http://doc.babylonjs.com/how_to/glow_layer
  46843. */
  46844. effectLayers: Array<EffectLayer>;
  46845. /**
  46846. * Removes the given effect layer from this scene.
  46847. * @param toRemove defines the effect layer to remove
  46848. * @returns the index of the removed effect layer
  46849. */
  46850. removeEffectLayer(toRemove: EffectLayer): number;
  46851. /**
  46852. * Adds the given effect layer to this scene
  46853. * @param newEffectLayer defines the effect layer to add
  46854. */
  46855. addEffectLayer(newEffectLayer: EffectLayer): void;
  46856. }
  46857. /**
  46858. * Defines the layer scene component responsible to manage any effect layers
  46859. * in a given scene.
  46860. */
  46861. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46862. /**
  46863. * The component name helpfull to identify the component in the list of scene components.
  46864. */
  46865. readonly name: string;
  46866. /**
  46867. * The scene the component belongs to.
  46868. */
  46869. scene: Scene;
  46870. private _engine;
  46871. private _renderEffects;
  46872. private _needStencil;
  46873. private _previousStencilState;
  46874. /**
  46875. * Creates a new instance of the component for the given scene
  46876. * @param scene Defines the scene to register the component in
  46877. */
  46878. constructor(scene: Scene);
  46879. /**
  46880. * Registers the component in a given scene
  46881. */
  46882. register(): void;
  46883. /**
  46884. * Rebuilds the elements related to this component in case of
  46885. * context lost for instance.
  46886. */
  46887. rebuild(): void;
  46888. /**
  46889. * Serializes the component data to the specified json object
  46890. * @param serializationObject The object to serialize to
  46891. */
  46892. serialize(serializationObject: any): void;
  46893. /**
  46894. * Adds all the elements from the container to the scene
  46895. * @param container the container holding the elements
  46896. */
  46897. addFromContainer(container: AbstractScene): void;
  46898. /**
  46899. * Removes all the elements in the container from the scene
  46900. * @param container contains the elements to remove
  46901. * @param dispose if the removed element should be disposed (default: false)
  46902. */
  46903. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46904. /**
  46905. * Disposes the component and the associated ressources.
  46906. */
  46907. dispose(): void;
  46908. private _isReadyForMesh;
  46909. private _renderMainTexture;
  46910. private _setStencil;
  46911. private _setStencilBack;
  46912. private _draw;
  46913. private _drawCamera;
  46914. private _drawRenderingGroup;
  46915. }
  46916. }
  46917. declare module BABYLON {
  46918. /** @hidden */
  46919. export var glowMapMergePixelShader: {
  46920. name: string;
  46921. shader: string;
  46922. };
  46923. }
  46924. declare module BABYLON {
  46925. /** @hidden */
  46926. export var glowMapMergeVertexShader: {
  46927. name: string;
  46928. shader: string;
  46929. };
  46930. }
  46931. declare module BABYLON {
  46932. interface AbstractScene {
  46933. /**
  46934. * Return a the first highlight layer of the scene with a given name.
  46935. * @param name The name of the highlight layer to look for.
  46936. * @return The highlight layer if found otherwise null.
  46937. */
  46938. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46939. }
  46940. /**
  46941. * Glow layer options. This helps customizing the behaviour
  46942. * of the glow layer.
  46943. */
  46944. export interface IGlowLayerOptions {
  46945. /**
  46946. * Multiplication factor apply to the canvas size to compute the render target size
  46947. * used to generated the glowing objects (the smaller the faster).
  46948. */
  46949. mainTextureRatio: number;
  46950. /**
  46951. * Enforces a fixed size texture to ensure resize independant blur.
  46952. */
  46953. mainTextureFixedSize?: number;
  46954. /**
  46955. * How big is the kernel of the blur texture.
  46956. */
  46957. blurKernelSize: number;
  46958. /**
  46959. * The camera attached to the layer.
  46960. */
  46961. camera: Nullable<Camera>;
  46962. /**
  46963. * Enable MSAA by chosing the number of samples.
  46964. */
  46965. mainTextureSamples?: number;
  46966. /**
  46967. * The rendering group to draw the layer in.
  46968. */
  46969. renderingGroupId: number;
  46970. }
  46971. /**
  46972. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46973. *
  46974. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46975. * glowy meshes to your scene.
  46976. *
  46977. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46978. */
  46979. export class GlowLayer extends EffectLayer {
  46980. /**
  46981. * Effect Name of the layer.
  46982. */
  46983. static readonly EffectName: string;
  46984. /**
  46985. * The default blur kernel size used for the glow.
  46986. */
  46987. static DefaultBlurKernelSize: number;
  46988. /**
  46989. * The default texture size ratio used for the glow.
  46990. */
  46991. static DefaultTextureRatio: number;
  46992. /**
  46993. * Sets the kernel size of the blur.
  46994. */
  46995. /**
  46996. * Gets the kernel size of the blur.
  46997. */
  46998. blurKernelSize: number;
  46999. /**
  47000. * Sets the glow intensity.
  47001. */
  47002. /**
  47003. * Gets the glow intensity.
  47004. */
  47005. intensity: number;
  47006. private _options;
  47007. private _intensity;
  47008. private _horizontalBlurPostprocess1;
  47009. private _verticalBlurPostprocess1;
  47010. private _horizontalBlurPostprocess2;
  47011. private _verticalBlurPostprocess2;
  47012. private _blurTexture1;
  47013. private _blurTexture2;
  47014. private _postProcesses1;
  47015. private _postProcesses2;
  47016. private _includedOnlyMeshes;
  47017. private _excludedMeshes;
  47018. /**
  47019. * Callback used to let the user override the color selection on a per mesh basis
  47020. */
  47021. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47022. /**
  47023. * Callback used to let the user override the texture selection on a per mesh basis
  47024. */
  47025. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47026. /**
  47027. * Instantiates a new glow Layer and references it to the scene.
  47028. * @param name The name of the layer
  47029. * @param scene The scene to use the layer in
  47030. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47031. */
  47032. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47033. /**
  47034. * Get the effect name of the layer.
  47035. * @return The effect name
  47036. */
  47037. getEffectName(): string;
  47038. /**
  47039. * Create the merge effect. This is the shader use to blit the information back
  47040. * to the main canvas at the end of the scene rendering.
  47041. */
  47042. protected _createMergeEffect(): Effect;
  47043. /**
  47044. * Creates the render target textures and post processes used in the glow layer.
  47045. */
  47046. protected _createTextureAndPostProcesses(): void;
  47047. /**
  47048. * Checks for the readiness of the element composing the layer.
  47049. * @param subMesh the mesh to check for
  47050. * @param useInstances specify wether or not to use instances to render the mesh
  47051. * @param emissiveTexture the associated emissive texture used to generate the glow
  47052. * @return true if ready otherwise, false
  47053. */
  47054. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47055. /**
  47056. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47057. */
  47058. needStencil(): boolean;
  47059. /**
  47060. * Returns true if the mesh can be rendered, otherwise false.
  47061. * @param mesh The mesh to render
  47062. * @param material The material used on the mesh
  47063. * @returns true if it can be rendered otherwise false
  47064. */
  47065. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47066. /**
  47067. * Implementation specific of rendering the generating effect on the main canvas.
  47068. * @param effect The effect used to render through
  47069. */
  47070. protected _internalRender(effect: Effect): void;
  47071. /**
  47072. * Sets the required values for both the emissive texture and and the main color.
  47073. */
  47074. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47075. /**
  47076. * Returns true if the mesh should render, otherwise false.
  47077. * @param mesh The mesh to render
  47078. * @returns true if it should render otherwise false
  47079. */
  47080. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47081. /**
  47082. * Adds specific effects defines.
  47083. * @param defines The defines to add specifics to.
  47084. */
  47085. protected _addCustomEffectDefines(defines: string[]): void;
  47086. /**
  47087. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47088. * @param mesh The mesh to exclude from the glow layer
  47089. */
  47090. addExcludedMesh(mesh: Mesh): void;
  47091. /**
  47092. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47093. * @param mesh The mesh to remove
  47094. */
  47095. removeExcludedMesh(mesh: Mesh): void;
  47096. /**
  47097. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47098. * @param mesh The mesh to include in the glow layer
  47099. */
  47100. addIncludedOnlyMesh(mesh: Mesh): void;
  47101. /**
  47102. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47103. * @param mesh The mesh to remove
  47104. */
  47105. removeIncludedOnlyMesh(mesh: Mesh): void;
  47106. /**
  47107. * Determine if a given mesh will be used in the glow layer
  47108. * @param mesh The mesh to test
  47109. * @returns true if the mesh will be highlighted by the current glow layer
  47110. */
  47111. hasMesh(mesh: AbstractMesh): boolean;
  47112. /**
  47113. * Free any resources and references associated to a mesh.
  47114. * Internal use
  47115. * @param mesh The mesh to free.
  47116. * @hidden
  47117. */ private _disposeMesh(mesh: Mesh): void;
  47118. /**
  47119. * Gets the class name of the effect layer
  47120. * @returns the string with the class name of the effect layer
  47121. */
  47122. getClassName(): string;
  47123. /**
  47124. * Serializes this glow layer
  47125. * @returns a serialized glow layer object
  47126. */
  47127. serialize(): any;
  47128. /**
  47129. * Creates a Glow Layer from parsed glow layer data
  47130. * @param parsedGlowLayer defines glow layer data
  47131. * @param scene defines the current scene
  47132. * @param rootUrl defines the root URL containing the glow layer information
  47133. * @returns a parsed Glow Layer
  47134. */
  47135. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47136. }
  47137. }
  47138. declare module BABYLON {
  47139. /** @hidden */
  47140. export var glowBlurPostProcessPixelShader: {
  47141. name: string;
  47142. shader: string;
  47143. };
  47144. }
  47145. declare module BABYLON {
  47146. interface AbstractScene {
  47147. /**
  47148. * Return a the first highlight layer of the scene with a given name.
  47149. * @param name The name of the highlight layer to look for.
  47150. * @return The highlight layer if found otherwise null.
  47151. */
  47152. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47153. }
  47154. /**
  47155. * Highlight layer options. This helps customizing the behaviour
  47156. * of the highlight layer.
  47157. */
  47158. export interface IHighlightLayerOptions {
  47159. /**
  47160. * Multiplication factor apply to the canvas size to compute the render target size
  47161. * used to generated the glowing objects (the smaller the faster).
  47162. */
  47163. mainTextureRatio: number;
  47164. /**
  47165. * Enforces a fixed size texture to ensure resize independant blur.
  47166. */
  47167. mainTextureFixedSize?: number;
  47168. /**
  47169. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47170. * of the picture to blur (the smaller the faster).
  47171. */
  47172. blurTextureSizeRatio: number;
  47173. /**
  47174. * How big in texel of the blur texture is the vertical blur.
  47175. */
  47176. blurVerticalSize: number;
  47177. /**
  47178. * How big in texel of the blur texture is the horizontal blur.
  47179. */
  47180. blurHorizontalSize: number;
  47181. /**
  47182. * Alpha blending mode used to apply the blur. Default is combine.
  47183. */
  47184. alphaBlendingMode: number;
  47185. /**
  47186. * The camera attached to the layer.
  47187. */
  47188. camera: Nullable<Camera>;
  47189. /**
  47190. * Should we display highlight as a solid stroke?
  47191. */
  47192. isStroke?: boolean;
  47193. /**
  47194. * The rendering group to draw the layer in.
  47195. */
  47196. renderingGroupId: number;
  47197. }
  47198. /**
  47199. * The highlight layer Helps adding a glow effect around a mesh.
  47200. *
  47201. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47202. * glowy meshes to your scene.
  47203. *
  47204. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47205. */
  47206. export class HighlightLayer extends EffectLayer {
  47207. name: string;
  47208. /**
  47209. * Effect Name of the highlight layer.
  47210. */
  47211. static readonly EffectName: string;
  47212. /**
  47213. * The neutral color used during the preparation of the glow effect.
  47214. * This is black by default as the blend operation is a blend operation.
  47215. */
  47216. static NeutralColor: Color4;
  47217. /**
  47218. * Stencil value used for glowing meshes.
  47219. */
  47220. static GlowingMeshStencilReference: number;
  47221. /**
  47222. * Stencil value used for the other meshes in the scene.
  47223. */
  47224. static NormalMeshStencilReference: number;
  47225. /**
  47226. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47227. */
  47228. innerGlow: boolean;
  47229. /**
  47230. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47231. */
  47232. outerGlow: boolean;
  47233. /**
  47234. * Specifies the horizontal size of the blur.
  47235. */
  47236. /**
  47237. * Gets the horizontal size of the blur.
  47238. */
  47239. blurHorizontalSize: number;
  47240. /**
  47241. * Specifies the vertical size of the blur.
  47242. */
  47243. /**
  47244. * Gets the vertical size of the blur.
  47245. */
  47246. blurVerticalSize: number;
  47247. /**
  47248. * An event triggered when the highlight layer is being blurred.
  47249. */
  47250. onBeforeBlurObservable: Observable<HighlightLayer>;
  47251. /**
  47252. * An event triggered when the highlight layer has been blurred.
  47253. */
  47254. onAfterBlurObservable: Observable<HighlightLayer>;
  47255. private _instanceGlowingMeshStencilReference;
  47256. private _options;
  47257. private _downSamplePostprocess;
  47258. private _horizontalBlurPostprocess;
  47259. private _verticalBlurPostprocess;
  47260. private _blurTexture;
  47261. private _meshes;
  47262. private _excludedMeshes;
  47263. /**
  47264. * Instantiates a new highlight Layer and references it to the scene..
  47265. * @param name The name of the layer
  47266. * @param scene The scene to use the layer in
  47267. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47268. */
  47269. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47270. /**
  47271. * Get the effect name of the layer.
  47272. * @return The effect name
  47273. */
  47274. getEffectName(): string;
  47275. /**
  47276. * Create the merge effect. This is the shader use to blit the information back
  47277. * to the main canvas at the end of the scene rendering.
  47278. */
  47279. protected _createMergeEffect(): Effect;
  47280. /**
  47281. * Creates the render target textures and post processes used in the highlight layer.
  47282. */
  47283. protected _createTextureAndPostProcesses(): void;
  47284. /**
  47285. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47286. */
  47287. needStencil(): boolean;
  47288. /**
  47289. * Checks for the readiness of the element composing the layer.
  47290. * @param subMesh the mesh to check for
  47291. * @param useInstances specify wether or not to use instances to render the mesh
  47292. * @param emissiveTexture the associated emissive texture used to generate the glow
  47293. * @return true if ready otherwise, false
  47294. */
  47295. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47296. /**
  47297. * Implementation specific of rendering the generating effect on the main canvas.
  47298. * @param effect The effect used to render through
  47299. */
  47300. protected _internalRender(effect: Effect): void;
  47301. /**
  47302. * Returns true if the layer contains information to display, otherwise false.
  47303. */
  47304. shouldRender(): boolean;
  47305. /**
  47306. * Returns true if the mesh should render, otherwise false.
  47307. * @param mesh The mesh to render
  47308. * @returns true if it should render otherwise false
  47309. */
  47310. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47311. /**
  47312. * Sets the required values for both the emissive texture and and the main color.
  47313. */
  47314. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47315. /**
  47316. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47317. * @param mesh The mesh to exclude from the highlight layer
  47318. */
  47319. addExcludedMesh(mesh: Mesh): void;
  47320. /**
  47321. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47322. * @param mesh The mesh to highlight
  47323. */
  47324. removeExcludedMesh(mesh: Mesh): void;
  47325. /**
  47326. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47327. * @param mesh mesh to test
  47328. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47329. */
  47330. hasMesh(mesh: AbstractMesh): boolean;
  47331. /**
  47332. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47333. * @param mesh The mesh to highlight
  47334. * @param color The color of the highlight
  47335. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47336. */
  47337. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47338. /**
  47339. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47340. * @param mesh The mesh to highlight
  47341. */
  47342. removeMesh(mesh: Mesh): void;
  47343. /**
  47344. * Force the stencil to the normal expected value for none glowing parts
  47345. */
  47346. private _defaultStencilReference;
  47347. /**
  47348. * Free any resources and references associated to a mesh.
  47349. * Internal use
  47350. * @param mesh The mesh to free.
  47351. * @hidden
  47352. */ private _disposeMesh(mesh: Mesh): void;
  47353. /**
  47354. * Dispose the highlight layer and free resources.
  47355. */
  47356. dispose(): void;
  47357. /**
  47358. * Gets the class name of the effect layer
  47359. * @returns the string with the class name of the effect layer
  47360. */
  47361. getClassName(): string;
  47362. /**
  47363. * Serializes this Highlight layer
  47364. * @returns a serialized Highlight layer object
  47365. */
  47366. serialize(): any;
  47367. /**
  47368. * Creates a Highlight layer from parsed Highlight layer data
  47369. * @param parsedHightlightLayer defines the Highlight layer data
  47370. * @param scene defines the current scene
  47371. * @param rootUrl defines the root URL containing the Highlight layer information
  47372. * @returns a parsed Highlight layer
  47373. */
  47374. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47375. }
  47376. }
  47377. declare module BABYLON {
  47378. interface AbstractScene {
  47379. /**
  47380. * The list of layers (background and foreground) of the scene
  47381. */
  47382. layers: Array<Layer>;
  47383. }
  47384. /**
  47385. * Defines the layer scene component responsible to manage any layers
  47386. * in a given scene.
  47387. */
  47388. export class LayerSceneComponent implements ISceneComponent {
  47389. /**
  47390. * The component name helpfull to identify the component in the list of scene components.
  47391. */
  47392. readonly name: string;
  47393. /**
  47394. * The scene the component belongs to.
  47395. */
  47396. scene: Scene;
  47397. private _engine;
  47398. /**
  47399. * Creates a new instance of the component for the given scene
  47400. * @param scene Defines the scene to register the component in
  47401. */
  47402. constructor(scene: Scene);
  47403. /**
  47404. * Registers the component in a given scene
  47405. */
  47406. register(): void;
  47407. /**
  47408. * Rebuilds the elements related to this component in case of
  47409. * context lost for instance.
  47410. */
  47411. rebuild(): void;
  47412. /**
  47413. * Disposes the component and the associated ressources.
  47414. */
  47415. dispose(): void;
  47416. private _draw;
  47417. private _drawCameraPredicate;
  47418. private _drawCameraBackground;
  47419. private _drawCameraForeground;
  47420. private _drawRenderTargetPredicate;
  47421. private _drawRenderTargetBackground;
  47422. private _drawRenderTargetForeground;
  47423. /**
  47424. * Adds all the elements from the container to the scene
  47425. * @param container the container holding the elements
  47426. */
  47427. addFromContainer(container: AbstractScene): void;
  47428. /**
  47429. * Removes all the elements in the container from the scene
  47430. * @param container contains the elements to remove
  47431. * @param dispose if the removed element should be disposed (default: false)
  47432. */
  47433. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47434. }
  47435. }
  47436. declare module BABYLON {
  47437. /** @hidden */
  47438. export var layerPixelShader: {
  47439. name: string;
  47440. shader: string;
  47441. };
  47442. }
  47443. declare module BABYLON {
  47444. /** @hidden */
  47445. export var layerVertexShader: {
  47446. name: string;
  47447. shader: string;
  47448. };
  47449. }
  47450. declare module BABYLON {
  47451. /**
  47452. * This represents a full screen 2d layer.
  47453. * This can be useful to display a picture in the background of your scene for instance.
  47454. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47455. */
  47456. export class Layer {
  47457. /**
  47458. * Define the name of the layer.
  47459. */
  47460. name: string;
  47461. /**
  47462. * Define the texture the layer should display.
  47463. */
  47464. texture: Nullable<Texture>;
  47465. /**
  47466. * Is the layer in background or foreground.
  47467. */
  47468. isBackground: boolean;
  47469. /**
  47470. * Define the color of the layer (instead of texture).
  47471. */
  47472. color: Color4;
  47473. /**
  47474. * Define the scale of the layer in order to zoom in out of the texture.
  47475. */
  47476. scale: Vector2;
  47477. /**
  47478. * Define an offset for the layer in order to shift the texture.
  47479. */
  47480. offset: Vector2;
  47481. /**
  47482. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47483. */
  47484. alphaBlendingMode: number;
  47485. /**
  47486. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47487. * Alpha test will not mix with the background color in case of transparency.
  47488. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47489. */
  47490. alphaTest: boolean;
  47491. /**
  47492. * Define a mask to restrict the layer to only some of the scene cameras.
  47493. */
  47494. layerMask: number;
  47495. /**
  47496. * Define the list of render target the layer is visible into.
  47497. */
  47498. renderTargetTextures: RenderTargetTexture[];
  47499. /**
  47500. * Define if the layer is only used in renderTarget or if it also
  47501. * renders in the main frame buffer of the canvas.
  47502. */
  47503. renderOnlyInRenderTargetTextures: boolean;
  47504. private _scene;
  47505. private _vertexBuffers;
  47506. private _indexBuffer;
  47507. private _effect;
  47508. private _alphaTestEffect;
  47509. /**
  47510. * An event triggered when the layer is disposed.
  47511. */
  47512. onDisposeObservable: Observable<Layer>;
  47513. private _onDisposeObserver;
  47514. /**
  47515. * Back compatibility with callback before the onDisposeObservable existed.
  47516. * The set callback will be triggered when the layer has been disposed.
  47517. */
  47518. onDispose: () => void;
  47519. /**
  47520. * An event triggered before rendering the scene
  47521. */
  47522. onBeforeRenderObservable: Observable<Layer>;
  47523. private _onBeforeRenderObserver;
  47524. /**
  47525. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47526. * The set callback will be triggered just before rendering the layer.
  47527. */
  47528. onBeforeRender: () => void;
  47529. /**
  47530. * An event triggered after rendering the scene
  47531. */
  47532. onAfterRenderObservable: Observable<Layer>;
  47533. private _onAfterRenderObserver;
  47534. /**
  47535. * Back compatibility with callback before the onAfterRenderObservable existed.
  47536. * The set callback will be triggered just after rendering the layer.
  47537. */
  47538. onAfterRender: () => void;
  47539. /**
  47540. * Instantiates a new layer.
  47541. * This represents a full screen 2d layer.
  47542. * This can be useful to display a picture in the background of your scene for instance.
  47543. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47544. * @param name Define the name of the layer in the scene
  47545. * @param imgUrl Define the url of the texture to display in the layer
  47546. * @param scene Define the scene the layer belongs to
  47547. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47548. * @param color Defines a color for the layer
  47549. */
  47550. constructor(
  47551. /**
  47552. * Define the name of the layer.
  47553. */
  47554. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47555. private _createIndexBuffer;
  47556. /** @hidden */ private _rebuild(): void;
  47557. /**
  47558. * Renders the layer in the scene.
  47559. */
  47560. render(): void;
  47561. /**
  47562. * Disposes and releases the associated ressources.
  47563. */
  47564. dispose(): void;
  47565. }
  47566. }
  47567. declare module BABYLON {
  47568. /** @hidden */
  47569. export var lensFlarePixelShader: {
  47570. name: string;
  47571. shader: string;
  47572. };
  47573. }
  47574. declare module BABYLON {
  47575. /** @hidden */
  47576. export var lensFlareVertexShader: {
  47577. name: string;
  47578. shader: string;
  47579. };
  47580. }
  47581. declare module BABYLON {
  47582. /**
  47583. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47584. * It is usually composed of several `lensFlare`.
  47585. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47586. */
  47587. export class LensFlareSystem {
  47588. /**
  47589. * Define the name of the lens flare system
  47590. */
  47591. name: string;
  47592. /**
  47593. * List of lens flares used in this system.
  47594. */
  47595. lensFlares: LensFlare[];
  47596. /**
  47597. * Define a limit from the border the lens flare can be visible.
  47598. */
  47599. borderLimit: number;
  47600. /**
  47601. * Define a viewport border we do not want to see the lens flare in.
  47602. */
  47603. viewportBorder: number;
  47604. /**
  47605. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47606. */
  47607. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47608. /**
  47609. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47610. */
  47611. layerMask: number;
  47612. /**
  47613. * Define the id of the lens flare system in the scene.
  47614. * (equal to name by default)
  47615. */
  47616. id: string;
  47617. private _scene;
  47618. private _emitter;
  47619. private _vertexBuffers;
  47620. private _indexBuffer;
  47621. private _effect;
  47622. private _positionX;
  47623. private _positionY;
  47624. private _isEnabled;
  47625. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47626. /**
  47627. * Instantiates a lens flare system.
  47628. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47629. * It is usually composed of several `lensFlare`.
  47630. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47631. * @param name Define the name of the lens flare system in the scene
  47632. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47633. * @param scene Define the scene the lens flare system belongs to
  47634. */
  47635. constructor(
  47636. /**
  47637. * Define the name of the lens flare system
  47638. */
  47639. name: string, emitter: any, scene: Scene);
  47640. /**
  47641. * Define if the lens flare system is enabled.
  47642. */
  47643. isEnabled: boolean;
  47644. /**
  47645. * Get the scene the effects belongs to.
  47646. * @returns the scene holding the lens flare system
  47647. */
  47648. getScene(): Scene;
  47649. /**
  47650. * Get the emitter of the lens flare system.
  47651. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47652. * @returns the emitter of the lens flare system
  47653. */
  47654. getEmitter(): any;
  47655. /**
  47656. * Set the emitter of the lens flare system.
  47657. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47658. * @param newEmitter Define the new emitter of the system
  47659. */
  47660. setEmitter(newEmitter: any): void;
  47661. /**
  47662. * Get the lens flare system emitter position.
  47663. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47664. * @returns the position
  47665. */
  47666. getEmitterPosition(): Vector3;
  47667. /**
  47668. * @hidden
  47669. */
  47670. computeEffectivePosition(globalViewport: Viewport): boolean;
  47671. /** @hidden */ private _isVisible(): boolean;
  47672. /**
  47673. * @hidden
  47674. */
  47675. render(): boolean;
  47676. /**
  47677. * Dispose and release the lens flare with its associated resources.
  47678. */
  47679. dispose(): void;
  47680. /**
  47681. * Parse a lens flare system from a JSON repressentation
  47682. * @param parsedLensFlareSystem Define the JSON to parse
  47683. * @param scene Define the scene the parsed system should be instantiated in
  47684. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47685. * @returns the parsed system
  47686. */
  47687. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47688. /**
  47689. * Serialize the current Lens Flare System into a JSON representation.
  47690. * @returns the serialized JSON
  47691. */
  47692. serialize(): any;
  47693. }
  47694. }
  47695. declare module BABYLON {
  47696. /**
  47697. * This represents one of the lens effect in a `lensFlareSystem`.
  47698. * It controls one of the indiviual texture used in the effect.
  47699. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47700. */
  47701. export class LensFlare {
  47702. /**
  47703. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47704. */
  47705. size: number;
  47706. /**
  47707. * 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.
  47708. */
  47709. position: number;
  47710. /**
  47711. * Define the lens color.
  47712. */
  47713. color: Color3;
  47714. /**
  47715. * Define the lens texture.
  47716. */
  47717. texture: Nullable<Texture>;
  47718. /**
  47719. * Define the alpha mode to render this particular lens.
  47720. */
  47721. alphaMode: number;
  47722. private _system;
  47723. /**
  47724. * Creates a new Lens Flare.
  47725. * This represents one of the lens effect in a `lensFlareSystem`.
  47726. * It controls one of the indiviual texture used in the effect.
  47727. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47728. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47729. * @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.
  47730. * @param color Define the lens color
  47731. * @param imgUrl Define the lens texture url
  47732. * @param system Define the `lensFlareSystem` this flare is part of
  47733. * @returns The newly created Lens Flare
  47734. */
  47735. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47736. /**
  47737. * Instantiates a new Lens Flare.
  47738. * This represents one of the lens effect in a `lensFlareSystem`.
  47739. * It controls one of the indiviual texture used in the effect.
  47740. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47741. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47742. * @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.
  47743. * @param color Define the lens color
  47744. * @param imgUrl Define the lens texture url
  47745. * @param system Define the `lensFlareSystem` this flare is part of
  47746. */
  47747. constructor(
  47748. /**
  47749. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47750. */
  47751. size: number,
  47752. /**
  47753. * 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.
  47754. */
  47755. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47756. /**
  47757. * Dispose and release the lens flare with its associated resources.
  47758. */
  47759. dispose(): void;
  47760. }
  47761. }
  47762. declare module BABYLON {
  47763. interface AbstractScene {
  47764. /**
  47765. * The list of lens flare system added to the scene
  47766. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47767. */
  47768. lensFlareSystems: Array<LensFlareSystem>;
  47769. /**
  47770. * Removes the given lens flare system from this scene.
  47771. * @param toRemove The lens flare system to remove
  47772. * @returns The index of the removed lens flare system
  47773. */
  47774. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47775. /**
  47776. * Adds the given lens flare system to this scene
  47777. * @param newLensFlareSystem The lens flare system to add
  47778. */
  47779. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47780. /**
  47781. * Gets a lens flare system using its name
  47782. * @param name defines the name to look for
  47783. * @returns the lens flare system or null if not found
  47784. */
  47785. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47786. /**
  47787. * Gets a lens flare system using its id
  47788. * @param id defines the id to look for
  47789. * @returns the lens flare system or null if not found
  47790. */
  47791. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47792. }
  47793. /**
  47794. * Defines the lens flare scene component responsible to manage any lens flares
  47795. * in a given scene.
  47796. */
  47797. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47798. /**
  47799. * The component name helpfull to identify the component in the list of scene components.
  47800. */
  47801. readonly name: string;
  47802. /**
  47803. * The scene the component belongs to.
  47804. */
  47805. scene: Scene;
  47806. /**
  47807. * Creates a new instance of the component for the given scene
  47808. * @param scene Defines the scene to register the component in
  47809. */
  47810. constructor(scene: Scene);
  47811. /**
  47812. * Registers the component in a given scene
  47813. */
  47814. register(): void;
  47815. /**
  47816. * Rebuilds the elements related to this component in case of
  47817. * context lost for instance.
  47818. */
  47819. rebuild(): void;
  47820. /**
  47821. * Adds all the elements from the container to the scene
  47822. * @param container the container holding the elements
  47823. */
  47824. addFromContainer(container: AbstractScene): void;
  47825. /**
  47826. * Removes all the elements in the container from the scene
  47827. * @param container contains the elements to remove
  47828. * @param dispose if the removed element should be disposed (default: false)
  47829. */
  47830. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47831. /**
  47832. * Serializes the component data to the specified json object
  47833. * @param serializationObject The object to serialize to
  47834. */
  47835. serialize(serializationObject: any): void;
  47836. /**
  47837. * Disposes the component and the associated ressources.
  47838. */
  47839. dispose(): void;
  47840. private _draw;
  47841. }
  47842. }
  47843. declare module BABYLON {
  47844. /**
  47845. * Defines the shadow generator component responsible to manage any shadow generators
  47846. * in a given scene.
  47847. */
  47848. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47849. /**
  47850. * The component name helpfull to identify the component in the list of scene components.
  47851. */
  47852. readonly name: string;
  47853. /**
  47854. * The scene the component belongs to.
  47855. */
  47856. scene: Scene;
  47857. /**
  47858. * Creates a new instance of the component for the given scene
  47859. * @param scene Defines the scene to register the component in
  47860. */
  47861. constructor(scene: Scene);
  47862. /**
  47863. * Registers the component in a given scene
  47864. */
  47865. register(): void;
  47866. /**
  47867. * Rebuilds the elements related to this component in case of
  47868. * context lost for instance.
  47869. */
  47870. rebuild(): void;
  47871. /**
  47872. * Serializes the component data to the specified json object
  47873. * @param serializationObject The object to serialize to
  47874. */
  47875. serialize(serializationObject: any): void;
  47876. /**
  47877. * Adds all the elements from the container to the scene
  47878. * @param container the container holding the elements
  47879. */
  47880. addFromContainer(container: AbstractScene): void;
  47881. /**
  47882. * Removes all the elements in the container from the scene
  47883. * @param container contains the elements to remove
  47884. * @param dispose if the removed element should be disposed (default: false)
  47885. */
  47886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47887. /**
  47888. * Rebuilds the elements related to this component in case of
  47889. * context lost for instance.
  47890. */
  47891. dispose(): void;
  47892. private _gatherRenderTargets;
  47893. }
  47894. }
  47895. declare module BABYLON {
  47896. /**
  47897. * A point light is a light defined by an unique point in world space.
  47898. * The light is emitted in every direction from this point.
  47899. * A good example of a point light is a standard light bulb.
  47900. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47901. */
  47902. export class PointLight extends ShadowLight {
  47903. private _shadowAngle;
  47904. /**
  47905. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47906. * This specifies what angle the shadow will use to be created.
  47907. *
  47908. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47909. */
  47910. /**
  47911. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47912. * This specifies what angle the shadow will use to be created.
  47913. *
  47914. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47915. */
  47916. shadowAngle: number;
  47917. /**
  47918. * Gets the direction if it has been set.
  47919. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47920. */
  47921. /**
  47922. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47923. */
  47924. direction: Vector3;
  47925. /**
  47926. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47927. * A PointLight emits the light in every direction.
  47928. * It can cast shadows.
  47929. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47930. * ```javascript
  47931. * var pointLight = new PointLight("pl", camera.position, scene);
  47932. * ```
  47933. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47934. * @param name The light friendly name
  47935. * @param position The position of the point light in the scene
  47936. * @param scene The scene the lights belongs to
  47937. */
  47938. constructor(name: string, position: Vector3, scene: Scene);
  47939. /**
  47940. * Returns the string "PointLight"
  47941. * @returns the class name
  47942. */
  47943. getClassName(): string;
  47944. /**
  47945. * Returns the integer 0.
  47946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47947. */
  47948. getTypeID(): number;
  47949. /**
  47950. * Specifies wether or not the shadowmap should be a cube texture.
  47951. * @returns true if the shadowmap needs to be a cube texture.
  47952. */
  47953. needCube(): boolean;
  47954. /**
  47955. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47956. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47957. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47958. */
  47959. getShadowDirection(faceIndex?: number): Vector3;
  47960. /**
  47961. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47962. * - fov = PI / 2
  47963. * - aspect ratio : 1.0
  47964. * - z-near and far equal to the active camera minZ and maxZ.
  47965. * Returns the PointLight.
  47966. */
  47967. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47968. protected _buildUniformLayout(): void;
  47969. /**
  47970. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47971. * @param effect The effect to update
  47972. * @param lightIndex The index of the light in the effect to update
  47973. * @returns The point light
  47974. */
  47975. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47976. /**
  47977. * Prepares the list of defines specific to the light type.
  47978. * @param defines the list of defines
  47979. * @param lightIndex defines the index of the light for the effect
  47980. */
  47981. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47982. }
  47983. }
  47984. declare module BABYLON {
  47985. /**
  47986. * Header information of HDR texture files.
  47987. */
  47988. export interface HDRInfo {
  47989. /**
  47990. * The height of the texture in pixels.
  47991. */
  47992. height: number;
  47993. /**
  47994. * The width of the texture in pixels.
  47995. */
  47996. width: number;
  47997. /**
  47998. * The index of the beginning of the data in the binary file.
  47999. */
  48000. dataPosition: number;
  48001. }
  48002. /**
  48003. * This groups tools to convert HDR texture to native colors array.
  48004. */
  48005. export class HDRTools {
  48006. private static Ldexp;
  48007. private static Rgbe2float;
  48008. private static readStringLine;
  48009. /**
  48010. * Reads header information from an RGBE texture stored in a native array.
  48011. * More information on this format are available here:
  48012. * https://en.wikipedia.org/wiki/RGBE_image_format
  48013. *
  48014. * @param uint8array The binary file stored in native array.
  48015. * @return The header information.
  48016. */
  48017. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48018. /**
  48019. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48020. * This RGBE texture needs to store the information as a panorama.
  48021. *
  48022. * More information on this format are available here:
  48023. * https://en.wikipedia.org/wiki/RGBE_image_format
  48024. *
  48025. * @param buffer The binary file stored in an array buffer.
  48026. * @param size The expected size of the extracted cubemap.
  48027. * @return The Cube Map information.
  48028. */
  48029. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48030. /**
  48031. * Returns the pixels data extracted from an RGBE texture.
  48032. * This pixels will be stored left to right up to down in the R G B order in one array.
  48033. *
  48034. * More information on this format are available here:
  48035. * https://en.wikipedia.org/wiki/RGBE_image_format
  48036. *
  48037. * @param uint8array The binary file stored in an array buffer.
  48038. * @param hdrInfo The header information of the file.
  48039. * @return The pixels data in RGB right to left up to down order.
  48040. */
  48041. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48042. private static RGBE_ReadPixels_RLE;
  48043. }
  48044. }
  48045. declare module BABYLON {
  48046. /**
  48047. * This represents a texture coming from an HDR input.
  48048. *
  48049. * The only supported format is currently panorama picture stored in RGBE format.
  48050. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48051. */
  48052. export class HDRCubeTexture extends BaseTexture {
  48053. private static _facesMapping;
  48054. private _generateHarmonics;
  48055. private _noMipmap;
  48056. private _textureMatrix;
  48057. private _size;
  48058. private _onLoad;
  48059. private _onError;
  48060. /**
  48061. * The texture URL.
  48062. */
  48063. url: string;
  48064. /**
  48065. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48066. */
  48067. coordinatesMode: number;
  48068. protected _isBlocking: boolean;
  48069. /**
  48070. * Sets wether or not the texture is blocking during loading.
  48071. */
  48072. /**
  48073. * Gets wether or not the texture is blocking during loading.
  48074. */
  48075. isBlocking: boolean;
  48076. protected _rotationY: number;
  48077. /**
  48078. * Sets texture matrix rotation angle around Y axis in radians.
  48079. */
  48080. /**
  48081. * Gets texture matrix rotation angle around Y axis radians.
  48082. */
  48083. rotationY: number;
  48084. /**
  48085. * Gets or sets the center of the bounding box associated with the cube texture
  48086. * It must define where the camera used to render the texture was set
  48087. */
  48088. boundingBoxPosition: Vector3;
  48089. private _boundingBoxSize;
  48090. /**
  48091. * Gets or sets the size of the bounding box associated with the cube texture
  48092. * When defined, the cubemap will switch to local mode
  48093. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48094. * @example https://www.babylonjs-playground.com/#RNASML
  48095. */
  48096. boundingBoxSize: Vector3;
  48097. /**
  48098. * Instantiates an HDRTexture from the following parameters.
  48099. *
  48100. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48101. * @param scene The scene the texture will be used in
  48102. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48103. * @param noMipmap Forces to not generate the mipmap if true
  48104. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48105. * @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)
  48106. * @param reserved Reserved flag for internal use.
  48107. */
  48108. 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>);
  48109. /**
  48110. * Get the current class name of the texture useful for serialization or dynamic coding.
  48111. * @returns "HDRCubeTexture"
  48112. */
  48113. getClassName(): string;
  48114. /**
  48115. * Occurs when the file is raw .hdr file.
  48116. */
  48117. private loadTexture;
  48118. clone(): HDRCubeTexture;
  48119. delayLoad(): void;
  48120. /**
  48121. * Get the texture reflection matrix used to rotate/transform the reflection.
  48122. * @returns the reflection matrix
  48123. */
  48124. getReflectionTextureMatrix(): Matrix;
  48125. /**
  48126. * Set the texture reflection matrix used to rotate/transform the reflection.
  48127. * @param value Define the reflection matrix to set
  48128. */
  48129. setReflectionTextureMatrix(value: Matrix): void;
  48130. /**
  48131. * Parses a JSON representation of an HDR Texture in order to create the texture
  48132. * @param parsedTexture Define the JSON representation
  48133. * @param scene Define the scene the texture should be created in
  48134. * @param rootUrl Define the root url in case we need to load relative dependencies
  48135. * @returns the newly created texture after parsing
  48136. */
  48137. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48138. serialize(): any;
  48139. }
  48140. }
  48141. declare module BABYLON {
  48142. /**
  48143. * Class used to control physics engine
  48144. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48145. */
  48146. export class PhysicsEngine implements IPhysicsEngine {
  48147. private _physicsPlugin;
  48148. /**
  48149. * Global value used to control the smallest number supported by the simulation
  48150. */
  48151. static Epsilon: number;
  48152. private _impostors;
  48153. private _joints;
  48154. /**
  48155. * Gets the gravity vector used by the simulation
  48156. */
  48157. gravity: Vector3;
  48158. /**
  48159. * Factory used to create the default physics plugin.
  48160. * @returns The default physics plugin
  48161. */
  48162. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48163. /**
  48164. * Creates a new Physics Engine
  48165. * @param gravity defines the gravity vector used by the simulation
  48166. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48167. */
  48168. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48169. /**
  48170. * Sets the gravity vector used by the simulation
  48171. * @param gravity defines the gravity vector to use
  48172. */
  48173. setGravity(gravity: Vector3): void;
  48174. /**
  48175. * Set the time step of the physics engine.
  48176. * Default is 1/60.
  48177. * To slow it down, enter 1/600 for example.
  48178. * To speed it up, 1/30
  48179. * @param newTimeStep defines the new timestep to apply to this world.
  48180. */
  48181. setTimeStep(newTimeStep?: number): void;
  48182. /**
  48183. * Get the time step of the physics engine.
  48184. * @returns the current time step
  48185. */
  48186. getTimeStep(): number;
  48187. /**
  48188. * Release all resources
  48189. */
  48190. dispose(): void;
  48191. /**
  48192. * Gets the name of the current physics plugin
  48193. * @returns the name of the plugin
  48194. */
  48195. getPhysicsPluginName(): string;
  48196. /**
  48197. * Adding a new impostor for the impostor tracking.
  48198. * This will be done by the impostor itself.
  48199. * @param impostor the impostor to add
  48200. */
  48201. addImpostor(impostor: PhysicsImpostor): void;
  48202. /**
  48203. * Remove an impostor from the engine.
  48204. * This impostor and its mesh will not longer be updated by the physics engine.
  48205. * @param impostor the impostor to remove
  48206. */
  48207. removeImpostor(impostor: PhysicsImpostor): void;
  48208. /**
  48209. * Add a joint to the physics engine
  48210. * @param mainImpostor defines the main impostor to which the joint is added.
  48211. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48212. * @param joint defines the joint that will connect both impostors.
  48213. */
  48214. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48215. /**
  48216. * Removes a joint from the simulation
  48217. * @param mainImpostor defines the impostor used with the joint
  48218. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48219. * @param joint defines the joint to remove
  48220. */
  48221. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48222. /**
  48223. * Called by the scene. No need to call it.
  48224. * @param delta defines the timespam between frames
  48225. */ private _step(delta: number): void;
  48226. /**
  48227. * Gets the current plugin used to run the simulation
  48228. * @returns current plugin
  48229. */
  48230. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48231. /**
  48232. * Gets the list of physic impostors
  48233. * @returns an array of PhysicsImpostor
  48234. */
  48235. getImpostors(): Array<PhysicsImpostor>;
  48236. /**
  48237. * Gets the impostor for a physics enabled object
  48238. * @param object defines the object impersonated by the impostor
  48239. * @returns the PhysicsImpostor or null if not found
  48240. */
  48241. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48242. /**
  48243. * Gets the impostor for a physics body object
  48244. * @param body defines physics body used by the impostor
  48245. * @returns the PhysicsImpostor or null if not found
  48246. */
  48247. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48248. /**
  48249. * Does a raycast in the physics world
  48250. * @param from when should the ray start?
  48251. * @param to when should the ray end?
  48252. * @returns PhysicsRaycastResult
  48253. */
  48254. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48255. }
  48256. }
  48257. declare module BABYLON {
  48258. /** @hidden */
  48259. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48260. private _useDeltaForWorldStep;
  48261. world: any;
  48262. name: string;
  48263. private _physicsMaterials;
  48264. private _fixedTimeStep;
  48265. private _cannonRaycastResult;
  48266. private _raycastResult;
  48267. private _removeAfterStep;
  48268. BJSCANNON: any;
  48269. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48270. setGravity(gravity: Vector3): void;
  48271. setTimeStep(timeStep: number): void;
  48272. getTimeStep(): number;
  48273. executeStep(delta: number): void;
  48274. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48275. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48276. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48277. private _processChildMeshes;
  48278. removePhysicsBody(impostor: PhysicsImpostor): void;
  48279. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48280. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48281. private _addMaterial;
  48282. private _checkWithEpsilon;
  48283. private _createShape;
  48284. private _createHeightmap;
  48285. private _minus90X;
  48286. private _plus90X;
  48287. private _tmpPosition;
  48288. private _tmpDeltaPosition;
  48289. private _tmpUnityRotation;
  48290. private _updatePhysicsBodyTransformation;
  48291. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48292. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48293. isSupported(): boolean;
  48294. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48295. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48296. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48297. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48298. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48299. getBodyMass(impostor: PhysicsImpostor): number;
  48300. getBodyFriction(impostor: PhysicsImpostor): number;
  48301. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48302. getBodyRestitution(impostor: PhysicsImpostor): number;
  48303. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48304. sleepBody(impostor: PhysicsImpostor): void;
  48305. wakeUpBody(impostor: PhysicsImpostor): void;
  48306. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48307. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48308. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48309. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48310. getRadius(impostor: PhysicsImpostor): number;
  48311. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48312. dispose(): void;
  48313. private _extendNamespace;
  48314. /**
  48315. * Does a raycast in the physics world
  48316. * @param from when should the ray start?
  48317. * @param to when should the ray end?
  48318. * @returns PhysicsRaycastResult
  48319. */
  48320. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48321. }
  48322. }
  48323. declare module BABYLON {
  48324. /** @hidden */
  48325. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48326. world: any;
  48327. name: string;
  48328. BJSOIMO: any;
  48329. private _raycastResult;
  48330. constructor(iterations?: number, oimoInjection?: any);
  48331. setGravity(gravity: Vector3): void;
  48332. setTimeStep(timeStep: number): void;
  48333. getTimeStep(): number;
  48334. private _tmpImpostorsArray;
  48335. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48339. private _tmpPositionVector;
  48340. removePhysicsBody(impostor: PhysicsImpostor): void;
  48341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48342. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48343. isSupported(): boolean;
  48344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48351. getBodyMass(impostor: PhysicsImpostor): number;
  48352. getBodyFriction(impostor: PhysicsImpostor): number;
  48353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48354. getBodyRestitution(impostor: PhysicsImpostor): number;
  48355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48356. sleepBody(impostor: PhysicsImpostor): void;
  48357. wakeUpBody(impostor: PhysicsImpostor): void;
  48358. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48359. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48360. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48361. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48362. getRadius(impostor: PhysicsImpostor): number;
  48363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48364. dispose(): void;
  48365. /**
  48366. * Does a raycast in the physics world
  48367. * @param from when should the ray start?
  48368. * @param to when should the ray end?
  48369. * @returns PhysicsRaycastResult
  48370. */
  48371. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48372. }
  48373. }
  48374. declare module BABYLON {
  48375. /**
  48376. * Class containing static functions to help procedurally build meshes
  48377. */
  48378. export class RibbonBuilder {
  48379. /**
  48380. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48381. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48382. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48383. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48384. * * 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
  48385. * * 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
  48386. * * 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
  48387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48388. * * 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
  48389. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48390. * * 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
  48391. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48392. * * 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
  48393. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48395. * @param name defines the name of the mesh
  48396. * @param options defines the options used to create the mesh
  48397. * @param scene defines the hosting scene
  48398. * @returns the ribbon mesh
  48399. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48400. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48401. */
  48402. static CreateRibbon(name: string, options: {
  48403. pathArray: Vector3[][];
  48404. closeArray?: boolean;
  48405. closePath?: boolean;
  48406. offset?: number;
  48407. updatable?: boolean;
  48408. sideOrientation?: number;
  48409. frontUVs?: Vector4;
  48410. backUVs?: Vector4;
  48411. instance?: Mesh;
  48412. invertUV?: boolean;
  48413. uvs?: Vector2[];
  48414. colors?: Color4[];
  48415. }, scene?: Nullable<Scene>): Mesh;
  48416. }
  48417. }
  48418. declare module BABYLON {
  48419. /**
  48420. * Class containing static functions to help procedurally build meshes
  48421. */
  48422. export class ShapeBuilder {
  48423. /**
  48424. * 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.
  48425. * * 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.
  48426. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48427. * * 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.
  48428. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48429. * * 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
  48430. * * 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
  48431. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48433. * * 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
  48434. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48436. * @param name defines the name of the mesh
  48437. * @param options defines the options used to create the mesh
  48438. * @param scene defines the hosting scene
  48439. * @returns the extruded shape mesh
  48440. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48442. */
  48443. static ExtrudeShape(name: string, options: {
  48444. shape: Vector3[];
  48445. path: Vector3[];
  48446. scale?: number;
  48447. rotation?: number;
  48448. cap?: number;
  48449. updatable?: boolean;
  48450. sideOrientation?: number;
  48451. frontUVs?: Vector4;
  48452. backUVs?: Vector4;
  48453. instance?: Mesh;
  48454. invertUV?: boolean;
  48455. }, scene?: Nullable<Scene>): Mesh;
  48456. /**
  48457. * Creates an custom extruded shape mesh.
  48458. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48459. * * 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.
  48460. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48461. * * 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
  48462. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48463. * * 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
  48464. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48465. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48466. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48467. * * 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
  48468. * * 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
  48469. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48471. * * 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
  48472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48474. * @param name defines the name of the mesh
  48475. * @param options defines the options used to create the mesh
  48476. * @param scene defines the hosting scene
  48477. * @returns the custom extruded shape mesh
  48478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48479. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48481. */
  48482. static ExtrudeShapeCustom(name: string, options: {
  48483. shape: Vector3[];
  48484. path: Vector3[];
  48485. scaleFunction?: any;
  48486. rotationFunction?: any;
  48487. ribbonCloseArray?: boolean;
  48488. ribbonClosePath?: boolean;
  48489. cap?: number;
  48490. updatable?: boolean;
  48491. sideOrientation?: number;
  48492. frontUVs?: Vector4;
  48493. backUVs?: Vector4;
  48494. instance?: Mesh;
  48495. invertUV?: boolean;
  48496. }, scene?: Nullable<Scene>): Mesh;
  48497. private static _ExtrudeShapeGeneric;
  48498. }
  48499. }
  48500. declare module BABYLON {
  48501. /**
  48502. * AmmoJS Physics plugin
  48503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48504. * @see https://github.com/kripken/ammo.js/
  48505. */
  48506. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48507. private _useDeltaForWorldStep;
  48508. /**
  48509. * Reference to the Ammo library
  48510. */
  48511. bjsAMMO: any;
  48512. /**
  48513. * Created ammoJS world which physics bodies are added to
  48514. */
  48515. world: any;
  48516. /**
  48517. * Name of the plugin
  48518. */
  48519. name: string;
  48520. private _timeStep;
  48521. private _fixedTimeStep;
  48522. private _maxSteps;
  48523. private _tmpQuaternion;
  48524. private _tmpAmmoTransform;
  48525. private _tmpAmmoQuaternion;
  48526. private _tmpAmmoConcreteContactResultCallback;
  48527. private _collisionConfiguration;
  48528. private _dispatcher;
  48529. private _overlappingPairCache;
  48530. private _solver;
  48531. private _softBodySolver;
  48532. private _tmpAmmoVectorA;
  48533. private _tmpAmmoVectorB;
  48534. private _tmpAmmoVectorC;
  48535. private _tmpAmmoVectorD;
  48536. private _tmpContactCallbackResult;
  48537. private _tmpAmmoVectorRCA;
  48538. private _tmpAmmoVectorRCB;
  48539. private _raycastResult;
  48540. private static readonly DISABLE_COLLISION_FLAG;
  48541. private static readonly KINEMATIC_FLAG;
  48542. private static readonly DISABLE_DEACTIVATION_FLAG;
  48543. /**
  48544. * Initializes the ammoJS plugin
  48545. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48546. * @param ammoInjection can be used to inject your own ammo reference
  48547. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  48548. */
  48549. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  48550. /**
  48551. * Sets the gravity of the physics world (m/(s^2))
  48552. * @param gravity Gravity to set
  48553. */
  48554. setGravity(gravity: Vector3): void;
  48555. /**
  48556. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48557. * @param timeStep timestep to use in seconds
  48558. */
  48559. setTimeStep(timeStep: number): void;
  48560. /**
  48561. * 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)
  48562. * @param fixedTimeStep fixedTimeStep to use in seconds
  48563. */
  48564. setFixedTimeStep(fixedTimeStep: number): void;
  48565. /**
  48566. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48567. * @param maxSteps the maximum number of steps by the physics engine per frame
  48568. */
  48569. setMaxSteps(maxSteps: number): void;
  48570. /**
  48571. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48572. * @returns the current timestep in seconds
  48573. */
  48574. getTimeStep(): number;
  48575. private _isImpostorInContact;
  48576. private _isImpostorPairInContact;
  48577. private _stepSimulation;
  48578. /**
  48579. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48580. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48581. * After the step the babylon meshes are set to the position of the physics imposters
  48582. * @param delta amount of time to step forward
  48583. * @param impostors array of imposters to update before/after the step
  48584. */
  48585. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48586. /**
  48587. * Update babylon mesh to match physics world object
  48588. * @param impostor imposter to match
  48589. */
  48590. private _afterSoftStep;
  48591. /**
  48592. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48593. * @param impostor imposter to match
  48594. */
  48595. private _ropeStep;
  48596. /**
  48597. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48598. * @param impostor imposter to match
  48599. */
  48600. private _softbodyOrClothStep;
  48601. private _tmpVector;
  48602. private _tmpMatrix;
  48603. /**
  48604. * Applies an impulse on the imposter
  48605. * @param impostor imposter to apply impulse to
  48606. * @param force amount of force to be applied to the imposter
  48607. * @param contactPoint the location to apply the impulse on the imposter
  48608. */
  48609. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48610. /**
  48611. * Applies a force on the imposter
  48612. * @param impostor imposter to apply force
  48613. * @param force amount of force to be applied to the imposter
  48614. * @param contactPoint the location to apply the force on the imposter
  48615. */
  48616. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48617. /**
  48618. * Creates a physics body using the plugin
  48619. * @param impostor the imposter to create the physics body on
  48620. */
  48621. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48622. /**
  48623. * Removes the physics body from the imposter and disposes of the body's memory
  48624. * @param impostor imposter to remove the physics body from
  48625. */
  48626. removePhysicsBody(impostor: PhysicsImpostor): void;
  48627. /**
  48628. * Generates a joint
  48629. * @param impostorJoint the imposter joint to create the joint with
  48630. */
  48631. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48632. /**
  48633. * Removes a joint
  48634. * @param impostorJoint the imposter joint to remove the joint from
  48635. */
  48636. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48637. private _addMeshVerts;
  48638. /**
  48639. * Initialise the soft body vertices to match its object's (mesh) vertices
  48640. * Softbody vertices (nodes) are in world space and to match this
  48641. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48642. * @param impostor to create the softbody for
  48643. */
  48644. private _softVertexData;
  48645. /**
  48646. * Create an impostor's soft body
  48647. * @param impostor to create the softbody for
  48648. */
  48649. private _createSoftbody;
  48650. /**
  48651. * Create cloth for an impostor
  48652. * @param impostor to create the softbody for
  48653. */
  48654. private _createCloth;
  48655. /**
  48656. * Create rope for an impostor
  48657. * @param impostor to create the softbody for
  48658. */
  48659. private _createRope;
  48660. private _addHullVerts;
  48661. private _createShape;
  48662. /**
  48663. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48664. * @param impostor imposter containing the physics body and babylon object
  48665. */
  48666. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48667. /**
  48668. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48669. * @param impostor imposter containing the physics body and babylon object
  48670. * @param newPosition new position
  48671. * @param newRotation new rotation
  48672. */
  48673. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48674. /**
  48675. * If this plugin is supported
  48676. * @returns true if its supported
  48677. */
  48678. isSupported(): boolean;
  48679. /**
  48680. * Sets the linear velocity of the physics body
  48681. * @param impostor imposter to set the velocity on
  48682. * @param velocity velocity to set
  48683. */
  48684. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48685. /**
  48686. * Sets the angular velocity of the physics body
  48687. * @param impostor imposter to set the velocity on
  48688. * @param velocity velocity to set
  48689. */
  48690. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48691. /**
  48692. * gets the linear velocity
  48693. * @param impostor imposter to get linear velocity from
  48694. * @returns linear velocity
  48695. */
  48696. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48697. /**
  48698. * gets the angular velocity
  48699. * @param impostor imposter to get angular velocity from
  48700. * @returns angular velocity
  48701. */
  48702. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48703. /**
  48704. * Sets the mass of physics body
  48705. * @param impostor imposter to set the mass on
  48706. * @param mass mass to set
  48707. */
  48708. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48709. /**
  48710. * Gets the mass of the physics body
  48711. * @param impostor imposter to get the mass from
  48712. * @returns mass
  48713. */
  48714. getBodyMass(impostor: PhysicsImpostor): number;
  48715. /**
  48716. * Gets friction of the impostor
  48717. * @param impostor impostor to get friction from
  48718. * @returns friction value
  48719. */
  48720. getBodyFriction(impostor: PhysicsImpostor): number;
  48721. /**
  48722. * Sets friction of the impostor
  48723. * @param impostor impostor to set friction on
  48724. * @param friction friction value
  48725. */
  48726. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48727. /**
  48728. * Gets restitution of the impostor
  48729. * @param impostor impostor to get restitution from
  48730. * @returns restitution value
  48731. */
  48732. getBodyRestitution(impostor: PhysicsImpostor): number;
  48733. /**
  48734. * Sets resitution of the impostor
  48735. * @param impostor impostor to set resitution on
  48736. * @param restitution resitution value
  48737. */
  48738. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48739. /**
  48740. * Gets pressure inside the impostor
  48741. * @param impostor impostor to get pressure from
  48742. * @returns pressure value
  48743. */
  48744. getBodyPressure(impostor: PhysicsImpostor): number;
  48745. /**
  48746. * Sets pressure inside a soft body impostor
  48747. * Cloth and rope must remain 0 pressure
  48748. * @param impostor impostor to set pressure on
  48749. * @param pressure pressure value
  48750. */
  48751. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48752. /**
  48753. * Gets stiffness of the impostor
  48754. * @param impostor impostor to get stiffness from
  48755. * @returns pressure value
  48756. */
  48757. getBodyStiffness(impostor: PhysicsImpostor): number;
  48758. /**
  48759. * Sets stiffness of the impostor
  48760. * @param impostor impostor to set stiffness on
  48761. * @param stiffness stiffness value from 0 to 1
  48762. */
  48763. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48764. /**
  48765. * Gets velocityIterations of the impostor
  48766. * @param impostor impostor to get velocity iterations from
  48767. * @returns velocityIterations value
  48768. */
  48769. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48770. /**
  48771. * Sets velocityIterations of the impostor
  48772. * @param impostor impostor to set velocity iterations on
  48773. * @param velocityIterations velocityIterations value
  48774. */
  48775. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48776. /**
  48777. * Gets positionIterations of the impostor
  48778. * @param impostor impostor to get position iterations from
  48779. * @returns positionIterations value
  48780. */
  48781. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48782. /**
  48783. * Sets positionIterations of the impostor
  48784. * @param impostor impostor to set position on
  48785. * @param positionIterations positionIterations value
  48786. */
  48787. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48788. /**
  48789. * Append an anchor to a cloth object
  48790. * @param impostor is the cloth impostor to add anchor to
  48791. * @param otherImpostor is the rigid impostor to anchor to
  48792. * @param width ratio across width from 0 to 1
  48793. * @param height ratio up height from 0 to 1
  48794. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48795. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48796. */
  48797. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48798. /**
  48799. * Append an hook to a rope object
  48800. * @param impostor is the rope impostor to add hook to
  48801. * @param otherImpostor is the rigid impostor to hook to
  48802. * @param length ratio along the rope from 0 to 1
  48803. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48804. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48805. */
  48806. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48807. /**
  48808. * Sleeps the physics body and stops it from being active
  48809. * @param impostor impostor to sleep
  48810. */
  48811. sleepBody(impostor: PhysicsImpostor): void;
  48812. /**
  48813. * Activates the physics body
  48814. * @param impostor impostor to activate
  48815. */
  48816. wakeUpBody(impostor: PhysicsImpostor): void;
  48817. /**
  48818. * Updates the distance parameters of the joint
  48819. * @param joint joint to update
  48820. * @param maxDistance maximum distance of the joint
  48821. * @param minDistance minimum distance of the joint
  48822. */
  48823. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48824. /**
  48825. * Sets a motor on the joint
  48826. * @param joint joint to set motor on
  48827. * @param speed speed of the motor
  48828. * @param maxForce maximum force of the motor
  48829. * @param motorIndex index of the motor
  48830. */
  48831. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48832. /**
  48833. * Sets the motors limit
  48834. * @param joint joint to set limit on
  48835. * @param upperLimit upper limit
  48836. * @param lowerLimit lower limit
  48837. */
  48838. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48839. /**
  48840. * Syncs the position and rotation of a mesh with the impostor
  48841. * @param mesh mesh to sync
  48842. * @param impostor impostor to update the mesh with
  48843. */
  48844. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48845. /**
  48846. * Gets the radius of the impostor
  48847. * @param impostor impostor to get radius from
  48848. * @returns the radius
  48849. */
  48850. getRadius(impostor: PhysicsImpostor): number;
  48851. /**
  48852. * Gets the box size of the impostor
  48853. * @param impostor impostor to get box size from
  48854. * @param result the resulting box size
  48855. */
  48856. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48857. /**
  48858. * Disposes of the impostor
  48859. */
  48860. dispose(): void;
  48861. /**
  48862. * Does a raycast in the physics world
  48863. * @param from when should the ray start?
  48864. * @param to when should the ray end?
  48865. * @returns PhysicsRaycastResult
  48866. */
  48867. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48868. }
  48869. }
  48870. declare module BABYLON {
  48871. interface AbstractScene {
  48872. /**
  48873. * The list of reflection probes added to the scene
  48874. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48875. */
  48876. reflectionProbes: Array<ReflectionProbe>;
  48877. /**
  48878. * Removes the given reflection probe from this scene.
  48879. * @param toRemove The reflection probe to remove
  48880. * @returns The index of the removed reflection probe
  48881. */
  48882. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48883. /**
  48884. * Adds the given reflection probe to this scene.
  48885. * @param newReflectionProbe The reflection probe to add
  48886. */
  48887. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48888. }
  48889. /**
  48890. * Class used to generate realtime reflection / refraction cube textures
  48891. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48892. */
  48893. export class ReflectionProbe {
  48894. /** defines the name of the probe */
  48895. name: string;
  48896. private _scene;
  48897. private _renderTargetTexture;
  48898. private _projectionMatrix;
  48899. private _viewMatrix;
  48900. private _target;
  48901. private _add;
  48902. private _attachedMesh;
  48903. private _invertYAxis;
  48904. /** Gets or sets probe position (center of the cube map) */
  48905. position: Vector3;
  48906. /**
  48907. * Creates a new reflection probe
  48908. * @param name defines the name of the probe
  48909. * @param size defines the texture resolution (for each face)
  48910. * @param scene defines the hosting scene
  48911. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48912. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48913. */
  48914. constructor(
  48915. /** defines the name of the probe */
  48916. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48917. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48918. samples: number;
  48919. /** Gets or sets the refresh rate to use (on every frame by default) */
  48920. refreshRate: number;
  48921. /**
  48922. * Gets the hosting scene
  48923. * @returns a Scene
  48924. */
  48925. getScene(): Scene;
  48926. /** Gets the internal CubeTexture used to render to */
  48927. readonly cubeTexture: RenderTargetTexture;
  48928. /** Gets the list of meshes to render */
  48929. readonly renderList: Nullable<AbstractMesh[]>;
  48930. /**
  48931. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48932. * @param mesh defines the mesh to attach to
  48933. */
  48934. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48935. /**
  48936. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48937. * @param renderingGroupId The rendering group id corresponding to its index
  48938. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48939. */
  48940. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48941. /**
  48942. * Clean all associated resources
  48943. */
  48944. dispose(): void;
  48945. /**
  48946. * Converts the reflection probe information to a readable string for debug purpose.
  48947. * @param fullDetails Supports for multiple levels of logging within scene loading
  48948. * @returns the human readable reflection probe info
  48949. */
  48950. toString(fullDetails?: boolean): string;
  48951. /**
  48952. * Get the class name of the relfection probe.
  48953. * @returns "ReflectionProbe"
  48954. */
  48955. getClassName(): string;
  48956. /**
  48957. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48958. * @returns The JSON representation of the texture
  48959. */
  48960. serialize(): any;
  48961. /**
  48962. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48963. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48964. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48965. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48966. * @returns The parsed reflection probe if successful
  48967. */
  48968. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48969. }
  48970. }
  48971. declare module BABYLON {
  48972. /** @hidden */
  48973. export var _BabylonLoaderRegistered: boolean;
  48974. }
  48975. declare module BABYLON {
  48976. /**
  48977. * The Physically based simple base material of BJS.
  48978. *
  48979. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48980. * It is used as the base class for both the specGloss and metalRough conventions.
  48981. */
  48982. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48983. /**
  48984. * Number of Simultaneous lights allowed on the material.
  48985. */
  48986. maxSimultaneousLights: number;
  48987. /**
  48988. * If sets to true, disables all the lights affecting the material.
  48989. */
  48990. disableLighting: boolean;
  48991. /**
  48992. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48993. */
  48994. environmentTexture: BaseTexture;
  48995. /**
  48996. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48997. */
  48998. invertNormalMapX: boolean;
  48999. /**
  49000. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49001. */
  49002. invertNormalMapY: boolean;
  49003. /**
  49004. * Normal map used in the model.
  49005. */
  49006. normalTexture: BaseTexture;
  49007. /**
  49008. * Emissivie color used to self-illuminate the model.
  49009. */
  49010. emissiveColor: Color3;
  49011. /**
  49012. * Emissivie texture used to self-illuminate the model.
  49013. */
  49014. emissiveTexture: BaseTexture;
  49015. /**
  49016. * Occlusion Channel Strenght.
  49017. */
  49018. occlusionStrength: number;
  49019. /**
  49020. * Occlusion Texture of the material (adding extra occlusion effects).
  49021. */
  49022. occlusionTexture: BaseTexture;
  49023. /**
  49024. * Defines the alpha limits in alpha test mode.
  49025. */
  49026. alphaCutOff: number;
  49027. /**
  49028. * Gets the current double sided mode.
  49029. */
  49030. /**
  49031. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49032. */
  49033. doubleSided: boolean;
  49034. /**
  49035. * Stores the pre-calculated light information of a mesh in a texture.
  49036. */
  49037. lightmapTexture: BaseTexture;
  49038. /**
  49039. * If true, the light map contains occlusion information instead of lighting info.
  49040. */
  49041. useLightmapAsShadowmap: boolean;
  49042. /**
  49043. * Instantiates a new PBRMaterial instance.
  49044. *
  49045. * @param name The material name
  49046. * @param scene The scene the material will be use in.
  49047. */
  49048. constructor(name: string, scene: Scene);
  49049. getClassName(): string;
  49050. }
  49051. }
  49052. declare module BABYLON {
  49053. /**
  49054. * The PBR material of BJS following the metal roughness convention.
  49055. *
  49056. * This fits to the PBR convention in the GLTF definition:
  49057. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49058. */
  49059. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49060. /**
  49061. * The base color has two different interpretations depending on the value of metalness.
  49062. * When the material is a metal, the base color is the specific measured reflectance value
  49063. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49064. * of the material.
  49065. */
  49066. baseColor: Color3;
  49067. /**
  49068. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49069. * well as opacity information in the alpha channel.
  49070. */
  49071. baseTexture: BaseTexture;
  49072. /**
  49073. * Specifies the metallic scalar value of the material.
  49074. * Can also be used to scale the metalness values of the metallic texture.
  49075. */
  49076. metallic: number;
  49077. /**
  49078. * Specifies the roughness scalar value of the material.
  49079. * Can also be used to scale the roughness values of the metallic texture.
  49080. */
  49081. roughness: number;
  49082. /**
  49083. * Texture containing both the metallic value in the B channel and the
  49084. * roughness value in the G channel to keep better precision.
  49085. */
  49086. metallicRoughnessTexture: BaseTexture;
  49087. /**
  49088. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49089. *
  49090. * @param name The material name
  49091. * @param scene The scene the material will be use in.
  49092. */
  49093. constructor(name: string, scene: Scene);
  49094. /**
  49095. * Return the currrent class name of the material.
  49096. */
  49097. getClassName(): string;
  49098. /**
  49099. * Makes a duplicate of the current material.
  49100. * @param name - name to use for the new material.
  49101. */
  49102. clone(name: string): PBRMetallicRoughnessMaterial;
  49103. /**
  49104. * Serialize the material to a parsable JSON object.
  49105. */
  49106. serialize(): any;
  49107. /**
  49108. * Parses a JSON object correponding to the serialize function.
  49109. */
  49110. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49111. }
  49112. }
  49113. declare module BABYLON {
  49114. /**
  49115. * The PBR material of BJS following the specular glossiness convention.
  49116. *
  49117. * This fits to the PBR convention in the GLTF definition:
  49118. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49119. */
  49120. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49121. /**
  49122. * Specifies the diffuse color of the material.
  49123. */
  49124. diffuseColor: Color3;
  49125. /**
  49126. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49127. * channel.
  49128. */
  49129. diffuseTexture: BaseTexture;
  49130. /**
  49131. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49132. */
  49133. specularColor: Color3;
  49134. /**
  49135. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49136. */
  49137. glossiness: number;
  49138. /**
  49139. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49140. */
  49141. specularGlossinessTexture: BaseTexture;
  49142. /**
  49143. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49144. *
  49145. * @param name The material name
  49146. * @param scene The scene the material will be use in.
  49147. */
  49148. constructor(name: string, scene: Scene);
  49149. /**
  49150. * Return the currrent class name of the material.
  49151. */
  49152. getClassName(): string;
  49153. /**
  49154. * Makes a duplicate of the current material.
  49155. * @param name - name to use for the new material.
  49156. */
  49157. clone(name: string): PBRSpecularGlossinessMaterial;
  49158. /**
  49159. * Serialize the material to a parsable JSON object.
  49160. */
  49161. serialize(): any;
  49162. /**
  49163. * Parses a JSON object correponding to the serialize function.
  49164. */
  49165. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49166. }
  49167. }
  49168. declare module BABYLON {
  49169. /**
  49170. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49171. * It can help converting any input color in a desired output one. This can then be used to create effects
  49172. * from sepia, black and white to sixties or futuristic rendering...
  49173. *
  49174. * The only supported format is currently 3dl.
  49175. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49176. */
  49177. export class ColorGradingTexture extends BaseTexture {
  49178. /**
  49179. * The current texture matrix. (will always be identity in color grading texture)
  49180. */
  49181. private _textureMatrix;
  49182. /**
  49183. * The texture URL.
  49184. */
  49185. url: string;
  49186. /**
  49187. * Empty line regex stored for GC.
  49188. */
  49189. private static _noneEmptyLineRegex;
  49190. private _engine;
  49191. /**
  49192. * Instantiates a ColorGradingTexture from the following parameters.
  49193. *
  49194. * @param url The location of the color gradind data (currently only supporting 3dl)
  49195. * @param scene The scene the texture will be used in
  49196. */
  49197. constructor(url: string, scene: Scene);
  49198. /**
  49199. * Returns the texture matrix used in most of the material.
  49200. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49201. */
  49202. getTextureMatrix(): Matrix;
  49203. /**
  49204. * Occurs when the file being loaded is a .3dl LUT file.
  49205. */
  49206. private load3dlTexture;
  49207. /**
  49208. * Starts the loading process of the texture.
  49209. */
  49210. private loadTexture;
  49211. /**
  49212. * Clones the color gradind texture.
  49213. */
  49214. clone(): ColorGradingTexture;
  49215. /**
  49216. * Called during delayed load for textures.
  49217. */
  49218. delayLoad(): void;
  49219. /**
  49220. * Parses a color grading texture serialized by Babylon.
  49221. * @param parsedTexture The texture information being parsedTexture
  49222. * @param scene The scene to load the texture in
  49223. * @param rootUrl The root url of the data assets to load
  49224. * @return A color gradind texture
  49225. */
  49226. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49227. /**
  49228. * Serializes the LUT texture to json format.
  49229. */
  49230. serialize(): any;
  49231. }
  49232. }
  49233. declare module BABYLON {
  49234. /**
  49235. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49236. */
  49237. export class EquiRectangularCubeTexture extends BaseTexture {
  49238. /** The six faces of the cube. */
  49239. private static _FacesMapping;
  49240. private _noMipmap;
  49241. private _onLoad;
  49242. private _onError;
  49243. /** The size of the cubemap. */
  49244. private _size;
  49245. /** The buffer of the image. */
  49246. private _buffer;
  49247. /** The width of the input image. */
  49248. private _width;
  49249. /** The height of the input image. */
  49250. private _height;
  49251. /** The URL to the image. */
  49252. url: string;
  49253. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49254. coordinatesMode: number;
  49255. /**
  49256. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49257. * @param url The location of the image
  49258. * @param scene The scene the texture will be used in
  49259. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49260. * @param noMipmap Forces to not generate the mipmap if true
  49261. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49262. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49263. * @param onLoad — defines a callback called when texture is loaded
  49264. * @param onError — defines a callback called if there is an error
  49265. */
  49266. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49267. /**
  49268. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49269. */
  49270. private loadImage;
  49271. /**
  49272. * Convert the image buffer into a cubemap and create a CubeTexture.
  49273. */
  49274. private loadTexture;
  49275. /**
  49276. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49277. * @param buffer The ArrayBuffer that should be converted.
  49278. * @returns The buffer as Float32Array.
  49279. */
  49280. private getFloat32ArrayFromArrayBuffer;
  49281. /**
  49282. * Get the current class name of the texture useful for serialization or dynamic coding.
  49283. * @returns "EquiRectangularCubeTexture"
  49284. */
  49285. getClassName(): string;
  49286. /**
  49287. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49288. * @returns A clone of the current EquiRectangularCubeTexture.
  49289. */
  49290. clone(): EquiRectangularCubeTexture;
  49291. }
  49292. }
  49293. declare module BABYLON {
  49294. /**
  49295. * Based on jsTGALoader - Javascript loader for TGA file
  49296. * By Vincent Thibault
  49297. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49298. */
  49299. export class TGATools {
  49300. private static _TYPE_INDEXED;
  49301. private static _TYPE_RGB;
  49302. private static _TYPE_GREY;
  49303. private static _TYPE_RLE_INDEXED;
  49304. private static _TYPE_RLE_RGB;
  49305. private static _TYPE_RLE_GREY;
  49306. private static _ORIGIN_MASK;
  49307. private static _ORIGIN_SHIFT;
  49308. private static _ORIGIN_BL;
  49309. private static _ORIGIN_BR;
  49310. private static _ORIGIN_UL;
  49311. private static _ORIGIN_UR;
  49312. /**
  49313. * Gets the header of a TGA file
  49314. * @param data defines the TGA data
  49315. * @returns the header
  49316. */
  49317. static GetTGAHeader(data: Uint8Array): any;
  49318. /**
  49319. * Uploads TGA content to a Babylon Texture
  49320. * @hidden
  49321. */
  49322. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49323. /** @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;
  49324. /** @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;
  49325. /** @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;
  49326. /** @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;
  49327. /** @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;
  49328. /** @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;
  49329. }
  49330. }
  49331. declare module BABYLON {
  49332. /**
  49333. * Implementation of the TGA Texture Loader.
  49334. * @hidden
  49335. */
  49336. export class _TGATextureLoader implements IInternalTextureLoader {
  49337. /**
  49338. * Defines wether the loader supports cascade loading the different faces.
  49339. */
  49340. readonly supportCascades: boolean;
  49341. /**
  49342. * This returns if the loader support the current file information.
  49343. * @param extension defines the file extension of the file being loaded
  49344. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49345. * @param fallback defines the fallback internal texture if any
  49346. * @param isBase64 defines whether the texture is encoded as a base64
  49347. * @param isBuffer defines whether the texture data are stored as a buffer
  49348. * @returns true if the loader can load the specified file
  49349. */
  49350. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49351. /**
  49352. * Transform the url before loading if required.
  49353. * @param rootUrl the url of the texture
  49354. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49355. * @returns the transformed texture
  49356. */
  49357. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49358. /**
  49359. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49360. * @param rootUrl the url of the texture
  49361. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49362. * @returns the fallback texture
  49363. */
  49364. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49365. /**
  49366. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49367. * @param data contains the texture data
  49368. * @param texture defines the BabylonJS internal texture
  49369. * @param createPolynomials will be true if polynomials have been requested
  49370. * @param onLoad defines the callback to trigger once the texture is ready
  49371. * @param onError defines the callback to trigger in case of error
  49372. */
  49373. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49374. /**
  49375. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49376. * @param data contains the texture data
  49377. * @param texture defines the BabylonJS internal texture
  49378. * @param callback defines the method to call once ready to upload
  49379. */
  49380. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49381. }
  49382. }
  49383. declare module BABYLON {
  49384. /**
  49385. * Info about the .basis files
  49386. */
  49387. class BasisFileInfo {
  49388. /**
  49389. * If the file has alpha
  49390. */
  49391. hasAlpha: boolean;
  49392. /**
  49393. * Info about each image of the basis file
  49394. */
  49395. images: Array<{
  49396. levels: Array<{
  49397. width: number;
  49398. height: number;
  49399. transcodedPixels: ArrayBufferView;
  49400. }>;
  49401. }>;
  49402. }
  49403. /**
  49404. * Configuration options for the Basis transcoder
  49405. */
  49406. export class BasisTranscodeConfiguration {
  49407. /**
  49408. * Supported compression formats used to determine the supported output format of the transcoder
  49409. */
  49410. supportedCompressionFormats?: {
  49411. /**
  49412. * etc1 compression format
  49413. */
  49414. etc1?: boolean;
  49415. /**
  49416. * s3tc compression format
  49417. */
  49418. s3tc?: boolean;
  49419. /**
  49420. * pvrtc compression format
  49421. */
  49422. pvrtc?: boolean;
  49423. /**
  49424. * etc2 compression format
  49425. */
  49426. etc2?: boolean;
  49427. };
  49428. /**
  49429. * If mipmap levels should be loaded for transcoded images (Default: true)
  49430. */
  49431. loadMipmapLevels?: boolean;
  49432. /**
  49433. * Index of a single image to load (Default: all images)
  49434. */
  49435. loadSingleImage?: number;
  49436. }
  49437. /**
  49438. * Used to load .Basis files
  49439. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  49440. */
  49441. export class BasisTools {
  49442. private static _IgnoreSupportedFormats;
  49443. /**
  49444. * URL to use when loading the basis transcoder
  49445. */
  49446. static JSModuleURL: string;
  49447. /**
  49448. * URL to use when loading the wasm module for the transcoder
  49449. */
  49450. static WasmModuleURL: string;
  49451. /**
  49452. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  49453. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  49454. * @returns internal format corresponding to the Basis format
  49455. */
  49456. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  49457. private static _WorkerPromise;
  49458. private static _Worker;
  49459. private static _actionId;
  49460. private static _CreateWorkerAsync;
  49461. /**
  49462. * Transcodes a loaded image file to compressed pixel data
  49463. * @param imageData image data to transcode
  49464. * @param config configuration options for the transcoding
  49465. * @returns a promise resulting in the transcoded image
  49466. */
  49467. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<{
  49468. fileInfo: BasisFileInfo;
  49469. format: number;
  49470. }>;
  49471. }
  49472. }
  49473. declare module BABYLON {
  49474. /**
  49475. * Loader for .basis file format
  49476. */
  49477. export class _BasisTextureLoader implements IInternalTextureLoader {
  49478. /**
  49479. * Defines whether the loader supports cascade loading the different faces.
  49480. */
  49481. readonly supportCascades: boolean;
  49482. /**
  49483. * This returns if the loader support the current file information.
  49484. * @param extension defines the file extension of the file being loaded
  49485. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49486. * @param fallback defines the fallback internal texture if any
  49487. * @param isBase64 defines whether the texture is encoded as a base64
  49488. * @param isBuffer defines whether the texture data are stored as a buffer
  49489. * @returns true if the loader can load the specified file
  49490. */
  49491. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49492. /**
  49493. * Transform the url before loading if required.
  49494. * @param rootUrl the url of the texture
  49495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49496. * @returns the transformed texture
  49497. */
  49498. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49499. /**
  49500. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49501. * @param rootUrl the url of the texture
  49502. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49503. * @returns the fallback texture
  49504. */
  49505. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49506. /**
  49507. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  49508. * @param data contains the texture data
  49509. * @param texture defines the BabylonJS internal texture
  49510. * @param createPolynomials will be true if polynomials have been requested
  49511. * @param onLoad defines the callback to trigger once the texture is ready
  49512. * @param onError defines the callback to trigger in case of error
  49513. */
  49514. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49515. /**
  49516. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49517. * @param data contains the texture data
  49518. * @param texture defines the BabylonJS internal texture
  49519. * @param callback defines the method to call once ready to upload
  49520. */
  49521. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49522. }
  49523. }
  49524. declare module BABYLON {
  49525. /**
  49526. * 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.
  49527. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49528. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49529. */
  49530. export class CustomProceduralTexture extends ProceduralTexture {
  49531. private _animate;
  49532. private _time;
  49533. private _config;
  49534. private _texturePath;
  49535. /**
  49536. * Instantiates a new Custom Procedural Texture.
  49537. * 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.
  49538. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49539. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49540. * @param name Define the name of the texture
  49541. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49542. * @param size Define the size of the texture to create
  49543. * @param scene Define the scene the texture belongs to
  49544. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49545. * @param generateMipMaps Define if the texture should creates mip maps or not
  49546. */
  49547. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49548. private _loadJson;
  49549. /**
  49550. * Is the texture ready to be used ? (rendered at least once)
  49551. * @returns true if ready, otherwise, false.
  49552. */
  49553. isReady(): boolean;
  49554. /**
  49555. * Render the texture to its associated render target.
  49556. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49557. */
  49558. render(useCameraPostProcess?: boolean): void;
  49559. /**
  49560. * Update the list of dependant textures samplers in the shader.
  49561. */
  49562. updateTextures(): void;
  49563. /**
  49564. * Update the uniform values of the procedural texture in the shader.
  49565. */
  49566. updateShaderUniforms(): void;
  49567. /**
  49568. * Define if the texture animates or not.
  49569. */
  49570. animate: boolean;
  49571. }
  49572. }
  49573. declare module BABYLON {
  49574. /** @hidden */
  49575. export var noisePixelShader: {
  49576. name: string;
  49577. shader: string;
  49578. };
  49579. }
  49580. declare module BABYLON {
  49581. /**
  49582. * Class used to generate noise procedural textures
  49583. */
  49584. export class NoiseProceduralTexture extends ProceduralTexture {
  49585. private _time;
  49586. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49587. brightness: number;
  49588. /** Defines the number of octaves to process */
  49589. octaves: number;
  49590. /** Defines the level of persistence (0.8 by default) */
  49591. persistence: number;
  49592. /** Gets or sets animation speed factor (default is 1) */
  49593. animationSpeedFactor: number;
  49594. /**
  49595. * Creates a new NoiseProceduralTexture
  49596. * @param name defines the name fo the texture
  49597. * @param size defines the size of the texture (default is 256)
  49598. * @param scene defines the hosting scene
  49599. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49600. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49601. */
  49602. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49603. private _updateShaderUniforms;
  49604. protected _getDefines(): string;
  49605. /** Generate the current state of the procedural texture */
  49606. render(useCameraPostProcess?: boolean): void;
  49607. /**
  49608. * Serializes this noise procedural texture
  49609. * @returns a serialized noise procedural texture object
  49610. */
  49611. serialize(): any;
  49612. /**
  49613. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49614. * @param parsedTexture defines parsed texture data
  49615. * @param scene defines the current scene
  49616. * @param rootUrl defines the root URL containing noise procedural texture information
  49617. * @returns a parsed NoiseProceduralTexture
  49618. */
  49619. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49620. }
  49621. }
  49622. declare module BABYLON {
  49623. /**
  49624. * Raw cube texture where the raw buffers are passed in
  49625. */
  49626. export class RawCubeTexture extends CubeTexture {
  49627. /**
  49628. * Creates a cube texture where the raw buffers are passed in.
  49629. * @param scene defines the scene the texture is attached to
  49630. * @param data defines the array of data to use to create each face
  49631. * @param size defines the size of the textures
  49632. * @param format defines the format of the data
  49633. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49634. * @param generateMipMaps defines if the engine should generate the mip levels
  49635. * @param invertY defines if data must be stored with Y axis inverted
  49636. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49637. * @param compression defines the compression used (null by default)
  49638. */
  49639. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49640. /**
  49641. * Updates the raw cube texture.
  49642. * @param data defines the data to store
  49643. * @param format defines the data format
  49644. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49645. * @param invertY defines if data must be stored with Y axis inverted
  49646. * @param compression defines the compression used (null by default)
  49647. * @param level defines which level of the texture to update
  49648. */
  49649. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49650. /**
  49651. * Updates a raw cube texture with RGBD encoded data.
  49652. * @param data defines the array of data [mipmap][face] to use to create each face
  49653. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49656. * @returns a promsie that resolves when the operation is complete
  49657. */
  49658. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49659. /**
  49660. * Clones the raw cube texture.
  49661. * @return a new cube texture
  49662. */
  49663. clone(): CubeTexture;
  49664. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49665. }
  49666. }
  49667. declare module BABYLON {
  49668. /**
  49669. * Class used to store 3D textures containing user data
  49670. */
  49671. export class RawTexture3D extends Texture {
  49672. /** Gets or sets the texture format to use */
  49673. format: number;
  49674. private _engine;
  49675. /**
  49676. * Create a new RawTexture3D
  49677. * @param data defines the data of the texture
  49678. * @param width defines the width of the texture
  49679. * @param height defines the height of the texture
  49680. * @param depth defines the depth of the texture
  49681. * @param format defines the texture format to use
  49682. * @param scene defines the hosting scene
  49683. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49684. * @param invertY defines if texture must be stored with Y axis inverted
  49685. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49686. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49687. */
  49688. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49689. /** Gets or sets the texture format to use */
  49690. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49691. /**
  49692. * Update the texture with new data
  49693. * @param data defines the data to store in the texture
  49694. */
  49695. update(data: ArrayBufferView): void;
  49696. }
  49697. }
  49698. declare module BABYLON {
  49699. /**
  49700. * Creates a refraction texture used by refraction channel of the standard material.
  49701. * It is like a mirror but to see through a material.
  49702. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49703. */
  49704. export class RefractionTexture extends RenderTargetTexture {
  49705. /**
  49706. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49707. * 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.
  49708. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49709. */
  49710. refractionPlane: Plane;
  49711. /**
  49712. * Define how deep under the surface we should see.
  49713. */
  49714. depth: number;
  49715. /**
  49716. * Creates a refraction texture used by refraction channel of the standard material.
  49717. * It is like a mirror but to see through a material.
  49718. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49719. * @param name Define the texture name
  49720. * @param size Define the size of the underlying texture
  49721. * @param scene Define the scene the refraction belongs to
  49722. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49723. */
  49724. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49725. /**
  49726. * Clone the refraction texture.
  49727. * @returns the cloned texture
  49728. */
  49729. clone(): RefractionTexture;
  49730. /**
  49731. * Serialize the texture to a JSON representation you could use in Parse later on
  49732. * @returns the serialized JSON representation
  49733. */
  49734. serialize(): any;
  49735. }
  49736. }
  49737. declare module BABYLON {
  49738. /**
  49739. * Defines the options related to the creation of an HtmlElementTexture
  49740. */
  49741. export interface IHtmlElementTextureOptions {
  49742. /**
  49743. * Defines wether mip maps should be created or not.
  49744. */
  49745. generateMipMaps?: boolean;
  49746. /**
  49747. * Defines the sampling mode of the texture.
  49748. */
  49749. samplingMode?: number;
  49750. /**
  49751. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49752. */
  49753. engine: Nullable<Engine>;
  49754. /**
  49755. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49756. */
  49757. scene: Nullable<Scene>;
  49758. }
  49759. /**
  49760. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49761. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49762. * is automatically managed.
  49763. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49764. * in your application.
  49765. *
  49766. * As the update is not automatic, you need to call them manually.
  49767. */
  49768. export class HtmlElementTexture extends BaseTexture {
  49769. /**
  49770. * The texture URL.
  49771. */
  49772. element: HTMLVideoElement | HTMLCanvasElement;
  49773. private static readonly DefaultOptions;
  49774. private _textureMatrix;
  49775. private _engine;
  49776. private _isVideo;
  49777. private _generateMipMaps;
  49778. private _samplingMode;
  49779. /**
  49780. * Instantiates a HtmlElementTexture from the following parameters.
  49781. *
  49782. * @param name Defines the name of the texture
  49783. * @param element Defines the video or canvas the texture is filled with
  49784. * @param options Defines the other none mandatory texture creation options
  49785. */
  49786. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49787. private _createInternalTexture;
  49788. /**
  49789. * Returns the texture matrix used in most of the material.
  49790. */
  49791. getTextureMatrix(): Matrix;
  49792. /**
  49793. * Updates the content of the texture.
  49794. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49795. */
  49796. update(invertY?: Nullable<boolean>): void;
  49797. }
  49798. }
  49799. declare module BABYLON {
  49800. /**
  49801. * Enum used to define the target of a block
  49802. */
  49803. export enum NodeMaterialBlockTargets {
  49804. /** Vertex shader */
  49805. Vertex = 1,
  49806. /** Fragment shader */
  49807. Fragment = 2,
  49808. /** Vertex and Fragment */
  49809. VertexAndFragment = 3
  49810. }
  49811. }
  49812. declare module BABYLON {
  49813. /**
  49814. * Defines the kind of connection point for node based material
  49815. */
  49816. export enum NodeMaterialBlockConnectionPointTypes {
  49817. /** Float */
  49818. Float = 1,
  49819. /** Int */
  49820. Int = 2,
  49821. /** Vector2 */
  49822. Vector2 = 4,
  49823. /** Vector3 */
  49824. Vector3 = 8,
  49825. /** Vector4 */
  49826. Vector4 = 16,
  49827. /** Color3 */
  49828. Color3 = 32,
  49829. /** Color4 */
  49830. Color4 = 64,
  49831. /** Matrix */
  49832. Matrix = 128,
  49833. /** Texture */
  49834. Texture = 256,
  49835. /** Texture3D */
  49836. Texture3D = 512,
  49837. /** Vector3 or Color3 */
  49838. Vector3OrColor3 = 40,
  49839. /** Vector3 or Vector4 */
  49840. Vector3OrVector4 = 24,
  49841. /** Vector4 or Color4 */
  49842. Vector4OrColor4 = 80,
  49843. /** Color3 or Color4 */
  49844. Color3OrColor4 = 96,
  49845. /** Vector3 or Color3 */
  49846. Vector3OrColor3OrVector4OrColor4 = 120,
  49847. /** Detect type based on connection */
  49848. AutoDetect = 1024,
  49849. /** Output type that will be defined by input type */
  49850. BasedOnInput = 2048,
  49851. /** Light */
  49852. Light = 4096
  49853. }
  49854. }
  49855. declare module BABYLON {
  49856. /**
  49857. * Enum used to define well known values e.g. values automatically provided by the system
  49858. */
  49859. export enum NodeMaterialWellKnownValues {
  49860. /** World */
  49861. World = 1,
  49862. /** View */
  49863. View = 2,
  49864. /** Projection */
  49865. Projection = 3,
  49866. /** ViewProjection */
  49867. ViewProjection = 4,
  49868. /** WorldView */
  49869. WorldView = 5,
  49870. /** WorldViewProjection */
  49871. WorldViewProjection = 6,
  49872. /** CameraPosition */
  49873. CameraPosition = 7,
  49874. /** Will be filled by the block itself */
  49875. Automatic = 8
  49876. }
  49877. }
  49878. declare module BABYLON {
  49879. /**
  49880. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  49881. */
  49882. export enum NodeMaterialBlockConnectionPointMode {
  49883. /** Value is an uniform */
  49884. Uniform = 0,
  49885. /** Value is a mesh attribute */
  49886. Attribute = 1,
  49887. /** Value is a varying between vertex and fragment shaders */
  49888. Varying = 2,
  49889. /** Mode is undefined */
  49890. Undefined = 3
  49891. }
  49892. }
  49893. declare module BABYLON {
  49894. /**
  49895. * Class used to store shared data between 2 NodeMaterialBuildState
  49896. */
  49897. export class NodeMaterialBuildStateSharedData {
  49898. /**
  49899. * Gets the list of emitted varyings
  49900. */
  49901. varyings: string[];
  49902. /**
  49903. * Gets the varying declaration string
  49904. */
  49905. varyingDeclaration: string;
  49906. /**
  49907. * Uniform connection points
  49908. */
  49909. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  49910. /**
  49911. * Bindable blocks (Blocks that need to set data to the effect)
  49912. */
  49913. bindableBlocks: NodeMaterialBlock[];
  49914. /**
  49915. * List of blocks that can provide a compilation fallback
  49916. */
  49917. blocksWithFallbacks: NodeMaterialBlock[];
  49918. /**
  49919. * List of blocks that can provide a define update
  49920. */
  49921. blocksWithDefines: NodeMaterialBlock[];
  49922. /**
  49923. * List of blocks that can provide a repeatable content
  49924. */
  49925. repeatableContentBlocks: NodeMaterialBlock[];
  49926. /**
  49927. * List of blocks that can block the isReady function for the material
  49928. */
  49929. blockingBlocks: NodeMaterialBlock[];
  49930. /**
  49931. * Build Id used to avoid multiple recompilations
  49932. */
  49933. buildId: number;
  49934. /** List of emitted variables */
  49935. variableNames: {
  49936. [key: string]: number;
  49937. };
  49938. /** List of emitted defines */
  49939. defineNames: {
  49940. [key: string]: number;
  49941. };
  49942. /** Should emit comments? */
  49943. emitComments: boolean;
  49944. /** Emit build activity */
  49945. verbose: boolean;
  49946. /**
  49947. * Gets the compilation hints emitted at compilation time
  49948. */
  49949. hints: {
  49950. needWorldViewMatrix: boolean;
  49951. needWorldViewProjectionMatrix: boolean;
  49952. needAlphaBlending: boolean;
  49953. needAlphaTesting: boolean;
  49954. };
  49955. /**
  49956. * List of compilation checks
  49957. */
  49958. checks: {
  49959. emitVertex: boolean;
  49960. emitFragment: boolean;
  49961. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  49962. };
  49963. /** Creates a new shared data */
  49964. constructor();
  49965. /**
  49966. * Emits console errors and exceptions if there is a failing check
  49967. */
  49968. emitErrors(): void;
  49969. }
  49970. }
  49971. declare module BABYLON {
  49972. /**
  49973. * Class used to store node based material build state
  49974. */
  49975. export class NodeMaterialBuildState {
  49976. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  49977. supportUniformBuffers: boolean;
  49978. /**
  49979. * Gets the list of emitted attributes
  49980. */
  49981. attributes: string[];
  49982. /**
  49983. * Gets the list of emitted uniforms
  49984. */
  49985. uniforms: string[];
  49986. /**
  49987. * Gets the list of emitted uniform buffers
  49988. */
  49989. uniformBuffers: string[];
  49990. /**
  49991. * Gets the list of emitted samplers
  49992. */
  49993. samplers: string[];
  49994. /**
  49995. * Gets the list of emitted functions
  49996. */
  49997. functions: {
  49998. [key: string]: string;
  49999. };
  50000. /**
  50001. * Gets the target of the compilation state
  50002. */
  50003. target: NodeMaterialBlockTargets;
  50004. /**
  50005. * Gets the list of emitted counters
  50006. */
  50007. counters: {
  50008. [key: string]: number;
  50009. };
  50010. /**
  50011. * Shared data between multiple NodeMaterialBuildState instances
  50012. */
  50013. sharedData: NodeMaterialBuildStateSharedData;
  50014. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  50015. private _attributeDeclaration;
  50016. private _uniformDeclaration;
  50017. private _samplerDeclaration;
  50018. private _varyingTransfer;
  50019. private _repeatableContentAnchorIndex;
  50020. /** @hidden */ private _builtCompilationString: string;
  50021. /**
  50022. * Gets the emitted compilation strings
  50023. */
  50024. compilationString: string;
  50025. /**
  50026. * Finalize the compilation strings
  50027. * @param state defines the current compilation state
  50028. */
  50029. finalize(state: NodeMaterialBuildState): void;
  50030. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  50031. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  50032. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  50033. /** @hidden */ private _excludeVariableName(name: string): void;
  50034. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50035. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  50036. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50037. replaceStrings?: {
  50038. search: RegExp;
  50039. replace: string;
  50040. }[];
  50041. }): string;
  50042. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50043. repeatKey?: string;
  50044. removeAttributes?: boolean;
  50045. removeUniforms?: boolean;
  50046. removeVaryings?: boolean;
  50047. removeIfDef?: boolean;
  50048. replaceStrings?: {
  50049. search: RegExp;
  50050. replace: string;
  50051. }[];
  50052. }, storeKey?: string): void;
  50053. /** @hidden */ private _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50054. private _emitDefine;
  50055. /** @hidden */ private _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50056. }
  50057. }
  50058. declare module BABYLON {
  50059. /**
  50060. * Root class for all node material optimizers
  50061. */
  50062. export class NodeMaterialOptimizer {
  50063. /**
  50064. * Function used to optimize a NodeMaterial graph
  50065. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50066. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50067. */
  50068. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50069. }
  50070. }
  50071. declare module BABYLON {
  50072. /**
  50073. * Block used to transform a vector4 with a matrix
  50074. */
  50075. export class Vector4TransformBlock extends NodeMaterialBlock {
  50076. /**
  50077. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50078. */
  50079. complementW: number;
  50080. /**
  50081. * Creates a new Vector4TransformBlock
  50082. * @param name defines the block name
  50083. */
  50084. constructor(name: string);
  50085. /**
  50086. * Gets the current class name
  50087. * @returns the class name
  50088. */
  50089. getClassName(): string;
  50090. /**
  50091. * Gets the vector input
  50092. */
  50093. readonly vector: NodeMaterialConnectionPoint;
  50094. /**
  50095. * Gets the output component
  50096. */
  50097. readonly output: NodeMaterialConnectionPoint;
  50098. /**
  50099. * Gets the matrix transform input
  50100. */
  50101. readonly transform: NodeMaterialConnectionPoint;
  50102. protected _buildBlock(state: NodeMaterialBuildState): this;
  50103. }
  50104. }
  50105. declare module BABYLON {
  50106. /**
  50107. * Block used to output the vertex position
  50108. */
  50109. export class VertexOutputBlock extends NodeMaterialBlock {
  50110. /**
  50111. * Creates a new VertexOutputBlock
  50112. * @param name defines the block name
  50113. */
  50114. constructor(name: string);
  50115. /**
  50116. * Gets the current class name
  50117. * @returns the class name
  50118. */
  50119. getClassName(): string;
  50120. /**
  50121. * Gets the vector input component
  50122. */
  50123. readonly vector: NodeMaterialConnectionPoint;
  50124. protected _buildBlock(state: NodeMaterialBuildState): this;
  50125. }
  50126. }
  50127. declare module BABYLON {
  50128. /**
  50129. * Block used to output the final color
  50130. */
  50131. export class FragmentOutputBlock extends NodeMaterialBlock {
  50132. /**
  50133. * Gets or sets a boolean indicating if this block will output an alpha value
  50134. */
  50135. alphaBlendingEnabled: boolean;
  50136. /**
  50137. * Create a new FragmentOutputBlock
  50138. * @param name defines the block name
  50139. */
  50140. constructor(name: string);
  50141. /**
  50142. * Gets the current class name
  50143. * @returns the class name
  50144. */
  50145. getClassName(): string;
  50146. /**
  50147. * Gets the color input component
  50148. */
  50149. readonly color: NodeMaterialConnectionPoint;
  50150. protected _buildBlock(state: NodeMaterialBuildState): this;
  50151. }
  50152. }
  50153. declare module BABYLON {
  50154. /**
  50155. * Interface used to configure the node material editor
  50156. */
  50157. export interface INodeMaterialEditorOptions {
  50158. /** Define the URl to load node editor script */
  50159. editorURL?: string;
  50160. }
  50161. /** @hidden */
  50162. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50163. /** BONES */
  50164. NUM_BONE_INFLUENCERS: number;
  50165. BonesPerMesh: number;
  50166. BONETEXTURE: boolean;
  50167. /** MORPH TARGETS */
  50168. MORPHTARGETS: boolean;
  50169. MORPHTARGETS_NORMAL: boolean;
  50170. MORPHTARGETS_TANGENT: boolean;
  50171. MORPHTARGETS_UV: boolean;
  50172. NUM_MORPH_INFLUENCERS: number;
  50173. /** IMAGE PROCESSING */
  50174. IMAGEPROCESSING: boolean;
  50175. VIGNETTE: boolean;
  50176. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50177. VIGNETTEBLENDMODEOPAQUE: boolean;
  50178. TONEMAPPING: boolean;
  50179. TONEMAPPING_ACES: boolean;
  50180. CONTRAST: boolean;
  50181. EXPOSURE: boolean;
  50182. COLORCURVES: boolean;
  50183. COLORGRADING: boolean;
  50184. COLORGRADING3D: boolean;
  50185. SAMPLER3DGREENDEPTH: boolean;
  50186. SAMPLER3DBGRMAP: boolean;
  50187. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50188. constructor();
  50189. setValue(name: string, value: boolean): void;
  50190. }
  50191. /**
  50192. * Class used to configure NodeMaterial
  50193. */
  50194. export interface INodeMaterialOptions {
  50195. /**
  50196. * Defines if blocks should emit comments
  50197. */
  50198. emitComments: boolean;
  50199. }
  50200. /**
  50201. * Class used to create a node based material built by assembling shader blocks
  50202. */
  50203. export class NodeMaterial extends PushMaterial {
  50204. private _options;
  50205. private _vertexCompilationState;
  50206. private _fragmentCompilationState;
  50207. private _sharedData;
  50208. private _buildId;
  50209. private _buildWasSuccessful;
  50210. private _cachedWorldViewMatrix;
  50211. private _cachedWorldViewProjectionMatrix;
  50212. private _textureConnectionPoints;
  50213. private _optimizers;
  50214. /** Define the URl to load node editor script */
  50215. static EditorURL: string;
  50216. private BJSNODEMATERIALEDITOR;
  50217. /** Get the inspector from bundle or global */
  50218. private _getGlobalNodeMaterialEditor;
  50219. /**
  50220. * Defines the maximum number of lights that can be used in the material
  50221. */
  50222. maxSimultaneousLights: number;
  50223. /**
  50224. * Observable raised when the material is built
  50225. */
  50226. onBuildObservable: Observable<NodeMaterial>;
  50227. /**
  50228. * Gets or sets the root nodes of the material vertex shader
  50229. */ private _vertexOutputNodes: NodeMaterialBlock[];
  50230. /**
  50231. * Gets or sets the root nodes of the material fragment (pixel) shader
  50232. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  50233. /** Gets or sets options to control the node material overall behavior */
  50234. options: INodeMaterialOptions;
  50235. /**
  50236. * Default configuration related to image processing available in the standard Material.
  50237. */
  50238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50239. /**
  50240. * Gets the image processing configuration used either in this material.
  50241. */
  50242. /**
  50243. * Sets the Default image processing configuration used either in the this material.
  50244. *
  50245. * If sets to null, the scene one is in use.
  50246. */
  50247. imageProcessingConfiguration: ImageProcessingConfiguration;
  50248. /**
  50249. * Create a new node based material
  50250. * @param name defines the material name
  50251. * @param scene defines the hosting scene
  50252. * @param options defines creation option
  50253. */
  50254. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50255. /**
  50256. * Gets the current class name of the material e.g. "NodeMaterial"
  50257. * @returns the class name
  50258. */
  50259. getClassName(): string;
  50260. /**
  50261. * Keep track of the image processing observer to allow dispose and replace.
  50262. */
  50263. private _imageProcessingObserver;
  50264. /**
  50265. * Attaches a new image processing configuration to the Standard Material.
  50266. * @param configuration
  50267. */
  50268. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50269. /**
  50270. * Adds a new optimizer to the list of optimizers
  50271. * @param optimizer defines the optimizers to add
  50272. * @returns the current material
  50273. */
  50274. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50275. /**
  50276. * Remove an optimizer from the list of optimizers
  50277. * @param optimizer defines the optimizers to remove
  50278. * @returns the current material
  50279. */
  50280. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50281. /**
  50282. * Add a new block to the list of output nodes
  50283. * @param node defines the node to add
  50284. * @returns the current material
  50285. */
  50286. addOutputNode(node: NodeMaterialBlock): this;
  50287. /**
  50288. * Remove a block from the list of root nodes
  50289. * @param node defines the node to remove
  50290. * @returns the current material
  50291. */
  50292. removeOutputNode(node: NodeMaterialBlock): this;
  50293. private _addVertexOutputNode;
  50294. private _removeVertexOutputNode;
  50295. private _addFragmentOutputNode;
  50296. private _removeFragmentOutputNode;
  50297. /**
  50298. * Specifies if the material will require alpha blending
  50299. * @returns a boolean specifying if alpha blending is needed
  50300. */
  50301. needAlphaBlending(): boolean;
  50302. /**
  50303. * Specifies if this material should be rendered in alpha test mode
  50304. * @returns a boolean specifying if an alpha test is needed.
  50305. */
  50306. needAlphaTesting(): boolean;
  50307. private _initializeBlock;
  50308. private _resetDualBlocks;
  50309. /**
  50310. * Build the material and generates the inner effect
  50311. * @param verbose defines if the build should log activity
  50312. */
  50313. build(verbose?: boolean): void;
  50314. /**
  50315. * Runs an otpimization phase to try to improve the shader code
  50316. */
  50317. optimize(): void;
  50318. private _prepareDefinesForAttributes;
  50319. /**
  50320. * Get if the submesh is ready to be used and all its information available.
  50321. * Child classes can use it to update shaders
  50322. * @param mesh defines the mesh to check
  50323. * @param subMesh defines which submesh to check
  50324. * @param useInstances specifies that instances should be used
  50325. * @returns a boolean indicating that the submesh is ready or not
  50326. */
  50327. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50328. /**
  50329. * Binds the world matrix to the material
  50330. * @param world defines the world transformation matrix
  50331. */
  50332. bindOnlyWorldMatrix(world: Matrix): void;
  50333. /**
  50334. * Binds the submesh to this material by preparing the effect and shader to draw
  50335. * @param world defines the world transformation matrix
  50336. * @param mesh defines the mesh containing the submesh
  50337. * @param subMesh defines the submesh to bind the material to
  50338. */
  50339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50340. /**
  50341. * Gets the active textures from the material
  50342. * @returns an array of textures
  50343. */
  50344. getActiveTextures(): BaseTexture[];
  50345. /**
  50346. * Specifies if the material uses a texture
  50347. * @param texture defines the texture to check against the material
  50348. * @returns a boolean specifying if the material uses the texture
  50349. */
  50350. hasTexture(texture: BaseTexture): boolean;
  50351. /**
  50352. * Disposes the material
  50353. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50354. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50355. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50356. */
  50357. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50358. /** Creates the node editor window. */
  50359. private _createNodeEditor;
  50360. /**
  50361. * Launch the node material editor
  50362. * @param config Define the configuration of the editor
  50363. * @return a promise fulfilled when the node editor is visible
  50364. */
  50365. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50366. /**
  50367. * Clear the current material
  50368. */
  50369. clear(): void;
  50370. /**
  50371. * Clear the current material and set it to a default state
  50372. */
  50373. setToDefault(): void;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * Defines a block that can be used inside a node based material
  50379. */
  50380. export class NodeMaterialBlock {
  50381. private _buildId;
  50382. private _target;
  50383. private _isFinalMerger;
  50384. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  50385. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  50386. /**
  50387. * Gets or sets the name of the block
  50388. */
  50389. name: string;
  50390. /**
  50391. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  50392. */
  50393. readonly isFinalMerger: boolean;
  50394. /**
  50395. * Gets or sets the build Id
  50396. */
  50397. buildId: number;
  50398. /**
  50399. * Gets or sets the target of the block
  50400. */
  50401. target: NodeMaterialBlockTargets;
  50402. /**
  50403. * Gets the list of input points
  50404. */
  50405. readonly inputs: NodeMaterialConnectionPoint[];
  50406. /** Gets the list of output points */
  50407. readonly outputs: NodeMaterialConnectionPoint[];
  50408. /**
  50409. * Find an input by its name
  50410. * @param name defines the name of the input to look for
  50411. * @returns the input or null if not found
  50412. */
  50413. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50414. /**
  50415. * Find an output by its name
  50416. * @param name defines the name of the outputto look for
  50417. * @returns the output or null if not found
  50418. */
  50419. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50420. /**
  50421. * Creates a new NodeMaterialBlock
  50422. * @param name defines the block name
  50423. * @param target defines the target of that block (Vertex by default)
  50424. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  50425. */
  50426. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  50427. /**
  50428. * Initialize the block and prepare the context for build
  50429. * @param state defines the state that will be used for the build
  50430. */
  50431. initialize(state: NodeMaterialBuildState): void;
  50432. /**
  50433. * Bind data to effect. Will only be called for blocks with isBindable === true
  50434. * @param effect defines the effect to bind data to
  50435. * @param nodeMaterial defines the hosting NodeMaterial
  50436. * @param mesh defines the mesh that will be rendered
  50437. */
  50438. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50439. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  50440. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  50441. protected _writeFloat(value: number): string;
  50442. /**
  50443. * Gets the current class name e.g. "NodeMaterialBlock"
  50444. * @returns the class name
  50445. */
  50446. getClassName(): string;
  50447. /**
  50448. * Register a new input. Must be called inside a block constructor
  50449. * @param name defines the connection point name
  50450. * @param type defines the connection point type
  50451. * @param isOptional defines a boolean indicating that this input can be omitted
  50452. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50453. * @returns the current block
  50454. */
  50455. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  50456. /**
  50457. * Register a new output. Must be called inside a block constructor
  50458. * @param name defines the connection point name
  50459. * @param type defines the connection point type
  50460. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50461. * @returns the current block
  50462. */
  50463. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  50464. /**
  50465. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  50466. * @param forOutput defines an optional connection point to check compatibility with
  50467. * @returns the first available input or null
  50468. */
  50469. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  50470. /**
  50471. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  50472. * @param forBlock defines an optional block to check compatibility with
  50473. * @returns the first available input or null
  50474. */
  50475. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  50476. /**
  50477. * Connect current block with another block
  50478. * @param other defines the block to connect with
  50479. * @param options define the various options to help pick the right connections
  50480. * @returns the current block
  50481. */
  50482. connectTo(other: NodeMaterialBlock, options?: {
  50483. input?: string;
  50484. output?: string;
  50485. outputSwizzle?: string;
  50486. }): this | undefined;
  50487. protected _buildBlock(state: NodeMaterialBuildState): void;
  50488. /**
  50489. * Add potential fallbacks if shader compilation fails
  50490. * @param mesh defines the mesh to be rendered
  50491. * @param fallbacks defines the current prioritized list of fallbacks
  50492. */
  50493. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50494. /**
  50495. * Update defines for shader compilation
  50496. * @param mesh defines the mesh to be rendered
  50497. * @param nodeMaterial defines the node material requesting the update
  50498. * @param defines defines the material defines to update
  50499. * @param useInstances specifies that instances should be used
  50500. */
  50501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50502. /**
  50503. * Lets the block try to connect some inputs automatically
  50504. */
  50505. autoConfigure(): void;
  50506. /**
  50507. * Function called when a block is declared as repeatable content generator
  50508. * @param vertexShaderState defines the current compilation state for the vertex shader
  50509. * @param fragmentShaderState defines the current compilation state for the fragment shader
  50510. * @param mesh defines the mesh to be rendered
  50511. * @param defines defines the material defines to update
  50512. */
  50513. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50514. /**
  50515. * Checks if the block is ready
  50516. * @param mesh defines the mesh to be rendered
  50517. * @param nodeMaterial defines the node material requesting the update
  50518. * @param defines defines the material defines to update
  50519. * @param useInstances specifies that instances should be used
  50520. * @returns true if the block is ready
  50521. */
  50522. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  50523. /**
  50524. * Compile the current node and generate the shader code
  50525. * @param state defines the current compilation state (uniforms, samplers, current string)
  50526. * @returns the current block
  50527. */
  50528. build(state: NodeMaterialBuildState): this | undefined;
  50529. }
  50530. }
  50531. declare module BABYLON {
  50532. /**
  50533. * Defines a connection point for a block
  50534. */
  50535. export class NodeMaterialConnectionPoint {
  50536. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  50537. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50538. private _associatedVariableName;
  50539. private _endpoints;
  50540. private _storedValue;
  50541. private _valueCallback;
  50542. private _mode;
  50543. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50544. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  50545. /** @hidden */ private _needToEmitVarying: boolean;
  50546. /** @hidden */ private _forceUniformInVertexShaderOnly: boolean;
  50547. private _type;
  50548. /**
  50549. * Gets or sets the connection point type (default is float)
  50550. */
  50551. type: NodeMaterialBlockConnectionPointTypes;
  50552. /**
  50553. * Gets or sets the connection point name
  50554. */
  50555. name: string;
  50556. /**
  50557. * Gets or sets the swizzle to apply to this connection point when reading or writing
  50558. */
  50559. swizzle: string;
  50560. /**
  50561. * Gets or sets a boolean indicating that this connection point can be omitted
  50562. */
  50563. isOptional: boolean;
  50564. /**
  50565. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  50566. */
  50567. define: string;
  50568. /** Gets or sets the target of that connection point */
  50569. target: NodeMaterialBlockTargets;
  50570. /**
  50571. * Gets or sets the value of that point.
  50572. * Please note that this value will be ignored if valueCallback is defined
  50573. */
  50574. value: any;
  50575. /**
  50576. * Gets or sets a callback used to get the value of that point.
  50577. * Please note that setting this value will force the connection point to ignore the value property
  50578. */
  50579. valueCallback: () => any;
  50580. /**
  50581. * Gets or sets the associated variable name in the shader
  50582. */
  50583. associatedVariableName: string;
  50584. /**
  50585. * Gets a boolean indicating that this connection point not defined yet
  50586. */
  50587. readonly isUndefined: boolean;
  50588. /**
  50589. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  50590. * In this case the connection point name must be the name of the uniform to use.
  50591. * Can only be set on inputs
  50592. */
  50593. isUniform: boolean;
  50594. /**
  50595. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  50596. * In this case the connection point name must be the name of the attribute to use
  50597. * Can only be set on inputs
  50598. */
  50599. isAttribute: boolean;
  50600. /**
  50601. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  50602. * Can only be set on exit points
  50603. */
  50604. isVarying: boolean;
  50605. /** Get the other side of the connection (if any) */
  50606. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50607. /** Get the block that owns this connection point */
  50608. readonly ownerBlock: NodeMaterialBlock;
  50609. /** Get the block connected on the other side of this connection (if any) */
  50610. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  50611. /** Get the block connected on the endpoints of this connection (if any) */
  50612. readonly connectedBlocks: Array<NodeMaterialBlock>;
  50613. /**
  50614. * Creates a new connection point
  50615. * @param name defines the connection point name
  50616. * @param ownerBlock defines the block hosting this connection point
  50617. */
  50618. constructor(name: string, ownerBlock: NodeMaterialBlock);
  50619. /**
  50620. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  50621. * @returns the class name
  50622. */
  50623. getClassName(): string;
  50624. /**
  50625. * Set the source of this connection point to a vertex attribute
  50626. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  50627. * @returns the current connection point
  50628. */
  50629. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  50630. /**
  50631. * Set the source of this connection point to a well known value
  50632. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  50633. * @returns the current connection point
  50634. */
  50635. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  50636. /**
  50637. * Gets a boolean indicating that the current connection point is a well known value
  50638. */
  50639. readonly isWellKnownValue: boolean;
  50640. /**
  50641. * Gets or sets the current well known value or null if not defined as well know value
  50642. */
  50643. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50644. private _getTypeLength;
  50645. /**
  50646. * Connect this point to another connection point
  50647. * @param connectionPoint defines the other connection point
  50648. * @returns the current connection point
  50649. */
  50650. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50651. /**
  50652. * Disconnect this point from one of his endpoint
  50653. * @param endpoint defines the other connection point
  50654. * @returns the current connection point
  50655. */
  50656. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50657. /**
  50658. * When connection point is an uniform, this function will send its value to the effect
  50659. * @param effect defines the effect to transmit value to
  50660. * @param world defines the world matrix
  50661. * @param worldView defines the worldxview matrix
  50662. * @param worldViewProjection defines the worldxviewxprojection matrix
  50663. */
  50664. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  50665. /**
  50666. * When connection point is an uniform, this function will send its value to the effect
  50667. * @param effect defines the effect to transmit value to
  50668. * @param scene defines the hosting scene
  50669. */
  50670. transmit(effect: Effect, scene: Scene): void;
  50671. }
  50672. }
  50673. declare module BABYLON {
  50674. /**
  50675. * Block used to add support for vertex skinning (bones)
  50676. */
  50677. export class BonesBlock extends NodeMaterialBlock {
  50678. /**
  50679. * Creates a new BonesBlock
  50680. * @param name defines the block name
  50681. */
  50682. constructor(name: string);
  50683. /**
  50684. * Initialize the block and prepare the context for build
  50685. * @param state defines the state that will be used for the build
  50686. */
  50687. initialize(state: NodeMaterialBuildState): void;
  50688. /**
  50689. * Gets the current class name
  50690. * @returns the class name
  50691. */
  50692. getClassName(): string;
  50693. /**
  50694. * Gets the matrix indices input component
  50695. */
  50696. readonly matricesIndices: NodeMaterialConnectionPoint;
  50697. /**
  50698. * Gets the matrix weights input component
  50699. */
  50700. readonly matricesWeights: NodeMaterialConnectionPoint;
  50701. /**
  50702. * Gets the extra matrix indices input component
  50703. */
  50704. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  50705. /**
  50706. * Gets the extra matrix weights input component
  50707. */
  50708. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  50709. /**
  50710. * Gets the world input component
  50711. */
  50712. readonly world: NodeMaterialConnectionPoint;
  50713. /**
  50714. * Gets the output component
  50715. */
  50716. readonly output: NodeMaterialConnectionPoint;
  50717. autoConfigure(): void;
  50718. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50721. protected _buildBlock(state: NodeMaterialBuildState): this;
  50722. }
  50723. }
  50724. declare module BABYLON {
  50725. /**
  50726. * Block used to add support for instances
  50727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  50728. */
  50729. export class InstancesBlock extends NodeMaterialBlock {
  50730. /**
  50731. * Creates a new InstancesBlock
  50732. * @param name defines the block name
  50733. */
  50734. constructor(name: string);
  50735. /**
  50736. * Gets the current class name
  50737. * @returns the class name
  50738. */
  50739. getClassName(): string;
  50740. /**
  50741. * Gets the first world row input component
  50742. */
  50743. readonly world0: NodeMaterialConnectionPoint;
  50744. /**
  50745. * Gets the second world row input component
  50746. */
  50747. readonly world1: NodeMaterialConnectionPoint;
  50748. /**
  50749. * Gets the third world row input component
  50750. */
  50751. readonly world2: NodeMaterialConnectionPoint;
  50752. /**
  50753. * Gets the forth world row input component
  50754. */
  50755. readonly world3: NodeMaterialConnectionPoint;
  50756. /**
  50757. * Gets the world input component
  50758. */
  50759. readonly world: NodeMaterialConnectionPoint;
  50760. /**
  50761. * Gets the output component
  50762. */
  50763. readonly output: NodeMaterialConnectionPoint;
  50764. autoConfigure(): void;
  50765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50766. protected _buildBlock(state: NodeMaterialBuildState): this;
  50767. }
  50768. }
  50769. declare module BABYLON {
  50770. /**
  50771. * Block used to add morph targets support to vertex shader
  50772. */
  50773. export class MorphTargetsBlock extends NodeMaterialBlock {
  50774. private _repeatableContentAnchor;
  50775. private _repeatebleContentGenerated;
  50776. /**
  50777. * Create a new MorphTargetsBlock
  50778. * @param name defines the block name
  50779. */
  50780. constructor(name: string);
  50781. /**
  50782. * Gets the current class name
  50783. * @returns the class name
  50784. */
  50785. getClassName(): string;
  50786. /**
  50787. * Gets the position input component
  50788. */
  50789. readonly position: NodeMaterialConnectionPoint;
  50790. /**
  50791. * Gets the normal input component
  50792. */
  50793. readonly normal: NodeMaterialConnectionPoint;
  50794. /**
  50795. * Gets the tangent input component
  50796. */
  50797. readonly tangent: NodeMaterialConnectionPoint;
  50798. /**
  50799. * Gets the tangent input component
  50800. */
  50801. readonly uv: NodeMaterialConnectionPoint;
  50802. /**
  50803. * Gets the position output component
  50804. */
  50805. readonly positionOutput: NodeMaterialConnectionPoint;
  50806. /**
  50807. * Gets the normal output component
  50808. */
  50809. readonly normalOutput: NodeMaterialConnectionPoint;
  50810. /**
  50811. * Gets the tangent output component
  50812. */
  50813. readonly tangentOutput: NodeMaterialConnectionPoint;
  50814. /**
  50815. * Gets the tangent output component
  50816. */
  50817. readonly uvOutput: NodeMaterialConnectionPoint;
  50818. initialize(state: NodeMaterialBuildState): void;
  50819. autoConfigure(): void;
  50820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50822. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50823. protected _buildBlock(state: NodeMaterialBuildState): this;
  50824. }
  50825. }
  50826. declare module BABYLON {
  50827. /**
  50828. * Block used to add an alpha test in the fragment shader
  50829. */
  50830. export class AlphaTestBlock extends NodeMaterialBlock {
  50831. /**
  50832. * Gets or sets the alpha value where alpha testing happens
  50833. */
  50834. alphaCutOff: number;
  50835. /**
  50836. * Create a new AlphaTestBlock
  50837. * @param name defines the block name
  50838. */
  50839. constructor(name: string);
  50840. /**
  50841. * Gets the current class name
  50842. * @returns the class name
  50843. */
  50844. getClassName(): string;
  50845. /**
  50846. * Gets the color input component
  50847. */
  50848. readonly color: NodeMaterialConnectionPoint;
  50849. protected _buildBlock(state: NodeMaterialBuildState): this;
  50850. }
  50851. }
  50852. declare module BABYLON {
  50853. /**
  50854. * Block used to create a Color4 out of 4 inputs (one for each component)
  50855. */
  50856. export class RGBAMergerBlock extends NodeMaterialBlock {
  50857. /**
  50858. * Create a new RGBAMergerBlock
  50859. * @param name defines the block name
  50860. */
  50861. constructor(name: string);
  50862. /**
  50863. * Gets the current class name
  50864. * @returns the class name
  50865. */
  50866. getClassName(): string;
  50867. /**
  50868. * Gets the R input component
  50869. */
  50870. readonly r: NodeMaterialConnectionPoint;
  50871. /**
  50872. * Gets the G input component
  50873. */
  50874. readonly g: NodeMaterialConnectionPoint;
  50875. /**
  50876. * Gets the B input component
  50877. */
  50878. readonly b: NodeMaterialConnectionPoint;
  50879. /**
  50880. * Gets the RGB input component
  50881. */
  50882. readonly rgb: NodeMaterialConnectionPoint;
  50883. /**
  50884. * Gets the R input component
  50885. */
  50886. readonly a: NodeMaterialConnectionPoint;
  50887. /**
  50888. * Gets the output component
  50889. */
  50890. readonly output: NodeMaterialConnectionPoint;
  50891. protected _buildBlock(state: NodeMaterialBuildState): this;
  50892. }
  50893. }
  50894. declare module BABYLON {
  50895. /**
  50896. * Block used to create a Color3 out of 3 inputs (one for each component)
  50897. */
  50898. export class RGBMergerBlock extends NodeMaterialBlock {
  50899. /**
  50900. * Create a new RGBMergerBlock
  50901. * @param name defines the block name
  50902. */
  50903. constructor(name: string);
  50904. /**
  50905. * Gets the current class name
  50906. * @returns the class name
  50907. */
  50908. getClassName(): string;
  50909. /**
  50910. * Gets the R component input
  50911. */
  50912. readonly r: NodeMaterialConnectionPoint;
  50913. /**
  50914. * Gets the G component input
  50915. */
  50916. readonly g: NodeMaterialConnectionPoint;
  50917. /**
  50918. * Gets the B component input
  50919. */
  50920. readonly b: NodeMaterialConnectionPoint;
  50921. /**
  50922. * Gets the output component
  50923. */
  50924. readonly output: NodeMaterialConnectionPoint;
  50925. protected _buildBlock(state: NodeMaterialBuildState): this;
  50926. }
  50927. }
  50928. declare module BABYLON {
  50929. /**
  50930. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  50931. */
  50932. export class RGBASplitterBlock extends NodeMaterialBlock {
  50933. /**
  50934. * Create a new RGBASplitterBlock
  50935. * @param name defines the block name
  50936. */
  50937. constructor(name: string);
  50938. /**
  50939. * Gets the current class name
  50940. * @returns the class name
  50941. */
  50942. getClassName(): string;
  50943. /**
  50944. * Gets the input component
  50945. */
  50946. readonly input: NodeMaterialConnectionPoint;
  50947. protected _buildBlock(state: NodeMaterialBuildState): this;
  50948. }
  50949. }
  50950. declare module BABYLON {
  50951. /**
  50952. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  50953. */
  50954. export class RGBSplitterBlock extends NodeMaterialBlock {
  50955. /**
  50956. * Create a new RGBSplitterBlock
  50957. * @param name defines the block name
  50958. */
  50959. constructor(name: string);
  50960. /**
  50961. * Gets the current class name
  50962. * @returns the class name
  50963. */
  50964. getClassName(): string;
  50965. /**
  50966. * Gets the input component
  50967. */
  50968. readonly input: NodeMaterialConnectionPoint;
  50969. protected _buildBlock(state: NodeMaterialBuildState): this;
  50970. }
  50971. }
  50972. declare module BABYLON {
  50973. /**
  50974. * Block used to read a texture from a sampler
  50975. */
  50976. export class TextureBlock extends NodeMaterialBlock {
  50977. private _defineName;
  50978. /**
  50979. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  50980. */
  50981. autoConnectTextureMatrix: boolean;
  50982. /**
  50983. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  50984. */
  50985. autoSelectUV: boolean;
  50986. /**
  50987. * Create a new TextureBlock
  50988. * @param name defines the block name
  50989. */
  50990. constructor(name: string);
  50991. /**
  50992. * Gets the current class name
  50993. * @returns the class name
  50994. */
  50995. getClassName(): string;
  50996. /**
  50997. * Gets the uv input component
  50998. */
  50999. readonly uv: NodeMaterialConnectionPoint;
  51000. /**
  51001. * Gets the texture information input component
  51002. */
  51003. readonly textureInfo: NodeMaterialConnectionPoint;
  51004. /**
  51005. * Gets the transformed uv input component
  51006. */
  51007. readonly transformedUV: NodeMaterialConnectionPoint;
  51008. /**
  51009. * Gets the texture input component
  51010. */
  51011. readonly texture: NodeMaterialConnectionPoint;
  51012. /**
  51013. * Gets the texture transform input component
  51014. */
  51015. readonly textureTransform: NodeMaterialConnectionPoint;
  51016. /**
  51017. * Gets the output component
  51018. */
  51019. readonly output: NodeMaterialConnectionPoint;
  51020. autoConfigure(): void;
  51021. initialize(state: NodeMaterialBuildState): void;
  51022. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51023. isReady(): boolean;
  51024. private _injectVertexCode;
  51025. protected _buildBlock(state: NodeMaterialBuildState): this;
  51026. }
  51027. }
  51028. declare module BABYLON {
  51029. /**
  51030. * Block used to add image processing support to fragment shader
  51031. */
  51032. export class ImageProcessingBlock extends NodeMaterialBlock {
  51033. /**
  51034. * Create a new ImageProcessingBlock
  51035. * @param name defines the block name
  51036. */
  51037. constructor(name: string);
  51038. /**
  51039. * Gets the current class name
  51040. * @returns the class name
  51041. */
  51042. getClassName(): string;
  51043. /**
  51044. * Gets the color input component
  51045. */
  51046. readonly color: NodeMaterialConnectionPoint;
  51047. /**
  51048. * Gets the output component
  51049. */
  51050. readonly output: NodeMaterialConnectionPoint;
  51051. /**
  51052. * Initialize the block and prepare the context for build
  51053. * @param state defines the state that will be used for the build
  51054. */
  51055. initialize(state: NodeMaterialBuildState): void;
  51056. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51059. protected _buildBlock(state: NodeMaterialBuildState): this;
  51060. }
  51061. }
  51062. declare module BABYLON {
  51063. /**
  51064. * Block used to add support for scene fog
  51065. */
  51066. export class FogBlock extends NodeMaterialBlock {
  51067. /**
  51068. * Create a new FogBlock
  51069. * @param name defines the block name
  51070. */
  51071. constructor(name: string);
  51072. /**
  51073. * Gets the current class name
  51074. * @returns the class name
  51075. */
  51076. getClassName(): string;
  51077. /**
  51078. * Gets the world position input component
  51079. */
  51080. readonly worldPosition: NodeMaterialConnectionPoint;
  51081. /**
  51082. * Gets the view input component
  51083. */
  51084. readonly view: NodeMaterialConnectionPoint;
  51085. /**
  51086. * Gets the color input component
  51087. */
  51088. readonly color: NodeMaterialConnectionPoint;
  51089. /**
  51090. * Gets the fog color input component
  51091. */
  51092. readonly fogColor: NodeMaterialConnectionPoint;
  51093. /**
  51094. * Gets the for parameter input component
  51095. */
  51096. readonly fogParameters: NodeMaterialConnectionPoint;
  51097. /**
  51098. * Gets the output component
  51099. */
  51100. readonly output: NodeMaterialConnectionPoint;
  51101. autoConfigure(): void;
  51102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51104. protected _buildBlock(state: NodeMaterialBuildState): this;
  51105. }
  51106. }
  51107. declare module BABYLON {
  51108. /**
  51109. * Block used to add light in the fragment shader
  51110. */
  51111. export class LightBlock extends NodeMaterialBlock {
  51112. private _lightId;
  51113. /**
  51114. * Create a new LightBlock
  51115. * @param name defines the block name
  51116. */
  51117. constructor(name: string);
  51118. /**
  51119. * Gets the current class name
  51120. * @returns the class name
  51121. */
  51122. getClassName(): string;
  51123. /**
  51124. * Gets the world position input component
  51125. */
  51126. readonly worldPosition: NodeMaterialConnectionPoint;
  51127. /**
  51128. * Gets the world normal input component
  51129. */
  51130. readonly worldNormal: NodeMaterialConnectionPoint;
  51131. /**
  51132. * Gets the light input component
  51133. */
  51134. readonly light: NodeMaterialConnectionPoint;
  51135. /**
  51136. * Gets the camera (or eye) position component
  51137. */
  51138. readonly cameraPosition: NodeMaterialConnectionPoint;
  51139. /**
  51140. * Gets the diffuse output component
  51141. */
  51142. readonly diffuseOutput: NodeMaterialConnectionPoint;
  51143. /**
  51144. * Gets the specular output component
  51145. */
  51146. readonly specularOutput: NodeMaterialConnectionPoint;
  51147. autoConfigure(): void;
  51148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51149. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51150. private _injectVertexCode;
  51151. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51152. }
  51153. }
  51154. declare module BABYLON {
  51155. /**
  51156. * Block used to multiply 2 vector4
  51157. */
  51158. export class MultiplyBlock extends NodeMaterialBlock {
  51159. /**
  51160. * Creates a new MultiplyBlock
  51161. * @param name defines the block name
  51162. */
  51163. constructor(name: string);
  51164. /**
  51165. * Gets the current class name
  51166. * @returns the class name
  51167. */
  51168. getClassName(): string;
  51169. /**
  51170. * Gets the left operand input component
  51171. */
  51172. readonly left: NodeMaterialConnectionPoint;
  51173. /**
  51174. * Gets the right operand input component
  51175. */
  51176. readonly right: NodeMaterialConnectionPoint;
  51177. /**
  51178. * Gets the output component
  51179. */
  51180. readonly output: NodeMaterialConnectionPoint;
  51181. protected _buildBlock(state: NodeMaterialBuildState): this;
  51182. }
  51183. }
  51184. declare module BABYLON {
  51185. /**
  51186. * Block used to add 2 vector4
  51187. */
  51188. export class AddBlock extends NodeMaterialBlock {
  51189. /**
  51190. * Creates a new AddBlock
  51191. * @param name defines the block name
  51192. */
  51193. constructor(name: string);
  51194. /**
  51195. * Gets the current class name
  51196. * @returns the class name
  51197. */
  51198. getClassName(): string;
  51199. /**
  51200. * Gets the left operand input component
  51201. */
  51202. readonly left: NodeMaterialConnectionPoint;
  51203. /**
  51204. * Gets the right operand input component
  51205. */
  51206. readonly right: NodeMaterialConnectionPoint;
  51207. /**
  51208. * Gets the output component
  51209. */
  51210. readonly output: NodeMaterialConnectionPoint;
  51211. protected _buildBlock(state: NodeMaterialBuildState): this;
  51212. }
  51213. }
  51214. declare module BABYLON {
  51215. /**
  51216. * Block used to clamp a float
  51217. */
  51218. export class ClampBlock extends NodeMaterialBlock {
  51219. /** Gets or sets the minimum range */
  51220. minimum: number;
  51221. /** Gets or sets the maximum range */
  51222. maximum: number;
  51223. /**
  51224. * Creates a new ClampBlock
  51225. * @param name defines the block name
  51226. */
  51227. constructor(name: string);
  51228. /**
  51229. * Gets the current class name
  51230. * @returns the class name
  51231. */
  51232. getClassName(): string;
  51233. /**
  51234. * Gets the value input component
  51235. */
  51236. readonly value: NodeMaterialConnectionPoint;
  51237. /**
  51238. * Gets the output component
  51239. */
  51240. readonly output: NodeMaterialConnectionPoint;
  51241. protected _buildBlock(state: NodeMaterialBuildState): this;
  51242. }
  51243. }
  51244. declare module BABYLON {
  51245. /**
  51246. * Block used to scale a value
  51247. */
  51248. export class ScaleBlock extends NodeMaterialBlock {
  51249. /**
  51250. * Creates a new ScaleBlock
  51251. * @param name defines the block name
  51252. */
  51253. constructor(name: string);
  51254. /**
  51255. * Gets the current class name
  51256. * @returns the class name
  51257. */
  51258. getClassName(): string;
  51259. /**
  51260. * Gets the value operand input component
  51261. */
  51262. readonly value: NodeMaterialConnectionPoint;
  51263. /**
  51264. * Gets the scale operand input component
  51265. */
  51266. readonly scale: NodeMaterialConnectionPoint;
  51267. /**
  51268. * Gets the output component
  51269. */
  51270. readonly output: NodeMaterialConnectionPoint;
  51271. protected _buildBlock(state: NodeMaterialBuildState): this;
  51272. }
  51273. }
  51274. declare module BABYLON {
  51275. /**
  51276. * Block used to transform a vector2 with a matrix
  51277. */
  51278. export class Vector2TransformBlock extends NodeMaterialBlock {
  51279. /**
  51280. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51281. */
  51282. complementZ: number;
  51283. /**
  51284. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51285. */
  51286. complementW: number;
  51287. /**
  51288. * Creates a new Vector2TransformBlock
  51289. * @param name defines the block name
  51290. */
  51291. constructor(name: string);
  51292. /**
  51293. * Gets the vector input
  51294. */
  51295. readonly vector: NodeMaterialConnectionPoint;
  51296. /**
  51297. * Gets the matrix transform input
  51298. */
  51299. readonly transform: NodeMaterialConnectionPoint;
  51300. /**
  51301. * Gets the output component
  51302. */
  51303. readonly output: NodeMaterialConnectionPoint;
  51304. /**
  51305. * Gets the current class name
  51306. * @returns the class name
  51307. */
  51308. getClassName(): string;
  51309. protected _buildBlock(state: NodeMaterialBuildState): this;
  51310. }
  51311. }
  51312. declare module BABYLON {
  51313. /**
  51314. * Block used to transform a vector3 with a matrix
  51315. */
  51316. export class Vector3TransformBlock extends NodeMaterialBlock {
  51317. /**
  51318. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51319. */
  51320. complement: number;
  51321. /**
  51322. * Creates a new Vector3TransformBlock
  51323. * @param name defines the block name
  51324. */
  51325. constructor(name: string);
  51326. /**
  51327. * Gets the vector input
  51328. */
  51329. readonly vector: NodeMaterialConnectionPoint;
  51330. /**
  51331. * Gets the matrix transform input
  51332. */
  51333. readonly transform: NodeMaterialConnectionPoint;
  51334. /**
  51335. * Gets the output component
  51336. */
  51337. readonly output: NodeMaterialConnectionPoint;
  51338. /**
  51339. * Gets the current class name
  51340. * @returns the class name
  51341. */
  51342. getClassName(): string;
  51343. protected _buildBlock(state: NodeMaterialBuildState): this;
  51344. }
  51345. }
  51346. declare module BABYLON {
  51347. /**
  51348. * Block used to multiply two matrices
  51349. */
  51350. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  51351. /**
  51352. * Creates a new MatrixMultiplicationBlock
  51353. * @param name defines the block name
  51354. */
  51355. constructor(name: string);
  51356. /**
  51357. * Gets the left operand
  51358. */
  51359. readonly left: NodeMaterialConnectionPoint;
  51360. /**
  51361. * Gets the right operand
  51362. */
  51363. readonly right: NodeMaterialConnectionPoint;
  51364. /**
  51365. * Gets the output component
  51366. */
  51367. readonly output: NodeMaterialConnectionPoint;
  51368. /**
  51369. * Gets the current class name
  51370. * @returns the class name
  51371. */
  51372. getClassName(): string;
  51373. protected _buildBlock(state: NodeMaterialBuildState): this;
  51374. }
  51375. }
  51376. declare module BABYLON {
  51377. /**
  51378. * Helper class to push actions to a pool of workers.
  51379. */
  51380. export class WorkerPool implements IDisposable {
  51381. private _workerInfos;
  51382. private _pendingActions;
  51383. /**
  51384. * Constructor
  51385. * @param workers Array of workers to use for actions
  51386. */
  51387. constructor(workers: Array<Worker>);
  51388. /**
  51389. * Terminates all workers and clears any pending actions.
  51390. */
  51391. dispose(): void;
  51392. /**
  51393. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51394. * pended until a worker has completed its action.
  51395. * @param action The action to perform. Call onComplete when the action is complete.
  51396. */
  51397. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51398. private _execute;
  51399. }
  51400. }
  51401. declare module BABYLON {
  51402. /**
  51403. * Configuration for Draco compression
  51404. */
  51405. export interface IDracoCompressionConfiguration {
  51406. /**
  51407. * Configuration for the decoder.
  51408. */
  51409. decoder: {
  51410. /**
  51411. * The url to the WebAssembly module.
  51412. */
  51413. wasmUrl?: string;
  51414. /**
  51415. * The url to the WebAssembly binary.
  51416. */
  51417. wasmBinaryUrl?: string;
  51418. /**
  51419. * The url to the fallback JavaScript module.
  51420. */
  51421. fallbackUrl?: string;
  51422. };
  51423. }
  51424. /**
  51425. * Draco compression (https://google.github.io/draco/)
  51426. *
  51427. * This class wraps the Draco module.
  51428. *
  51429. * **Encoder**
  51430. *
  51431. * The encoder is not currently implemented.
  51432. *
  51433. * **Decoder**
  51434. *
  51435. * 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.
  51436. *
  51437. * To update the configuration, use the following code:
  51438. * ```javascript
  51439. * DracoCompression.Configuration = {
  51440. * decoder: {
  51441. * wasmUrl: "<url to the WebAssembly library>",
  51442. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51443. * fallbackUrl: "<url to the fallback JavaScript library>",
  51444. * }
  51445. * };
  51446. * ```
  51447. *
  51448. * 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.
  51449. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51450. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51451. *
  51452. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51453. * ```javascript
  51454. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51455. * ```
  51456. *
  51457. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51458. */
  51459. export class DracoCompression implements IDisposable {
  51460. private _workerPoolPromise?;
  51461. private _decoderModulePromise?;
  51462. /**
  51463. * The configuration. Defaults to the following urls:
  51464. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51465. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51466. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51467. */
  51468. static Configuration: IDracoCompressionConfiguration;
  51469. /**
  51470. * Returns true if the decoder configuration is available.
  51471. */
  51472. static readonly DecoderAvailable: boolean;
  51473. /**
  51474. * Default number of workers to create when creating the draco compression object.
  51475. */
  51476. static DefaultNumWorkers: number;
  51477. private static GetDefaultNumWorkers;
  51478. private static _Default;
  51479. /**
  51480. * Default instance for the draco compression object.
  51481. */
  51482. static readonly Default: DracoCompression;
  51483. /**
  51484. * Constructor
  51485. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  51486. */
  51487. constructor(numWorkers?: number);
  51488. /**
  51489. * Stop all async operations and release resources.
  51490. */
  51491. dispose(): void;
  51492. /**
  51493. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51494. * @returns a promise that resolves when ready
  51495. */
  51496. whenReadyAsync(): Promise<void>;
  51497. /**
  51498. * Decode Draco compressed mesh data to vertex data.
  51499. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51500. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51501. * @returns A promise that resolves with the decoded vertex data
  51502. */
  51503. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51504. [kind: string]: number;
  51505. }): Promise<VertexData>;
  51506. }
  51507. }
  51508. declare module BABYLON {
  51509. /**
  51510. * Class for building Constructive Solid Geometry
  51511. */
  51512. export class CSG {
  51513. private polygons;
  51514. /**
  51515. * The world matrix
  51516. */
  51517. matrix: Matrix;
  51518. /**
  51519. * Stores the position
  51520. */
  51521. position: Vector3;
  51522. /**
  51523. * Stores the rotation
  51524. */
  51525. rotation: Vector3;
  51526. /**
  51527. * Stores the rotation quaternion
  51528. */
  51529. rotationQuaternion: Nullable<Quaternion>;
  51530. /**
  51531. * Stores the scaling vector
  51532. */
  51533. scaling: Vector3;
  51534. /**
  51535. * Convert the Mesh to CSG
  51536. * @param mesh The Mesh to convert to CSG
  51537. * @returns A new CSG from the Mesh
  51538. */
  51539. static FromMesh(mesh: Mesh): CSG;
  51540. /**
  51541. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51542. * @param polygons Polygons used to construct a CSG solid
  51543. */
  51544. private static FromPolygons;
  51545. /**
  51546. * Clones, or makes a deep copy, of the CSG
  51547. * @returns A new CSG
  51548. */
  51549. clone(): CSG;
  51550. /**
  51551. * Unions this CSG with another CSG
  51552. * @param csg The CSG to union against this CSG
  51553. * @returns The unioned CSG
  51554. */
  51555. union(csg: CSG): CSG;
  51556. /**
  51557. * Unions this CSG with another CSG in place
  51558. * @param csg The CSG to union against this CSG
  51559. */
  51560. unionInPlace(csg: CSG): void;
  51561. /**
  51562. * Subtracts this CSG with another CSG
  51563. * @param csg The CSG to subtract against this CSG
  51564. * @returns A new CSG
  51565. */
  51566. subtract(csg: CSG): CSG;
  51567. /**
  51568. * Subtracts this CSG with another CSG in place
  51569. * @param csg The CSG to subtact against this CSG
  51570. */
  51571. subtractInPlace(csg: CSG): void;
  51572. /**
  51573. * Intersect this CSG with another CSG
  51574. * @param csg The CSG to intersect against this CSG
  51575. * @returns A new CSG
  51576. */
  51577. intersect(csg: CSG): CSG;
  51578. /**
  51579. * Intersects this CSG with another CSG in place
  51580. * @param csg The CSG to intersect against this CSG
  51581. */
  51582. intersectInPlace(csg: CSG): void;
  51583. /**
  51584. * Return a new CSG solid with solid and empty space switched. This solid is
  51585. * not modified.
  51586. * @returns A new CSG solid with solid and empty space switched
  51587. */
  51588. inverse(): CSG;
  51589. /**
  51590. * Inverses the CSG in place
  51591. */
  51592. inverseInPlace(): void;
  51593. /**
  51594. * This is used to keep meshes transformations so they can be restored
  51595. * when we build back a Babylon Mesh
  51596. * NB : All CSG operations are performed in world coordinates
  51597. * @param csg The CSG to copy the transform attributes from
  51598. * @returns This CSG
  51599. */
  51600. copyTransformAttributes(csg: CSG): CSG;
  51601. /**
  51602. * Build Raw mesh from CSG
  51603. * Coordinates here are in world space
  51604. * @param name The name of the mesh geometry
  51605. * @param scene The Scene
  51606. * @param keepSubMeshes Specifies if the submeshes should be kept
  51607. * @returns A new Mesh
  51608. */
  51609. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51610. /**
  51611. * Build Mesh from CSG taking material and transforms into account
  51612. * @param name The name of the Mesh
  51613. * @param material The material of the Mesh
  51614. * @param scene The Scene
  51615. * @param keepSubMeshes Specifies if submeshes should be kept
  51616. * @returns The new Mesh
  51617. */
  51618. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51619. }
  51620. }
  51621. declare module BABYLON {
  51622. /**
  51623. * Class used to create a trail following a mesh
  51624. */
  51625. export class TrailMesh extends Mesh {
  51626. private _generator;
  51627. private _autoStart;
  51628. private _running;
  51629. private _diameter;
  51630. private _length;
  51631. private _sectionPolygonPointsCount;
  51632. private _sectionVectors;
  51633. private _sectionNormalVectors;
  51634. private _beforeRenderObserver;
  51635. /**
  51636. * @constructor
  51637. * @param name The value used by scene.getMeshByName() to do a lookup.
  51638. * @param generator The mesh to generate a trail.
  51639. * @param scene The scene to add this mesh to.
  51640. * @param diameter Diameter of trailing mesh. Default is 1.
  51641. * @param length Length of trailing mesh. Default is 60.
  51642. * @param autoStart Automatically start trailing mesh. Default true.
  51643. */
  51644. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51645. /**
  51646. * "TrailMesh"
  51647. * @returns "TrailMesh"
  51648. */
  51649. getClassName(): string;
  51650. private _createMesh;
  51651. /**
  51652. * Start trailing mesh.
  51653. */
  51654. start(): void;
  51655. /**
  51656. * Stop trailing mesh.
  51657. */
  51658. stop(): void;
  51659. /**
  51660. * Update trailing mesh geometry.
  51661. */
  51662. update(): void;
  51663. /**
  51664. * Returns a new TrailMesh object.
  51665. * @param name is a string, the name given to the new mesh
  51666. * @param newGenerator use new generator object for cloned trail mesh
  51667. * @returns a new mesh
  51668. */
  51669. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51670. /**
  51671. * Serializes this trail mesh
  51672. * @param serializationObject object to write serialization to
  51673. */
  51674. serialize(serializationObject: any): void;
  51675. /**
  51676. * Parses a serialized trail mesh
  51677. * @param parsedMesh the serialized mesh
  51678. * @param scene the scene to create the trail mesh in
  51679. * @returns the created trail mesh
  51680. */
  51681. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51682. }
  51683. }
  51684. declare module BABYLON {
  51685. /**
  51686. * Class containing static functions to help procedurally build meshes
  51687. */
  51688. export class TiledBoxBuilder {
  51689. /**
  51690. * Creates a box mesh
  51691. * 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)
  51692. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51694. * * 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
  51695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51696. * @param name defines the name of the mesh
  51697. * @param options defines the options used to create the mesh
  51698. * @param scene defines the hosting scene
  51699. * @returns the box mesh
  51700. */
  51701. static CreateTiledBox(name: string, options: {
  51702. pattern?: number;
  51703. width?: number;
  51704. height?: number;
  51705. depth?: number;
  51706. tileSize?: number;
  51707. tileWidth?: number;
  51708. tileHeight?: number;
  51709. alignHorizontal?: number;
  51710. alignVertical?: number;
  51711. faceUV?: Vector4[];
  51712. faceColors?: Color4[];
  51713. sideOrientation?: number;
  51714. updatable?: boolean;
  51715. }, scene?: Nullable<Scene>): Mesh;
  51716. }
  51717. }
  51718. declare module BABYLON {
  51719. /**
  51720. * Class containing static functions to help procedurally build meshes
  51721. */
  51722. export class TorusKnotBuilder {
  51723. /**
  51724. * Creates a torus knot mesh
  51725. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51726. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51727. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51728. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51730. * * 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
  51731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51732. * @param name defines the name of the mesh
  51733. * @param options defines the options used to create the mesh
  51734. * @param scene defines the hosting scene
  51735. * @returns the torus knot mesh
  51736. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51737. */
  51738. static CreateTorusKnot(name: string, options: {
  51739. radius?: number;
  51740. tube?: number;
  51741. radialSegments?: number;
  51742. tubularSegments?: number;
  51743. p?: number;
  51744. q?: number;
  51745. updatable?: boolean;
  51746. sideOrientation?: number;
  51747. frontUVs?: Vector4;
  51748. backUVs?: Vector4;
  51749. }, scene: any): Mesh;
  51750. }
  51751. }
  51752. declare module BABYLON {
  51753. /**
  51754. * Polygon
  51755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51756. */
  51757. export class Polygon {
  51758. /**
  51759. * Creates a rectangle
  51760. * @param xmin bottom X coord
  51761. * @param ymin bottom Y coord
  51762. * @param xmax top X coord
  51763. * @param ymax top Y coord
  51764. * @returns points that make the resulting rectation
  51765. */
  51766. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51767. /**
  51768. * Creates a circle
  51769. * @param radius radius of circle
  51770. * @param cx scale in x
  51771. * @param cy scale in y
  51772. * @param numberOfSides number of sides that make up the circle
  51773. * @returns points that make the resulting circle
  51774. */
  51775. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51776. /**
  51777. * Creates a polygon from input string
  51778. * @param input Input polygon data
  51779. * @returns the parsed points
  51780. */
  51781. static Parse(input: string): Vector2[];
  51782. /**
  51783. * Starts building a polygon from x and y coordinates
  51784. * @param x x coordinate
  51785. * @param y y coordinate
  51786. * @returns the started path2
  51787. */
  51788. static StartingAt(x: number, y: number): Path2;
  51789. }
  51790. /**
  51791. * Builds a polygon
  51792. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51793. */
  51794. export class PolygonMeshBuilder {
  51795. private _points;
  51796. private _outlinepoints;
  51797. private _holes;
  51798. private _name;
  51799. private _scene;
  51800. private _epoints;
  51801. private _eholes;
  51802. private _addToepoint;
  51803. /**
  51804. * Babylon reference to the earcut plugin.
  51805. */
  51806. bjsEarcut: any;
  51807. /**
  51808. * Creates a PolygonMeshBuilder
  51809. * @param name name of the builder
  51810. * @param contours Path of the polygon
  51811. * @param scene scene to add to when creating the mesh
  51812. * @param earcutInjection can be used to inject your own earcut reference
  51813. */
  51814. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51815. /**
  51816. * Adds a whole within the polygon
  51817. * @param hole Array of points defining the hole
  51818. * @returns this
  51819. */
  51820. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51821. /**
  51822. * Creates the polygon
  51823. * @param updatable If the mesh should be updatable
  51824. * @param depth The depth of the mesh created
  51825. * @returns the created mesh
  51826. */
  51827. build(updatable?: boolean, depth?: number): Mesh;
  51828. /**
  51829. * Creates the polygon
  51830. * @param depth The depth of the mesh created
  51831. * @returns the created VertexData
  51832. */
  51833. buildVertexData(depth?: number): VertexData;
  51834. /**
  51835. * Adds a side to the polygon
  51836. * @param positions points that make the polygon
  51837. * @param normals normals of the polygon
  51838. * @param uvs uvs of the polygon
  51839. * @param indices indices of the polygon
  51840. * @param bounds bounds of the polygon
  51841. * @param points points of the polygon
  51842. * @param depth depth of the polygon
  51843. * @param flip flip of the polygon
  51844. */
  51845. private addSide;
  51846. }
  51847. }
  51848. declare module BABYLON {
  51849. /**
  51850. * Class containing static functions to help procedurally build meshes
  51851. */
  51852. export class PolygonBuilder {
  51853. /**
  51854. * Creates a polygon mesh
  51855. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51856. * * 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
  51857. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51859. * * 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)
  51860. * * Remember you can only change the shape positions, not their number when updating a polygon
  51861. * @param name defines the name of the mesh
  51862. * @param options defines the options used to create the mesh
  51863. * @param scene defines the hosting scene
  51864. * @param earcutInjection can be used to inject your own earcut reference
  51865. * @returns the polygon mesh
  51866. */
  51867. static CreatePolygon(name: string, options: {
  51868. shape: Vector3[];
  51869. holes?: Vector3[][];
  51870. depth?: number;
  51871. faceUV?: Vector4[];
  51872. faceColors?: Color4[];
  51873. updatable?: boolean;
  51874. sideOrientation?: number;
  51875. frontUVs?: Vector4;
  51876. backUVs?: Vector4;
  51877. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51878. /**
  51879. * Creates an extruded polygon mesh, with depth in the Y direction.
  51880. * * 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)
  51881. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51882. * @param name defines the name of the mesh
  51883. * @param options defines the options used to create the mesh
  51884. * @param scene defines the hosting scene
  51885. * @param earcutInjection can be used to inject your own earcut reference
  51886. * @returns the polygon mesh
  51887. */
  51888. static ExtrudePolygon(name: string, options: {
  51889. shape: Vector3[];
  51890. holes?: Vector3[][];
  51891. depth?: number;
  51892. faceUV?: Vector4[];
  51893. faceColors?: Color4[];
  51894. updatable?: boolean;
  51895. sideOrientation?: number;
  51896. frontUVs?: Vector4;
  51897. backUVs?: Vector4;
  51898. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51899. }
  51900. }
  51901. declare module BABYLON {
  51902. /**
  51903. * Class containing static functions to help procedurally build meshes
  51904. */
  51905. export class LatheBuilder {
  51906. /**
  51907. * Creates lathe mesh.
  51908. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51909. * * 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
  51910. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51911. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51912. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51913. * * 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
  51914. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51915. * * 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
  51916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51917. * * 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
  51918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51920. * @param name defines the name of the mesh
  51921. * @param options defines the options used to create the mesh
  51922. * @param scene defines the hosting scene
  51923. * @returns the lathe mesh
  51924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51925. */
  51926. static CreateLathe(name: string, options: {
  51927. shape: Vector3[];
  51928. radius?: number;
  51929. tessellation?: number;
  51930. clip?: number;
  51931. arc?: number;
  51932. closed?: boolean;
  51933. updatable?: boolean;
  51934. sideOrientation?: number;
  51935. frontUVs?: Vector4;
  51936. backUVs?: Vector4;
  51937. cap?: number;
  51938. invertUV?: boolean;
  51939. }, scene?: Nullable<Scene>): Mesh;
  51940. }
  51941. }
  51942. declare module BABYLON {
  51943. /**
  51944. * Class containing static functions to help procedurally build meshes
  51945. */
  51946. export class TiledPlaneBuilder {
  51947. /**
  51948. * Creates a tiled plane mesh
  51949. * * The parameter `pattern` will, depending on value, do nothing or
  51950. * * * flip (reflect about central vertical) alternate tiles across and up
  51951. * * * flip every tile on alternate rows
  51952. * * * rotate (180 degs) alternate tiles across and up
  51953. * * * rotate every tile on alternate rows
  51954. * * * flip and rotate alternate tiles across and up
  51955. * * * flip and rotate every tile on alternate rows
  51956. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  51957. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  51958. * * 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
  51959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51960. * * 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)
  51961. * * 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)
  51962. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51963. * @param name defines the name of the mesh
  51964. * @param options defines the options used to create the mesh
  51965. * @param scene defines the hosting scene
  51966. * @returns the box mesh
  51967. */
  51968. static CreateTiledPlane(name: string, options: {
  51969. pattern?: number;
  51970. tileSize?: number;
  51971. tileWidth?: number;
  51972. tileHeight?: number;
  51973. size?: number;
  51974. width?: number;
  51975. height?: number;
  51976. alignHorizontal?: number;
  51977. alignVertical?: number;
  51978. sideOrientation?: number;
  51979. frontUVs?: Vector4;
  51980. backUVs?: Vector4;
  51981. updatable?: boolean;
  51982. }, scene?: Nullable<Scene>): Mesh;
  51983. }
  51984. }
  51985. declare module BABYLON {
  51986. /**
  51987. * Class containing static functions to help procedurally build meshes
  51988. */
  51989. export class TubeBuilder {
  51990. /**
  51991. * Creates a tube mesh.
  51992. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51993. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51994. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51995. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51996. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51997. * * 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)
  51998. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51999. * * 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
  52000. * * 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
  52001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52002. * * 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
  52003. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52005. * @param name defines the name of the mesh
  52006. * @param options defines the options used to create the mesh
  52007. * @param scene defines the hosting scene
  52008. * @returns the tube mesh
  52009. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52010. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52011. */
  52012. static CreateTube(name: string, options: {
  52013. path: Vector3[];
  52014. radius?: number;
  52015. tessellation?: number;
  52016. radiusFunction?: {
  52017. (i: number, distance: number): number;
  52018. };
  52019. cap?: number;
  52020. arc?: number;
  52021. updatable?: boolean;
  52022. sideOrientation?: number;
  52023. frontUVs?: Vector4;
  52024. backUVs?: Vector4;
  52025. instance?: Mesh;
  52026. invertUV?: boolean;
  52027. }, scene?: Nullable<Scene>): Mesh;
  52028. }
  52029. }
  52030. declare module BABYLON {
  52031. /**
  52032. * Class containing static functions to help procedurally build meshes
  52033. */
  52034. export class IcoSphereBuilder {
  52035. /**
  52036. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52037. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52038. * * 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`)
  52039. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52040. * * 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
  52041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52042. * * 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
  52043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52044. * @param name defines the name of the mesh
  52045. * @param options defines the options used to create the mesh
  52046. * @param scene defines the hosting scene
  52047. * @returns the icosahedron mesh
  52048. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52049. */
  52050. static CreateIcoSphere(name: string, options: {
  52051. radius?: number;
  52052. radiusX?: number;
  52053. radiusY?: number;
  52054. radiusZ?: number;
  52055. flat?: boolean;
  52056. subdivisions?: number;
  52057. sideOrientation?: number;
  52058. frontUVs?: Vector4;
  52059. backUVs?: Vector4;
  52060. updatable?: boolean;
  52061. }, scene?: Nullable<Scene>): Mesh;
  52062. }
  52063. }
  52064. declare module BABYLON {
  52065. /**
  52066. * Class containing static functions to help procedurally build meshes
  52067. */
  52068. export class DecalBuilder {
  52069. /**
  52070. * Creates a decal mesh.
  52071. * 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
  52072. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52073. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52074. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52075. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52076. * @param name defines the name of the mesh
  52077. * @param sourceMesh defines the mesh where the decal must be applied
  52078. * @param options defines the options used to create the mesh
  52079. * @param scene defines the hosting scene
  52080. * @returns the decal mesh
  52081. * @see https://doc.babylonjs.com/how_to/decals
  52082. */
  52083. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52084. position?: Vector3;
  52085. normal?: Vector3;
  52086. size?: Vector3;
  52087. angle?: number;
  52088. }): Mesh;
  52089. }
  52090. }
  52091. declare module BABYLON {
  52092. /**
  52093. * Class containing static functions to help procedurally build meshes
  52094. */
  52095. export class MeshBuilder {
  52096. /**
  52097. * Creates a box mesh
  52098. * * The parameter `size` sets the size (float) of each box side (default 1)
  52099. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52100. * * 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)
  52101. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52105. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52106. * @param name defines the name of the mesh
  52107. * @param options defines the options used to create the mesh
  52108. * @param scene defines the hosting scene
  52109. * @returns the box mesh
  52110. */
  52111. static CreateBox(name: string, options: {
  52112. size?: number;
  52113. width?: number;
  52114. height?: number;
  52115. depth?: number;
  52116. faceUV?: Vector4[];
  52117. faceColors?: Color4[];
  52118. sideOrientation?: number;
  52119. frontUVs?: Vector4;
  52120. backUVs?: Vector4;
  52121. updatable?: boolean;
  52122. }, scene?: Nullable<Scene>): Mesh;
  52123. /**
  52124. * Creates a tiled box mesh
  52125. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52127. * @param name defines the name of the mesh
  52128. * @param options defines the options used to create the mesh
  52129. * @param scene defines the hosting scene
  52130. * @returns the tiled box mesh
  52131. */
  52132. static CreateTiledBox(name: string, options: {
  52133. pattern?: number;
  52134. size?: number;
  52135. width?: number;
  52136. height?: number;
  52137. depth: number;
  52138. tileSize?: number;
  52139. tileWidth?: number;
  52140. tileHeight?: number;
  52141. faceUV?: Vector4[];
  52142. faceColors?: Color4[];
  52143. alignHorizontal?: number;
  52144. alignVertical?: number;
  52145. sideOrientation?: number;
  52146. updatable?: boolean;
  52147. }, scene?: Nullable<Scene>): Mesh;
  52148. /**
  52149. * Creates a sphere mesh
  52150. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52151. * * 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`)
  52152. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52153. * * 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
  52154. * * 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)
  52155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52156. * * 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
  52157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52158. * @param name defines the name of the mesh
  52159. * @param options defines the options used to create the mesh
  52160. * @param scene defines the hosting scene
  52161. * @returns the sphere mesh
  52162. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52163. */
  52164. static CreateSphere(name: string, options: {
  52165. segments?: number;
  52166. diameter?: number;
  52167. diameterX?: number;
  52168. diameterY?: number;
  52169. diameterZ?: number;
  52170. arc?: number;
  52171. slice?: number;
  52172. sideOrientation?: number;
  52173. frontUVs?: Vector4;
  52174. backUVs?: Vector4;
  52175. updatable?: boolean;
  52176. }, scene?: Nullable<Scene>): Mesh;
  52177. /**
  52178. * Creates a plane polygonal mesh. By default, this is a disc
  52179. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52180. * * 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
  52181. * * 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
  52182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52183. * * 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
  52184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52185. * @param name defines the name of the mesh
  52186. * @param options defines the options used to create the mesh
  52187. * @param scene defines the hosting scene
  52188. * @returns the plane polygonal mesh
  52189. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52190. */
  52191. static CreateDisc(name: string, options: {
  52192. radius?: number;
  52193. tessellation?: number;
  52194. arc?: number;
  52195. updatable?: boolean;
  52196. sideOrientation?: number;
  52197. frontUVs?: Vector4;
  52198. backUVs?: Vector4;
  52199. }, scene?: Nullable<Scene>): Mesh;
  52200. /**
  52201. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52202. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52203. * * 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`)
  52204. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52205. * * 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
  52206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52207. * * 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
  52208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52209. * @param name defines the name of the mesh
  52210. * @param options defines the options used to create the mesh
  52211. * @param scene defines the hosting scene
  52212. * @returns the icosahedron mesh
  52213. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52214. */
  52215. static CreateIcoSphere(name: string, options: {
  52216. radius?: number;
  52217. radiusX?: number;
  52218. radiusY?: number;
  52219. radiusZ?: number;
  52220. flat?: boolean;
  52221. subdivisions?: number;
  52222. sideOrientation?: number;
  52223. frontUVs?: Vector4;
  52224. backUVs?: Vector4;
  52225. updatable?: boolean;
  52226. }, scene?: Nullable<Scene>): Mesh;
  52227. /**
  52228. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52229. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52230. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52231. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52232. * * 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
  52233. * * 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
  52234. * * 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
  52235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52236. * * 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
  52237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52238. * * 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
  52239. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52240. * * 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
  52241. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52243. * @param name defines the name of the mesh
  52244. * @param options defines the options used to create the mesh
  52245. * @param scene defines the hosting scene
  52246. * @returns the ribbon mesh
  52247. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52249. */
  52250. static CreateRibbon(name: string, options: {
  52251. pathArray: Vector3[][];
  52252. closeArray?: boolean;
  52253. closePath?: boolean;
  52254. offset?: number;
  52255. updatable?: boolean;
  52256. sideOrientation?: number;
  52257. frontUVs?: Vector4;
  52258. backUVs?: Vector4;
  52259. instance?: Mesh;
  52260. invertUV?: boolean;
  52261. uvs?: Vector2[];
  52262. colors?: Color4[];
  52263. }, scene?: Nullable<Scene>): Mesh;
  52264. /**
  52265. * Creates a cylinder or a cone mesh
  52266. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52267. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52268. * * 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.
  52269. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52270. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52271. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52272. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52273. * * 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).
  52274. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52275. * * 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).
  52276. * * 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
  52277. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52278. * * 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
  52279. * * 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.
  52280. * * If `enclose` is false, a ring surface is one element.
  52281. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52282. * * 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
  52283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52284. * * 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
  52285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52286. * @param name defines the name of the mesh
  52287. * @param options defines the options used to create the mesh
  52288. * @param scene defines the hosting scene
  52289. * @returns the cylinder mesh
  52290. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52291. */
  52292. static CreateCylinder(name: string, options: {
  52293. height?: number;
  52294. diameterTop?: number;
  52295. diameterBottom?: number;
  52296. diameter?: number;
  52297. tessellation?: number;
  52298. subdivisions?: number;
  52299. arc?: number;
  52300. faceColors?: Color4[];
  52301. faceUV?: Vector4[];
  52302. updatable?: boolean;
  52303. hasRings?: boolean;
  52304. enclose?: boolean;
  52305. cap?: number;
  52306. sideOrientation?: number;
  52307. frontUVs?: Vector4;
  52308. backUVs?: Vector4;
  52309. }, scene?: Nullable<Scene>): Mesh;
  52310. /**
  52311. * Creates a torus mesh
  52312. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52313. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52314. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52316. * * 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
  52317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52318. * @param name defines the name of the mesh
  52319. * @param options defines the options used to create the mesh
  52320. * @param scene defines the hosting scene
  52321. * @returns the torus mesh
  52322. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52323. */
  52324. static CreateTorus(name: string, options: {
  52325. diameter?: number;
  52326. thickness?: number;
  52327. tessellation?: number;
  52328. updatable?: boolean;
  52329. sideOrientation?: number;
  52330. frontUVs?: Vector4;
  52331. backUVs?: Vector4;
  52332. }, scene?: Nullable<Scene>): Mesh;
  52333. /**
  52334. * Creates a torus knot mesh
  52335. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52336. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52337. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52338. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52340. * * 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
  52341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52342. * @param name defines the name of the mesh
  52343. * @param options defines the options used to create the mesh
  52344. * @param scene defines the hosting scene
  52345. * @returns the torus knot mesh
  52346. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52347. */
  52348. static CreateTorusKnot(name: string, options: {
  52349. radius?: number;
  52350. tube?: number;
  52351. radialSegments?: number;
  52352. tubularSegments?: number;
  52353. p?: number;
  52354. q?: number;
  52355. updatable?: boolean;
  52356. sideOrientation?: number;
  52357. frontUVs?: Vector4;
  52358. backUVs?: Vector4;
  52359. }, scene?: Nullable<Scene>): Mesh;
  52360. /**
  52361. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52362. * * 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
  52363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52364. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52365. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52366. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52367. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52368. * * 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
  52369. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52372. * @param name defines the name of the new line system
  52373. * @param options defines the options used to create the line system
  52374. * @param scene defines the hosting scene
  52375. * @returns a new line system mesh
  52376. */
  52377. static CreateLineSystem(name: string, options: {
  52378. lines: Vector3[][];
  52379. updatable?: boolean;
  52380. instance?: Nullable<LinesMesh>;
  52381. colors?: Nullable<Color4[][]>;
  52382. useVertexAlpha?: boolean;
  52383. }, scene: Nullable<Scene>): LinesMesh;
  52384. /**
  52385. * Creates a line mesh
  52386. * 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
  52387. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52388. * * The parameter `points` is an array successive Vector3
  52389. * * 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
  52390. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52391. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52392. * * When updating an instance, remember that only point positions can change, not the number of points
  52393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52395. * @param name defines the name of the new line system
  52396. * @param options defines the options used to create the line system
  52397. * @param scene defines the hosting scene
  52398. * @returns a new line mesh
  52399. */
  52400. static CreateLines(name: string, options: {
  52401. points: Vector3[];
  52402. updatable?: boolean;
  52403. instance?: Nullable<LinesMesh>;
  52404. colors?: Color4[];
  52405. useVertexAlpha?: boolean;
  52406. }, scene?: Nullable<Scene>): LinesMesh;
  52407. /**
  52408. * Creates a dashed line mesh
  52409. * * 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
  52410. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52411. * * The parameter `points` is an array successive Vector3
  52412. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52413. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52414. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52415. * * 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
  52416. * * When updating an instance, remember that only point positions can change, not the number of points
  52417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52418. * @param name defines the name of the mesh
  52419. * @param options defines the options used to create the mesh
  52420. * @param scene defines the hosting scene
  52421. * @returns the dashed line mesh
  52422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52423. */
  52424. static CreateDashedLines(name: string, options: {
  52425. points: Vector3[];
  52426. dashSize?: number;
  52427. gapSize?: number;
  52428. dashNb?: number;
  52429. updatable?: boolean;
  52430. instance?: LinesMesh;
  52431. }, scene?: Nullable<Scene>): LinesMesh;
  52432. /**
  52433. * 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.
  52434. * * 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.
  52435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52436. * * 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.
  52437. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52438. * * 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
  52439. * * 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
  52440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52442. * * 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
  52443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52445. * @param name defines the name of the mesh
  52446. * @param options defines the options used to create the mesh
  52447. * @param scene defines the hosting scene
  52448. * @returns the extruded shape mesh
  52449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52451. */
  52452. static ExtrudeShape(name: string, options: {
  52453. shape: Vector3[];
  52454. path: Vector3[];
  52455. scale?: number;
  52456. rotation?: number;
  52457. cap?: number;
  52458. updatable?: boolean;
  52459. sideOrientation?: number;
  52460. frontUVs?: Vector4;
  52461. backUVs?: Vector4;
  52462. instance?: Mesh;
  52463. invertUV?: boolean;
  52464. }, scene?: Nullable<Scene>): Mesh;
  52465. /**
  52466. * Creates an custom extruded shape mesh.
  52467. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52468. * * 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.
  52469. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52470. * * 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
  52471. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52472. * * 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
  52473. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52474. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52475. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52476. * * 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
  52477. * * 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
  52478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52480. * * 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
  52481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52483. * @param name defines the name of the mesh
  52484. * @param options defines the options used to create the mesh
  52485. * @param scene defines the hosting scene
  52486. * @returns the custom extruded shape mesh
  52487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52490. */
  52491. static ExtrudeShapeCustom(name: string, options: {
  52492. shape: Vector3[];
  52493. path: Vector3[];
  52494. scaleFunction?: any;
  52495. rotationFunction?: any;
  52496. ribbonCloseArray?: boolean;
  52497. ribbonClosePath?: boolean;
  52498. cap?: number;
  52499. updatable?: boolean;
  52500. sideOrientation?: number;
  52501. frontUVs?: Vector4;
  52502. backUVs?: Vector4;
  52503. instance?: Mesh;
  52504. invertUV?: boolean;
  52505. }, scene?: Nullable<Scene>): Mesh;
  52506. /**
  52507. * Creates lathe mesh.
  52508. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52509. * * 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
  52510. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52511. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52512. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52513. * * 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
  52514. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52515. * * 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
  52516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52517. * * 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
  52518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52520. * @param name defines the name of the mesh
  52521. * @param options defines the options used to create the mesh
  52522. * @param scene defines the hosting scene
  52523. * @returns the lathe mesh
  52524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52525. */
  52526. static CreateLathe(name: string, options: {
  52527. shape: Vector3[];
  52528. radius?: number;
  52529. tessellation?: number;
  52530. clip?: number;
  52531. arc?: number;
  52532. closed?: boolean;
  52533. updatable?: boolean;
  52534. sideOrientation?: number;
  52535. frontUVs?: Vector4;
  52536. backUVs?: Vector4;
  52537. cap?: number;
  52538. invertUV?: boolean;
  52539. }, scene?: Nullable<Scene>): Mesh;
  52540. /**
  52541. * Creates a tiled plane mesh
  52542. * * You can set a limited pattern arrangement with the tiles
  52543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52544. * * 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
  52545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52546. * @param name defines the name of the mesh
  52547. * @param options defines the options used to create the mesh
  52548. * @param scene defines the hosting scene
  52549. * @returns the plane mesh
  52550. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52551. */
  52552. static CreateTiledPlane(name: string, options: {
  52553. pattern?: number;
  52554. tileSize?: number;
  52555. tileWidth?: number;
  52556. tileHeight?: number;
  52557. size?: number;
  52558. width?: number;
  52559. height?: number;
  52560. alignHorizontal?: number;
  52561. alignVertical?: number;
  52562. sideOrientation?: number;
  52563. frontUVs?: Vector4;
  52564. backUVs?: Vector4;
  52565. updatable?: boolean;
  52566. }, scene?: Nullable<Scene>): Mesh;
  52567. /**
  52568. * Creates a plane mesh
  52569. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52570. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52571. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52573. * * 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
  52574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52575. * @param name defines the name of the mesh
  52576. * @param options defines the options used to create the mesh
  52577. * @param scene defines the hosting scene
  52578. * @returns the plane mesh
  52579. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52580. */
  52581. static CreatePlane(name: string, options: {
  52582. size?: number;
  52583. width?: number;
  52584. height?: number;
  52585. sideOrientation?: number;
  52586. frontUVs?: Vector4;
  52587. backUVs?: Vector4;
  52588. updatable?: boolean;
  52589. sourcePlane?: Plane;
  52590. }, scene?: Nullable<Scene>): Mesh;
  52591. /**
  52592. * Creates a ground mesh
  52593. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52594. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52596. * @param name defines the name of the mesh
  52597. * @param options defines the options used to create the mesh
  52598. * @param scene defines the hosting scene
  52599. * @returns the ground mesh
  52600. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52601. */
  52602. static CreateGround(name: string, options: {
  52603. width?: number;
  52604. height?: number;
  52605. subdivisions?: number;
  52606. subdivisionsX?: number;
  52607. subdivisionsY?: number;
  52608. updatable?: boolean;
  52609. }, scene?: Nullable<Scene>): Mesh;
  52610. /**
  52611. * Creates a tiled ground mesh
  52612. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52613. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52614. * * 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
  52615. * * 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
  52616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52617. * @param name defines the name of the mesh
  52618. * @param options defines the options used to create the mesh
  52619. * @param scene defines the hosting scene
  52620. * @returns the tiled ground mesh
  52621. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52622. */
  52623. static CreateTiledGround(name: string, options: {
  52624. xmin: number;
  52625. zmin: number;
  52626. xmax: number;
  52627. zmax: number;
  52628. subdivisions?: {
  52629. w: number;
  52630. h: number;
  52631. };
  52632. precision?: {
  52633. w: number;
  52634. h: number;
  52635. };
  52636. updatable?: boolean;
  52637. }, scene?: Nullable<Scene>): Mesh;
  52638. /**
  52639. * Creates a ground mesh from a height map
  52640. * * The parameter `url` sets the URL of the height map image resource.
  52641. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52642. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52643. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52644. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52645. * * 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.
  52646. * * 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).
  52647. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52649. * @param name defines the name of the mesh
  52650. * @param url defines the url to the height map
  52651. * @param options defines the options used to create the mesh
  52652. * @param scene defines the hosting scene
  52653. * @returns the ground mesh
  52654. * @see https://doc.babylonjs.com/babylon101/height_map
  52655. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52656. */
  52657. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52658. width?: number;
  52659. height?: number;
  52660. subdivisions?: number;
  52661. minHeight?: number;
  52662. maxHeight?: number;
  52663. colorFilter?: Color3;
  52664. alphaFilter?: number;
  52665. updatable?: boolean;
  52666. onReady?: (mesh: GroundMesh) => void;
  52667. }, scene?: Nullable<Scene>): GroundMesh;
  52668. /**
  52669. * Creates a polygon mesh
  52670. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52671. * * 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
  52672. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52674. * * 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)
  52675. * * Remember you can only change the shape positions, not their number when updating a polygon
  52676. * @param name defines the name of the mesh
  52677. * @param options defines the options used to create the mesh
  52678. * @param scene defines the hosting scene
  52679. * @param earcutInjection can be used to inject your own earcut reference
  52680. * @returns the polygon mesh
  52681. */
  52682. static CreatePolygon(name: string, options: {
  52683. shape: Vector3[];
  52684. holes?: Vector3[][];
  52685. depth?: number;
  52686. faceUV?: Vector4[];
  52687. faceColors?: Color4[];
  52688. updatable?: boolean;
  52689. sideOrientation?: number;
  52690. frontUVs?: Vector4;
  52691. backUVs?: Vector4;
  52692. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52693. /**
  52694. * Creates an extruded polygon mesh, with depth in the Y direction.
  52695. * * 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)
  52696. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52697. * @param name defines the name of the mesh
  52698. * @param options defines the options used to create the mesh
  52699. * @param scene defines the hosting scene
  52700. * @param earcutInjection can be used to inject your own earcut reference
  52701. * @returns the polygon mesh
  52702. */
  52703. static ExtrudePolygon(name: string, options: {
  52704. shape: Vector3[];
  52705. holes?: Vector3[][];
  52706. depth?: number;
  52707. faceUV?: Vector4[];
  52708. faceColors?: Color4[];
  52709. updatable?: boolean;
  52710. sideOrientation?: number;
  52711. frontUVs?: Vector4;
  52712. backUVs?: Vector4;
  52713. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52714. /**
  52715. * Creates a tube mesh.
  52716. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52717. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52718. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52719. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52720. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52721. * * 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)
  52722. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52723. * * 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
  52724. * * 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
  52725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52726. * * 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
  52727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52729. * @param name defines the name of the mesh
  52730. * @param options defines the options used to create the mesh
  52731. * @param scene defines the hosting scene
  52732. * @returns the tube mesh
  52733. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52734. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52735. */
  52736. static CreateTube(name: string, options: {
  52737. path: Vector3[];
  52738. radius?: number;
  52739. tessellation?: number;
  52740. radiusFunction?: {
  52741. (i: number, distance: number): number;
  52742. };
  52743. cap?: number;
  52744. arc?: number;
  52745. updatable?: boolean;
  52746. sideOrientation?: number;
  52747. frontUVs?: Vector4;
  52748. backUVs?: Vector4;
  52749. instance?: Mesh;
  52750. invertUV?: boolean;
  52751. }, scene?: Nullable<Scene>): Mesh;
  52752. /**
  52753. * Creates a polyhedron mesh
  52754. * * 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
  52755. * * The parameter `size` (positive float, default 1) sets the polygon size
  52756. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52757. * * 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`
  52758. * * 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
  52759. * * 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)`)
  52760. * * 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
  52761. * * 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
  52762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52763. * * 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
  52764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52765. * @param name defines the name of the mesh
  52766. * @param options defines the options used to create the mesh
  52767. * @param scene defines the hosting scene
  52768. * @returns the polyhedron mesh
  52769. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52770. */
  52771. static CreatePolyhedron(name: string, options: {
  52772. type?: number;
  52773. size?: number;
  52774. sizeX?: number;
  52775. sizeY?: number;
  52776. sizeZ?: number;
  52777. custom?: any;
  52778. faceUV?: Vector4[];
  52779. faceColors?: Color4[];
  52780. flat?: boolean;
  52781. updatable?: boolean;
  52782. sideOrientation?: number;
  52783. frontUVs?: Vector4;
  52784. backUVs?: Vector4;
  52785. }, scene?: Nullable<Scene>): Mesh;
  52786. /**
  52787. * Creates a decal mesh.
  52788. * 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
  52789. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52790. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52791. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52792. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52793. * @param name defines the name of the mesh
  52794. * @param sourceMesh defines the mesh where the decal must be applied
  52795. * @param options defines the options used to create the mesh
  52796. * @param scene defines the hosting scene
  52797. * @returns the decal mesh
  52798. * @see https://doc.babylonjs.com/how_to/decals
  52799. */
  52800. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52801. position?: Vector3;
  52802. normal?: Vector3;
  52803. size?: Vector3;
  52804. angle?: number;
  52805. }): Mesh;
  52806. }
  52807. }
  52808. declare module BABYLON {
  52809. /**
  52810. * A simplifier interface for future simplification implementations
  52811. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52812. */
  52813. export interface ISimplifier {
  52814. /**
  52815. * Simplification of a given mesh according to the given settings.
  52816. * Since this requires computation, it is assumed that the function runs async.
  52817. * @param settings The settings of the simplification, including quality and distance
  52818. * @param successCallback A callback that will be called after the mesh was simplified.
  52819. * @param errorCallback in case of an error, this callback will be called. optional.
  52820. */
  52821. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52822. }
  52823. /**
  52824. * Expected simplification settings.
  52825. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52826. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52827. */
  52828. export interface ISimplificationSettings {
  52829. /**
  52830. * Gets or sets the expected quality
  52831. */
  52832. quality: number;
  52833. /**
  52834. * Gets or sets the distance when this optimized version should be used
  52835. */
  52836. distance: number;
  52837. /**
  52838. * Gets an already optimized mesh
  52839. */
  52840. optimizeMesh?: boolean;
  52841. }
  52842. /**
  52843. * Class used to specify simplification options
  52844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52845. */
  52846. export class SimplificationSettings implements ISimplificationSettings {
  52847. /** expected quality */
  52848. quality: number;
  52849. /** distance when this optimized version should be used */
  52850. distance: number;
  52851. /** already optimized mesh */
  52852. optimizeMesh?: boolean | undefined;
  52853. /**
  52854. * Creates a SimplificationSettings
  52855. * @param quality expected quality
  52856. * @param distance distance when this optimized version should be used
  52857. * @param optimizeMesh already optimized mesh
  52858. */
  52859. constructor(
  52860. /** expected quality */
  52861. quality: number,
  52862. /** distance when this optimized version should be used */
  52863. distance: number,
  52864. /** already optimized mesh */
  52865. optimizeMesh?: boolean | undefined);
  52866. }
  52867. /**
  52868. * Interface used to define a simplification task
  52869. */
  52870. export interface ISimplificationTask {
  52871. /**
  52872. * Array of settings
  52873. */
  52874. settings: Array<ISimplificationSettings>;
  52875. /**
  52876. * Simplification type
  52877. */
  52878. simplificationType: SimplificationType;
  52879. /**
  52880. * Mesh to simplify
  52881. */
  52882. mesh: Mesh;
  52883. /**
  52884. * Callback called on success
  52885. */
  52886. successCallback?: () => void;
  52887. /**
  52888. * Defines if parallel processing can be used
  52889. */
  52890. parallelProcessing: boolean;
  52891. }
  52892. /**
  52893. * Queue used to order the simplification tasks
  52894. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52895. */
  52896. export class SimplificationQueue {
  52897. private _simplificationArray;
  52898. /**
  52899. * Gets a boolean indicating that the process is still running
  52900. */
  52901. running: boolean;
  52902. /**
  52903. * Creates a new queue
  52904. */
  52905. constructor();
  52906. /**
  52907. * Adds a new simplification task
  52908. * @param task defines a task to add
  52909. */
  52910. addTask(task: ISimplificationTask): void;
  52911. /**
  52912. * Execute next task
  52913. */
  52914. executeNext(): void;
  52915. /**
  52916. * Execute a simplification task
  52917. * @param task defines the task to run
  52918. */
  52919. runSimplification(task: ISimplificationTask): void;
  52920. private getSimplifier;
  52921. }
  52922. /**
  52923. * The implemented types of simplification
  52924. * At the moment only Quadratic Error Decimation is implemented
  52925. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52926. */
  52927. export enum SimplificationType {
  52928. /** Quadratic error decimation */
  52929. QUADRATIC = 0
  52930. }
  52931. }
  52932. declare module BABYLON {
  52933. interface Scene {
  52934. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  52935. /**
  52936. * Gets or sets the simplification queue attached to the scene
  52937. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52938. */
  52939. simplificationQueue: SimplificationQueue;
  52940. }
  52941. interface Mesh {
  52942. /**
  52943. * Simplify the mesh according to the given array of settings.
  52944. * Function will return immediately and will simplify async
  52945. * @param settings a collection of simplification settings
  52946. * @param parallelProcessing should all levels calculate parallel or one after the other
  52947. * @param simplificationType the type of simplification to run
  52948. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52949. * @returns the current mesh
  52950. */
  52951. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52952. }
  52953. /**
  52954. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52955. * created in a scene
  52956. */
  52957. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52958. /**
  52959. * The component name helpfull to identify the component in the list of scene components.
  52960. */
  52961. readonly name: string;
  52962. /**
  52963. * The scene the component belongs to.
  52964. */
  52965. scene: Scene;
  52966. /**
  52967. * Creates a new instance of the component for the given scene
  52968. * @param scene Defines the scene to register the component in
  52969. */
  52970. constructor(scene: Scene);
  52971. /**
  52972. * Registers the component in a given scene
  52973. */
  52974. register(): void;
  52975. /**
  52976. * Rebuilds the elements related to this component in case of
  52977. * context lost for instance.
  52978. */
  52979. rebuild(): void;
  52980. /**
  52981. * Disposes the component and the associated ressources
  52982. */
  52983. dispose(): void;
  52984. private _beforeCameraUpdate;
  52985. }
  52986. }
  52987. declare module BABYLON {
  52988. /**
  52989. * Class used to enable access to IndexedDB
  52990. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52991. */
  52992. export class Database implements IOfflineProvider {
  52993. private _callbackManifestChecked;
  52994. private _currentSceneUrl;
  52995. private _db;
  52996. private _enableSceneOffline;
  52997. private _enableTexturesOffline;
  52998. private _manifestVersionFound;
  52999. private _mustUpdateRessources;
  53000. private _hasReachedQuota;
  53001. private _isSupported;
  53002. private _idbFactory;
  53003. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53004. private static IsUASupportingBlobStorage;
  53005. /**
  53006. * Gets a boolean indicating if Database storate is enabled (off by default)
  53007. */
  53008. static IDBStorageEnabled: boolean;
  53009. /**
  53010. * Gets a boolean indicating if scene must be saved in the database
  53011. */
  53012. readonly enableSceneOffline: boolean;
  53013. /**
  53014. * Gets a boolean indicating if textures must be saved in the database
  53015. */
  53016. readonly enableTexturesOffline: boolean;
  53017. /**
  53018. * Creates a new Database
  53019. * @param urlToScene defines the url to load the scene
  53020. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53021. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53022. */
  53023. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53024. private static _ParseURL;
  53025. private static _ReturnFullUrlLocation;
  53026. private _checkManifestFile;
  53027. /**
  53028. * Open the database and make it available
  53029. * @param successCallback defines the callback to call on success
  53030. * @param errorCallback defines the callback to call on error
  53031. */
  53032. open(successCallback: () => void, errorCallback: () => void): void;
  53033. /**
  53034. * Loads an image from the database
  53035. * @param url defines the url to load from
  53036. * @param image defines the target DOM image
  53037. */
  53038. loadImage(url: string, image: HTMLImageElement): void;
  53039. private _loadImageFromDBAsync;
  53040. private _saveImageIntoDBAsync;
  53041. private _checkVersionFromDB;
  53042. private _loadVersionFromDBAsync;
  53043. private _saveVersionIntoDBAsync;
  53044. /**
  53045. * Loads a file from database
  53046. * @param url defines the URL to load from
  53047. * @param sceneLoaded defines a callback to call on success
  53048. * @param progressCallBack defines a callback to call when progress changed
  53049. * @param errorCallback defines a callback to call on error
  53050. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53051. */
  53052. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53053. private _loadFileAsync;
  53054. private _saveFileAsync;
  53055. /**
  53056. * Validates if xhr data is correct
  53057. * @param xhr defines the request to validate
  53058. * @param dataType defines the expected data type
  53059. * @returns true if data is correct
  53060. */
  53061. private static _ValidateXHRData;
  53062. }
  53063. }
  53064. declare module BABYLON {
  53065. /** @hidden */
  53066. export var gpuUpdateParticlesPixelShader: {
  53067. name: string;
  53068. shader: string;
  53069. };
  53070. }
  53071. declare module BABYLON {
  53072. /** @hidden */
  53073. export var gpuUpdateParticlesVertexShader: {
  53074. name: string;
  53075. shader: string;
  53076. };
  53077. }
  53078. declare module BABYLON {
  53079. /** @hidden */
  53080. export var clipPlaneFragmentDeclaration2: {
  53081. name: string;
  53082. shader: string;
  53083. };
  53084. }
  53085. declare module BABYLON {
  53086. /** @hidden */
  53087. export var gpuRenderParticlesPixelShader: {
  53088. name: string;
  53089. shader: string;
  53090. };
  53091. }
  53092. declare module BABYLON {
  53093. /** @hidden */
  53094. export var clipPlaneVertexDeclaration2: {
  53095. name: string;
  53096. shader: string;
  53097. };
  53098. }
  53099. declare module BABYLON {
  53100. /** @hidden */
  53101. export var gpuRenderParticlesVertexShader: {
  53102. name: string;
  53103. shader: string;
  53104. };
  53105. }
  53106. declare module BABYLON {
  53107. /**
  53108. * This represents a GPU particle system in Babylon
  53109. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53110. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53111. */
  53112. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53113. /**
  53114. * The layer mask we are rendering the particles through.
  53115. */
  53116. layerMask: number;
  53117. private _capacity;
  53118. private _activeCount;
  53119. private _currentActiveCount;
  53120. private _accumulatedCount;
  53121. private _renderEffect;
  53122. private _updateEffect;
  53123. private _buffer0;
  53124. private _buffer1;
  53125. private _spriteBuffer;
  53126. private _updateVAO;
  53127. private _renderVAO;
  53128. private _targetIndex;
  53129. private _sourceBuffer;
  53130. private _targetBuffer;
  53131. private _engine;
  53132. private _currentRenderId;
  53133. private _started;
  53134. private _stopped;
  53135. private _timeDelta;
  53136. private _randomTexture;
  53137. private _randomTexture2;
  53138. private _attributesStrideSize;
  53139. private _updateEffectOptions;
  53140. private _randomTextureSize;
  53141. private _actualFrame;
  53142. private readonly _rawTextureWidth;
  53143. /**
  53144. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53145. */
  53146. static readonly IsSupported: boolean;
  53147. /**
  53148. * An event triggered when the system is disposed.
  53149. */
  53150. onDisposeObservable: Observable<GPUParticleSystem>;
  53151. /**
  53152. * Gets the maximum number of particles active at the same time.
  53153. * @returns The max number of active particles.
  53154. */
  53155. getCapacity(): number;
  53156. /**
  53157. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53158. * to override the particles.
  53159. */
  53160. forceDepthWrite: boolean;
  53161. /**
  53162. * Gets or set the number of active particles
  53163. */
  53164. activeParticleCount: number;
  53165. private _preWarmDone;
  53166. /**
  53167. * Is this system ready to be used/rendered
  53168. * @return true if the system is ready
  53169. */
  53170. isReady(): boolean;
  53171. /**
  53172. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53173. * @returns True if it has been started, otherwise false.
  53174. */
  53175. isStarted(): boolean;
  53176. /**
  53177. * Starts the particle system and begins to emit
  53178. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53179. */
  53180. start(delay?: number): void;
  53181. /**
  53182. * Stops the particle system.
  53183. */
  53184. stop(): void;
  53185. /**
  53186. * Remove all active particles
  53187. */
  53188. reset(): void;
  53189. /**
  53190. * Returns the string "GPUParticleSystem"
  53191. * @returns a string containing the class name
  53192. */
  53193. getClassName(): string;
  53194. private _colorGradientsTexture;
  53195. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53196. /**
  53197. * Adds a new color gradient
  53198. * @param gradient defines the gradient to use (between 0 and 1)
  53199. * @param color1 defines the color to affect to the specified gradient
  53200. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53201. * @returns the current particle system
  53202. */
  53203. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53204. /**
  53205. * Remove a specific color gradient
  53206. * @param gradient defines the gradient to remove
  53207. * @returns the current particle system
  53208. */
  53209. removeColorGradient(gradient: number): GPUParticleSystem;
  53210. private _angularSpeedGradientsTexture;
  53211. private _sizeGradientsTexture;
  53212. private _velocityGradientsTexture;
  53213. private _limitVelocityGradientsTexture;
  53214. private _dragGradientsTexture;
  53215. private _addFactorGradient;
  53216. /**
  53217. * Adds a new size gradient
  53218. * @param gradient defines the gradient to use (between 0 and 1)
  53219. * @param factor defines the size factor to affect to the specified gradient
  53220. * @returns the current particle system
  53221. */
  53222. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53223. /**
  53224. * Remove a specific size gradient
  53225. * @param gradient defines the gradient to remove
  53226. * @returns the current particle system
  53227. */
  53228. removeSizeGradient(gradient: number): GPUParticleSystem;
  53229. /**
  53230. * Adds a new angular speed gradient
  53231. * @param gradient defines the gradient to use (between 0 and 1)
  53232. * @param factor defines the angular speed to affect to the specified gradient
  53233. * @returns the current particle system
  53234. */
  53235. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53236. /**
  53237. * Remove a specific angular speed gradient
  53238. * @param gradient defines the gradient to remove
  53239. * @returns the current particle system
  53240. */
  53241. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53242. /**
  53243. * Adds a new velocity gradient
  53244. * @param gradient defines the gradient to use (between 0 and 1)
  53245. * @param factor defines the velocity to affect to the specified gradient
  53246. * @returns the current particle system
  53247. */
  53248. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53249. /**
  53250. * Remove a specific velocity gradient
  53251. * @param gradient defines the gradient to remove
  53252. * @returns the current particle system
  53253. */
  53254. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53255. /**
  53256. * Adds a new limit velocity gradient
  53257. * @param gradient defines the gradient to use (between 0 and 1)
  53258. * @param factor defines the limit velocity value to affect to the specified gradient
  53259. * @returns the current particle system
  53260. */
  53261. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53262. /**
  53263. * Remove a specific limit velocity gradient
  53264. * @param gradient defines the gradient to remove
  53265. * @returns the current particle system
  53266. */
  53267. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53268. /**
  53269. * Adds a new drag gradient
  53270. * @param gradient defines the gradient to use (between 0 and 1)
  53271. * @param factor defines the drag value to affect to the specified gradient
  53272. * @returns the current particle system
  53273. */
  53274. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53275. /**
  53276. * Remove a specific drag gradient
  53277. * @param gradient defines the gradient to remove
  53278. * @returns the current particle system
  53279. */
  53280. removeDragGradient(gradient: number): GPUParticleSystem;
  53281. /**
  53282. * Not supported by GPUParticleSystem
  53283. * @param gradient defines the gradient to use (between 0 and 1)
  53284. * @param factor defines the emit rate value to affect to the specified gradient
  53285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53286. * @returns the current particle system
  53287. */
  53288. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53289. /**
  53290. * Not supported by GPUParticleSystem
  53291. * @param gradient defines the gradient to remove
  53292. * @returns the current particle system
  53293. */
  53294. removeEmitRateGradient(gradient: number): IParticleSystem;
  53295. /**
  53296. * Not supported by GPUParticleSystem
  53297. * @param gradient defines the gradient to use (between 0 and 1)
  53298. * @param factor defines the start size value to affect to the specified gradient
  53299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53300. * @returns the current particle system
  53301. */
  53302. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53303. /**
  53304. * Not supported by GPUParticleSystem
  53305. * @param gradient defines the gradient to remove
  53306. * @returns the current particle system
  53307. */
  53308. removeStartSizeGradient(gradient: number): IParticleSystem;
  53309. /**
  53310. * Not supported by GPUParticleSystem
  53311. * @param gradient defines the gradient to use (between 0 and 1)
  53312. * @param min defines the color remap minimal range
  53313. * @param max defines the color remap maximal range
  53314. * @returns the current particle system
  53315. */
  53316. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53317. /**
  53318. * Not supported by GPUParticleSystem
  53319. * @param gradient defines the gradient to remove
  53320. * @returns the current particle system
  53321. */
  53322. removeColorRemapGradient(): IParticleSystem;
  53323. /**
  53324. * Not supported by GPUParticleSystem
  53325. * @param gradient defines the gradient to use (between 0 and 1)
  53326. * @param min defines the alpha remap minimal range
  53327. * @param max defines the alpha remap maximal range
  53328. * @returns the current particle system
  53329. */
  53330. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53331. /**
  53332. * Not supported by GPUParticleSystem
  53333. * @param gradient defines the gradient to remove
  53334. * @returns the current particle system
  53335. */
  53336. removeAlphaRemapGradient(): IParticleSystem;
  53337. /**
  53338. * Not supported by GPUParticleSystem
  53339. * @param gradient defines the gradient to use (between 0 and 1)
  53340. * @param color defines the color to affect to the specified gradient
  53341. * @returns the current particle system
  53342. */
  53343. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53344. /**
  53345. * Not supported by GPUParticleSystem
  53346. * @param gradient defines the gradient to remove
  53347. * @returns the current particle system
  53348. */
  53349. removeRampGradient(): IParticleSystem;
  53350. /**
  53351. * Not supported by GPUParticleSystem
  53352. * @returns the list of ramp gradients
  53353. */
  53354. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53355. /**
  53356. * Not supported by GPUParticleSystem
  53357. * Gets or sets a boolean indicating that ramp gradients must be used
  53358. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53359. */
  53360. useRampGradients: boolean;
  53361. /**
  53362. * Not supported by GPUParticleSystem
  53363. * @param gradient defines the gradient to use (between 0 and 1)
  53364. * @param factor defines the life time factor to affect to the specified gradient
  53365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53366. * @returns the current particle system
  53367. */
  53368. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53369. /**
  53370. * Not supported by GPUParticleSystem
  53371. * @param gradient defines the gradient to remove
  53372. * @returns the current particle system
  53373. */
  53374. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53375. /**
  53376. * Instantiates a GPU particle system.
  53377. * 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.
  53378. * @param name The name of the particle system
  53379. * @param options The options used to create the system
  53380. * @param scene The scene the particle system belongs to
  53381. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53382. */
  53383. constructor(name: string, options: Partial<{
  53384. capacity: number;
  53385. randomTextureSize: number;
  53386. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53387. protected _reset(): void;
  53388. private _createUpdateVAO;
  53389. private _createRenderVAO;
  53390. private _initialize;
  53391. /** @hidden */ private _recreateUpdateEffect(): void;
  53392. /** @hidden */ private _recreateRenderEffect(): void;
  53393. /**
  53394. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53395. * @param preWarm defines if we are in the pre-warmimg phase
  53396. */
  53397. animate(preWarm?: boolean): void;
  53398. private _createFactorGradientTexture;
  53399. private _createSizeGradientTexture;
  53400. private _createAngularSpeedGradientTexture;
  53401. private _createVelocityGradientTexture;
  53402. private _createLimitVelocityGradientTexture;
  53403. private _createDragGradientTexture;
  53404. private _createColorGradientTexture;
  53405. /**
  53406. * Renders the particle system in its current state
  53407. * @param preWarm defines if the system should only update the particles but not render them
  53408. * @returns the current number of particles
  53409. */
  53410. render(preWarm?: boolean): number;
  53411. /**
  53412. * Rebuilds the particle system
  53413. */
  53414. rebuild(): void;
  53415. private _releaseBuffers;
  53416. private _releaseVAOs;
  53417. /**
  53418. * Disposes the particle system and free the associated resources
  53419. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53420. */
  53421. dispose(disposeTexture?: boolean): void;
  53422. /**
  53423. * Clones the particle system.
  53424. * @param name The name of the cloned object
  53425. * @param newEmitter The new emitter to use
  53426. * @returns the cloned particle system
  53427. */
  53428. clone(name: string, newEmitter: any): GPUParticleSystem;
  53429. /**
  53430. * Serializes the particle system to a JSON object.
  53431. * @returns the JSON object
  53432. */
  53433. serialize(): any;
  53434. /**
  53435. * Parses a JSON object to create a GPU particle system.
  53436. * @param parsedParticleSystem The JSON object to parse
  53437. * @param scene The scene to create the particle system in
  53438. * @param rootUrl The root url to use to load external dependencies like texture
  53439. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53440. * @returns the parsed GPU particle system
  53441. */
  53442. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53443. }
  53444. }
  53445. declare module BABYLON {
  53446. /**
  53447. * Represents a set of particle systems working together to create a specific effect
  53448. */
  53449. export class ParticleSystemSet implements IDisposable {
  53450. private _emitterCreationOptions;
  53451. private _emitterNode;
  53452. /**
  53453. * Gets the particle system list
  53454. */
  53455. systems: IParticleSystem[];
  53456. /**
  53457. * Gets the emitter node used with this set
  53458. */
  53459. readonly emitterNode: Nullable<TransformNode>;
  53460. /**
  53461. * Creates a new emitter mesh as a sphere
  53462. * @param options defines the options used to create the sphere
  53463. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53464. * @param scene defines the hosting scene
  53465. */
  53466. setEmitterAsSphere(options: {
  53467. diameter: number;
  53468. segments: number;
  53469. color: Color3;
  53470. }, renderingGroupId: number, scene: Scene): void;
  53471. /**
  53472. * Starts all particle systems of the set
  53473. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53474. */
  53475. start(emitter?: AbstractMesh): void;
  53476. /**
  53477. * Release all associated resources
  53478. */
  53479. dispose(): void;
  53480. /**
  53481. * Serialize the set into a JSON compatible object
  53482. * @returns a JSON compatible representation of the set
  53483. */
  53484. serialize(): any;
  53485. /**
  53486. * Parse a new ParticleSystemSet from a serialized source
  53487. * @param data defines a JSON compatible representation of the set
  53488. * @param scene defines the hosting scene
  53489. * @param gpu defines if we want GPU particles or CPU particles
  53490. * @returns a new ParticleSystemSet
  53491. */
  53492. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53493. }
  53494. }
  53495. declare module BABYLON {
  53496. /**
  53497. * This class is made for on one-liner static method to help creating particle system set.
  53498. */
  53499. export class ParticleHelper {
  53500. /**
  53501. * Gets or sets base Assets URL
  53502. */
  53503. static BaseAssetsUrl: string;
  53504. /**
  53505. * Create a default particle system that you can tweak
  53506. * @param emitter defines the emitter to use
  53507. * @param capacity defines the system capacity (default is 500 particles)
  53508. * @param scene defines the hosting scene
  53509. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53510. * @returns the new Particle system
  53511. */
  53512. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53513. /**
  53514. * This is the main static method (one-liner) of this helper to create different particle systems
  53515. * @param type This string represents the type to the particle system to create
  53516. * @param scene The scene where the particle system should live
  53517. * @param gpu If the system will use gpu
  53518. * @returns the ParticleSystemSet created
  53519. */
  53520. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53521. /**
  53522. * Static function used to export a particle system to a ParticleSystemSet variable.
  53523. * Please note that the emitter shape is not exported
  53524. * @param systems defines the particle systems to export
  53525. * @returns the created particle system set
  53526. */
  53527. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53528. }
  53529. }
  53530. declare module BABYLON {
  53531. interface Engine {
  53532. /**
  53533. * Create an effect to use with particle systems.
  53534. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53535. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53536. * @param uniformsNames defines a list of attribute names
  53537. * @param samplers defines an array of string used to represent textures
  53538. * @param defines defines the string containing the defines to use to compile the shaders
  53539. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53540. * @param onCompiled defines a function to call when the effect creation is successful
  53541. * @param onError defines a function to call when the effect creation has failed
  53542. * @returns the new Effect
  53543. */
  53544. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53545. }
  53546. interface Mesh {
  53547. /**
  53548. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53549. * @returns an array of IParticleSystem
  53550. */
  53551. getEmittedParticleSystems(): IParticleSystem[];
  53552. /**
  53553. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53554. * @returns an array of IParticleSystem
  53555. */
  53556. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53557. }
  53558. /**
  53559. * @hidden
  53560. */
  53561. export var _IDoNeedToBeInTheBuild: number;
  53562. }
  53563. declare module BABYLON {
  53564. interface Scene {
  53565. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  53566. /**
  53567. * Gets the current physics engine
  53568. * @returns a IPhysicsEngine or null if none attached
  53569. */
  53570. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53571. /**
  53572. * Enables physics to the current scene
  53573. * @param gravity defines the scene's gravity for the physics engine
  53574. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53575. * @return a boolean indicating if the physics engine was initialized
  53576. */
  53577. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53578. /**
  53579. * Disables and disposes the physics engine associated with the scene
  53580. */
  53581. disablePhysicsEngine(): void;
  53582. /**
  53583. * Gets a boolean indicating if there is an active physics engine
  53584. * @returns a boolean indicating if there is an active physics engine
  53585. */
  53586. isPhysicsEnabled(): boolean;
  53587. /**
  53588. * Deletes a physics compound impostor
  53589. * @param compound defines the compound to delete
  53590. */
  53591. deleteCompoundImpostor(compound: any): void;
  53592. /**
  53593. * An event triggered when physic simulation is about to be run
  53594. */
  53595. onBeforePhysicsObservable: Observable<Scene>;
  53596. /**
  53597. * An event triggered when physic simulation has been done
  53598. */
  53599. onAfterPhysicsObservable: Observable<Scene>;
  53600. }
  53601. interface AbstractMesh {
  53602. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  53603. /**
  53604. * Gets or sets impostor used for physic simulation
  53605. * @see http://doc.babylonjs.com/features/physics_engine
  53606. */
  53607. physicsImpostor: Nullable<PhysicsImpostor>;
  53608. /**
  53609. * Gets the current physics impostor
  53610. * @see http://doc.babylonjs.com/features/physics_engine
  53611. * @returns a physics impostor or null
  53612. */
  53613. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53614. /** Apply a physic impulse to the mesh
  53615. * @param force defines the force to apply
  53616. * @param contactPoint defines where to apply the force
  53617. * @returns the current mesh
  53618. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53619. */
  53620. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53621. /**
  53622. * Creates a physic joint between two meshes
  53623. * @param otherMesh defines the other mesh to use
  53624. * @param pivot1 defines the pivot to use on this mesh
  53625. * @param pivot2 defines the pivot to use on the other mesh
  53626. * @param options defines additional options (can be plugin dependent)
  53627. * @returns the current mesh
  53628. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53629. */
  53630. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53631. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  53632. }
  53633. /**
  53634. * Defines the physics engine scene component responsible to manage a physics engine
  53635. */
  53636. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53637. /**
  53638. * The component name helpful to identify the component in the list of scene components.
  53639. */
  53640. readonly name: string;
  53641. /**
  53642. * The scene the component belongs to.
  53643. */
  53644. scene: Scene;
  53645. /**
  53646. * Creates a new instance of the component for the given scene
  53647. * @param scene Defines the scene to register the component in
  53648. */
  53649. constructor(scene: Scene);
  53650. /**
  53651. * Registers the component in a given scene
  53652. */
  53653. register(): void;
  53654. /**
  53655. * Rebuilds the elements related to this component in case of
  53656. * context lost for instance.
  53657. */
  53658. rebuild(): void;
  53659. /**
  53660. * Disposes the component and the associated ressources
  53661. */
  53662. dispose(): void;
  53663. }
  53664. }
  53665. declare module BABYLON {
  53666. /**
  53667. * A helper for physics simulations
  53668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53669. */
  53670. export class PhysicsHelper {
  53671. private _scene;
  53672. private _physicsEngine;
  53673. /**
  53674. * Initializes the Physics helper
  53675. * @param scene Babylon.js scene
  53676. */
  53677. constructor(scene: Scene);
  53678. /**
  53679. * Applies a radial explosion impulse
  53680. * @param origin the origin of the explosion
  53681. * @param radiusOrEventOptions the radius or the options of radial explosion
  53682. * @param strength the explosion strength
  53683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53684. * @returns A physics radial explosion event, or null
  53685. */
  53686. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53687. /**
  53688. * Applies a radial explosion force
  53689. * @param origin the origin of the explosion
  53690. * @param radiusOrEventOptions the radius or the options of radial explosion
  53691. * @param strength the explosion strength
  53692. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53693. * @returns A physics radial explosion event, or null
  53694. */
  53695. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53696. /**
  53697. * Creates a gravitational field
  53698. * @param origin the origin of the explosion
  53699. * @param radiusOrEventOptions the radius or the options of radial explosion
  53700. * @param strength the explosion strength
  53701. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53702. * @returns A physics gravitational field event, or null
  53703. */
  53704. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53705. /**
  53706. * Creates a physics updraft event
  53707. * @param origin the origin of the updraft
  53708. * @param radiusOrEventOptions the radius or the options of the updraft
  53709. * @param strength the strength of the updraft
  53710. * @param height the height of the updraft
  53711. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53712. * @returns A physics updraft event, or null
  53713. */
  53714. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53715. /**
  53716. * Creates a physics vortex event
  53717. * @param origin the of the vortex
  53718. * @param radiusOrEventOptions the radius or the options of the vortex
  53719. * @param strength the strength of the vortex
  53720. * @param height the height of the vortex
  53721. * @returns a Physics vortex event, or null
  53722. * A physics vortex event or null
  53723. */
  53724. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53725. }
  53726. /**
  53727. * Represents a physics radial explosion event
  53728. */
  53729. class PhysicsRadialExplosionEvent {
  53730. private _scene;
  53731. private _options;
  53732. private _sphere;
  53733. private _dataFetched;
  53734. /**
  53735. * Initializes a radial explosioin event
  53736. * @param _scene BabylonJS scene
  53737. * @param _options The options for the vortex event
  53738. */
  53739. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53740. /**
  53741. * Returns the data related to the radial explosion event (sphere).
  53742. * @returns The radial explosion event data
  53743. */
  53744. getData(): PhysicsRadialExplosionEventData;
  53745. /**
  53746. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53747. * @param impostor A physics imposter
  53748. * @param origin the origin of the explosion
  53749. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53750. */
  53751. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53752. /**
  53753. * Triggers affecterd impostors callbacks
  53754. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53755. */
  53756. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53757. /**
  53758. * Disposes the sphere.
  53759. * @param force Specifies if the sphere should be disposed by force
  53760. */
  53761. dispose(force?: boolean): void;
  53762. /*** Helpers ***/
  53763. private _prepareSphere;
  53764. private _intersectsWithSphere;
  53765. }
  53766. /**
  53767. * Represents a gravitational field event
  53768. */
  53769. class PhysicsGravitationalFieldEvent {
  53770. private _physicsHelper;
  53771. private _scene;
  53772. private _origin;
  53773. private _options;
  53774. private _tickCallback;
  53775. private _sphere;
  53776. private _dataFetched;
  53777. /**
  53778. * Initializes the physics gravitational field event
  53779. * @param _physicsHelper A physics helper
  53780. * @param _scene BabylonJS scene
  53781. * @param _origin The origin position of the gravitational field event
  53782. * @param _options The options for the vortex event
  53783. */
  53784. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53785. /**
  53786. * Returns the data related to the gravitational field event (sphere).
  53787. * @returns A gravitational field event
  53788. */
  53789. getData(): PhysicsGravitationalFieldEventData;
  53790. /**
  53791. * Enables the gravitational field.
  53792. */
  53793. enable(): void;
  53794. /**
  53795. * Disables the gravitational field.
  53796. */
  53797. disable(): void;
  53798. /**
  53799. * Disposes the sphere.
  53800. * @param force The force to dispose from the gravitational field event
  53801. */
  53802. dispose(force?: boolean): void;
  53803. private _tick;
  53804. }
  53805. /**
  53806. * Represents a physics updraft event
  53807. */
  53808. class PhysicsUpdraftEvent {
  53809. private _scene;
  53810. private _origin;
  53811. private _options;
  53812. private _physicsEngine;
  53813. private _originTop;
  53814. private _originDirection;
  53815. private _tickCallback;
  53816. private _cylinder;
  53817. private _cylinderPosition;
  53818. private _dataFetched;
  53819. /**
  53820. * Initializes the physics updraft event
  53821. * @param _scene BabylonJS scene
  53822. * @param _origin The origin position of the updraft
  53823. * @param _options The options for the updraft event
  53824. */
  53825. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53826. /**
  53827. * Returns the data related to the updraft event (cylinder).
  53828. * @returns A physics updraft event
  53829. */
  53830. getData(): PhysicsUpdraftEventData;
  53831. /**
  53832. * Enables the updraft.
  53833. */
  53834. enable(): void;
  53835. /**
  53836. * Disables the updraft.
  53837. */
  53838. disable(): void;
  53839. /**
  53840. * Disposes the cylinder.
  53841. * @param force Specifies if the updraft should be disposed by force
  53842. */
  53843. dispose(force?: boolean): void;
  53844. private getImpostorHitData;
  53845. private _tick;
  53846. /*** Helpers ***/
  53847. private _prepareCylinder;
  53848. private _intersectsWithCylinder;
  53849. }
  53850. /**
  53851. * Represents a physics vortex event
  53852. */
  53853. class PhysicsVortexEvent {
  53854. private _scene;
  53855. private _origin;
  53856. private _options;
  53857. private _physicsEngine;
  53858. private _originTop;
  53859. private _tickCallback;
  53860. private _cylinder;
  53861. private _cylinderPosition;
  53862. private _dataFetched;
  53863. /**
  53864. * Initializes the physics vortex event
  53865. * @param _scene The BabylonJS scene
  53866. * @param _origin The origin position of the vortex
  53867. * @param _options The options for the vortex event
  53868. */
  53869. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53870. /**
  53871. * Returns the data related to the vortex event (cylinder).
  53872. * @returns The physics vortex event data
  53873. */
  53874. getData(): PhysicsVortexEventData;
  53875. /**
  53876. * Enables the vortex.
  53877. */
  53878. enable(): void;
  53879. /**
  53880. * Disables the cortex.
  53881. */
  53882. disable(): void;
  53883. /**
  53884. * Disposes the sphere.
  53885. * @param force
  53886. */
  53887. dispose(force?: boolean): void;
  53888. private getImpostorHitData;
  53889. private _tick;
  53890. /*** Helpers ***/
  53891. private _prepareCylinder;
  53892. private _intersectsWithCylinder;
  53893. }
  53894. /**
  53895. * Options fot the radial explosion event
  53896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53897. */
  53898. export class PhysicsRadialExplosionEventOptions {
  53899. /**
  53900. * The radius of the sphere for the radial explosion.
  53901. */
  53902. radius: number;
  53903. /**
  53904. * The strenth of the explosion.
  53905. */
  53906. strength: number;
  53907. /**
  53908. * The strenght of the force in correspondence to the distance of the affected object
  53909. */
  53910. falloff: PhysicsRadialImpulseFalloff;
  53911. /**
  53912. * Sphere options for the radial explosion.
  53913. */
  53914. sphere: {
  53915. segments: number;
  53916. diameter: number;
  53917. };
  53918. /**
  53919. * Sphere options for the radial explosion.
  53920. */
  53921. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53922. }
  53923. /**
  53924. * Options fot the updraft event
  53925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53926. */
  53927. export class PhysicsUpdraftEventOptions {
  53928. /**
  53929. * The radius of the cylinder for the vortex
  53930. */
  53931. radius: number;
  53932. /**
  53933. * The strenth of the updraft.
  53934. */
  53935. strength: number;
  53936. /**
  53937. * The height of the cylinder for the updraft.
  53938. */
  53939. height: number;
  53940. /**
  53941. * The mode for the the updraft.
  53942. */
  53943. updraftMode: PhysicsUpdraftMode;
  53944. }
  53945. /**
  53946. * Options fot the vortex event
  53947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53948. */
  53949. export class PhysicsVortexEventOptions {
  53950. /**
  53951. * The radius of the cylinder for the vortex
  53952. */
  53953. radius: number;
  53954. /**
  53955. * The strenth of the vortex.
  53956. */
  53957. strength: number;
  53958. /**
  53959. * The height of the cylinder for the vortex.
  53960. */
  53961. height: number;
  53962. /**
  53963. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53964. */
  53965. centripetalForceThreshold: number;
  53966. /**
  53967. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53968. */
  53969. centripetalForceMultiplier: number;
  53970. /**
  53971. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53972. */
  53973. centrifugalForceMultiplier: number;
  53974. /**
  53975. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53976. */
  53977. updraftForceMultiplier: number;
  53978. }
  53979. /**
  53980. * The strenght of the force in correspondence to the distance of the affected object
  53981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53982. */
  53983. export enum PhysicsRadialImpulseFalloff {
  53984. /** Defines that impulse is constant in strength across it's whole radius */
  53985. Constant = 0,
  53986. /** Defines that impulse gets weaker if it's further from the origin */
  53987. Linear = 1
  53988. }
  53989. /**
  53990. * The strength of the force in correspondence to the distance of the affected object
  53991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53992. */
  53993. export enum PhysicsUpdraftMode {
  53994. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53995. Center = 0,
  53996. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53997. Perpendicular = 1
  53998. }
  53999. /**
  54000. * Interface for a physics hit data
  54001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54002. */
  54003. export interface PhysicsHitData {
  54004. /**
  54005. * The force applied at the contact point
  54006. */
  54007. force: Vector3;
  54008. /**
  54009. * The contact point
  54010. */
  54011. contactPoint: Vector3;
  54012. /**
  54013. * The distance from the origin to the contact point
  54014. */
  54015. distanceFromOrigin: number;
  54016. }
  54017. /**
  54018. * Interface for radial explosion event data
  54019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54020. */
  54021. export interface PhysicsRadialExplosionEventData {
  54022. /**
  54023. * A sphere used for the radial explosion event
  54024. */
  54025. sphere: Mesh;
  54026. }
  54027. /**
  54028. * Interface for gravitational field event data
  54029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54030. */
  54031. export interface PhysicsGravitationalFieldEventData {
  54032. /**
  54033. * A sphere mesh used for the gravitational field event
  54034. */
  54035. sphere: Mesh;
  54036. }
  54037. /**
  54038. * Interface for updraft event data
  54039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54040. */
  54041. export interface PhysicsUpdraftEventData {
  54042. /**
  54043. * A cylinder used for the updraft event
  54044. */
  54045. cylinder: Mesh;
  54046. }
  54047. /**
  54048. * Interface for vortex event data
  54049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54050. */
  54051. export interface PhysicsVortexEventData {
  54052. /**
  54053. * A cylinder used for the vortex event
  54054. */
  54055. cylinder: Mesh;
  54056. }
  54057. /**
  54058. * Interface for an affected physics impostor
  54059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54060. */
  54061. export interface PhysicsAffectedImpostorWithData {
  54062. /**
  54063. * The impostor affected by the effect
  54064. */
  54065. impostor: PhysicsImpostor;
  54066. /**
  54067. * The data about the hit/horce from the explosion
  54068. */
  54069. hitData: PhysicsHitData;
  54070. }
  54071. }
  54072. declare module BABYLON {
  54073. /** @hidden */
  54074. export var blackAndWhitePixelShader: {
  54075. name: string;
  54076. shader: string;
  54077. };
  54078. }
  54079. declare module BABYLON {
  54080. /**
  54081. * Post process used to render in black and white
  54082. */
  54083. export class BlackAndWhitePostProcess extends PostProcess {
  54084. /**
  54085. * Linear about to convert he result to black and white (default: 1)
  54086. */
  54087. degree: number;
  54088. /**
  54089. * Creates a black and white post process
  54090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54091. * @param name The name of the effect.
  54092. * @param options The required width/height ratio to downsize to before computing the render pass.
  54093. * @param camera The camera to apply the render pass to.
  54094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54095. * @param engine The engine which the post process will be applied. (default: current engine)
  54096. * @param reusable If the post process can be reused on the same frame. (default: false)
  54097. */
  54098. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54099. }
  54100. }
  54101. declare module BABYLON {
  54102. /**
  54103. * This represents a set of one or more post processes in Babylon.
  54104. * A post process can be used to apply a shader to a texture after it is rendered.
  54105. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54106. */
  54107. export class PostProcessRenderEffect {
  54108. private _postProcesses;
  54109. private _getPostProcesses;
  54110. private _singleInstance;
  54111. private _cameras;
  54112. private _indicesForCamera;
  54113. /**
  54114. * Name of the effect
  54115. * @hidden
  54116. */ private _name: string;
  54117. /**
  54118. * Instantiates a post process render effect.
  54119. * A post process can be used to apply a shader to a texture after it is rendered.
  54120. * @param engine The engine the effect is tied to
  54121. * @param name The name of the effect
  54122. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54123. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54124. */
  54125. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54126. /**
  54127. * Checks if all the post processes in the effect are supported.
  54128. */
  54129. readonly isSupported: boolean;
  54130. /**
  54131. * Updates the current state of the effect
  54132. * @hidden
  54133. */ private _update(): void;
  54134. /**
  54135. * Attaches the effect on cameras
  54136. * @param cameras The camera to attach to.
  54137. * @hidden
  54138. */ private _attachCameras(cameras: Camera): void;
  54139. /**
  54140. * Attaches the effect on cameras
  54141. * @param cameras The camera to attach to.
  54142. * @hidden
  54143. */ private _attachCameras(cameras: Camera[]): void;
  54144. /**
  54145. * Detaches the effect on cameras
  54146. * @param cameras The camera to detatch from.
  54147. * @hidden
  54148. */ private _detachCameras(cameras: Camera): void;
  54149. /**
  54150. * Detatches the effect on cameras
  54151. * @param cameras The camera to detatch from.
  54152. * @hidden
  54153. */ private _detachCameras(cameras: Camera[]): void;
  54154. /**
  54155. * Enables the effect on given cameras
  54156. * @param cameras The camera to enable.
  54157. * @hidden
  54158. */ private _enable(cameras: Camera): void;
  54159. /**
  54160. * Enables the effect on given cameras
  54161. * @param cameras The camera to enable.
  54162. * @hidden
  54163. */ private _enable(cameras: Nullable<Camera[]>): void;
  54164. /**
  54165. * Disables the effect on the given cameras
  54166. * @param cameras The camera to disable.
  54167. * @hidden
  54168. */ private _disable(cameras: Camera): void;
  54169. /**
  54170. * Disables the effect on the given cameras
  54171. * @param cameras The camera to disable.
  54172. * @hidden
  54173. */ private _disable(cameras: Nullable<Camera[]>): void;
  54174. /**
  54175. * Gets a list of the post processes contained in the effect.
  54176. * @param camera The camera to get the post processes on.
  54177. * @returns The list of the post processes in the effect.
  54178. */
  54179. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54180. }
  54181. }
  54182. declare module BABYLON {
  54183. /** @hidden */
  54184. export var extractHighlightsPixelShader: {
  54185. name: string;
  54186. shader: string;
  54187. };
  54188. }
  54189. declare module BABYLON {
  54190. /**
  54191. * 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.
  54192. */
  54193. export class ExtractHighlightsPostProcess extends PostProcess {
  54194. /**
  54195. * The luminance threshold, pixels below this value will be set to black.
  54196. */
  54197. threshold: number;
  54198. /** @hidden */ private _exposure: number;
  54199. /**
  54200. * Post process which has the input texture to be used when performing highlight extraction
  54201. * @hidden
  54202. */ private _inputPostProcess: Nullable<PostProcess>;
  54203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54204. }
  54205. }
  54206. declare module BABYLON {
  54207. /** @hidden */
  54208. export var bloomMergePixelShader: {
  54209. name: string;
  54210. shader: string;
  54211. };
  54212. }
  54213. declare module BABYLON {
  54214. /**
  54215. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54216. */
  54217. export class BloomMergePostProcess extends PostProcess {
  54218. /** Weight of the bloom to be added to the original input. */
  54219. weight: number;
  54220. /**
  54221. * Creates a new instance of @see BloomMergePostProcess
  54222. * @param name The name of the effect.
  54223. * @param originalFromInput Post process which's input will be used for the merge.
  54224. * @param blurred Blurred highlights post process which's output will be used.
  54225. * @param weight Weight of the bloom to be added to the original input.
  54226. * @param options The required width/height ratio to downsize to before computing the render pass.
  54227. * @param camera The camera to apply the render pass to.
  54228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54229. * @param engine The engine which the post process will be applied. (default: current engine)
  54230. * @param reusable If the post process can be reused on the same frame. (default: false)
  54231. * @param textureType Type of textures used when performing the post process. (default: 0)
  54232. * @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)
  54233. */
  54234. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54235. /** Weight of the bloom to be added to the original input. */
  54236. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54237. }
  54238. }
  54239. declare module BABYLON {
  54240. /**
  54241. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54242. */
  54243. export class BloomEffect extends PostProcessRenderEffect {
  54244. private bloomScale;
  54245. /**
  54246. * @hidden Internal
  54247. */ private _effects: Array<PostProcess>;
  54248. /**
  54249. * @hidden Internal
  54250. */ private _downscale: ExtractHighlightsPostProcess;
  54251. private _blurX;
  54252. private _blurY;
  54253. private _merge;
  54254. /**
  54255. * The luminance threshold to find bright areas of the image to bloom.
  54256. */
  54257. threshold: number;
  54258. /**
  54259. * The strength of the bloom.
  54260. */
  54261. weight: number;
  54262. /**
  54263. * Specifies the size of the bloom blur kernel, relative to the final output size
  54264. */
  54265. kernel: number;
  54266. /**
  54267. * Creates a new instance of @see BloomEffect
  54268. * @param scene The scene the effect belongs to.
  54269. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54270. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54271. * @param bloomWeight The the strength of bloom.
  54272. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54273. * @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)
  54274. */
  54275. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54276. /**
  54277. * Disposes each of the internal effects for a given camera.
  54278. * @param camera The camera to dispose the effect on.
  54279. */
  54280. disposeEffects(camera: Camera): void;
  54281. /**
  54282. * @hidden Internal
  54283. */ private _updateEffects(): void;
  54284. /**
  54285. * Internal
  54286. * @returns if all the contained post processes are ready.
  54287. * @hidden
  54288. */ private _isReady(): boolean;
  54289. }
  54290. }
  54291. declare module BABYLON {
  54292. /** @hidden */
  54293. export var chromaticAberrationPixelShader: {
  54294. name: string;
  54295. shader: string;
  54296. };
  54297. }
  54298. declare module BABYLON {
  54299. /**
  54300. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54301. */
  54302. export class ChromaticAberrationPostProcess extends PostProcess {
  54303. /**
  54304. * The amount of seperation of rgb channels (default: 30)
  54305. */
  54306. aberrationAmount: number;
  54307. /**
  54308. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54309. */
  54310. radialIntensity: number;
  54311. /**
  54312. * 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))
  54313. */
  54314. direction: Vector2;
  54315. /**
  54316. * 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))
  54317. */
  54318. centerPosition: Vector2;
  54319. /**
  54320. * Creates a new instance ChromaticAberrationPostProcess
  54321. * @param name The name of the effect.
  54322. * @param screenWidth The width of the screen to apply the effect on.
  54323. * @param screenHeight The height of the screen to apply the effect on.
  54324. * @param options The required width/height ratio to downsize to before computing the render pass.
  54325. * @param camera The camera to apply the render pass to.
  54326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54327. * @param engine The engine which the post process will be applied. (default: current engine)
  54328. * @param reusable If the post process can be reused on the same frame. (default: false)
  54329. * @param textureType Type of textures used when performing the post process. (default: 0)
  54330. * @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)
  54331. */
  54332. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54333. }
  54334. }
  54335. declare module BABYLON {
  54336. /** @hidden */
  54337. export var circleOfConfusionPixelShader: {
  54338. name: string;
  54339. shader: string;
  54340. };
  54341. }
  54342. declare module BABYLON {
  54343. /**
  54344. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54345. */
  54346. export class CircleOfConfusionPostProcess extends PostProcess {
  54347. /**
  54348. * 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.
  54349. */
  54350. lensSize: number;
  54351. /**
  54352. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54353. */
  54354. fStop: number;
  54355. /**
  54356. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54357. */
  54358. focusDistance: number;
  54359. /**
  54360. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54361. */
  54362. focalLength: number;
  54363. private _depthTexture;
  54364. /**
  54365. * Creates a new instance CircleOfConfusionPostProcess
  54366. * @param name The name of the effect.
  54367. * @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.
  54368. * @param options The required width/height ratio to downsize to before computing the render pass.
  54369. * @param camera The camera to apply the render pass to.
  54370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54371. * @param engine The engine which the post process will be applied. (default: current engine)
  54372. * @param reusable If the post process can be reused on the same frame. (default: false)
  54373. * @param textureType Type of textures used when performing the post process. (default: 0)
  54374. * @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)
  54375. */
  54376. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54377. /**
  54378. * 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.
  54379. */
  54380. depthTexture: RenderTargetTexture;
  54381. }
  54382. }
  54383. declare module BABYLON {
  54384. /** @hidden */
  54385. export var colorCorrectionPixelShader: {
  54386. name: string;
  54387. shader: string;
  54388. };
  54389. }
  54390. declare module BABYLON {
  54391. /**
  54392. *
  54393. * This post-process allows the modification of rendered colors by using
  54394. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54395. *
  54396. * The object needs to be provided an url to a texture containing the color
  54397. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54398. * Use an image editing software to tweak the LUT to match your needs.
  54399. *
  54400. * For an example of a color LUT, see here:
  54401. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54402. * For explanations on color grading, see here:
  54403. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54404. *
  54405. */
  54406. export class ColorCorrectionPostProcess extends PostProcess {
  54407. private _colorTableTexture;
  54408. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54409. }
  54410. }
  54411. declare module BABYLON {
  54412. /** @hidden */
  54413. export var convolutionPixelShader: {
  54414. name: string;
  54415. shader: string;
  54416. };
  54417. }
  54418. declare module BABYLON {
  54419. /**
  54420. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54421. * input texture to perform effects such as edge detection or sharpening
  54422. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54423. */
  54424. export class ConvolutionPostProcess extends PostProcess {
  54425. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54426. kernel: number[];
  54427. /**
  54428. * Creates a new instance ConvolutionPostProcess
  54429. * @param name The name of the effect.
  54430. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  54431. * @param options The required width/height ratio to downsize to before computing the render pass.
  54432. * @param camera The camera to apply the render pass to.
  54433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54434. * @param engine The engine which the post process will be applied. (default: current engine)
  54435. * @param reusable If the post process can be reused on the same frame. (default: false)
  54436. * @param textureType Type of textures used when performing the post process. (default: 0)
  54437. */
  54438. constructor(name: string,
  54439. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54440. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54441. /**
  54442. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54443. */
  54444. static EdgeDetect0Kernel: number[];
  54445. /**
  54446. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54447. */
  54448. static EdgeDetect1Kernel: number[];
  54449. /**
  54450. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54451. */
  54452. static EdgeDetect2Kernel: number[];
  54453. /**
  54454. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54455. */
  54456. static SharpenKernel: number[];
  54457. /**
  54458. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54459. */
  54460. static EmbossKernel: number[];
  54461. /**
  54462. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54463. */
  54464. static GaussianKernel: number[];
  54465. }
  54466. }
  54467. declare module BABYLON {
  54468. /**
  54469. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54470. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54471. * based on samples that have a large difference in distance than the center pixel.
  54472. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54473. */
  54474. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54475. direction: Vector2;
  54476. /**
  54477. * Creates a new instance CircleOfConfusionPostProcess
  54478. * @param name The name of the effect.
  54479. * @param scene The scene the effect belongs to.
  54480. * @param direction The direction the blur should be applied.
  54481. * @param kernel The size of the kernel used to blur.
  54482. * @param options The required width/height ratio to downsize to before computing the render pass.
  54483. * @param camera The camera to apply the render pass to.
  54484. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54485. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54487. * @param engine The engine which the post process will be applied. (default: current engine)
  54488. * @param reusable If the post process can be reused on the same frame. (default: false)
  54489. * @param textureType Type of textures used when performing the post process. (default: 0)
  54490. * @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)
  54491. */
  54492. 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);
  54493. }
  54494. }
  54495. declare module BABYLON {
  54496. /** @hidden */
  54497. export var depthOfFieldMergePixelShader: {
  54498. name: string;
  54499. shader: string;
  54500. };
  54501. }
  54502. declare module BABYLON {
  54503. /**
  54504. * Options to be set when merging outputs from the default pipeline.
  54505. */
  54506. export class DepthOfFieldMergePostProcessOptions {
  54507. /**
  54508. * The original image to merge on top of
  54509. */
  54510. originalFromInput: PostProcess;
  54511. /**
  54512. * Parameters to perform the merge of the depth of field effect
  54513. */
  54514. depthOfField?: {
  54515. circleOfConfusion: PostProcess;
  54516. blurSteps: Array<PostProcess>;
  54517. };
  54518. /**
  54519. * Parameters to perform the merge of bloom effect
  54520. */
  54521. bloom?: {
  54522. blurred: PostProcess;
  54523. weight: number;
  54524. };
  54525. }
  54526. /**
  54527. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54528. */
  54529. export class DepthOfFieldMergePostProcess extends PostProcess {
  54530. private blurSteps;
  54531. /**
  54532. * Creates a new instance of DepthOfFieldMergePostProcess
  54533. * @param name The name of the effect.
  54534. * @param originalFromInput Post process which's input will be used for the merge.
  54535. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54536. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54537. * @param options The required width/height ratio to downsize to before computing the render pass.
  54538. * @param camera The camera to apply the render pass to.
  54539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54540. * @param engine The engine which the post process will be applied. (default: current engine)
  54541. * @param reusable If the post process can be reused on the same frame. (default: false)
  54542. * @param textureType Type of textures used when performing the post process. (default: 0)
  54543. * @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)
  54544. */
  54545. 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);
  54546. /**
  54547. * Updates the effect with the current post process compile time values and recompiles the shader.
  54548. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54549. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54550. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54551. * @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
  54552. * @param onCompiled Called when the shader has been compiled.
  54553. * @param onError Called if there is an error when compiling a shader.
  54554. */
  54555. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54556. }
  54557. }
  54558. declare module BABYLON {
  54559. /**
  54560. * Specifies the level of max blur that should be applied when using the depth of field effect
  54561. */
  54562. export enum DepthOfFieldEffectBlurLevel {
  54563. /**
  54564. * Subtle blur
  54565. */
  54566. Low = 0,
  54567. /**
  54568. * Medium blur
  54569. */
  54570. Medium = 1,
  54571. /**
  54572. * Large blur
  54573. */
  54574. High = 2
  54575. }
  54576. /**
  54577. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54578. */
  54579. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54580. private _circleOfConfusion;
  54581. /**
  54582. * @hidden Internal, blurs from high to low
  54583. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54584. private _depthOfFieldBlurY;
  54585. private _dofMerge;
  54586. /**
  54587. * @hidden Internal post processes in depth of field effect
  54588. */ private _effects: Array<PostProcess>;
  54589. /**
  54590. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54591. */
  54592. focalLength: number;
  54593. /**
  54594. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54595. */
  54596. fStop: number;
  54597. /**
  54598. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54599. */
  54600. focusDistance: number;
  54601. /**
  54602. * 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.
  54603. */
  54604. lensSize: number;
  54605. /**
  54606. * Creates a new instance DepthOfFieldEffect
  54607. * @param scene The scene the effect belongs to.
  54608. * @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.
  54609. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54610. * @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)
  54611. */
  54612. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54613. /**
  54614. * Get the current class name of the current effet
  54615. * @returns "DepthOfFieldEffect"
  54616. */
  54617. getClassName(): string;
  54618. /**
  54619. * 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.
  54620. */
  54621. depthTexture: RenderTargetTexture;
  54622. /**
  54623. * Disposes each of the internal effects for a given camera.
  54624. * @param camera The camera to dispose the effect on.
  54625. */
  54626. disposeEffects(camera: Camera): void;
  54627. /**
  54628. * @hidden Internal
  54629. */ private _updateEffects(): void;
  54630. /**
  54631. * Internal
  54632. * @returns if all the contained post processes are ready.
  54633. * @hidden
  54634. */ private _isReady(): boolean;
  54635. }
  54636. }
  54637. declare module BABYLON {
  54638. /** @hidden */
  54639. export var displayPassPixelShader: {
  54640. name: string;
  54641. shader: string;
  54642. };
  54643. }
  54644. declare module BABYLON {
  54645. /**
  54646. * DisplayPassPostProcess which produces an output the same as it's input
  54647. */
  54648. export class DisplayPassPostProcess extends PostProcess {
  54649. /**
  54650. * Creates the DisplayPassPostProcess
  54651. * @param name The name of the effect.
  54652. * @param options The required width/height ratio to downsize to before computing the render pass.
  54653. * @param camera The camera to apply the render pass to.
  54654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54655. * @param engine The engine which the post process will be applied. (default: current engine)
  54656. * @param reusable If the post process can be reused on the same frame. (default: false)
  54657. */
  54658. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54659. }
  54660. }
  54661. declare module BABYLON {
  54662. /** @hidden */
  54663. export var filterPixelShader: {
  54664. name: string;
  54665. shader: string;
  54666. };
  54667. }
  54668. declare module BABYLON {
  54669. /**
  54670. * Applies a kernel filter to the image
  54671. */
  54672. export class FilterPostProcess extends PostProcess {
  54673. /** The matrix to be applied to the image */
  54674. kernelMatrix: Matrix;
  54675. /**
  54676. *
  54677. * @param name The name of the effect.
  54678. * @param kernelMatrix The matrix to be applied to the image
  54679. * @param options The required width/height ratio to downsize to before computing the render pass.
  54680. * @param camera The camera to apply the render pass to.
  54681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54682. * @param engine The engine which the post process will be applied. (default: current engine)
  54683. * @param reusable If the post process can be reused on the same frame. (default: false)
  54684. */
  54685. constructor(name: string,
  54686. /** The matrix to be applied to the image */
  54687. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54688. }
  54689. }
  54690. declare module BABYLON {
  54691. /** @hidden */
  54692. export var fxaaPixelShader: {
  54693. name: string;
  54694. shader: string;
  54695. };
  54696. }
  54697. declare module BABYLON {
  54698. /** @hidden */
  54699. export var fxaaVertexShader: {
  54700. name: string;
  54701. shader: string;
  54702. };
  54703. }
  54704. declare module BABYLON {
  54705. /**
  54706. * Fxaa post process
  54707. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54708. */
  54709. export class FxaaPostProcess extends PostProcess {
  54710. /** @hidden */
  54711. texelWidth: number;
  54712. /** @hidden */
  54713. texelHeight: number;
  54714. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54715. private _getDefines;
  54716. }
  54717. }
  54718. declare module BABYLON {
  54719. /** @hidden */
  54720. export var grainPixelShader: {
  54721. name: string;
  54722. shader: string;
  54723. };
  54724. }
  54725. declare module BABYLON {
  54726. /**
  54727. * The GrainPostProcess adds noise to the image at mid luminance levels
  54728. */
  54729. export class GrainPostProcess extends PostProcess {
  54730. /**
  54731. * The intensity of the grain added (default: 30)
  54732. */
  54733. intensity: number;
  54734. /**
  54735. * If the grain should be randomized on every frame
  54736. */
  54737. animated: boolean;
  54738. /**
  54739. * Creates a new instance of @see GrainPostProcess
  54740. * @param name The name of the effect.
  54741. * @param options The required width/height ratio to downsize to before computing the render pass.
  54742. * @param camera The camera to apply the render pass to.
  54743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54744. * @param engine The engine which the post process will be applied. (default: current engine)
  54745. * @param reusable If the post process can be reused on the same frame. (default: false)
  54746. * @param textureType Type of textures used when performing the post process. (default: 0)
  54747. * @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)
  54748. */
  54749. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54750. }
  54751. }
  54752. declare module BABYLON {
  54753. /** @hidden */
  54754. export var highlightsPixelShader: {
  54755. name: string;
  54756. shader: string;
  54757. };
  54758. }
  54759. declare module BABYLON {
  54760. /**
  54761. * Extracts highlights from the image
  54762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54763. */
  54764. export class HighlightsPostProcess extends PostProcess {
  54765. /**
  54766. * Extracts highlights from the image
  54767. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54768. * @param name The name of the effect.
  54769. * @param options The required width/height ratio to downsize to before computing the render pass.
  54770. * @param camera The camera to apply the render pass to.
  54771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54772. * @param engine The engine which the post process will be applied. (default: current engine)
  54773. * @param reusable If the post process can be reused on the same frame. (default: false)
  54774. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54775. */
  54776. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54777. }
  54778. }
  54779. declare module BABYLON {
  54780. /** @hidden */
  54781. export var mrtFragmentDeclaration: {
  54782. name: string;
  54783. shader: string;
  54784. };
  54785. }
  54786. declare module BABYLON {
  54787. /** @hidden */
  54788. export var geometryPixelShader: {
  54789. name: string;
  54790. shader: string;
  54791. };
  54792. }
  54793. declare module BABYLON {
  54794. /** @hidden */
  54795. export var geometryVertexShader: {
  54796. name: string;
  54797. shader: string;
  54798. };
  54799. }
  54800. declare module BABYLON {
  54801. /** @hidden */
  54802. interface ISavedTransformationMatrix {
  54803. world: Matrix;
  54804. viewProjection: Matrix;
  54805. }
  54806. /**
  54807. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54808. */
  54809. export class GeometryBufferRenderer {
  54810. /**
  54811. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54812. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54813. */
  54814. static readonly POSITION_TEXTURE_TYPE: number;
  54815. /**
  54816. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54817. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54818. */
  54819. static readonly VELOCITY_TEXTURE_TYPE: number;
  54820. /**
  54821. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54822. * in order to compute objects velocities when enableVelocity is set to "true"
  54823. * @hidden
  54824. */ private _previousTransformationMatrices: {
  54825. [index: number]: ISavedTransformationMatrix;
  54826. };
  54827. /**
  54828. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  54829. * in order to compute objects velocities when enableVelocity is set to "true"
  54830. * @hidden
  54831. */ private _previousBonesTransformationMatrices: {
  54832. [index: number]: Float32Array;
  54833. };
  54834. /**
  54835. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  54836. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  54837. */
  54838. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  54839. private _scene;
  54840. private _multiRenderTarget;
  54841. private _ratio;
  54842. private _enablePosition;
  54843. private _enableVelocity;
  54844. private _positionIndex;
  54845. private _velocityIndex;
  54846. protected _effect: Effect;
  54847. protected _cachedDefines: string;
  54848. /**
  54849. * Set the render list (meshes to be rendered) used in the G buffer.
  54850. */
  54851. renderList: Mesh[];
  54852. /**
  54853. * Gets wether or not G buffer are supported by the running hardware.
  54854. * This requires draw buffer supports
  54855. */
  54856. readonly isSupported: boolean;
  54857. /**
  54858. * Returns the index of the given texture type in the G-Buffer textures array
  54859. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54860. * @returns the index of the given texture type in the G-Buffer textures array
  54861. */
  54862. getTextureIndex(textureType: number): number;
  54863. /**
  54864. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54865. */
  54866. /**
  54867. * Sets whether or not objects positions are enabled for the G buffer.
  54868. */
  54869. enablePosition: boolean;
  54870. /**
  54871. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54872. */
  54873. /**
  54874. * Sets wether or not objects velocities are enabled for the G buffer.
  54875. */
  54876. enableVelocity: boolean;
  54877. /**
  54878. * Gets the scene associated with the buffer.
  54879. */
  54880. readonly scene: Scene;
  54881. /**
  54882. * Gets the ratio used by the buffer during its creation.
  54883. * How big is the buffer related to the main canvas.
  54884. */
  54885. readonly ratio: number;
  54886. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  54887. /**
  54888. * Creates a new G Buffer for the scene
  54889. * @param scene The scene the buffer belongs to
  54890. * @param ratio How big is the buffer related to the main canvas.
  54891. */
  54892. constructor(scene: Scene, ratio?: number);
  54893. /**
  54894. * Checks wether everything is ready to render a submesh to the G buffer.
  54895. * @param subMesh the submesh to check readiness for
  54896. * @param useInstances is the mesh drawn using instance or not
  54897. * @returns true if ready otherwise false
  54898. */
  54899. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54900. /**
  54901. * Gets the current underlying G Buffer.
  54902. * @returns the buffer
  54903. */
  54904. getGBuffer(): MultiRenderTarget;
  54905. /**
  54906. * Gets the number of samples used to render the buffer (anti aliasing).
  54907. */
  54908. /**
  54909. * Sets the number of samples used to render the buffer (anti aliasing).
  54910. */
  54911. samples: number;
  54912. /**
  54913. * Disposes the renderer and frees up associated resources.
  54914. */
  54915. dispose(): void;
  54916. protected _createRenderTargets(): void;
  54917. private _copyBonesTransformationMatrices;
  54918. }
  54919. }
  54920. declare module BABYLON {
  54921. interface Scene {
  54922. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54923. /**
  54924. * Gets or Sets the current geometry buffer associated to the scene.
  54925. */
  54926. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54927. /**
  54928. * Enables a GeometryBufferRender and associates it with the scene
  54929. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54930. * @returns the GeometryBufferRenderer
  54931. */
  54932. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54933. /**
  54934. * Disables the GeometryBufferRender associated with the scene
  54935. */
  54936. disableGeometryBufferRenderer(): void;
  54937. }
  54938. /**
  54939. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54940. * in several rendering techniques.
  54941. */
  54942. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54943. /**
  54944. * The component name helpful to identify the component in the list of scene components.
  54945. */
  54946. readonly name: string;
  54947. /**
  54948. * The scene the component belongs to.
  54949. */
  54950. scene: Scene;
  54951. /**
  54952. * Creates a new instance of the component for the given scene
  54953. * @param scene Defines the scene to register the component in
  54954. */
  54955. constructor(scene: Scene);
  54956. /**
  54957. * Registers the component in a given scene
  54958. */
  54959. register(): void;
  54960. /**
  54961. * Rebuilds the elements related to this component in case of
  54962. * context lost for instance.
  54963. */
  54964. rebuild(): void;
  54965. /**
  54966. * Disposes the component and the associated ressources
  54967. */
  54968. dispose(): void;
  54969. private _gatherRenderTargets;
  54970. }
  54971. }
  54972. declare module BABYLON {
  54973. /** @hidden */
  54974. export var motionBlurPixelShader: {
  54975. name: string;
  54976. shader: string;
  54977. };
  54978. }
  54979. declare module BABYLON {
  54980. /**
  54981. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54982. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54983. * As an example, all you have to do is to create the post-process:
  54984. * var mb = new BABYLON.MotionBlurPostProcess(
  54985. * 'mb', // The name of the effect.
  54986. * scene, // The scene containing the objects to blur according to their velocity.
  54987. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54988. * camera // The camera to apply the render pass to.
  54989. * );
  54990. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54991. */
  54992. export class MotionBlurPostProcess extends PostProcess {
  54993. /**
  54994. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54995. */
  54996. motionStrength: number;
  54997. /**
  54998. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54999. */
  55000. /**
  55001. * Sets the number of iterations to be used for motion blur quality
  55002. */
  55003. motionBlurSamples: number;
  55004. private _motionBlurSamples;
  55005. private _geometryBufferRenderer;
  55006. /**
  55007. * Creates a new instance MotionBlurPostProcess
  55008. * @param name The name of the effect.
  55009. * @param scene The scene containing the objects to blur according to their velocity.
  55010. * @param options The required width/height ratio to downsize to before computing the render pass.
  55011. * @param camera The camera to apply the render pass to.
  55012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55013. * @param engine The engine which the post process will be applied. (default: current engine)
  55014. * @param reusable If the post process can be reused on the same frame. (default: false)
  55015. * @param textureType Type of textures used when performing the post process. (default: 0)
  55016. * @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)
  55017. */
  55018. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55019. /**
  55020. * Excludes the given skinned mesh from computing bones velocities.
  55021. * 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.
  55022. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55023. */
  55024. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55025. /**
  55026. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55027. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55028. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55029. */
  55030. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55031. /**
  55032. * Disposes the post process.
  55033. * @param camera The camera to dispose the post process on.
  55034. */
  55035. dispose(camera?: Camera): void;
  55036. }
  55037. }
  55038. declare module BABYLON {
  55039. /** @hidden */
  55040. export var refractionPixelShader: {
  55041. name: string;
  55042. shader: string;
  55043. };
  55044. }
  55045. declare module BABYLON {
  55046. /**
  55047. * Post process which applies a refractin texture
  55048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55049. */
  55050. export class RefractionPostProcess extends PostProcess {
  55051. /** the base color of the refraction (used to taint the rendering) */
  55052. color: Color3;
  55053. /** simulated refraction depth */
  55054. depth: number;
  55055. /** the coefficient of the base color (0 to remove base color tainting) */
  55056. colorLevel: number;
  55057. private _refTexture;
  55058. private _ownRefractionTexture;
  55059. /**
  55060. * Gets or sets the refraction texture
  55061. * Please note that you are responsible for disposing the texture if you set it manually
  55062. */
  55063. refractionTexture: Texture;
  55064. /**
  55065. * Initializes the RefractionPostProcess
  55066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55067. * @param name The name of the effect.
  55068. * @param refractionTextureUrl Url of the refraction texture to use
  55069. * @param color the base color of the refraction (used to taint the rendering)
  55070. * @param depth simulated refraction depth
  55071. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55072. * @param camera The camera to apply the render pass to.
  55073. * @param options The required width/height ratio to downsize to before computing the render pass.
  55074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55075. * @param engine The engine which the post process will be applied. (default: current engine)
  55076. * @param reusable If the post process can be reused on the same frame. (default: false)
  55077. */
  55078. constructor(name: string, refractionTextureUrl: string,
  55079. /** the base color of the refraction (used to taint the rendering) */
  55080. color: Color3,
  55081. /** simulated refraction depth */
  55082. depth: number,
  55083. /** the coefficient of the base color (0 to remove base color tainting) */
  55084. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55085. /**
  55086. * Disposes of the post process
  55087. * @param camera Camera to dispose post process on
  55088. */
  55089. dispose(camera: Camera): void;
  55090. }
  55091. }
  55092. declare module BABYLON {
  55093. /** @hidden */
  55094. export var sharpenPixelShader: {
  55095. name: string;
  55096. shader: string;
  55097. };
  55098. }
  55099. declare module BABYLON {
  55100. /**
  55101. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55102. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55103. */
  55104. export class SharpenPostProcess extends PostProcess {
  55105. /**
  55106. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55107. */
  55108. colorAmount: number;
  55109. /**
  55110. * How much sharpness should be applied (default: 0.3)
  55111. */
  55112. edgeAmount: number;
  55113. /**
  55114. * Creates a new instance ConvolutionPostProcess
  55115. * @param name The name of the effect.
  55116. * @param options The required width/height ratio to downsize to before computing the render pass.
  55117. * @param camera The camera to apply the render pass to.
  55118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55119. * @param engine The engine which the post process will be applied. (default: current engine)
  55120. * @param reusable If the post process can be reused on the same frame. (default: false)
  55121. * @param textureType Type of textures used when performing the post process. (default: 0)
  55122. * @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)
  55123. */
  55124. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55125. }
  55126. }
  55127. declare module BABYLON {
  55128. /**
  55129. * PostProcessRenderPipeline
  55130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55131. */
  55132. export class PostProcessRenderPipeline {
  55133. private engine;
  55134. private _renderEffects;
  55135. private _renderEffectsForIsolatedPass;
  55136. /**
  55137. * List of inspectable custom properties (used by the Inspector)
  55138. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55139. */
  55140. inspectableCustomProperties: IInspectable[];
  55141. /**
  55142. * @hidden
  55143. */
  55144. protected _cameras: Camera[];
  55145. /** @hidden */ private _name: string;
  55146. /**
  55147. * Gets pipeline name
  55148. */
  55149. readonly name: string;
  55150. /**
  55151. * Initializes a PostProcessRenderPipeline
  55152. * @param engine engine to add the pipeline to
  55153. * @param name name of the pipeline
  55154. */
  55155. constructor(engine: Engine, name: string);
  55156. /**
  55157. * Gets the class name
  55158. * @returns "PostProcessRenderPipeline"
  55159. */
  55160. getClassName(): string;
  55161. /**
  55162. * If all the render effects in the pipeline are supported
  55163. */
  55164. readonly isSupported: boolean;
  55165. /**
  55166. * Adds an effect to the pipeline
  55167. * @param renderEffect the effect to add
  55168. */
  55169. addEffect(renderEffect: PostProcessRenderEffect): void;
  55170. /** @hidden */ private _rebuild(): void;
  55171. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  55172. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55173. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55174. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55175. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  55176. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  55177. /** @hidden */ private _detachCameras(cameras: Camera): void;
  55178. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  55179. /** @hidden */ private _update(): void;
  55180. /** @hidden */ private _reset(): void;
  55181. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55182. /**
  55183. * Disposes of the pipeline
  55184. */
  55185. dispose(): void;
  55186. }
  55187. }
  55188. declare module BABYLON {
  55189. /**
  55190. * PostProcessRenderPipelineManager class
  55191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55192. */
  55193. export class PostProcessRenderPipelineManager {
  55194. private _renderPipelines;
  55195. /**
  55196. * Initializes a PostProcessRenderPipelineManager
  55197. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55198. */
  55199. constructor();
  55200. /**
  55201. * Gets the list of supported render pipelines
  55202. */
  55203. readonly supportedPipelines: PostProcessRenderPipeline[];
  55204. /**
  55205. * Adds a pipeline to the manager
  55206. * @param renderPipeline The pipeline to add
  55207. */
  55208. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55209. /**
  55210. * Attaches a camera to the pipeline
  55211. * @param renderPipelineName The name of the pipeline to attach to
  55212. * @param cameras the camera to attach
  55213. * @param unique if the camera can be attached multiple times to the pipeline
  55214. */
  55215. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55216. /**
  55217. * Detaches a camera from the pipeline
  55218. * @param renderPipelineName The name of the pipeline to detach from
  55219. * @param cameras the camera to detach
  55220. */
  55221. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55222. /**
  55223. * Enables an effect by name on a pipeline
  55224. * @param renderPipelineName the name of the pipeline to enable the effect in
  55225. * @param renderEffectName the name of the effect to enable
  55226. * @param cameras the cameras that the effect should be enabled on
  55227. */
  55228. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55229. /**
  55230. * Disables an effect by name on a pipeline
  55231. * @param renderPipelineName the name of the pipeline to disable the effect in
  55232. * @param renderEffectName the name of the effect to disable
  55233. * @param cameras the cameras that the effect should be disabled on
  55234. */
  55235. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55236. /**
  55237. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55238. */
  55239. update(): void;
  55240. /** @hidden */ private _rebuild(): void;
  55241. /**
  55242. * Disposes of the manager and pipelines
  55243. */
  55244. dispose(): void;
  55245. }
  55246. }
  55247. declare module BABYLON {
  55248. interface Scene {
  55249. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55250. /**
  55251. * Gets the postprocess render pipeline manager
  55252. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55253. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55254. */
  55255. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55256. }
  55257. /**
  55258. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55259. */
  55260. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55261. /**
  55262. * The component name helpfull to identify the component in the list of scene components.
  55263. */
  55264. readonly name: string;
  55265. /**
  55266. * The scene the component belongs to.
  55267. */
  55268. scene: Scene;
  55269. /**
  55270. * Creates a new instance of the component for the given scene
  55271. * @param scene Defines the scene to register the component in
  55272. */
  55273. constructor(scene: Scene);
  55274. /**
  55275. * Registers the component in a given scene
  55276. */
  55277. register(): void;
  55278. /**
  55279. * Rebuilds the elements related to this component in case of
  55280. * context lost for instance.
  55281. */
  55282. rebuild(): void;
  55283. /**
  55284. * Disposes the component and the associated ressources
  55285. */
  55286. dispose(): void;
  55287. private _gatherRenderTargets;
  55288. }
  55289. }
  55290. declare module BABYLON {
  55291. /**
  55292. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55293. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55294. */
  55295. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55296. private _scene;
  55297. private _camerasToBeAttached;
  55298. /**
  55299. * ID of the sharpen post process,
  55300. */
  55301. private readonly SharpenPostProcessId;
  55302. /**
  55303. * @ignore
  55304. * ID of the image processing post process;
  55305. */
  55306. readonly ImageProcessingPostProcessId: string;
  55307. /**
  55308. * @ignore
  55309. * ID of the Fast Approximate Anti-Aliasing post process;
  55310. */
  55311. readonly FxaaPostProcessId: string;
  55312. /**
  55313. * ID of the chromatic aberration post process,
  55314. */
  55315. private readonly ChromaticAberrationPostProcessId;
  55316. /**
  55317. * ID of the grain post process
  55318. */
  55319. private readonly GrainPostProcessId;
  55320. /**
  55321. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55322. */
  55323. sharpen: SharpenPostProcess;
  55324. private _sharpenEffect;
  55325. private bloom;
  55326. /**
  55327. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55328. */
  55329. depthOfField: DepthOfFieldEffect;
  55330. /**
  55331. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55332. */
  55333. fxaa: FxaaPostProcess;
  55334. /**
  55335. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55336. */
  55337. imageProcessing: ImageProcessingPostProcess;
  55338. /**
  55339. * Chromatic aberration post process which will shift rgb colors in the image
  55340. */
  55341. chromaticAberration: ChromaticAberrationPostProcess;
  55342. private _chromaticAberrationEffect;
  55343. /**
  55344. * Grain post process which add noise to the image
  55345. */
  55346. grain: GrainPostProcess;
  55347. private _grainEffect;
  55348. /**
  55349. * Glow post process which adds a glow to emissive areas of the image
  55350. */
  55351. private _glowLayer;
  55352. /**
  55353. * Animations which can be used to tweak settings over a period of time
  55354. */
  55355. animations: Animation[];
  55356. private _imageProcessingConfigurationObserver;
  55357. private _sharpenEnabled;
  55358. private _bloomEnabled;
  55359. private _depthOfFieldEnabled;
  55360. private _depthOfFieldBlurLevel;
  55361. private _fxaaEnabled;
  55362. private _imageProcessingEnabled;
  55363. private _defaultPipelineTextureType;
  55364. private _bloomScale;
  55365. private _chromaticAberrationEnabled;
  55366. private _grainEnabled;
  55367. private _buildAllowed;
  55368. /**
  55369. * Gets active scene
  55370. */
  55371. readonly scene: Scene;
  55372. /**
  55373. * Enable or disable the sharpen process from the pipeline
  55374. */
  55375. sharpenEnabled: boolean;
  55376. private _resizeObserver;
  55377. private _hardwareScaleLevel;
  55378. private _bloomKernel;
  55379. /**
  55380. * Specifies the size of the bloom blur kernel, relative to the final output size
  55381. */
  55382. bloomKernel: number;
  55383. /**
  55384. * Specifies the weight of the bloom in the final rendering
  55385. */
  55386. private _bloomWeight;
  55387. /**
  55388. * Specifies the luma threshold for the area that will be blurred by the bloom
  55389. */
  55390. private _bloomThreshold;
  55391. private _hdr;
  55392. /**
  55393. * The strength of the bloom.
  55394. */
  55395. bloomWeight: number;
  55396. /**
  55397. * The strength of the bloom.
  55398. */
  55399. bloomThreshold: number;
  55400. /**
  55401. * The scale of the bloom, lower value will provide better performance.
  55402. */
  55403. bloomScale: number;
  55404. /**
  55405. * Enable or disable the bloom from the pipeline
  55406. */
  55407. bloomEnabled: boolean;
  55408. private _rebuildBloom;
  55409. /**
  55410. * If the depth of field is enabled.
  55411. */
  55412. depthOfFieldEnabled: boolean;
  55413. /**
  55414. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55415. */
  55416. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55417. /**
  55418. * If the anti aliasing is enabled.
  55419. */
  55420. fxaaEnabled: boolean;
  55421. private _samples;
  55422. /**
  55423. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55424. */
  55425. samples: number;
  55426. /**
  55427. * If image processing is enabled.
  55428. */
  55429. imageProcessingEnabled: boolean;
  55430. /**
  55431. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55432. */
  55433. glowLayerEnabled: boolean;
  55434. /**
  55435. * Gets the glow layer (or null if not defined)
  55436. */
  55437. readonly glowLayer: Nullable<GlowLayer>;
  55438. /**
  55439. * Enable or disable the chromaticAberration process from the pipeline
  55440. */
  55441. chromaticAberrationEnabled: boolean;
  55442. /**
  55443. * Enable or disable the grain process from the pipeline
  55444. */
  55445. grainEnabled: boolean;
  55446. /**
  55447. * @constructor
  55448. * @param name - The rendering pipeline name (default: "")
  55449. * @param hdr - If high dynamic range textures should be used (default: true)
  55450. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55451. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55452. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55453. */
  55454. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55455. /**
  55456. * Get the class name
  55457. * @returns "DefaultRenderingPipeline"
  55458. */
  55459. getClassName(): string;
  55460. /**
  55461. * Force the compilation of the entire pipeline.
  55462. */
  55463. prepare(): void;
  55464. private _hasCleared;
  55465. private _prevPostProcess;
  55466. private _prevPrevPostProcess;
  55467. private _setAutoClearAndTextureSharing;
  55468. private _depthOfFieldSceneObserver;
  55469. private _buildPipeline;
  55470. private _disposePostProcesses;
  55471. /**
  55472. * Adds a camera to the pipeline
  55473. * @param camera the camera to be added
  55474. */
  55475. addCamera(camera: Camera): void;
  55476. /**
  55477. * Removes a camera from the pipeline
  55478. * @param camera the camera to remove
  55479. */
  55480. removeCamera(camera: Camera): void;
  55481. /**
  55482. * Dispose of the pipeline and stop all post processes
  55483. */
  55484. dispose(): void;
  55485. /**
  55486. * Serialize the rendering pipeline (Used when exporting)
  55487. * @returns the serialized object
  55488. */
  55489. serialize(): any;
  55490. /**
  55491. * Parse the serialized pipeline
  55492. * @param source Source pipeline.
  55493. * @param scene The scene to load the pipeline to.
  55494. * @param rootUrl The URL of the serialized pipeline.
  55495. * @returns An instantiated pipeline from the serialized object.
  55496. */
  55497. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55498. }
  55499. }
  55500. declare module BABYLON {
  55501. /** @hidden */
  55502. export var lensHighlightsPixelShader: {
  55503. name: string;
  55504. shader: string;
  55505. };
  55506. }
  55507. declare module BABYLON {
  55508. /** @hidden */
  55509. export var depthOfFieldPixelShader: {
  55510. name: string;
  55511. shader: string;
  55512. };
  55513. }
  55514. declare module BABYLON {
  55515. /**
  55516. * BABYLON.JS Chromatic Aberration GLSL Shader
  55517. * Author: Olivier Guyot
  55518. * Separates very slightly R, G and B colors on the edges of the screen
  55519. * Inspired by Francois Tarlier & Martins Upitis
  55520. */
  55521. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55522. /**
  55523. * @ignore
  55524. * The chromatic aberration PostProcess id in the pipeline
  55525. */
  55526. LensChromaticAberrationEffect: string;
  55527. /**
  55528. * @ignore
  55529. * The highlights enhancing PostProcess id in the pipeline
  55530. */
  55531. HighlightsEnhancingEffect: string;
  55532. /**
  55533. * @ignore
  55534. * The depth-of-field PostProcess id in the pipeline
  55535. */
  55536. LensDepthOfFieldEffect: string;
  55537. private _scene;
  55538. private _depthTexture;
  55539. private _grainTexture;
  55540. private _chromaticAberrationPostProcess;
  55541. private _highlightsPostProcess;
  55542. private _depthOfFieldPostProcess;
  55543. private _edgeBlur;
  55544. private _grainAmount;
  55545. private _chromaticAberration;
  55546. private _distortion;
  55547. private _highlightsGain;
  55548. private _highlightsThreshold;
  55549. private _dofDistance;
  55550. private _dofAperture;
  55551. private _dofDarken;
  55552. private _dofPentagon;
  55553. private _blurNoise;
  55554. /**
  55555. * @constructor
  55556. *
  55557. * Effect parameters are as follow:
  55558. * {
  55559. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55560. * edge_blur: number; // from 0 to x (1 for realism)
  55561. * distortion: number; // from 0 to x (1 for realism)
  55562. * grain_amount: number; // from 0 to 1
  55563. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55564. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55565. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55566. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55567. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55568. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55569. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55570. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55571. * }
  55572. * Note: if an effect parameter is unset, effect is disabled
  55573. *
  55574. * @param name The rendering pipeline name
  55575. * @param parameters - An object containing all parameters (see above)
  55576. * @param scene The scene linked to this pipeline
  55577. * @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)
  55578. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55579. */
  55580. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55581. /**
  55582. * Get the class name
  55583. * @returns "LensRenderingPipeline"
  55584. */
  55585. getClassName(): string;
  55586. /**
  55587. * Gets associated scene
  55588. */
  55589. readonly scene: Scene;
  55590. /**
  55591. * Gets or sets the edge blur
  55592. */
  55593. edgeBlur: number;
  55594. /**
  55595. * Gets or sets the grain amount
  55596. */
  55597. grainAmount: number;
  55598. /**
  55599. * Gets or sets the chromatic aberration amount
  55600. */
  55601. chromaticAberration: number;
  55602. /**
  55603. * Gets or sets the depth of field aperture
  55604. */
  55605. dofAperture: number;
  55606. /**
  55607. * Gets or sets the edge distortion
  55608. */
  55609. edgeDistortion: number;
  55610. /**
  55611. * Gets or sets the depth of field distortion
  55612. */
  55613. dofDistortion: number;
  55614. /**
  55615. * Gets or sets the darken out of focus amount
  55616. */
  55617. darkenOutOfFocus: number;
  55618. /**
  55619. * Gets or sets a boolean indicating if blur noise is enabled
  55620. */
  55621. blurNoise: boolean;
  55622. /**
  55623. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55624. */
  55625. pentagonBokeh: boolean;
  55626. /**
  55627. * Gets or sets the highlight grain amount
  55628. */
  55629. highlightsGain: number;
  55630. /**
  55631. * Gets or sets the highlight threshold
  55632. */
  55633. highlightsThreshold: number;
  55634. /**
  55635. * Sets the amount of blur at the edges
  55636. * @param amount blur amount
  55637. */
  55638. setEdgeBlur(amount: number): void;
  55639. /**
  55640. * Sets edge blur to 0
  55641. */
  55642. disableEdgeBlur(): void;
  55643. /**
  55644. * Sets the amout of grain
  55645. * @param amount Amount of grain
  55646. */
  55647. setGrainAmount(amount: number): void;
  55648. /**
  55649. * Set grain amount to 0
  55650. */
  55651. disableGrain(): void;
  55652. /**
  55653. * Sets the chromatic aberration amount
  55654. * @param amount amount of chromatic aberration
  55655. */
  55656. setChromaticAberration(amount: number): void;
  55657. /**
  55658. * Sets chromatic aberration amount to 0
  55659. */
  55660. disableChromaticAberration(): void;
  55661. /**
  55662. * Sets the EdgeDistortion amount
  55663. * @param amount amount of EdgeDistortion
  55664. */
  55665. setEdgeDistortion(amount: number): void;
  55666. /**
  55667. * Sets edge distortion to 0
  55668. */
  55669. disableEdgeDistortion(): void;
  55670. /**
  55671. * Sets the FocusDistance amount
  55672. * @param amount amount of FocusDistance
  55673. */
  55674. setFocusDistance(amount: number): void;
  55675. /**
  55676. * Disables depth of field
  55677. */
  55678. disableDepthOfField(): void;
  55679. /**
  55680. * Sets the Aperture amount
  55681. * @param amount amount of Aperture
  55682. */
  55683. setAperture(amount: number): void;
  55684. /**
  55685. * Sets the DarkenOutOfFocus amount
  55686. * @param amount amount of DarkenOutOfFocus
  55687. */
  55688. setDarkenOutOfFocus(amount: number): void;
  55689. private _pentagonBokehIsEnabled;
  55690. /**
  55691. * Creates a pentagon bokeh effect
  55692. */
  55693. enablePentagonBokeh(): void;
  55694. /**
  55695. * Disables the pentagon bokeh effect
  55696. */
  55697. disablePentagonBokeh(): void;
  55698. /**
  55699. * Enables noise blur
  55700. */
  55701. enableNoiseBlur(): void;
  55702. /**
  55703. * Disables noise blur
  55704. */
  55705. disableNoiseBlur(): void;
  55706. /**
  55707. * Sets the HighlightsGain amount
  55708. * @param amount amount of HighlightsGain
  55709. */
  55710. setHighlightsGain(amount: number): void;
  55711. /**
  55712. * Sets the HighlightsThreshold amount
  55713. * @param amount amount of HighlightsThreshold
  55714. */
  55715. setHighlightsThreshold(amount: number): void;
  55716. /**
  55717. * Disables highlights
  55718. */
  55719. disableHighlights(): void;
  55720. /**
  55721. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55722. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55723. */
  55724. dispose(disableDepthRender?: boolean): void;
  55725. private _createChromaticAberrationPostProcess;
  55726. private _createHighlightsPostProcess;
  55727. private _createDepthOfFieldPostProcess;
  55728. private _createGrainTexture;
  55729. }
  55730. }
  55731. declare module BABYLON {
  55732. /** @hidden */
  55733. export var ssao2PixelShader: {
  55734. name: string;
  55735. shader: string;
  55736. };
  55737. }
  55738. declare module BABYLON {
  55739. /** @hidden */
  55740. export var ssaoCombinePixelShader: {
  55741. name: string;
  55742. shader: string;
  55743. };
  55744. }
  55745. declare module BABYLON {
  55746. /**
  55747. * Render pipeline to produce ssao effect
  55748. */
  55749. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55750. /**
  55751. * @ignore
  55752. * The PassPostProcess id in the pipeline that contains the original scene color
  55753. */
  55754. SSAOOriginalSceneColorEffect: string;
  55755. /**
  55756. * @ignore
  55757. * The SSAO PostProcess id in the pipeline
  55758. */
  55759. SSAORenderEffect: string;
  55760. /**
  55761. * @ignore
  55762. * The horizontal blur PostProcess id in the pipeline
  55763. */
  55764. SSAOBlurHRenderEffect: string;
  55765. /**
  55766. * @ignore
  55767. * The vertical blur PostProcess id in the pipeline
  55768. */
  55769. SSAOBlurVRenderEffect: string;
  55770. /**
  55771. * @ignore
  55772. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55773. */
  55774. SSAOCombineRenderEffect: string;
  55775. /**
  55776. * The output strength of the SSAO post-process. Default value is 1.0.
  55777. */
  55778. totalStrength: number;
  55779. /**
  55780. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55781. */
  55782. maxZ: number;
  55783. /**
  55784. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55785. */
  55786. minZAspect: number;
  55787. private _samples;
  55788. /**
  55789. * Number of samples used for the SSAO calculations. Default value is 8
  55790. */
  55791. samples: number;
  55792. private _textureSamples;
  55793. /**
  55794. * Number of samples to use for antialiasing
  55795. */
  55796. textureSamples: number;
  55797. /**
  55798. * Ratio object used for SSAO ratio and blur ratio
  55799. */
  55800. private _ratio;
  55801. /**
  55802. * Dynamically generated sphere sampler.
  55803. */
  55804. private _sampleSphere;
  55805. /**
  55806. * Blur filter offsets
  55807. */
  55808. private _samplerOffsets;
  55809. private _expensiveBlur;
  55810. /**
  55811. * If bilateral blur should be used
  55812. */
  55813. expensiveBlur: boolean;
  55814. /**
  55815. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55816. */
  55817. radius: number;
  55818. /**
  55819. * The base color of the SSAO post-process
  55820. * The final result is "base + ssao" between [0, 1]
  55821. */
  55822. base: number;
  55823. /**
  55824. * Support test.
  55825. */
  55826. static readonly IsSupported: boolean;
  55827. private _scene;
  55828. private _depthTexture;
  55829. private _normalTexture;
  55830. private _randomTexture;
  55831. private _originalColorPostProcess;
  55832. private _ssaoPostProcess;
  55833. private _blurHPostProcess;
  55834. private _blurVPostProcess;
  55835. private _ssaoCombinePostProcess;
  55836. private _firstUpdate;
  55837. /**
  55838. * Gets active scene
  55839. */
  55840. readonly scene: Scene;
  55841. /**
  55842. * @constructor
  55843. * @param name The rendering pipeline name
  55844. * @param scene The scene linked to this pipeline
  55845. * @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 }
  55846. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55847. */
  55848. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55849. /**
  55850. * Get the class name
  55851. * @returns "SSAO2RenderingPipeline"
  55852. */
  55853. getClassName(): string;
  55854. /**
  55855. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55856. */
  55857. dispose(disableGeometryBufferRenderer?: boolean): void;
  55858. private _createBlurPostProcess;
  55859. /** @hidden */ private _rebuild(): void;
  55860. private _bits;
  55861. private _radicalInverse_VdC;
  55862. private _hammersley;
  55863. private _hemisphereSample_uniform;
  55864. private _generateHemisphere;
  55865. private _createSSAOPostProcess;
  55866. private _createSSAOCombinePostProcess;
  55867. private _createRandomTexture;
  55868. /**
  55869. * Serialize the rendering pipeline (Used when exporting)
  55870. * @returns the serialized object
  55871. */
  55872. serialize(): any;
  55873. /**
  55874. * Parse the serialized pipeline
  55875. * @param source Source pipeline.
  55876. * @param scene The scene to load the pipeline to.
  55877. * @param rootUrl The URL of the serialized pipeline.
  55878. * @returns An instantiated pipeline from the serialized object.
  55879. */
  55880. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55881. }
  55882. }
  55883. declare module BABYLON {
  55884. /** @hidden */
  55885. export var ssaoPixelShader: {
  55886. name: string;
  55887. shader: string;
  55888. };
  55889. }
  55890. declare module BABYLON {
  55891. /**
  55892. * Render pipeline to produce ssao effect
  55893. */
  55894. export class SSAORenderingPipeline 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. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55926. */
  55927. radius: number;
  55928. /**
  55929. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55930. * Must not be equal to fallOff and superior to fallOff.
  55931. * Default value is 0.0075
  55932. */
  55933. area: number;
  55934. /**
  55935. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55936. * Must not be equal to area and inferior to area.
  55937. * Default value is 0.000001
  55938. */
  55939. fallOff: number;
  55940. /**
  55941. * The base color of the SSAO post-process
  55942. * The final result is "base + ssao" between [0, 1]
  55943. */
  55944. base: number;
  55945. private _scene;
  55946. private _depthTexture;
  55947. private _randomTexture;
  55948. private _originalColorPostProcess;
  55949. private _ssaoPostProcess;
  55950. private _blurHPostProcess;
  55951. private _blurVPostProcess;
  55952. private _ssaoCombinePostProcess;
  55953. private _firstUpdate;
  55954. /**
  55955. * Gets active scene
  55956. */
  55957. readonly scene: Scene;
  55958. /**
  55959. * @constructor
  55960. * @param name - The rendering pipeline name
  55961. * @param scene - The scene linked to this pipeline
  55962. * @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 }
  55963. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55964. */
  55965. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55966. /**
  55967. * Get the class name
  55968. * @returns "SSAORenderingPipeline"
  55969. */
  55970. getClassName(): string;
  55971. /**
  55972. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55973. */
  55974. dispose(disableDepthRender?: boolean): void;
  55975. private _createBlurPostProcess;
  55976. /** @hidden */ private _rebuild(): void;
  55977. private _createSSAOPostProcess;
  55978. private _createSSAOCombinePostProcess;
  55979. private _createRandomTexture;
  55980. }
  55981. }
  55982. declare module BABYLON {
  55983. /** @hidden */
  55984. export var standardPixelShader: {
  55985. name: string;
  55986. shader: string;
  55987. };
  55988. }
  55989. declare module BABYLON {
  55990. /**
  55991. * Standard rendering pipeline
  55992. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55993. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55994. */
  55995. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55996. /**
  55997. * Public members
  55998. */
  55999. /**
  56000. * Post-process which contains the original scene color before the pipeline applies all the effects
  56001. */
  56002. originalPostProcess: Nullable<PostProcess>;
  56003. /**
  56004. * Post-process used to down scale an image x4
  56005. */
  56006. downSampleX4PostProcess: Nullable<PostProcess>;
  56007. /**
  56008. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56009. */
  56010. brightPassPostProcess: Nullable<PostProcess>;
  56011. /**
  56012. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56013. */
  56014. blurHPostProcesses: PostProcess[];
  56015. /**
  56016. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56017. */
  56018. blurVPostProcesses: PostProcess[];
  56019. /**
  56020. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56021. */
  56022. textureAdderPostProcess: Nullable<PostProcess>;
  56023. /**
  56024. * Post-process used to create volumetric lighting effect
  56025. */
  56026. volumetricLightPostProcess: Nullable<PostProcess>;
  56027. /**
  56028. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56029. */
  56030. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56031. /**
  56032. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56033. */
  56034. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56035. /**
  56036. * Post-process used to merge the volumetric light effect and the real scene color
  56037. */
  56038. volumetricLightMergePostProces: Nullable<PostProcess>;
  56039. /**
  56040. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56041. */
  56042. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56043. /**
  56044. * Base post-process used to calculate the average luminance of the final image for HDR
  56045. */
  56046. luminancePostProcess: Nullable<PostProcess>;
  56047. /**
  56048. * Post-processes used to create down sample post-processes in order to get
  56049. * the average luminance of the final image for HDR
  56050. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56051. */
  56052. luminanceDownSamplePostProcesses: PostProcess[];
  56053. /**
  56054. * Post-process used to create a HDR effect (light adaptation)
  56055. */
  56056. hdrPostProcess: Nullable<PostProcess>;
  56057. /**
  56058. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56059. */
  56060. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56061. /**
  56062. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56063. */
  56064. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56065. /**
  56066. * Post-process used to merge the final HDR post-process and the real scene color
  56067. */
  56068. hdrFinalPostProcess: Nullable<PostProcess>;
  56069. /**
  56070. * Post-process used to create a lens flare effect
  56071. */
  56072. lensFlarePostProcess: Nullable<PostProcess>;
  56073. /**
  56074. * Post-process that merges the result of the lens flare post-process and the real scene color
  56075. */
  56076. lensFlareComposePostProcess: Nullable<PostProcess>;
  56077. /**
  56078. * Post-process used to create a motion blur effect
  56079. */
  56080. motionBlurPostProcess: Nullable<PostProcess>;
  56081. /**
  56082. * Post-process used to create a depth of field effect
  56083. */
  56084. depthOfFieldPostProcess: Nullable<PostProcess>;
  56085. /**
  56086. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56087. */
  56088. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56089. /**
  56090. * Represents the brightness threshold in order to configure the illuminated surfaces
  56091. */
  56092. brightThreshold: number;
  56093. /**
  56094. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56095. */
  56096. blurWidth: number;
  56097. /**
  56098. * Sets if the blur for highlighted surfaces must be only horizontal
  56099. */
  56100. horizontalBlur: boolean;
  56101. /**
  56102. * Gets the overall exposure used by the pipeline
  56103. */
  56104. /**
  56105. * Sets the overall exposure used by the pipeline
  56106. */
  56107. exposure: number;
  56108. /**
  56109. * Texture used typically to simulate "dirty" on camera lens
  56110. */
  56111. lensTexture: Nullable<Texture>;
  56112. /**
  56113. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56114. */
  56115. volumetricLightCoefficient: number;
  56116. /**
  56117. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56118. */
  56119. volumetricLightPower: number;
  56120. /**
  56121. * Used the set the blur intensity to smooth the volumetric lights
  56122. */
  56123. volumetricLightBlurScale: number;
  56124. /**
  56125. * Light (spot or directional) used to generate the volumetric lights rays
  56126. * The source light must have a shadow generate so the pipeline can get its
  56127. * depth map
  56128. */
  56129. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56130. /**
  56131. * For eye adaptation, represents the minimum luminance the eye can see
  56132. */
  56133. hdrMinimumLuminance: number;
  56134. /**
  56135. * For eye adaptation, represents the decrease luminance speed
  56136. */
  56137. hdrDecreaseRate: number;
  56138. /**
  56139. * For eye adaptation, represents the increase luminance speed
  56140. */
  56141. hdrIncreaseRate: number;
  56142. /**
  56143. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56144. */
  56145. /**
  56146. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56147. */
  56148. hdrAutoExposure: boolean;
  56149. /**
  56150. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56151. */
  56152. lensColorTexture: Nullable<Texture>;
  56153. /**
  56154. * The overall strengh for the lens flare effect
  56155. */
  56156. lensFlareStrength: number;
  56157. /**
  56158. * Dispersion coefficient for lens flare ghosts
  56159. */
  56160. lensFlareGhostDispersal: number;
  56161. /**
  56162. * Main lens flare halo width
  56163. */
  56164. lensFlareHaloWidth: number;
  56165. /**
  56166. * Based on the lens distortion effect, defines how much the lens flare result
  56167. * is distorted
  56168. */
  56169. lensFlareDistortionStrength: number;
  56170. /**
  56171. * Lens star texture must be used to simulate rays on the flares and is available
  56172. * in the documentation
  56173. */
  56174. lensStarTexture: Nullable<Texture>;
  56175. /**
  56176. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56177. * flare effect by taking account of the dirt texture
  56178. */
  56179. lensFlareDirtTexture: Nullable<Texture>;
  56180. /**
  56181. * Represents the focal length for the depth of field effect
  56182. */
  56183. depthOfFieldDistance: number;
  56184. /**
  56185. * Represents the blur intensity for the blurred part of the depth of field effect
  56186. */
  56187. depthOfFieldBlurWidth: number;
  56188. /**
  56189. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56190. */
  56191. /**
  56192. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56193. */
  56194. motionStrength: number;
  56195. /**
  56196. * Gets wether or not the motion blur post-process is object based or screen based.
  56197. */
  56198. /**
  56199. * Sets wether or not the motion blur post-process should be object based or screen based
  56200. */
  56201. objectBasedMotionBlur: boolean;
  56202. /**
  56203. * List of animations for the pipeline (IAnimatable implementation)
  56204. */
  56205. animations: Animation[];
  56206. /**
  56207. * Private members
  56208. */
  56209. private _scene;
  56210. private _currentDepthOfFieldSource;
  56211. private _basePostProcess;
  56212. private _fixedExposure;
  56213. private _currentExposure;
  56214. private _hdrAutoExposure;
  56215. private _hdrCurrentLuminance;
  56216. private _motionStrength;
  56217. private _isObjectBasedMotionBlur;
  56218. private _floatTextureType;
  56219. private _ratio;
  56220. private _bloomEnabled;
  56221. private _depthOfFieldEnabled;
  56222. private _vlsEnabled;
  56223. private _lensFlareEnabled;
  56224. private _hdrEnabled;
  56225. private _motionBlurEnabled;
  56226. private _fxaaEnabled;
  56227. private _motionBlurSamples;
  56228. private _volumetricLightStepsCount;
  56229. private _samples;
  56230. /**
  56231. * @ignore
  56232. * Specifies if the bloom pipeline is enabled
  56233. */
  56234. BloomEnabled: boolean;
  56235. /**
  56236. * @ignore
  56237. * Specifies if the depth of field pipeline is enabed
  56238. */
  56239. DepthOfFieldEnabled: boolean;
  56240. /**
  56241. * @ignore
  56242. * Specifies if the lens flare pipeline is enabed
  56243. */
  56244. LensFlareEnabled: boolean;
  56245. /**
  56246. * @ignore
  56247. * Specifies if the HDR pipeline is enabled
  56248. */
  56249. HDREnabled: boolean;
  56250. /**
  56251. * @ignore
  56252. * Specifies if the volumetric lights scattering effect is enabled
  56253. */
  56254. VLSEnabled: boolean;
  56255. /**
  56256. * @ignore
  56257. * Specifies if the motion blur effect is enabled
  56258. */
  56259. MotionBlurEnabled: boolean;
  56260. /**
  56261. * Specifies if anti-aliasing is enabled
  56262. */
  56263. fxaaEnabled: boolean;
  56264. /**
  56265. * Specifies the number of steps used to calculate the volumetric lights
  56266. * Typically in interval [50, 200]
  56267. */
  56268. volumetricLightStepsCount: number;
  56269. /**
  56270. * Specifies the number of samples used for the motion blur effect
  56271. * Typically in interval [16, 64]
  56272. */
  56273. motionBlurSamples: number;
  56274. /**
  56275. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56276. */
  56277. samples: number;
  56278. /**
  56279. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56280. * @constructor
  56281. * @param name The rendering pipeline name
  56282. * @param scene The scene linked to this pipeline
  56283. * @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)
  56284. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56285. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56286. */
  56287. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56288. private _buildPipeline;
  56289. private _createDownSampleX4PostProcess;
  56290. private _createBrightPassPostProcess;
  56291. private _createBlurPostProcesses;
  56292. private _createTextureAdderPostProcess;
  56293. private _createVolumetricLightPostProcess;
  56294. private _createLuminancePostProcesses;
  56295. private _createHdrPostProcess;
  56296. private _createLensFlarePostProcess;
  56297. private _createDepthOfFieldPostProcess;
  56298. private _createMotionBlurPostProcess;
  56299. private _getDepthTexture;
  56300. private _disposePostProcesses;
  56301. /**
  56302. * Dispose of the pipeline and stop all post processes
  56303. */
  56304. dispose(): void;
  56305. /**
  56306. * Serialize the rendering pipeline (Used when exporting)
  56307. * @returns the serialized object
  56308. */
  56309. serialize(): any;
  56310. /**
  56311. * Parse the serialized pipeline
  56312. * @param source Source pipeline.
  56313. * @param scene The scene to load the pipeline to.
  56314. * @param rootUrl The URL of the serialized pipeline.
  56315. * @returns An instantiated pipeline from the serialized object.
  56316. */
  56317. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56318. /**
  56319. * Luminance steps
  56320. */
  56321. static LuminanceSteps: number;
  56322. }
  56323. }
  56324. declare module BABYLON {
  56325. /** @hidden */
  56326. export var tonemapPixelShader: {
  56327. name: string;
  56328. shader: string;
  56329. };
  56330. }
  56331. declare module BABYLON {
  56332. /** Defines operator used for tonemapping */
  56333. export enum TonemappingOperator {
  56334. /** Hable */
  56335. Hable = 0,
  56336. /** Reinhard */
  56337. Reinhard = 1,
  56338. /** HejiDawson */
  56339. HejiDawson = 2,
  56340. /** Photographic */
  56341. Photographic = 3
  56342. }
  56343. /**
  56344. * Defines a post process to apply tone mapping
  56345. */
  56346. export class TonemapPostProcess extends PostProcess {
  56347. private _operator;
  56348. /** Defines the required exposure adjustement */
  56349. exposureAdjustment: number;
  56350. /**
  56351. * Creates a new TonemapPostProcess
  56352. * @param name defines the name of the postprocess
  56353. * @param _operator defines the operator to use
  56354. * @param exposureAdjustment defines the required exposure adjustement
  56355. * @param camera defines the camera to use (can be null)
  56356. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56357. * @param engine defines the hosting engine (can be ignore if camera is set)
  56358. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56359. */
  56360. constructor(name: string, _operator: TonemappingOperator,
  56361. /** Defines the required exposure adjustement */
  56362. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56363. }
  56364. }
  56365. declare module BABYLON {
  56366. /** @hidden */
  56367. export var depthVertexShader: {
  56368. name: string;
  56369. shader: string;
  56370. };
  56371. }
  56372. declare module BABYLON {
  56373. /** @hidden */
  56374. export var volumetricLightScatteringPixelShader: {
  56375. name: string;
  56376. shader: string;
  56377. };
  56378. }
  56379. declare module BABYLON {
  56380. /** @hidden */
  56381. export var volumetricLightScatteringPassPixelShader: {
  56382. name: string;
  56383. shader: string;
  56384. };
  56385. }
  56386. declare module BABYLON {
  56387. /**
  56388. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56389. */
  56390. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56391. private _volumetricLightScatteringPass;
  56392. private _volumetricLightScatteringRTT;
  56393. private _viewPort;
  56394. private _screenCoordinates;
  56395. private _cachedDefines;
  56396. /**
  56397. * If not undefined, the mesh position is computed from the attached node position
  56398. */
  56399. attachedNode: {
  56400. position: Vector3;
  56401. };
  56402. /**
  56403. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56404. */
  56405. customMeshPosition: Vector3;
  56406. /**
  56407. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56408. */
  56409. useCustomMeshPosition: boolean;
  56410. /**
  56411. * If the post-process should inverse the light scattering direction
  56412. */
  56413. invert: boolean;
  56414. /**
  56415. * The internal mesh used by the post-process
  56416. */
  56417. mesh: Mesh;
  56418. /**
  56419. * @hidden
  56420. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56421. */
  56422. useDiffuseColor: boolean;
  56423. /**
  56424. * Array containing the excluded meshes not rendered in the internal pass
  56425. */
  56426. excludedMeshes: AbstractMesh[];
  56427. /**
  56428. * Controls the overall intensity of the post-process
  56429. */
  56430. exposure: number;
  56431. /**
  56432. * Dissipates each sample's contribution in range [0, 1]
  56433. */
  56434. decay: number;
  56435. /**
  56436. * Controls the overall intensity of each sample
  56437. */
  56438. weight: number;
  56439. /**
  56440. * Controls the density of each sample
  56441. */
  56442. density: number;
  56443. /**
  56444. * @constructor
  56445. * @param name The post-process name
  56446. * @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)
  56447. * @param camera The camera that the post-process will be attached to
  56448. * @param mesh The mesh used to create the light scattering
  56449. * @param samples The post-process quality, default 100
  56450. * @param samplingModeThe post-process filtering mode
  56451. * @param engine The babylon engine
  56452. * @param reusable If the post-process is reusable
  56453. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56454. */
  56455. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56456. /**
  56457. * Returns the string "VolumetricLightScatteringPostProcess"
  56458. * @returns "VolumetricLightScatteringPostProcess"
  56459. */
  56460. getClassName(): string;
  56461. private _isReady;
  56462. /**
  56463. * Sets the new light position for light scattering effect
  56464. * @param position The new custom light position
  56465. */
  56466. setCustomMeshPosition(position: Vector3): void;
  56467. /**
  56468. * Returns the light position for light scattering effect
  56469. * @return Vector3 The custom light position
  56470. */
  56471. getCustomMeshPosition(): Vector3;
  56472. /**
  56473. * Disposes the internal assets and detaches the post-process from the camera
  56474. */
  56475. dispose(camera: Camera): void;
  56476. /**
  56477. * Returns the render target texture used by the post-process
  56478. * @return the render target texture used by the post-process
  56479. */
  56480. getPass(): RenderTargetTexture;
  56481. private _meshExcluded;
  56482. private _createPass;
  56483. private _updateMeshScreenCoordinates;
  56484. /**
  56485. * Creates a default mesh for the Volumeric Light Scattering post-process
  56486. * @param name The mesh name
  56487. * @param scene The scene where to create the mesh
  56488. * @return the default mesh
  56489. */
  56490. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56491. }
  56492. }
  56493. declare module BABYLON {
  56494. interface Scene {
  56495. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  56496. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  56497. /**
  56498. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56499. */
  56500. forceShowBoundingBoxes: boolean;
  56501. /**
  56502. * Gets the bounding box renderer associated with the scene
  56503. * @returns a BoundingBoxRenderer
  56504. */
  56505. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56506. }
  56507. interface AbstractMesh {
  56508. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  56509. /**
  56510. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56511. */
  56512. showBoundingBox: boolean;
  56513. }
  56514. /**
  56515. * Component responsible of rendering the bounding box of the meshes in a scene.
  56516. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56517. */
  56518. export class BoundingBoxRenderer implements ISceneComponent {
  56519. /**
  56520. * The component name helpfull to identify the component in the list of scene components.
  56521. */
  56522. readonly name: string;
  56523. /**
  56524. * The scene the component belongs to.
  56525. */
  56526. scene: Scene;
  56527. /**
  56528. * Color of the bounding box lines placed in front of an object
  56529. */
  56530. frontColor: Color3;
  56531. /**
  56532. * Color of the bounding box lines placed behind an object
  56533. */
  56534. backColor: Color3;
  56535. /**
  56536. * Defines if the renderer should show the back lines or not
  56537. */
  56538. showBackLines: boolean;
  56539. /**
  56540. * @hidden
  56541. */
  56542. renderList: SmartArray<BoundingBox>;
  56543. private _colorShader;
  56544. private _vertexBuffers;
  56545. private _indexBuffer;
  56546. private _fillIndexBuffer;
  56547. private _fillIndexData;
  56548. /**
  56549. * Instantiates a new bounding box renderer in a scene.
  56550. * @param scene the scene the renderer renders in
  56551. */
  56552. constructor(scene: Scene);
  56553. /**
  56554. * Registers the component in a given scene
  56555. */
  56556. register(): void;
  56557. private _evaluateSubMesh;
  56558. private _activeMesh;
  56559. private _prepareRessources;
  56560. private _createIndexBuffer;
  56561. /**
  56562. * Rebuilds the elements related to this component in case of
  56563. * context lost for instance.
  56564. */
  56565. rebuild(): void;
  56566. /**
  56567. * @hidden
  56568. */
  56569. reset(): void;
  56570. /**
  56571. * Render the bounding boxes of a specific rendering group
  56572. * @param renderingGroupId defines the rendering group to render
  56573. */
  56574. render(renderingGroupId: number): void;
  56575. /**
  56576. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56577. * @param mesh Define the mesh to render the occlusion bounding box for
  56578. */
  56579. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56580. /**
  56581. * Dispose and release the resources attached to this renderer.
  56582. */
  56583. dispose(): void;
  56584. }
  56585. }
  56586. declare module BABYLON {
  56587. /** @hidden */
  56588. export var depthPixelShader: {
  56589. name: string;
  56590. shader: string;
  56591. };
  56592. }
  56593. declare module BABYLON {
  56594. /**
  56595. * This represents a depth renderer in Babylon.
  56596. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56597. */
  56598. export class DepthRenderer {
  56599. private _scene;
  56600. private _depthMap;
  56601. private _effect;
  56602. private _cachedDefines;
  56603. private _camera;
  56604. /**
  56605. * Specifiess that the depth renderer will only be used within
  56606. * the camera it is created for.
  56607. * This can help forcing its rendering during the camera processing.
  56608. */
  56609. useOnlyInActiveCamera: boolean;
  56610. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  56611. /**
  56612. * Instantiates a depth renderer
  56613. * @param scene The scene the renderer belongs to
  56614. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56615. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56616. */
  56617. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56618. /**
  56619. * Creates the depth rendering effect and checks if the effect is ready.
  56620. * @param subMesh The submesh to be used to render the depth map of
  56621. * @param useInstances If multiple world instances should be used
  56622. * @returns if the depth renderer is ready to render the depth map
  56623. */
  56624. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56625. /**
  56626. * Gets the texture which the depth map will be written to.
  56627. * @returns The depth map texture
  56628. */
  56629. getDepthMap(): RenderTargetTexture;
  56630. /**
  56631. * Disposes of the depth renderer.
  56632. */
  56633. dispose(): void;
  56634. }
  56635. }
  56636. declare module BABYLON {
  56637. interface Scene {
  56638. /** @hidden (Backing field) */ private _depthRenderer: {
  56639. [id: string]: DepthRenderer;
  56640. };
  56641. /**
  56642. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56643. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56644. * @returns the created depth renderer
  56645. */
  56646. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56647. /**
  56648. * Disables a depth renderer for a given camera
  56649. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56650. */
  56651. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56652. }
  56653. /**
  56654. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56655. * in several rendering techniques.
  56656. */
  56657. export class DepthRendererSceneComponent implements ISceneComponent {
  56658. /**
  56659. * The component name helpfull to identify the component in the list of scene components.
  56660. */
  56661. readonly name: string;
  56662. /**
  56663. * The scene the component belongs to.
  56664. */
  56665. scene: Scene;
  56666. /**
  56667. * Creates a new instance of the component for the given scene
  56668. * @param scene Defines the scene to register the component in
  56669. */
  56670. constructor(scene: Scene);
  56671. /**
  56672. * Registers the component in a given scene
  56673. */
  56674. register(): void;
  56675. /**
  56676. * Rebuilds the elements related to this component in case of
  56677. * context lost for instance.
  56678. */
  56679. rebuild(): void;
  56680. /**
  56681. * Disposes the component and the associated ressources
  56682. */
  56683. dispose(): void;
  56684. private _gatherRenderTargets;
  56685. private _gatherActiveCameraRenderTargets;
  56686. }
  56687. }
  56688. declare module BABYLON {
  56689. /** @hidden */
  56690. export var outlinePixelShader: {
  56691. name: string;
  56692. shader: string;
  56693. };
  56694. }
  56695. declare module BABYLON {
  56696. /** @hidden */
  56697. export var outlineVertexShader: {
  56698. name: string;
  56699. shader: string;
  56700. };
  56701. }
  56702. declare module BABYLON {
  56703. interface Scene {
  56704. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  56705. /**
  56706. * Gets the outline renderer associated with the scene
  56707. * @returns a OutlineRenderer
  56708. */
  56709. getOutlineRenderer(): OutlineRenderer;
  56710. }
  56711. interface AbstractMesh {
  56712. /** @hidden (Backing field) */ private _renderOutline: boolean;
  56713. /**
  56714. * Gets or sets a boolean indicating if the outline must be rendered as well
  56715. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56716. */
  56717. renderOutline: boolean;
  56718. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  56719. /**
  56720. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56721. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56722. */
  56723. renderOverlay: boolean;
  56724. }
  56725. /**
  56726. * This class is responsible to draw bothe outline/overlay of meshes.
  56727. * It should not be used directly but through the available method on mesh.
  56728. */
  56729. export class OutlineRenderer implements ISceneComponent {
  56730. /**
  56731. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56732. */
  56733. private static _StencilReference;
  56734. /**
  56735. * The name of the component. Each component must have a unique name.
  56736. */
  56737. name: string;
  56738. /**
  56739. * The scene the component belongs to.
  56740. */
  56741. scene: Scene;
  56742. /**
  56743. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56744. */
  56745. zOffset: number;
  56746. private _engine;
  56747. private _effect;
  56748. private _cachedDefines;
  56749. private _savedDepthWrite;
  56750. /**
  56751. * Instantiates a new outline renderer. (There could be only one per scene).
  56752. * @param scene Defines the scene it belongs to
  56753. */
  56754. constructor(scene: Scene);
  56755. /**
  56756. * Register the component to one instance of a scene.
  56757. */
  56758. register(): void;
  56759. /**
  56760. * Rebuilds the elements related to this component in case of
  56761. * context lost for instance.
  56762. */
  56763. rebuild(): void;
  56764. /**
  56765. * Disposes the component and the associated ressources.
  56766. */
  56767. dispose(): void;
  56768. /**
  56769. * Renders the outline in the canvas.
  56770. * @param subMesh Defines the sumesh to render
  56771. * @param batch Defines the batch of meshes in case of instances
  56772. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56773. */
  56774. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56775. /**
  56776. * Returns whether or not the outline renderer is ready for a given submesh.
  56777. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56778. * @param subMesh Defines the submesh to check readyness for
  56779. * @param useInstances Defines wheter wee are trying to render instances or not
  56780. * @returns true if ready otherwise false
  56781. */
  56782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56783. private _beforeRenderingMesh;
  56784. private _afterRenderingMesh;
  56785. }
  56786. }
  56787. declare module BABYLON {
  56788. /**
  56789. * Defines the list of states available for a task inside a AssetsManager
  56790. */
  56791. export enum AssetTaskState {
  56792. /**
  56793. * Initialization
  56794. */
  56795. INIT = 0,
  56796. /**
  56797. * Running
  56798. */
  56799. RUNNING = 1,
  56800. /**
  56801. * Done
  56802. */
  56803. DONE = 2,
  56804. /**
  56805. * Error
  56806. */
  56807. ERROR = 3
  56808. }
  56809. /**
  56810. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56811. */
  56812. export abstract class AbstractAssetTask {
  56813. /**
  56814. * Task name
  56815. */ name: string;
  56816. /**
  56817. * Callback called when the task is successful
  56818. */
  56819. onSuccess: (task: any) => void;
  56820. /**
  56821. * Callback called when the task is not successful
  56822. */
  56823. onError: (task: any, message?: string, exception?: any) => void;
  56824. /**
  56825. * Creates a new AssetsManager
  56826. * @param name defines the name of the task
  56827. */
  56828. constructor(
  56829. /**
  56830. * Task name
  56831. */ name: string);
  56832. private _isCompleted;
  56833. private _taskState;
  56834. private _errorObject;
  56835. /**
  56836. * Get if the task is completed
  56837. */
  56838. readonly isCompleted: boolean;
  56839. /**
  56840. * Gets the current state of the task
  56841. */
  56842. readonly taskState: AssetTaskState;
  56843. /**
  56844. * Gets the current error object (if task is in error)
  56845. */
  56846. readonly errorObject: {
  56847. message?: string;
  56848. exception?: any;
  56849. };
  56850. /**
  56851. * Internal only
  56852. * @hidden
  56853. */ private _setErrorObject(message?: string, exception?: any): void;
  56854. /**
  56855. * Execute the current task
  56856. * @param scene defines the scene where you want your assets to be loaded
  56857. * @param onSuccess is a callback called when the task is successfully executed
  56858. * @param onError is a callback called if an error occurs
  56859. */
  56860. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56861. /**
  56862. * Execute the current task
  56863. * @param scene defines the scene where you want your assets to be loaded
  56864. * @param onSuccess is a callback called when the task is successfully executed
  56865. * @param onError is a callback called if an error occurs
  56866. */
  56867. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56868. /**
  56869. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56870. * This can be used with failed tasks that have the reason for failure fixed.
  56871. */
  56872. reset(): void;
  56873. private onErrorCallback;
  56874. private onDoneCallback;
  56875. }
  56876. /**
  56877. * Define the interface used by progress events raised during assets loading
  56878. */
  56879. export interface IAssetsProgressEvent {
  56880. /**
  56881. * Defines the number of remaining tasks to process
  56882. */
  56883. remainingCount: number;
  56884. /**
  56885. * Defines the total number of tasks
  56886. */
  56887. totalCount: number;
  56888. /**
  56889. * Defines the task that was just processed
  56890. */
  56891. task: AbstractAssetTask;
  56892. }
  56893. /**
  56894. * Class used to share progress information about assets loading
  56895. */
  56896. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56897. /**
  56898. * Defines the number of remaining tasks to process
  56899. */
  56900. remainingCount: number;
  56901. /**
  56902. * Defines the total number of tasks
  56903. */
  56904. totalCount: number;
  56905. /**
  56906. * Defines the task that was just processed
  56907. */
  56908. task: AbstractAssetTask;
  56909. /**
  56910. * Creates a AssetsProgressEvent
  56911. * @param remainingCount defines the number of remaining tasks to process
  56912. * @param totalCount defines the total number of tasks
  56913. * @param task defines the task that was just processed
  56914. */
  56915. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56916. }
  56917. /**
  56918. * Define a task used by AssetsManager to load meshes
  56919. */
  56920. export class MeshAssetTask extends AbstractAssetTask {
  56921. /**
  56922. * Defines the name of the task
  56923. */
  56924. name: string;
  56925. /**
  56926. * Defines the list of mesh's names you want to load
  56927. */
  56928. meshesNames: any;
  56929. /**
  56930. * Defines the root url to use as a base to load your meshes and associated resources
  56931. */
  56932. rootUrl: string;
  56933. /**
  56934. * Defines the filename of the scene to load from
  56935. */
  56936. sceneFilename: string;
  56937. /**
  56938. * Gets the list of loaded meshes
  56939. */
  56940. loadedMeshes: Array<AbstractMesh>;
  56941. /**
  56942. * Gets the list of loaded particle systems
  56943. */
  56944. loadedParticleSystems: Array<IParticleSystem>;
  56945. /**
  56946. * Gets the list of loaded skeletons
  56947. */
  56948. loadedSkeletons: Array<Skeleton>;
  56949. /**
  56950. * Gets the list of loaded animation groups
  56951. */
  56952. loadedAnimationGroups: Array<AnimationGroup>;
  56953. /**
  56954. * Callback called when the task is successful
  56955. */
  56956. onSuccess: (task: MeshAssetTask) => void;
  56957. /**
  56958. * Callback called when the task is successful
  56959. */
  56960. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56961. /**
  56962. * Creates a new MeshAssetTask
  56963. * @param name defines the name of the task
  56964. * @param meshesNames defines the list of mesh's names you want to load
  56965. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56966. * @param sceneFilename defines the filename of the scene to load from
  56967. */
  56968. constructor(
  56969. /**
  56970. * Defines the name of the task
  56971. */
  56972. name: string,
  56973. /**
  56974. * Defines the list of mesh's names you want to load
  56975. */
  56976. meshesNames: any,
  56977. /**
  56978. * Defines the root url to use as a base to load your meshes and associated resources
  56979. */
  56980. rootUrl: string,
  56981. /**
  56982. * Defines the filename of the scene to load from
  56983. */
  56984. sceneFilename: string);
  56985. /**
  56986. * Execute the current task
  56987. * @param scene defines the scene where you want your assets to be loaded
  56988. * @param onSuccess is a callback called when the task is successfully executed
  56989. * @param onError is a callback called if an error occurs
  56990. */
  56991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56992. }
  56993. /**
  56994. * Define a task used by AssetsManager to load text content
  56995. */
  56996. export class TextFileAssetTask extends AbstractAssetTask {
  56997. /**
  56998. * Defines the name of the task
  56999. */
  57000. name: string;
  57001. /**
  57002. * Defines the location of the file to load
  57003. */
  57004. url: string;
  57005. /**
  57006. * Gets the loaded text string
  57007. */
  57008. text: string;
  57009. /**
  57010. * Callback called when the task is successful
  57011. */
  57012. onSuccess: (task: TextFileAssetTask) => void;
  57013. /**
  57014. * Callback called when the task is successful
  57015. */
  57016. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57017. /**
  57018. * Creates a new TextFileAssetTask object
  57019. * @param name defines the name of the task
  57020. * @param url defines the location of the file to load
  57021. */
  57022. constructor(
  57023. /**
  57024. * Defines the name of the task
  57025. */
  57026. name: string,
  57027. /**
  57028. * Defines the location of the file to load
  57029. */
  57030. url: string);
  57031. /**
  57032. * Execute the current task
  57033. * @param scene defines the scene where you want your assets to be loaded
  57034. * @param onSuccess is a callback called when the task is successfully executed
  57035. * @param onError is a callback called if an error occurs
  57036. */
  57037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57038. }
  57039. /**
  57040. * Define a task used by AssetsManager to load binary data
  57041. */
  57042. export class BinaryFileAssetTask extends AbstractAssetTask {
  57043. /**
  57044. * Defines the name of the task
  57045. */
  57046. name: string;
  57047. /**
  57048. * Defines the location of the file to load
  57049. */
  57050. url: string;
  57051. /**
  57052. * Gets the lodaded data (as an array buffer)
  57053. */
  57054. data: ArrayBuffer;
  57055. /**
  57056. * Callback called when the task is successful
  57057. */
  57058. onSuccess: (task: BinaryFileAssetTask) => void;
  57059. /**
  57060. * Callback called when the task is successful
  57061. */
  57062. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57063. /**
  57064. * Creates a new BinaryFileAssetTask object
  57065. * @param name defines the name of the new task
  57066. * @param url defines the location of the file to load
  57067. */
  57068. constructor(
  57069. /**
  57070. * Defines the name of the task
  57071. */
  57072. name: string,
  57073. /**
  57074. * Defines the location of the file to load
  57075. */
  57076. url: string);
  57077. /**
  57078. * Execute the current task
  57079. * @param scene defines the scene where you want your assets to be loaded
  57080. * @param onSuccess is a callback called when the task is successfully executed
  57081. * @param onError is a callback called if an error occurs
  57082. */
  57083. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57084. }
  57085. /**
  57086. * Define a task used by AssetsManager to load images
  57087. */
  57088. export class ImageAssetTask extends AbstractAssetTask {
  57089. /**
  57090. * Defines the name of the task
  57091. */
  57092. name: string;
  57093. /**
  57094. * Defines the location of the image to load
  57095. */
  57096. url: string;
  57097. /**
  57098. * Gets the loaded images
  57099. */
  57100. image: HTMLImageElement;
  57101. /**
  57102. * Callback called when the task is successful
  57103. */
  57104. onSuccess: (task: ImageAssetTask) => void;
  57105. /**
  57106. * Callback called when the task is successful
  57107. */
  57108. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57109. /**
  57110. * Creates a new ImageAssetTask
  57111. * @param name defines the name of the task
  57112. * @param url defines the location of the image to load
  57113. */
  57114. constructor(
  57115. /**
  57116. * Defines the name of the task
  57117. */
  57118. name: string,
  57119. /**
  57120. * Defines the location of the image to load
  57121. */
  57122. url: string);
  57123. /**
  57124. * Execute the current task
  57125. * @param scene defines the scene where you want your assets to be loaded
  57126. * @param onSuccess is a callback called when the task is successfully executed
  57127. * @param onError is a callback called if an error occurs
  57128. */
  57129. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57130. }
  57131. /**
  57132. * Defines the interface used by texture loading tasks
  57133. */
  57134. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57135. /**
  57136. * Gets the loaded texture
  57137. */
  57138. texture: TEX;
  57139. }
  57140. /**
  57141. * Define a task used by AssetsManager to load 2D textures
  57142. */
  57143. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57144. /**
  57145. * Defines the name of the task
  57146. */
  57147. name: string;
  57148. /**
  57149. * Defines the location of the file to load
  57150. */
  57151. url: string;
  57152. /**
  57153. * Defines if mipmap should not be generated (default is false)
  57154. */
  57155. noMipmap?: boolean | undefined;
  57156. /**
  57157. * Defines if texture must be inverted on Y axis (default is false)
  57158. */
  57159. invertY?: boolean | undefined;
  57160. /**
  57161. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57162. */
  57163. samplingMode: number;
  57164. /**
  57165. * Gets the loaded texture
  57166. */
  57167. texture: Texture;
  57168. /**
  57169. * Callback called when the task is successful
  57170. */
  57171. onSuccess: (task: TextureAssetTask) => void;
  57172. /**
  57173. * Callback called when the task is successful
  57174. */
  57175. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57176. /**
  57177. * Creates a new TextureAssetTask object
  57178. * @param name defines the name of the task
  57179. * @param url defines the location of the file to load
  57180. * @param noMipmap defines if mipmap should not be generated (default is false)
  57181. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57182. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57183. */
  57184. constructor(
  57185. /**
  57186. * Defines the name of the task
  57187. */
  57188. name: string,
  57189. /**
  57190. * Defines the location of the file to load
  57191. */
  57192. url: string,
  57193. /**
  57194. * Defines if mipmap should not be generated (default is false)
  57195. */
  57196. noMipmap?: boolean | undefined,
  57197. /**
  57198. * Defines if texture must be inverted on Y axis (default is false)
  57199. */
  57200. invertY?: boolean | undefined,
  57201. /**
  57202. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57203. */
  57204. samplingMode?: number);
  57205. /**
  57206. * Execute the current task
  57207. * @param scene defines the scene where you want your assets to be loaded
  57208. * @param onSuccess is a callback called when the task is successfully executed
  57209. * @param onError is a callback called if an error occurs
  57210. */
  57211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57212. }
  57213. /**
  57214. * Define a task used by AssetsManager to load cube textures
  57215. */
  57216. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57217. /**
  57218. * Defines the name of the task
  57219. */
  57220. name: string;
  57221. /**
  57222. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57223. */
  57224. url: string;
  57225. /**
  57226. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57227. */
  57228. extensions?: string[] | undefined;
  57229. /**
  57230. * Defines if mipmaps should not be generated (default is false)
  57231. */
  57232. noMipmap?: boolean | undefined;
  57233. /**
  57234. * Defines the explicit list of files (undefined by default)
  57235. */
  57236. files?: string[] | undefined;
  57237. /**
  57238. * Gets the loaded texture
  57239. */
  57240. texture: CubeTexture;
  57241. /**
  57242. * Callback called when the task is successful
  57243. */
  57244. onSuccess: (task: CubeTextureAssetTask) => void;
  57245. /**
  57246. * Callback called when the task is successful
  57247. */
  57248. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57249. /**
  57250. * Creates a new CubeTextureAssetTask
  57251. * @param name defines the name of the task
  57252. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57253. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57254. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57255. * @param files defines the explicit list of files (undefined by default)
  57256. */
  57257. constructor(
  57258. /**
  57259. * Defines the name of the task
  57260. */
  57261. name: string,
  57262. /**
  57263. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57264. */
  57265. url: string,
  57266. /**
  57267. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57268. */
  57269. extensions?: string[] | undefined,
  57270. /**
  57271. * Defines if mipmaps should not be generated (default is false)
  57272. */
  57273. noMipmap?: boolean | undefined,
  57274. /**
  57275. * Defines the explicit list of files (undefined by default)
  57276. */
  57277. files?: string[] | undefined);
  57278. /**
  57279. * Execute the current task
  57280. * @param scene defines the scene where you want your assets to be loaded
  57281. * @param onSuccess is a callback called when the task is successfully executed
  57282. * @param onError is a callback called if an error occurs
  57283. */
  57284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57285. }
  57286. /**
  57287. * Define a task used by AssetsManager to load HDR cube textures
  57288. */
  57289. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57290. /**
  57291. * Defines the name of the task
  57292. */
  57293. name: string;
  57294. /**
  57295. * Defines the location of the file to load
  57296. */
  57297. url: string;
  57298. /**
  57299. * Defines the desired size (the more it increases the longer the generation will be)
  57300. */
  57301. size: number;
  57302. /**
  57303. * Defines if mipmaps should not be generated (default is false)
  57304. */
  57305. noMipmap: boolean;
  57306. /**
  57307. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57308. */
  57309. generateHarmonics: boolean;
  57310. /**
  57311. * 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)
  57312. */
  57313. gammaSpace: boolean;
  57314. /**
  57315. * Internal Use Only
  57316. */
  57317. reserved: boolean;
  57318. /**
  57319. * Gets the loaded texture
  57320. */
  57321. texture: HDRCubeTexture;
  57322. /**
  57323. * Callback called when the task is successful
  57324. */
  57325. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57326. /**
  57327. * Callback called when the task is successful
  57328. */
  57329. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57330. /**
  57331. * Creates a new HDRCubeTextureAssetTask object
  57332. * @param name defines the name of the task
  57333. * @param url defines the location of the file to load
  57334. * @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.
  57335. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57336. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57337. * @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)
  57338. * @param reserved Internal use only
  57339. */
  57340. constructor(
  57341. /**
  57342. * Defines the name of the task
  57343. */
  57344. name: string,
  57345. /**
  57346. * Defines the location of the file to load
  57347. */
  57348. url: string,
  57349. /**
  57350. * Defines the desired size (the more it increases the longer the generation will be)
  57351. */
  57352. size: number,
  57353. /**
  57354. * Defines if mipmaps should not be generated (default is false)
  57355. */
  57356. noMipmap?: boolean,
  57357. /**
  57358. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57359. */
  57360. generateHarmonics?: boolean,
  57361. /**
  57362. * 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)
  57363. */
  57364. gammaSpace?: boolean,
  57365. /**
  57366. * Internal Use Only
  57367. */
  57368. reserved?: boolean);
  57369. /**
  57370. * Execute the current task
  57371. * @param scene defines the scene where you want your assets to be loaded
  57372. * @param onSuccess is a callback called when the task is successfully executed
  57373. * @param onError is a callback called if an error occurs
  57374. */
  57375. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57376. }
  57377. /**
  57378. * Define a task used by AssetsManager to load Equirectangular cube textures
  57379. */
  57380. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57381. /**
  57382. * Defines the name of the task
  57383. */
  57384. name: string;
  57385. /**
  57386. * Defines the location of the file to load
  57387. */
  57388. url: string;
  57389. /**
  57390. * Defines the desired size (the more it increases the longer the generation will be)
  57391. */
  57392. size: number;
  57393. /**
  57394. * Defines if mipmaps should not be generated (default is false)
  57395. */
  57396. noMipmap: boolean;
  57397. /**
  57398. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57399. * but the standard material would require them in Gamma space) (default is true)
  57400. */
  57401. gammaSpace: boolean;
  57402. /**
  57403. * Gets the loaded texture
  57404. */
  57405. texture: EquiRectangularCubeTexture;
  57406. /**
  57407. * Callback called when the task is successful
  57408. */
  57409. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57410. /**
  57411. * Callback called when the task is successful
  57412. */
  57413. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57414. /**
  57415. * Creates a new EquiRectangularCubeTextureAssetTask object
  57416. * @param name defines the name of the task
  57417. * @param url defines the location of the file to load
  57418. * @param size defines the desired size (the more it increases the longer the generation will be)
  57419. * If the size is omitted this implies you are using a preprocessed cubemap.
  57420. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57421. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57422. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57423. * (default is true)
  57424. */
  57425. constructor(
  57426. /**
  57427. * Defines the name of the task
  57428. */
  57429. name: string,
  57430. /**
  57431. * Defines the location of the file to load
  57432. */
  57433. url: string,
  57434. /**
  57435. * Defines the desired size (the more it increases the longer the generation will be)
  57436. */
  57437. size: number,
  57438. /**
  57439. * Defines if mipmaps should not be generated (default is false)
  57440. */
  57441. noMipmap?: boolean,
  57442. /**
  57443. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57444. * but the standard material would require them in Gamma space) (default is true)
  57445. */
  57446. gammaSpace?: boolean);
  57447. /**
  57448. * Execute the current task
  57449. * @param scene defines the scene where you want your assets to be loaded
  57450. * @param onSuccess is a callback called when the task is successfully executed
  57451. * @param onError is a callback called if an error occurs
  57452. */
  57453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57454. }
  57455. /**
  57456. * This class can be used to easily import assets into a scene
  57457. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57458. */
  57459. export class AssetsManager {
  57460. private _scene;
  57461. private _isLoading;
  57462. protected _tasks: AbstractAssetTask[];
  57463. protected _waitingTasksCount: number;
  57464. protected _totalTasksCount: number;
  57465. /**
  57466. * Callback called when all tasks are processed
  57467. */
  57468. onFinish: (tasks: AbstractAssetTask[]) => void;
  57469. /**
  57470. * Callback called when a task is successful
  57471. */
  57472. onTaskSuccess: (task: AbstractAssetTask) => void;
  57473. /**
  57474. * Callback called when a task had an error
  57475. */
  57476. onTaskError: (task: AbstractAssetTask) => void;
  57477. /**
  57478. * Callback called when a task is done (whatever the result is)
  57479. */
  57480. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57481. /**
  57482. * Observable called when all tasks are processed
  57483. */
  57484. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57485. /**
  57486. * Observable called when a task had an error
  57487. */
  57488. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57489. /**
  57490. * Observable called when all tasks were executed
  57491. */
  57492. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57493. /**
  57494. * Observable called when a task is done (whatever the result is)
  57495. */
  57496. onProgressObservable: Observable<IAssetsProgressEvent>;
  57497. /**
  57498. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57499. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57500. */
  57501. useDefaultLoadingScreen: boolean;
  57502. /**
  57503. * Creates a new AssetsManager
  57504. * @param scene defines the scene to work on
  57505. */
  57506. constructor(scene: Scene);
  57507. /**
  57508. * Add a MeshAssetTask to the list of active tasks
  57509. * @param taskName defines the name of the new task
  57510. * @param meshesNames defines the name of meshes to load
  57511. * @param rootUrl defines the root url to use to locate files
  57512. * @param sceneFilename defines the filename of the scene file
  57513. * @returns a new MeshAssetTask object
  57514. */
  57515. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57516. /**
  57517. * Add a TextFileAssetTask to the list of active tasks
  57518. * @param taskName defines the name of the new task
  57519. * @param url defines the url of the file to load
  57520. * @returns a new TextFileAssetTask object
  57521. */
  57522. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57523. /**
  57524. * Add a BinaryFileAssetTask to the list of active tasks
  57525. * @param taskName defines the name of the new task
  57526. * @param url defines the url of the file to load
  57527. * @returns a new BinaryFileAssetTask object
  57528. */
  57529. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57530. /**
  57531. * Add a ImageAssetTask to the list of active tasks
  57532. * @param taskName defines the name of the new task
  57533. * @param url defines the url of the file to load
  57534. * @returns a new ImageAssetTask object
  57535. */
  57536. addImageTask(taskName: string, url: string): ImageAssetTask;
  57537. /**
  57538. * Add a TextureAssetTask to the list of active tasks
  57539. * @param taskName defines the name of the new task
  57540. * @param url defines the url of the file to load
  57541. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57542. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57543. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57544. * @returns a new TextureAssetTask object
  57545. */
  57546. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57547. /**
  57548. * Add a CubeTextureAssetTask to the list of active tasks
  57549. * @param taskName defines the name of the new task
  57550. * @param url defines the url of the file to load
  57551. * @param extensions defines the extension to use to load the cube map (can be null)
  57552. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57553. * @param files defines the list of files to load (can be null)
  57554. * @returns a new CubeTextureAssetTask object
  57555. */
  57556. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57557. /**
  57558. *
  57559. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57560. * @param taskName defines the name of the new task
  57561. * @param url defines the url of the file to load
  57562. * @param size defines the size you want for the cubemap (can be null)
  57563. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57564. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57565. * @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)
  57566. * @param reserved Internal use only
  57567. * @returns a new HDRCubeTextureAssetTask object
  57568. */
  57569. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57570. /**
  57571. *
  57572. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57573. * @param taskName defines the name of the new task
  57574. * @param url defines the url of the file to load
  57575. * @param size defines the size you want for the cubemap (can be null)
  57576. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57577. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57578. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57579. * @returns a new EquiRectangularCubeTextureAssetTask object
  57580. */
  57581. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57582. /**
  57583. * Remove a task from the assets manager.
  57584. * @param task the task to remove
  57585. */
  57586. removeTask(task: AbstractAssetTask): void;
  57587. private _decreaseWaitingTasksCount;
  57588. private _runTask;
  57589. /**
  57590. * Reset the AssetsManager and remove all tasks
  57591. * @return the current instance of the AssetsManager
  57592. */
  57593. reset(): AssetsManager;
  57594. /**
  57595. * Start the loading process
  57596. * @return the current instance of the AssetsManager
  57597. */
  57598. load(): AssetsManager;
  57599. /**
  57600. * Start the loading process as an async operation
  57601. * @return a promise returning the list of failed tasks
  57602. */
  57603. loadAsync(): Promise<void>;
  57604. }
  57605. }
  57606. declare module BABYLON {
  57607. /**
  57608. * Wrapper class for promise with external resolve and reject.
  57609. */
  57610. export class Deferred<T> {
  57611. /**
  57612. * The promise associated with this deferred object.
  57613. */
  57614. readonly promise: Promise<T>;
  57615. private _resolve;
  57616. private _reject;
  57617. /**
  57618. * The resolve method of the promise associated with this deferred object.
  57619. */
  57620. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57621. /**
  57622. * The reject method of the promise associated with this deferred object.
  57623. */
  57624. readonly reject: (reason?: any) => void;
  57625. /**
  57626. * Constructor for this deferred object.
  57627. */
  57628. constructor();
  57629. }
  57630. }
  57631. declare module BABYLON {
  57632. /**
  57633. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57634. */
  57635. export class MeshExploder {
  57636. private _centerMesh;
  57637. private _meshes;
  57638. private _meshesOrigins;
  57639. private _toCenterVectors;
  57640. private _scaledDirection;
  57641. private _newPosition;
  57642. private _centerPosition;
  57643. /**
  57644. * Explodes meshes from a center mesh.
  57645. * @param meshes The meshes to explode.
  57646. * @param centerMesh The mesh to be center of explosion.
  57647. */
  57648. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57649. private _setCenterMesh;
  57650. /**
  57651. * Get class name
  57652. * @returns "MeshExploder"
  57653. */
  57654. getClassName(): string;
  57655. /**
  57656. * "Exploded meshes"
  57657. * @returns Array of meshes with the centerMesh at index 0.
  57658. */
  57659. getMeshes(): Array<Mesh>;
  57660. /**
  57661. * Explodes meshes giving a specific direction
  57662. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57663. */
  57664. explode(direction?: number): void;
  57665. }
  57666. }
  57667. declare module BABYLON {
  57668. /**
  57669. * Class used to help managing file picking and drag'n'drop
  57670. */
  57671. export class FilesInput {
  57672. /**
  57673. * List of files ready to be loaded
  57674. */
  57675. static readonly FilesToLoad: {
  57676. [key: string]: File;
  57677. };
  57678. /**
  57679. * Callback called when a file is processed
  57680. */
  57681. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57682. private _engine;
  57683. private _currentScene;
  57684. private _sceneLoadedCallback;
  57685. private _progressCallback;
  57686. private _additionalRenderLoopLogicCallback;
  57687. private _textureLoadingCallback;
  57688. private _startingProcessingFilesCallback;
  57689. private _onReloadCallback;
  57690. private _errorCallback;
  57691. private _elementToMonitor;
  57692. private _sceneFileToLoad;
  57693. private _filesToLoad;
  57694. /**
  57695. * Creates a new FilesInput
  57696. * @param engine defines the rendering engine
  57697. * @param scene defines the hosting scene
  57698. * @param sceneLoadedCallback callback called when scene is loaded
  57699. * @param progressCallback callback called to track progress
  57700. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57701. * @param textureLoadingCallback callback called when a texture is loading
  57702. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57703. * @param onReloadCallback callback called when a reload is requested
  57704. * @param errorCallback callback call if an error occurs
  57705. */
  57706. 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);
  57707. private _dragEnterHandler;
  57708. private _dragOverHandler;
  57709. private _dropHandler;
  57710. /**
  57711. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57712. * @param elementToMonitor defines the DOM element to track
  57713. */
  57714. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57715. /**
  57716. * Release all associated resources
  57717. */
  57718. dispose(): void;
  57719. private renderFunction;
  57720. private drag;
  57721. private drop;
  57722. private _traverseFolder;
  57723. private _processFiles;
  57724. /**
  57725. * Load files from a drop event
  57726. * @param event defines the drop event to use as source
  57727. */
  57728. loadFiles(event: any): void;
  57729. private _processReload;
  57730. /**
  57731. * Reload the current scene from the loaded files
  57732. */
  57733. reload(): void;
  57734. }
  57735. }
  57736. declare module BABYLON {
  57737. /**
  57738. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57740. */
  57741. export class SceneOptimization {
  57742. /**
  57743. * Defines the priority of this optimization (0 by default which means first in the list)
  57744. */
  57745. priority: number;
  57746. /**
  57747. * Gets a string describing the action executed by the current optimization
  57748. * @returns description string
  57749. */
  57750. getDescription(): string;
  57751. /**
  57752. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57753. * @param scene defines the current scene where to apply this optimization
  57754. * @param optimizer defines the current optimizer
  57755. * @returns true if everything that can be done was applied
  57756. */
  57757. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57758. /**
  57759. * Creates the SceneOptimization object
  57760. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57761. * @param desc defines the description associated with the optimization
  57762. */
  57763. constructor(
  57764. /**
  57765. * Defines the priority of this optimization (0 by default which means first in the list)
  57766. */
  57767. priority?: number);
  57768. }
  57769. /**
  57770. * Defines an optimization used to reduce the size of render target textures
  57771. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57772. */
  57773. export class TextureOptimization extends SceneOptimization {
  57774. /**
  57775. * Defines the priority of this optimization (0 by default which means first in the list)
  57776. */
  57777. priority: number;
  57778. /**
  57779. * 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
  57780. */
  57781. maximumSize: number;
  57782. /**
  57783. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57784. */
  57785. step: number;
  57786. /**
  57787. * Gets a string describing the action executed by the current optimization
  57788. * @returns description string
  57789. */
  57790. getDescription(): string;
  57791. /**
  57792. * Creates the TextureOptimization object
  57793. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57794. * @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
  57795. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57796. */
  57797. constructor(
  57798. /**
  57799. * Defines the priority of this optimization (0 by default which means first in the list)
  57800. */
  57801. priority?: number,
  57802. /**
  57803. * 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
  57804. */
  57805. maximumSize?: number,
  57806. /**
  57807. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57808. */
  57809. step?: number);
  57810. /**
  57811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57812. * @param scene defines the current scene where to apply this optimization
  57813. * @param optimizer defines the current optimizer
  57814. * @returns true if everything that can be done was applied
  57815. */
  57816. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57817. }
  57818. /**
  57819. * Defines an optimization used to increase or decrease the rendering resolution
  57820. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57821. */
  57822. export class HardwareScalingOptimization extends SceneOptimization {
  57823. /**
  57824. * Defines the priority of this optimization (0 by default which means first in the list)
  57825. */
  57826. priority: number;
  57827. /**
  57828. * Defines the maximum scale to use (2 by default)
  57829. */
  57830. maximumScale: number;
  57831. /**
  57832. * Defines the step to use between two passes (0.5 by default)
  57833. */
  57834. step: number;
  57835. private _currentScale;
  57836. private _directionOffset;
  57837. /**
  57838. * Gets a string describing the action executed by the current optimization
  57839. * @return description string
  57840. */
  57841. getDescription(): string;
  57842. /**
  57843. * Creates the HardwareScalingOptimization object
  57844. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57845. * @param maximumScale defines the maximum scale to use (2 by default)
  57846. * @param step defines the step to use between two passes (0.5 by default)
  57847. */
  57848. constructor(
  57849. /**
  57850. * Defines the priority of this optimization (0 by default which means first in the list)
  57851. */
  57852. priority?: number,
  57853. /**
  57854. * Defines the maximum scale to use (2 by default)
  57855. */
  57856. maximumScale?: number,
  57857. /**
  57858. * Defines the step to use between two passes (0.5 by default)
  57859. */
  57860. step?: number);
  57861. /**
  57862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57863. * @param scene defines the current scene where to apply this optimization
  57864. * @param optimizer defines the current optimizer
  57865. * @returns true if everything that can be done was applied
  57866. */
  57867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57868. }
  57869. /**
  57870. * Defines an optimization used to remove shadows
  57871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57872. */
  57873. export class ShadowsOptimization extends SceneOptimization {
  57874. /**
  57875. * Gets a string describing the action executed by the current optimization
  57876. * @return description string
  57877. */
  57878. getDescription(): string;
  57879. /**
  57880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57881. * @param scene defines the current scene where to apply this optimization
  57882. * @param optimizer defines the current optimizer
  57883. * @returns true if everything that can be done was applied
  57884. */
  57885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57886. }
  57887. /**
  57888. * Defines an optimization used to turn post-processes off
  57889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57890. */
  57891. export class PostProcessesOptimization extends SceneOptimization {
  57892. /**
  57893. * Gets a string describing the action executed by the current optimization
  57894. * @return description string
  57895. */
  57896. getDescription(): string;
  57897. /**
  57898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57899. * @param scene defines the current scene where to apply this optimization
  57900. * @param optimizer defines the current optimizer
  57901. * @returns true if everything that can be done was applied
  57902. */
  57903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57904. }
  57905. /**
  57906. * Defines an optimization used to turn lens flares off
  57907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57908. */
  57909. export class LensFlaresOptimization extends SceneOptimization {
  57910. /**
  57911. * Gets a string describing the action executed by the current optimization
  57912. * @return description string
  57913. */
  57914. getDescription(): string;
  57915. /**
  57916. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57917. * @param scene defines the current scene where to apply this optimization
  57918. * @param optimizer defines the current optimizer
  57919. * @returns true if everything that can be done was applied
  57920. */
  57921. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57922. }
  57923. /**
  57924. * Defines an optimization based on user defined callback.
  57925. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57926. */
  57927. export class CustomOptimization extends SceneOptimization {
  57928. /**
  57929. * Callback called to apply the custom optimization.
  57930. */
  57931. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57932. /**
  57933. * Callback called to get custom description
  57934. */
  57935. onGetDescription: () => string;
  57936. /**
  57937. * Gets a string describing the action executed by the current optimization
  57938. * @returns description string
  57939. */
  57940. getDescription(): string;
  57941. /**
  57942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57943. * @param scene defines the current scene where to apply this optimization
  57944. * @param optimizer defines the current optimizer
  57945. * @returns true if everything that can be done was applied
  57946. */
  57947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57948. }
  57949. /**
  57950. * Defines an optimization used to turn particles off
  57951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57952. */
  57953. export class ParticlesOptimization extends SceneOptimization {
  57954. /**
  57955. * Gets a string describing the action executed by the current optimization
  57956. * @return description string
  57957. */
  57958. getDescription(): string;
  57959. /**
  57960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57961. * @param scene defines the current scene where to apply this optimization
  57962. * @param optimizer defines the current optimizer
  57963. * @returns true if everything that can be done was applied
  57964. */
  57965. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57966. }
  57967. /**
  57968. * Defines an optimization used to turn render targets off
  57969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57970. */
  57971. export class RenderTargetsOptimization extends SceneOptimization {
  57972. /**
  57973. * Gets a string describing the action executed by the current optimization
  57974. * @return description string
  57975. */
  57976. getDescription(): string;
  57977. /**
  57978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57979. * @param scene defines the current scene where to apply this optimization
  57980. * @param optimizer defines the current optimizer
  57981. * @returns true if everything that can be done was applied
  57982. */
  57983. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57984. }
  57985. /**
  57986. * Defines an optimization used to merge meshes with compatible materials
  57987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57988. */
  57989. export class MergeMeshesOptimization extends SceneOptimization {
  57990. private static _UpdateSelectionTree;
  57991. /**
  57992. * Gets or sets a boolean which defines if optimization octree has to be updated
  57993. */
  57994. /**
  57995. * Gets or sets a boolean which defines if optimization octree has to be updated
  57996. */
  57997. static UpdateSelectionTree: boolean;
  57998. /**
  57999. * Gets a string describing the action executed by the current optimization
  58000. * @return description string
  58001. */
  58002. getDescription(): string;
  58003. private _canBeMerged;
  58004. /**
  58005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58006. * @param scene defines the current scene where to apply this optimization
  58007. * @param optimizer defines the current optimizer
  58008. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58009. * @returns true if everything that can be done was applied
  58010. */
  58011. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58012. }
  58013. /**
  58014. * Defines a list of options used by SceneOptimizer
  58015. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58016. */
  58017. export class SceneOptimizerOptions {
  58018. /**
  58019. * Defines the target frame rate to reach (60 by default)
  58020. */
  58021. targetFrameRate: number;
  58022. /**
  58023. * Defines the interval between two checkes (2000ms by default)
  58024. */
  58025. trackerDuration: number;
  58026. /**
  58027. * Gets the list of optimizations to apply
  58028. */
  58029. optimizations: SceneOptimization[];
  58030. /**
  58031. * Creates a new list of options used by SceneOptimizer
  58032. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58033. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58034. */
  58035. constructor(
  58036. /**
  58037. * Defines the target frame rate to reach (60 by default)
  58038. */
  58039. targetFrameRate?: number,
  58040. /**
  58041. * Defines the interval between two checkes (2000ms by default)
  58042. */
  58043. trackerDuration?: number);
  58044. /**
  58045. * Add a new optimization
  58046. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58047. * @returns the current SceneOptimizerOptions
  58048. */
  58049. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58050. /**
  58051. * Add a new custom optimization
  58052. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58053. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58054. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58055. * @returns the current SceneOptimizerOptions
  58056. */
  58057. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58058. /**
  58059. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58060. * @param targetFrameRate defines the target frame rate (60 by default)
  58061. * @returns a SceneOptimizerOptions object
  58062. */
  58063. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58064. /**
  58065. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58066. * @param targetFrameRate defines the target frame rate (60 by default)
  58067. * @returns a SceneOptimizerOptions object
  58068. */
  58069. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58070. /**
  58071. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58072. * @param targetFrameRate defines the target frame rate (60 by default)
  58073. * @returns a SceneOptimizerOptions object
  58074. */
  58075. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58076. }
  58077. /**
  58078. * Class used to run optimizations in order to reach a target frame rate
  58079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58080. */
  58081. export class SceneOptimizer implements IDisposable {
  58082. private _isRunning;
  58083. private _options;
  58084. private _scene;
  58085. private _currentPriorityLevel;
  58086. private _targetFrameRate;
  58087. private _trackerDuration;
  58088. private _currentFrameRate;
  58089. private _sceneDisposeObserver;
  58090. private _improvementMode;
  58091. /**
  58092. * Defines an observable called when the optimizer reaches the target frame rate
  58093. */
  58094. onSuccessObservable: Observable<SceneOptimizer>;
  58095. /**
  58096. * Defines an observable called when the optimizer enables an optimization
  58097. */
  58098. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58099. /**
  58100. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58101. */
  58102. onFailureObservable: Observable<SceneOptimizer>;
  58103. /**
  58104. * Gets a boolean indicating if the optimizer is in improvement mode
  58105. */
  58106. readonly isInImprovementMode: boolean;
  58107. /**
  58108. * Gets the current priority level (0 at start)
  58109. */
  58110. readonly currentPriorityLevel: number;
  58111. /**
  58112. * Gets the current frame rate checked by the SceneOptimizer
  58113. */
  58114. readonly currentFrameRate: number;
  58115. /**
  58116. * Gets or sets the current target frame rate (60 by default)
  58117. */
  58118. /**
  58119. * Gets or sets the current target frame rate (60 by default)
  58120. */
  58121. targetFrameRate: number;
  58122. /**
  58123. * Gets or sets the current interval between two checks (every 2000ms by default)
  58124. */
  58125. /**
  58126. * Gets or sets the current interval between two checks (every 2000ms by default)
  58127. */
  58128. trackerDuration: number;
  58129. /**
  58130. * Gets the list of active optimizations
  58131. */
  58132. readonly optimizations: SceneOptimization[];
  58133. /**
  58134. * Creates a new SceneOptimizer
  58135. * @param scene defines the scene to work on
  58136. * @param options defines the options to use with the SceneOptimizer
  58137. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58138. * @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)
  58139. */
  58140. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58141. /**
  58142. * Stops the current optimizer
  58143. */
  58144. stop(): void;
  58145. /**
  58146. * Reset the optimizer to initial step (current priority level = 0)
  58147. */
  58148. reset(): void;
  58149. /**
  58150. * Start the optimizer. By default it will try to reach a specific framerate
  58151. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58152. */
  58153. start(): void;
  58154. private _checkCurrentState;
  58155. /**
  58156. * Release all resources
  58157. */
  58158. dispose(): void;
  58159. /**
  58160. * Helper function to create a SceneOptimizer with one single line of code
  58161. * @param scene defines the scene to work on
  58162. * @param options defines the options to use with the SceneOptimizer
  58163. * @param onSuccess defines a callback to call on success
  58164. * @param onFailure defines a callback to call on failure
  58165. * @returns the new SceneOptimizer object
  58166. */
  58167. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58168. }
  58169. }
  58170. declare module BABYLON {
  58171. /**
  58172. * Class used to serialize a scene into a string
  58173. */
  58174. export class SceneSerializer {
  58175. /**
  58176. * Clear cache used by a previous serialization
  58177. */
  58178. static ClearCache(): void;
  58179. /**
  58180. * Serialize a scene into a JSON compatible object
  58181. * @param scene defines the scene to serialize
  58182. * @returns a JSON compatible object
  58183. */
  58184. static Serialize(scene: Scene): any;
  58185. /**
  58186. * Serialize a mesh into a JSON compatible object
  58187. * @param toSerialize defines the mesh to serialize
  58188. * @param withParents defines if parents must be serialized as well
  58189. * @param withChildren defines if children must be serialized as well
  58190. * @returns a JSON compatible object
  58191. */
  58192. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58193. }
  58194. }
  58195. declare module BABYLON {
  58196. /**
  58197. * Class used to host texture specific utilities
  58198. */
  58199. export class TextureTools {
  58200. /**
  58201. * Uses the GPU to create a copy texture rescaled at a given size
  58202. * @param texture Texture to copy from
  58203. * @param width defines the desired width
  58204. * @param height defines the desired height
  58205. * @param useBilinearMode defines if bilinear mode has to be used
  58206. * @return the generated texture
  58207. */
  58208. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58209. }
  58210. }
  58211. declare module BABYLON {
  58212. /**
  58213. * This represents the different options available for the video capture.
  58214. */
  58215. export interface VideoRecorderOptions {
  58216. /** Defines the mime type of the video. */
  58217. mimeType: string;
  58218. /** Defines the FPS the video should be recorded at. */
  58219. fps: number;
  58220. /** Defines the chunk size for the recording data. */
  58221. recordChunckSize: number;
  58222. /** The audio tracks to attach to the recording. */
  58223. audioTracks?: MediaStreamTrack[];
  58224. }
  58225. /**
  58226. * This can help with recording videos from BabylonJS.
  58227. * This is based on the available WebRTC functionalities of the browser.
  58228. *
  58229. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58230. */
  58231. export class VideoRecorder {
  58232. private static readonly _defaultOptions;
  58233. /**
  58234. * Returns whether or not the VideoRecorder is available in your browser.
  58235. * @param engine Defines the Babylon Engine.
  58236. * @returns true if supported otherwise false.
  58237. */
  58238. static IsSupported(engine: Engine): boolean;
  58239. private readonly _options;
  58240. private _canvas;
  58241. private _mediaRecorder;
  58242. private _recordedChunks;
  58243. private _fileName;
  58244. private _resolve;
  58245. private _reject;
  58246. /**
  58247. * True when a recording is already in progress.
  58248. */
  58249. readonly isRecording: boolean;
  58250. /**
  58251. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  58252. * @param engine Defines the BabylonJS Engine you wish to record.
  58253. * @param options Defines options that can be used to customize the capture.
  58254. */
  58255. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58256. /**
  58257. * Stops the current recording before the default capture timeout passed in the startRecording function.
  58258. */
  58259. stopRecording(): void;
  58260. /**
  58261. * Starts recording the canvas for a max duration specified in parameters.
  58262. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  58263. * If null no automatic download will start and you can rely on the promise to get the data back.
  58264. * @param maxDuration Defines the maximum recording time in seconds.
  58265. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58266. * @return A promise callback at the end of the recording with the video data in Blob.
  58267. */
  58268. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58269. /**
  58270. * Releases internal resources used during the recording.
  58271. */
  58272. dispose(): void;
  58273. private _handleDataAvailable;
  58274. private _handleError;
  58275. private _handleStop;
  58276. }
  58277. }
  58278. declare module BABYLON {
  58279. /**
  58280. * Class containing a set of static utilities functions for screenshots
  58281. */
  58282. export class ScreenshotTools {
  58283. /**
  58284. * Captures a screenshot of the current rendering
  58285. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58286. * @param engine defines the rendering engine
  58287. * @param camera defines the source camera
  58288. * @param size This parameter can be set to a single number or to an object with the
  58289. * following (optional) properties: precision, width, height. If a single number is passed,
  58290. * it will be used for both width and height. If an object is passed, the screenshot size
  58291. * will be derived from the parameters. The precision property is a multiplier allowing
  58292. * rendering at a higher or lower resolution
  58293. * @param successCallback defines the callback receives a single parameter which contains the
  58294. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58295. * src parameter of an <img> to display it
  58296. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58297. * Check your browser for supported MIME types
  58298. */
  58299. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58300. /**
  58301. * Generates an image screenshot from the specified camera.
  58302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58303. * @param engine The engine to use for rendering
  58304. * @param camera The camera to use for rendering
  58305. * @param size This parameter can be set to a single number or to an object with the
  58306. * following (optional) properties: precision, width, height. If a single number is passed,
  58307. * it will be used for both width and height. If an object is passed, the screenshot size
  58308. * will be derived from the parameters. The precision property is a multiplier allowing
  58309. * rendering at a higher or lower resolution
  58310. * @param successCallback The callback receives a single parameter which contains the
  58311. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58312. * src parameter of an <img> to display it
  58313. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58314. * Check your browser for supported MIME types
  58315. * @param samples Texture samples (default: 1)
  58316. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58317. * @param fileName A name for for the downloaded file.
  58318. */
  58319. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58320. }
  58321. }
  58322. declare module BABYLON {
  58323. /**
  58324. * A cursor which tracks a point on a path
  58325. */
  58326. export class PathCursor {
  58327. private path;
  58328. /**
  58329. * Stores path cursor callbacks for when an onchange event is triggered
  58330. */
  58331. private _onchange;
  58332. /**
  58333. * The value of the path cursor
  58334. */
  58335. value: number;
  58336. /**
  58337. * The animation array of the path cursor
  58338. */
  58339. animations: Animation[];
  58340. /**
  58341. * Initializes the path cursor
  58342. * @param path The path to track
  58343. */
  58344. constructor(path: Path2);
  58345. /**
  58346. * Gets the cursor point on the path
  58347. * @returns A point on the path cursor at the cursor location
  58348. */
  58349. getPoint(): Vector3;
  58350. /**
  58351. * Moves the cursor ahead by the step amount
  58352. * @param step The amount to move the cursor forward
  58353. * @returns This path cursor
  58354. */
  58355. moveAhead(step?: number): PathCursor;
  58356. /**
  58357. * Moves the cursor behind by the step amount
  58358. * @param step The amount to move the cursor back
  58359. * @returns This path cursor
  58360. */
  58361. moveBack(step?: number): PathCursor;
  58362. /**
  58363. * Moves the cursor by the step amount
  58364. * If the step amount is greater than one, an exception is thrown
  58365. * @param step The amount to move the cursor
  58366. * @returns This path cursor
  58367. */
  58368. move(step: number): PathCursor;
  58369. /**
  58370. * Ensures that the value is limited between zero and one
  58371. * @returns This path cursor
  58372. */
  58373. private ensureLimits;
  58374. /**
  58375. * Runs onchange callbacks on change (used by the animation engine)
  58376. * @returns This path cursor
  58377. */
  58378. private raiseOnChange;
  58379. /**
  58380. * Executes a function on change
  58381. * @param f A path cursor onchange callback
  58382. * @returns This path cursor
  58383. */
  58384. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58385. }
  58386. }
  58387. declare module BABYLON {
  58388. /** @hidden */
  58389. export var blurPixelShader: {
  58390. name: string;
  58391. shader: string;
  58392. };
  58393. }
  58394. declare module BABYLON {
  58395. /** @hidden */
  58396. export var bones300Declaration: {
  58397. name: string;
  58398. shader: string;
  58399. };
  58400. }
  58401. declare module BABYLON {
  58402. /** @hidden */
  58403. export var instances300Declaration: {
  58404. name: string;
  58405. shader: string;
  58406. };
  58407. }
  58408. declare module BABYLON {
  58409. /** @hidden */
  58410. export var pointCloudVertexDeclaration: {
  58411. name: string;
  58412. shader: string;
  58413. };
  58414. }
  58415. // Mixins
  58416. interface Window {
  58417. mozIndexedDB: IDBFactory;
  58418. webkitIndexedDB: IDBFactory;
  58419. msIndexedDB: IDBFactory;
  58420. webkitURL: typeof URL;
  58421. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58422. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58423. WebGLRenderingContext: WebGLRenderingContext;
  58424. MSGesture: MSGesture;
  58425. CANNON: any;
  58426. AudioContext: AudioContext;
  58427. webkitAudioContext: AudioContext;
  58428. PointerEvent: any;
  58429. Math: Math;
  58430. Uint8Array: Uint8ArrayConstructor;
  58431. Float32Array: Float32ArrayConstructor;
  58432. mozURL: typeof URL;
  58433. msURL: typeof URL;
  58434. VRFrameData: any; // WebVR, from specs 1.1
  58435. DracoDecoderModule: any;
  58436. setImmediate(handler: (...args: any[]) => void): number;
  58437. }
  58438. interface HTMLCanvasElement {
  58439. requestPointerLock(): void;
  58440. msRequestPointerLock?(): void;
  58441. mozRequestPointerLock?(): void;
  58442. webkitRequestPointerLock?(): void;
  58443. /** Track wether a record is in progress */
  58444. isRecording: boolean;
  58445. /** Capture Stream method defined by some browsers */
  58446. captureStream(fps?: number): MediaStream;
  58447. }
  58448. interface CanvasRenderingContext2D {
  58449. msImageSmoothingEnabled: boolean;
  58450. }
  58451. interface MouseEvent {
  58452. mozMovementX: number;
  58453. mozMovementY: number;
  58454. webkitMovementX: number;
  58455. webkitMovementY: number;
  58456. msMovementX: number;
  58457. msMovementY: number;
  58458. }
  58459. interface Navigator {
  58460. mozGetVRDevices: (any: any) => any;
  58461. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58462. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58463. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58464. webkitGetGamepads(): Gamepad[];
  58465. msGetGamepads(): Gamepad[];
  58466. webkitGamepads(): Gamepad[];
  58467. }
  58468. interface HTMLVideoElement {
  58469. mozSrcObject: any;
  58470. }
  58471. interface Math {
  58472. fround(x: number): number;
  58473. imul(a: number, b: number): number;
  58474. }
  58475. interface WebGLRenderingContext {
  58476. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58477. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58478. vertexAttribDivisor(index: number, divisor: number): void;
  58479. createVertexArray(): any;
  58480. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58481. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58482. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58483. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58484. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58485. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58486. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58487. // Queries
  58488. createQuery(): WebGLQuery;
  58489. deleteQuery(query: WebGLQuery): void;
  58490. beginQuery(target: number, query: WebGLQuery): void;
  58491. endQuery(target: number): void;
  58492. getQueryParameter(query: WebGLQuery, pname: number): any;
  58493. getQuery(target: number, pname: number): any;
  58494. MAX_SAMPLES: number;
  58495. RGBA8: number;
  58496. READ_FRAMEBUFFER: number;
  58497. DRAW_FRAMEBUFFER: number;
  58498. UNIFORM_BUFFER: number;
  58499. HALF_FLOAT_OES: number;
  58500. RGBA16F: number;
  58501. RGBA32F: number;
  58502. R32F: number;
  58503. RG32F: number;
  58504. RGB32F: number;
  58505. R16F: number;
  58506. RG16F: number;
  58507. RGB16F: number;
  58508. RED: number;
  58509. RG: number;
  58510. R8: number;
  58511. RG8: number;
  58512. UNSIGNED_INT_24_8: number;
  58513. DEPTH24_STENCIL8: number;
  58514. /* Multiple Render Targets */
  58515. drawBuffers(buffers: number[]): void;
  58516. readBuffer(src: number): void;
  58517. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58518. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58519. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58520. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58521. // Occlusion Query
  58522. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58523. ANY_SAMPLES_PASSED: number;
  58524. QUERY_RESULT_AVAILABLE: number;
  58525. QUERY_RESULT: number;
  58526. }
  58527. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58528. }
  58529. interface EXT_disjoint_timer_query {
  58530. QUERY_COUNTER_BITS_EXT: number;
  58531. TIME_ELAPSED_EXT: number;
  58532. TIMESTAMP_EXT: number;
  58533. GPU_DISJOINT_EXT: number;
  58534. QUERY_RESULT_EXT: number;
  58535. QUERY_RESULT_AVAILABLE_EXT: number;
  58536. queryCounterEXT(query: WebGLQuery, target: number): void;
  58537. createQueryEXT(): WebGLQuery;
  58538. beginQueryEXT(target: number, query: WebGLQuery): void;
  58539. endQueryEXT(target: number): void;
  58540. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58541. deleteQueryEXT(query: WebGLQuery): void;
  58542. }
  58543. interface WebGLUniformLocation { private _currentState: any;
  58544. }
  58545. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58546. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58547. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58548. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58549. interface WebGLRenderingContext {
  58550. readonly RASTERIZER_DISCARD: number;
  58551. readonly DEPTH_COMPONENT24: number;
  58552. readonly TEXTURE_3D: number;
  58553. readonly TEXTURE_2D_ARRAY: number;
  58554. readonly TEXTURE_COMPARE_FUNC: number;
  58555. readonly TEXTURE_COMPARE_MODE: number;
  58556. readonly COMPARE_REF_TO_TEXTURE: number;
  58557. readonly TEXTURE_WRAP_R: number;
  58558. readonly HALF_FLOAT: number;
  58559. readonly RGB8: number;
  58560. readonly RED_INTEGER: number;
  58561. readonly RG_INTEGER: number;
  58562. readonly RGB_INTEGER: number;
  58563. readonly RGBA_INTEGER: number;
  58564. readonly R8_SNORM: number;
  58565. readonly RG8_SNORM: number;
  58566. readonly RGB8_SNORM: number;
  58567. readonly RGBA8_SNORM: number;
  58568. readonly R8I: number;
  58569. readonly RG8I: number;
  58570. readonly RGB8I: number;
  58571. readonly RGBA8I: number;
  58572. readonly R8UI: number;
  58573. readonly RG8UI: number;
  58574. readonly RGB8UI: number;
  58575. readonly RGBA8UI: number;
  58576. readonly R16I: number;
  58577. readonly RG16I: number;
  58578. readonly RGB16I: number;
  58579. readonly RGBA16I: number;
  58580. readonly R16UI: number;
  58581. readonly RG16UI: number;
  58582. readonly RGB16UI: number;
  58583. readonly RGBA16UI: number;
  58584. readonly R32I: number;
  58585. readonly RG32I: number;
  58586. readonly RGB32I: number;
  58587. readonly RGBA32I: number;
  58588. readonly R32UI: number;
  58589. readonly RG32UI: number;
  58590. readonly RGB32UI: number;
  58591. readonly RGBA32UI: number;
  58592. readonly RGB10_A2UI: number;
  58593. readonly R11F_G11F_B10F: number;
  58594. readonly RGB9_E5: number;
  58595. readonly RGB10_A2: number;
  58596. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58597. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58598. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58599. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58600. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58601. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58602. 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;
  58603. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58604. readonly TRANSFORM_FEEDBACK: number;
  58605. readonly INTERLEAVED_ATTRIBS: number;
  58606. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58607. createTransformFeedback(): WebGLTransformFeedback;
  58608. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58609. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58610. beginTransformFeedback(primitiveMode: number): void;
  58611. endTransformFeedback(): void;
  58612. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58613. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58614. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58615. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58616. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58617. }
  58618. interface ImageBitmap {
  58619. readonly width: number;
  58620. readonly height: number;
  58621. close(): void;
  58622. }
  58623. interface WebGLQuery extends WebGLObject {
  58624. }
  58625. declare var WebGLQuery: {
  58626. prototype: WebGLQuery;
  58627. new(): WebGLQuery;
  58628. };
  58629. interface WebGLSampler extends WebGLObject {
  58630. }
  58631. declare var WebGLSampler: {
  58632. prototype: WebGLSampler;
  58633. new(): WebGLSampler;
  58634. };
  58635. interface WebGLSync extends WebGLObject {
  58636. }
  58637. declare var WebGLSync: {
  58638. prototype: WebGLSync;
  58639. new(): WebGLSync;
  58640. };
  58641. interface WebGLTransformFeedback extends WebGLObject {
  58642. }
  58643. declare var WebGLTransformFeedback: {
  58644. prototype: WebGLTransformFeedback;
  58645. new(): WebGLTransformFeedback;
  58646. };
  58647. interface WebGLVertexArrayObject extends WebGLObject {
  58648. }
  58649. declare var WebGLVertexArrayObject: {
  58650. prototype: WebGLVertexArrayObject;
  58651. new(): WebGLVertexArrayObject;
  58652. };
  58653. // Type definitions for WebVR API
  58654. // Project: https://w3c.github.io/webvr/
  58655. // Definitions by: six a <https://github.com/lostfictions>
  58656. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58657. interface VRDisplay extends EventTarget {
  58658. /**
  58659. * Dictionary of capabilities describing the VRDisplay.
  58660. */
  58661. readonly capabilities: VRDisplayCapabilities;
  58662. /**
  58663. * z-depth defining the far plane of the eye view frustum
  58664. * enables mapping of values in the render target depth
  58665. * attachment to scene coordinates. Initially set to 10000.0.
  58666. */
  58667. depthFar: number;
  58668. /**
  58669. * z-depth defining the near plane of the eye view frustum
  58670. * enables mapping of values in the render target depth
  58671. * attachment to scene coordinates. Initially set to 0.01.
  58672. */
  58673. depthNear: number;
  58674. /**
  58675. * An identifier for this distinct VRDisplay. Used as an
  58676. * association point in the Gamepad API.
  58677. */
  58678. readonly displayId: number;
  58679. /**
  58680. * A display name, a user-readable name identifying it.
  58681. */
  58682. readonly displayName: string;
  58683. readonly isConnected: boolean;
  58684. readonly isPresenting: boolean;
  58685. /**
  58686. * If this VRDisplay supports room-scale experiences, the optional
  58687. * stage attribute contains details on the room-scale parameters.
  58688. */
  58689. readonly stageParameters: VRStageParameters | null;
  58690. /**
  58691. * Passing the value returned by `requestAnimationFrame` to
  58692. * `cancelAnimationFrame` will unregister the callback.
  58693. * @param handle Define the hanle of the request to cancel
  58694. */
  58695. cancelAnimationFrame(handle: number): void;
  58696. /**
  58697. * Stops presenting to the VRDisplay.
  58698. * @returns a promise to know when it stopped
  58699. */
  58700. exitPresent(): Promise<void>;
  58701. /**
  58702. * Return the current VREyeParameters for the given eye.
  58703. * @param whichEye Define the eye we want the parameter for
  58704. * @returns the eye parameters
  58705. */
  58706. getEyeParameters(whichEye: string): VREyeParameters;
  58707. /**
  58708. * Populates the passed VRFrameData with the information required to render
  58709. * the current frame.
  58710. * @param frameData Define the data structure to populate
  58711. * @returns true if ok otherwise false
  58712. */
  58713. getFrameData(frameData: VRFrameData): boolean;
  58714. /**
  58715. * Get the layers currently being presented.
  58716. * @returns the list of VR layers
  58717. */
  58718. getLayers(): VRLayer[];
  58719. /**
  58720. * Return a VRPose containing the future predicted pose of the VRDisplay
  58721. * when the current frame will be presented. The value returned will not
  58722. * change until JavaScript has returned control to the browser.
  58723. *
  58724. * The VRPose will contain the position, orientation, velocity,
  58725. * and acceleration of each of these properties.
  58726. * @returns the pose object
  58727. */
  58728. getPose(): VRPose;
  58729. /**
  58730. * Return the current instantaneous pose of the VRDisplay, with no
  58731. * prediction applied.
  58732. * @returns the current instantaneous pose
  58733. */
  58734. getImmediatePose(): VRPose;
  58735. /**
  58736. * The callback passed to `requestAnimationFrame` will be called
  58737. * any time a new frame should be rendered. When the VRDisplay is
  58738. * presenting the callback will be called at the native refresh
  58739. * rate of the HMD. When not presenting this function acts
  58740. * identically to how window.requestAnimationFrame acts. Content should
  58741. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58742. * asynchronously from other displays and at differing refresh rates.
  58743. * @param callback Define the eaction to run next frame
  58744. * @returns the request handle it
  58745. */
  58746. requestAnimationFrame(callback: FrameRequestCallback): number;
  58747. /**
  58748. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58749. * Repeat calls while already presenting will update the VRLayers being displayed.
  58750. * @param layers Define the list of layer to present
  58751. * @returns a promise to know when the request has been fulfilled
  58752. */
  58753. requestPresent(layers: VRLayer[]): Promise<void>;
  58754. /**
  58755. * Reset the pose for this display, treating its current position and
  58756. * orientation as the "origin/zero" values. VRPose.position,
  58757. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58758. * updated when calling resetPose(). This should be called in only
  58759. * sitting-space experiences.
  58760. */
  58761. resetPose(): void;
  58762. /**
  58763. * The VRLayer provided to the VRDisplay will be captured and presented
  58764. * in the HMD. Calling this function has the same effect on the source
  58765. * canvas as any other operation that uses its source image, and canvases
  58766. * created without preserveDrawingBuffer set to true will be cleared.
  58767. * @param pose Define the pose to submit
  58768. */
  58769. submitFrame(pose?: VRPose): void;
  58770. }
  58771. declare var VRDisplay: {
  58772. prototype: VRDisplay;
  58773. new(): VRDisplay;
  58774. };
  58775. interface VRLayer {
  58776. leftBounds?: number[] | Float32Array | null;
  58777. rightBounds?: number[] | Float32Array | null;
  58778. source?: HTMLCanvasElement | null;
  58779. }
  58780. interface VRDisplayCapabilities {
  58781. readonly canPresent: boolean;
  58782. readonly hasExternalDisplay: boolean;
  58783. readonly hasOrientation: boolean;
  58784. readonly hasPosition: boolean;
  58785. readonly maxLayers: number;
  58786. }
  58787. interface VREyeParameters {
  58788. /** @deprecated */
  58789. readonly fieldOfView: VRFieldOfView;
  58790. readonly offset: Float32Array;
  58791. readonly renderHeight: number;
  58792. readonly renderWidth: number;
  58793. }
  58794. interface VRFieldOfView {
  58795. readonly downDegrees: number;
  58796. readonly leftDegrees: number;
  58797. readonly rightDegrees: number;
  58798. readonly upDegrees: number;
  58799. }
  58800. interface VRFrameData {
  58801. readonly leftProjectionMatrix: Float32Array;
  58802. readonly leftViewMatrix: Float32Array;
  58803. readonly pose: VRPose;
  58804. readonly rightProjectionMatrix: Float32Array;
  58805. readonly rightViewMatrix: Float32Array;
  58806. readonly timestamp: number;
  58807. }
  58808. interface VRPose {
  58809. readonly angularAcceleration: Float32Array | null;
  58810. readonly angularVelocity: Float32Array | null;
  58811. readonly linearAcceleration: Float32Array | null;
  58812. readonly linearVelocity: Float32Array | null;
  58813. readonly orientation: Float32Array | null;
  58814. readonly position: Float32Array | null;
  58815. readonly timestamp: number;
  58816. }
  58817. interface VRStageParameters {
  58818. sittingToStandingTransform?: Float32Array;
  58819. sizeX?: number;
  58820. sizeY?: number;
  58821. }
  58822. interface Navigator {
  58823. getVRDisplays(): Promise<VRDisplay[]>;
  58824. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58825. }
  58826. interface Window {
  58827. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58828. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58829. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58830. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58831. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58832. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58833. }
  58834. interface Gamepad {
  58835. readonly displayId: number;
  58836. }
  58837. interface XRDevice {
  58838. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58839. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58840. }
  58841. interface XRSession {
  58842. getInputSources(): Array<any>;
  58843. baseLayer: XRWebGLLayer;
  58844. requestFrameOfReference(type: string): Promise<void>;
  58845. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58846. end(): Promise<void>;
  58847. requestAnimationFrame: Function;
  58848. addEventListener: Function;
  58849. }
  58850. interface XRSessionCreationOptions {
  58851. outputContext?: WebGLRenderingContext | null;
  58852. immersive?: boolean;
  58853. environmentIntegration?: boolean;
  58854. }
  58855. interface XRLayer {
  58856. getViewport: Function;
  58857. framebufferWidth: number;
  58858. framebufferHeight: number;
  58859. }
  58860. interface XRView {
  58861. projectionMatrix: Float32Array;
  58862. }
  58863. interface XRFrame {
  58864. getDevicePose: Function;
  58865. getInputPose: Function;
  58866. views: Array<XRView>;
  58867. baseLayer: XRLayer;
  58868. }
  58869. interface XRFrameOfReference {
  58870. }
  58871. interface XRWebGLLayer extends XRLayer {
  58872. framebuffer: WebGLFramebuffer;
  58873. }
  58874. declare var XRWebGLLayer: {
  58875. prototype: XRWebGLLayer;
  58876. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58877. };
  58878. declare module BABYLON.GUI {
  58879. /**
  58880. * Class used to specific a value and its associated unit
  58881. */
  58882. export class ValueAndUnit {
  58883. /** defines the unit to store */
  58884. unit: number;
  58885. /** defines a boolean indicating if the value can be negative */
  58886. negativeValueAllowed: boolean;
  58887. private _value;
  58888. private _originalUnit;
  58889. /**
  58890. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  58891. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58892. */
  58893. ignoreAdaptiveScaling: boolean;
  58894. /**
  58895. * Creates a new ValueAndUnit
  58896. * @param value defines the value to store
  58897. * @param unit defines the unit to store
  58898. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  58899. */
  58900. constructor(value: number,
  58901. /** defines the unit to store */
  58902. unit?: number,
  58903. /** defines a boolean indicating if the value can be negative */
  58904. negativeValueAllowed?: boolean);
  58905. /** Gets a boolean indicating if the value is a percentage */
  58906. readonly isPercentage: boolean;
  58907. /** Gets a boolean indicating if the value is store as pixel */
  58908. readonly isPixel: boolean;
  58909. /** Gets direct internal value */
  58910. readonly internalValue: number;
  58911. /**
  58912. * Gets value as pixel
  58913. * @param host defines the root host
  58914. * @param refValue defines the reference value for percentages
  58915. * @returns the value as pixel
  58916. */
  58917. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  58918. /**
  58919. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  58920. * @param value defines the value to store
  58921. * @param unit defines the unit to store
  58922. * @returns the current ValueAndUnit
  58923. */
  58924. updateInPlace(value: number, unit?: number): ValueAndUnit;
  58925. /**
  58926. * Gets the value accordingly to its unit
  58927. * @param host defines the root host
  58928. * @returns the value
  58929. */
  58930. getValue(host: AdvancedDynamicTexture): number;
  58931. /**
  58932. * Gets a string representation of the value
  58933. * @param host defines the root host
  58934. * @param decimals defines an optional number of decimals to display
  58935. * @returns a string
  58936. */
  58937. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  58938. /**
  58939. * Store a value parsed from a string
  58940. * @param source defines the source string
  58941. * @returns true if the value was successfully parsed
  58942. */
  58943. fromString(source: string | number): boolean;
  58944. private static _Regex;
  58945. private static _UNITMODE_PERCENTAGE;
  58946. private static _UNITMODE_PIXEL;
  58947. /** UNITMODE_PERCENTAGE */
  58948. static readonly UNITMODE_PERCENTAGE: number;
  58949. /** UNITMODE_PIXEL */
  58950. static readonly UNITMODE_PIXEL: number;
  58951. }
  58952. }
  58953. declare module BABYLON.GUI {
  58954. /**
  58955. * Define a style used by control to automatically setup properties based on a template.
  58956. * Only support font related properties so far
  58957. */
  58958. export class Style implements BABYLON.IDisposable {
  58959. private _fontFamily;
  58960. private _fontStyle;
  58961. private _fontWeight;
  58962. /** @hidden */ private _host: AdvancedDynamicTexture;
  58963. /** @hidden */ private _fontSize: ValueAndUnit;
  58964. /**
  58965. * BABYLON.Observable raised when the style values are changed
  58966. */
  58967. onChangedObservable: BABYLON.Observable<Style>;
  58968. /**
  58969. * Creates a new style object
  58970. * @param host defines the AdvancedDynamicTexture which hosts this style
  58971. */
  58972. constructor(host: AdvancedDynamicTexture);
  58973. /**
  58974. * Gets or sets the font size
  58975. */
  58976. fontSize: string | number;
  58977. /**
  58978. * Gets or sets the font family
  58979. */
  58980. fontFamily: string;
  58981. /**
  58982. * Gets or sets the font style
  58983. */
  58984. fontStyle: string;
  58985. /** Gets or sets font weight */
  58986. fontWeight: string;
  58987. /** Dispose all associated resources */
  58988. dispose(): void;
  58989. }
  58990. }
  58991. declare module BABYLON.GUI {
  58992. /**
  58993. * Class used to transport BABYLON.Vector2 information for pointer events
  58994. */
  58995. export class Vector2WithInfo extends BABYLON.Vector2 {
  58996. /** defines the current mouse button index */
  58997. buttonIndex: number;
  58998. /**
  58999. * Creates a new Vector2WithInfo
  59000. * @param source defines the vector2 data to transport
  59001. * @param buttonIndex defines the current mouse button index
  59002. */
  59003. constructor(source: BABYLON.Vector2,
  59004. /** defines the current mouse button index */
  59005. buttonIndex?: number);
  59006. }
  59007. /** Class used to provide 2D matrix features */
  59008. export class Matrix2D {
  59009. /** Gets the internal array of 6 floats used to store matrix data */
  59010. m: Float32Array;
  59011. /**
  59012. * Creates a new matrix
  59013. * @param m00 defines value for (0, 0)
  59014. * @param m01 defines value for (0, 1)
  59015. * @param m10 defines value for (1, 0)
  59016. * @param m11 defines value for (1, 1)
  59017. * @param m20 defines value for (2, 0)
  59018. * @param m21 defines value for (2, 1)
  59019. */
  59020. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59021. /**
  59022. * Fills the matrix from direct values
  59023. * @param m00 defines value for (0, 0)
  59024. * @param m01 defines value for (0, 1)
  59025. * @param m10 defines value for (1, 0)
  59026. * @param m11 defines value for (1, 1)
  59027. * @param m20 defines value for (2, 0)
  59028. * @param m21 defines value for (2, 1)
  59029. * @returns the current modified matrix
  59030. */
  59031. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59032. /**
  59033. * Gets matrix determinant
  59034. * @returns the determinant
  59035. */
  59036. determinant(): number;
  59037. /**
  59038. * Inverses the matrix and stores it in a target matrix
  59039. * @param result defines the target matrix
  59040. * @returns the current matrix
  59041. */
  59042. invertToRef(result: Matrix2D): Matrix2D;
  59043. /**
  59044. * Multiplies the current matrix with another one
  59045. * @param other defines the second operand
  59046. * @param result defines the target matrix
  59047. * @returns the current matrix
  59048. */
  59049. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59050. /**
  59051. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59052. * @param x defines the x coordinate to transform
  59053. * @param y defines the x coordinate to transform
  59054. * @param result defines the target vector2
  59055. * @returns the current matrix
  59056. */
  59057. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59058. /**
  59059. * Creates an identity matrix
  59060. * @returns a new matrix
  59061. */
  59062. static Identity(): Matrix2D;
  59063. /**
  59064. * Creates a translation matrix and stores it in a target matrix
  59065. * @param x defines the x coordinate of the translation
  59066. * @param y defines the y coordinate of the translation
  59067. * @param result defines the target matrix
  59068. */
  59069. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59070. /**
  59071. * Creates a scaling matrix and stores it in a target matrix
  59072. * @param x defines the x coordinate of the scaling
  59073. * @param y defines the y coordinate of the scaling
  59074. * @param result defines the target matrix
  59075. */
  59076. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59077. /**
  59078. * Creates a rotation matrix and stores it in a target matrix
  59079. * @param angle defines the rotation angle
  59080. * @param result defines the target matrix
  59081. */
  59082. static RotationToRef(angle: number, result: Matrix2D): void;
  59083. private static _TempPreTranslationMatrix;
  59084. private static _TempPostTranslationMatrix;
  59085. private static _TempRotationMatrix;
  59086. private static _TempScalingMatrix;
  59087. private static _TempCompose0;
  59088. private static _TempCompose1;
  59089. private static _TempCompose2;
  59090. /**
  59091. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59092. * @param tx defines the x coordinate of the translation
  59093. * @param ty defines the y coordinate of the translation
  59094. * @param angle defines the rotation angle
  59095. * @param scaleX defines the x coordinate of the scaling
  59096. * @param scaleY defines the y coordinate of the scaling
  59097. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59098. * @param result defines the target matrix
  59099. */
  59100. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59101. }
  59102. }
  59103. declare module BABYLON.GUI {
  59104. /**
  59105. * Class used to store 2D control sizes
  59106. */
  59107. export class Measure {
  59108. /** defines left coordinate */
  59109. left: number;
  59110. /** defines top coordinate */
  59111. top: number;
  59112. /** defines width dimension */
  59113. width: number;
  59114. /** defines height dimension */
  59115. height: number;
  59116. /**
  59117. * Creates a new measure
  59118. * @param left defines left coordinate
  59119. * @param top defines top coordinate
  59120. * @param width defines width dimension
  59121. * @param height defines height dimension
  59122. */
  59123. constructor(
  59124. /** defines left coordinate */
  59125. left: number,
  59126. /** defines top coordinate */
  59127. top: number,
  59128. /** defines width dimension */
  59129. width: number,
  59130. /** defines height dimension */
  59131. height: number);
  59132. /**
  59133. * Copy from another measure
  59134. * @param other defines the other measure to copy from
  59135. */
  59136. copyFrom(other: Measure): void;
  59137. /**
  59138. * Copy from a group of 4 floats
  59139. * @param left defines left coordinate
  59140. * @param top defines top coordinate
  59141. * @param width defines width dimension
  59142. * @param height defines height dimension
  59143. */
  59144. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59145. /**
  59146. * Computes the axis aligned bounding box measure for two given measures
  59147. * @param a Input measure
  59148. * @param b Input measure
  59149. * @param result the resulting bounding measure
  59150. */
  59151. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59152. /**
  59153. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59154. * @param transform the matrix to transform the measure before computing the AABB
  59155. * @param result the resulting AABB
  59156. */
  59157. transformToRef(transform: Matrix2D, result: Measure): void;
  59158. /**
  59159. * Check equality between this measure and another one
  59160. * @param other defines the other measures
  59161. * @returns true if both measures are equals
  59162. */
  59163. isEqualsTo(other: Measure): boolean;
  59164. /**
  59165. * Creates an empty measure
  59166. * @returns a new measure
  59167. */
  59168. static Empty(): Measure;
  59169. }
  59170. }
  59171. declare module BABYLON.GUI {
  59172. /**
  59173. * Interface used to define a control that can receive focus
  59174. */
  59175. export interface IFocusableControl {
  59176. /**
  59177. * Function called when the control receives the focus
  59178. */
  59179. onFocus(): void;
  59180. /**
  59181. * Function called when the control loses the focus
  59182. */
  59183. onBlur(): void;
  59184. /**
  59185. * Function called to let the control handle keyboard events
  59186. * @param evt defines the current keyboard event
  59187. */
  59188. processKeyboard(evt: KeyboardEvent): void;
  59189. /**
  59190. * Function called to get the list of controls that should not steal the focus from this control
  59191. * @returns an array of controls
  59192. */
  59193. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59194. }
  59195. /**
  59196. * Class used to create texture to support 2D GUI elements
  59197. * @see http://doc.babylonjs.com/how_to/gui
  59198. */
  59199. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59200. private _isDirty;
  59201. private _renderObserver;
  59202. private _resizeObserver;
  59203. private _preKeyboardObserver;
  59204. private _pointerMoveObserver;
  59205. private _pointerObserver;
  59206. private _canvasPointerOutObserver;
  59207. private _background;
  59208. /** @hidden */ private _rootContainer: Container;
  59209. /** @hidden */ private _lastPickedControl: Control;
  59210. /** @hidden */ private _lastControlOver: {
  59211. [pointerId: number]: Control;
  59212. };
  59213. /** @hidden */ private _lastControlDown: {
  59214. [pointerId: number]: Control;
  59215. };
  59216. /** @hidden */ private _capturingControl: {
  59217. [pointerId: number]: Control;
  59218. };
  59219. /** @hidden */ private _shouldBlockPointer: boolean;
  59220. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59221. /** @hidden */ private _linkedControls: Control[];
  59222. private _isFullscreen;
  59223. private _fullscreenViewport;
  59224. private _idealWidth;
  59225. private _idealHeight;
  59226. private _useSmallestIdeal;
  59227. private _renderAtIdealSize;
  59228. private _focusedControl;
  59229. private _blockNextFocusCheck;
  59230. private _renderScale;
  59231. private _rootCanvas;
  59232. private _cursorChanged;
  59233. /**
  59234. * Define type to string to ensure compatibility across browsers
  59235. * Safari doesn't support DataTransfer constructor
  59236. */
  59237. private _clipboardData;
  59238. /**
  59239. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59240. */
  59241. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59242. /**
  59243. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59244. */
  59245. onControlPickedObservable: BABYLON.Observable<Control>;
  59246. /**
  59247. * BABYLON.Observable event triggered before layout is evaluated
  59248. */
  59249. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59250. /**
  59251. * BABYLON.Observable event triggered after the layout was evaluated
  59252. */
  59253. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59254. /**
  59255. * BABYLON.Observable event triggered before the texture is rendered
  59256. */
  59257. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59258. /**
  59259. * BABYLON.Observable event triggered after the texture was rendered
  59260. */
  59261. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59262. /**
  59263. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59264. */
  59265. premulAlpha: boolean;
  59266. /**
  59267. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59268. * Useful when you want more antialiasing
  59269. */
  59270. renderScale: number;
  59271. /** Gets or sets the background color */
  59272. background: string;
  59273. /**
  59274. * Gets or sets the ideal width used to design controls.
  59275. * The GUI will then rescale everything accordingly
  59276. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59277. */
  59278. idealWidth: number;
  59279. /**
  59280. * Gets or sets the ideal height used to design controls.
  59281. * The GUI will then rescale everything accordingly
  59282. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59283. */
  59284. idealHeight: number;
  59285. /**
  59286. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59287. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59288. */
  59289. useSmallestIdeal: boolean;
  59290. /**
  59291. * Gets or sets a boolean indicating if adaptive scaling must be used
  59292. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59293. */
  59294. renderAtIdealSize: boolean;
  59295. /**
  59296. * Gets the underlying layer used to render the texture when in fullscreen mode
  59297. */
  59298. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59299. /**
  59300. * Gets the root container control
  59301. */
  59302. readonly rootContainer: Container;
  59303. /**
  59304. * Returns an array containing the root container.
  59305. * This is mostly used to let the Inspector introspects the ADT
  59306. * @returns an array containing the rootContainer
  59307. */
  59308. getChildren(): Array<Container>;
  59309. /**
  59310. * Will return all controls that are inside this texture
  59311. * @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
  59312. * @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
  59313. * @return all child controls
  59314. */
  59315. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59316. /**
  59317. * Gets or sets the current focused control
  59318. */
  59319. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59320. /**
  59321. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59322. */
  59323. isForeground: boolean;
  59324. /**
  59325. * Gets or set information about clipboardData
  59326. */
  59327. clipboardData: string;
  59328. /**
  59329. * Creates a new AdvancedDynamicTexture
  59330. * @param name defines the name of the texture
  59331. * @param width defines the width of the texture
  59332. * @param height defines the height of the texture
  59333. * @param scene defines the hosting scene
  59334. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59335. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59336. */
  59337. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59338. /**
  59339. * Get the current class name of the texture useful for serialization or dynamic coding.
  59340. * @returns "AdvancedDynamicTexture"
  59341. */
  59342. getClassName(): string;
  59343. /**
  59344. * Function used to execute a function on all controls
  59345. * @param func defines the function to execute
  59346. * @param container defines the container where controls belong. If null the root container will be used
  59347. */
  59348. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59349. private _useInvalidateRectOptimization;
  59350. /**
  59351. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59352. */
  59353. useInvalidateRectOptimization: boolean;
  59354. private _invalidatedRectangle;
  59355. /**
  59356. * Invalidates a rectangle area on the gui texture
  59357. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59358. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59359. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59360. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59361. */
  59362. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59363. /**
  59364. * Marks the texture as dirty forcing a complete update
  59365. */
  59366. markAsDirty(): void;
  59367. /**
  59368. * Helper function used to create a new style
  59369. * @returns a new style
  59370. * @see http://doc.babylonjs.com/how_to/gui#styles
  59371. */
  59372. createStyle(): Style;
  59373. /**
  59374. * Adds a new control to the root container
  59375. * @param control defines the control to add
  59376. * @returns the current texture
  59377. */
  59378. addControl(control: Control): AdvancedDynamicTexture;
  59379. /**
  59380. * Removes a control from the root container
  59381. * @param control defines the control to remove
  59382. * @returns the current texture
  59383. */
  59384. removeControl(control: Control): AdvancedDynamicTexture;
  59385. /**
  59386. * Release all resources
  59387. */
  59388. dispose(): void;
  59389. private _onResize;
  59390. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59391. /**
  59392. * Get screen coordinates for a vector3
  59393. * @param position defines the position to project
  59394. * @param worldMatrix defines the world matrix to use
  59395. * @returns the projected position
  59396. */
  59397. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59398. private _checkUpdate;
  59399. private _clearMeasure;
  59400. private _render;
  59401. /** @hidden */ private _changeCursor(cursor: string): void;
  59402. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  59403. private _doPicking;
  59404. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  59405. [pointerId: number]: Control;
  59406. }, control: Control): void;
  59407. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  59408. /** Attach to all scene events required to support pointer events */
  59409. attach(): void;
  59410. /** @hidden */
  59411. private onClipboardCopy;
  59412. /** @hidden */
  59413. private onClipboardCut;
  59414. /** @hidden */
  59415. private onClipboardPaste;
  59416. /**
  59417. * Register the clipboard Events onto the canvas
  59418. */
  59419. registerClipboardEvents(): void;
  59420. /**
  59421. * Unregister the clipboard Events from the canvas
  59422. */
  59423. unRegisterClipboardEvents(): void;
  59424. /**
  59425. * Connect the texture to a hosting mesh to enable interactions
  59426. * @param mesh defines the mesh to attach to
  59427. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  59428. */
  59429. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  59430. /**
  59431. * Move the focus to a specific control
  59432. * @param control defines the control which will receive the focus
  59433. */
  59434. moveFocusToControl(control: IFocusableControl): void;
  59435. private _manageFocus;
  59436. private _attachToOnPointerOut;
  59437. /**
  59438. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  59439. * @param mesh defines the mesh which will receive the texture
  59440. * @param width defines the texture width (1024 by default)
  59441. * @param height defines the texture height (1024 by default)
  59442. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  59443. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  59444. * @returns a new AdvancedDynamicTexture
  59445. */
  59446. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  59447. /**
  59448. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  59449. * In this mode the texture will rely on a layer for its rendering.
  59450. * This allows it to be treated like any other layer.
  59451. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  59452. * LayerMask is set through advancedTexture.layer.layerMask
  59453. * @param name defines name for the texture
  59454. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  59455. * @param scene defines the hsoting scene
  59456. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  59457. * @returns a new AdvancedDynamicTexture
  59458. */
  59459. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  59460. }
  59461. }
  59462. declare module BABYLON.GUI {
  59463. /**
  59464. * Root class used for all 2D controls
  59465. * @see http://doc.babylonjs.com/how_to/gui#controls
  59466. */
  59467. export class Control {
  59468. /** defines the name of the control */
  59469. name?: string | undefined;
  59470. /**
  59471. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  59472. */
  59473. static AllowAlphaInheritance: boolean;
  59474. private _alpha;
  59475. private _alphaSet;
  59476. private _zIndex;
  59477. /** @hidden */ private _host: AdvancedDynamicTexture;
  59478. /** Gets or sets the control parent */
  59479. parent: BABYLON.Nullable<Container>;
  59480. /** @hidden */ private _currentMeasure: Measure;
  59481. private _fontFamily;
  59482. private _fontStyle;
  59483. private _fontWeight;
  59484. private _fontSize;
  59485. private _font;
  59486. /** @hidden */ private _width: ValueAndUnit;
  59487. /** @hidden */ private _height: ValueAndUnit;
  59488. /** @hidden */
  59489. protected _fontOffset: {
  59490. ascent: number;
  59491. height: number;
  59492. descent: number;
  59493. };
  59494. private _color;
  59495. private _style;
  59496. private _styleObserver;
  59497. /** @hidden */
  59498. protected _horizontalAlignment: number;
  59499. /** @hidden */
  59500. protected _verticalAlignment: number;
  59501. /** @hidden */
  59502. protected _isDirty: boolean;
  59503. /** @hidden */
  59504. protected _wasDirty: boolean;
  59505. /** @hidden */ private _tempParentMeasure: Measure;
  59506. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  59507. /** @hidden */
  59508. protected _cachedParentMeasure: Measure;
  59509. private _paddingLeft;
  59510. private _paddingRight;
  59511. private _paddingTop;
  59512. private _paddingBottom;
  59513. /** @hidden */ private _left: ValueAndUnit;
  59514. /** @hidden */ private _top: ValueAndUnit;
  59515. private _scaleX;
  59516. private _scaleY;
  59517. private _rotation;
  59518. private _transformCenterX;
  59519. private _transformCenterY;
  59520. /** @hidden */ private _transformMatrix: Matrix2D;
  59521. /** @hidden */
  59522. protected _invertTransformMatrix: Matrix2D;
  59523. /** @hidden */
  59524. protected _transformedPosition: BABYLON.Vector2;
  59525. private _isMatrixDirty;
  59526. private _cachedOffsetX;
  59527. private _cachedOffsetY;
  59528. private _isVisible;
  59529. private _isHighlighted;
  59530. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59531. private _fontSet;
  59532. private _dummyVector2;
  59533. private _downCount;
  59534. private _enterCount;
  59535. private _doNotRender;
  59536. private _downPointerIds;
  59537. protected _isEnabled: boolean;
  59538. protected _disabledColor: string;
  59539. /** @hidden */
  59540. protected _rebuildLayout: boolean;
  59541. /** @hidden */ private _isClipped: boolean;
  59542. /** @hidden */ private _tag: any;
  59543. /**
  59544. * 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
  59545. */
  59546. uniqueId: number;
  59547. /**
  59548. * Gets or sets an object used to store user defined information for the node
  59549. */
  59550. metadata: any;
  59551. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  59552. isHitTestVisible: boolean;
  59553. /** Gets or sets a boolean indicating if the control can block pointer events */
  59554. isPointerBlocker: boolean;
  59555. /** Gets or sets a boolean indicating if the control can be focusable */
  59556. isFocusInvisible: boolean;
  59557. /**
  59558. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  59559. * 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
  59560. */
  59561. clipChildren: boolean;
  59562. /**
  59563. * Gets or sets a boolean indicating that control content must be clipped
  59564. * 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
  59565. */
  59566. clipContent: boolean;
  59567. /**
  59568. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  59569. */
  59570. useBitmapCache: boolean;
  59571. private _cacheData;
  59572. private _shadowOffsetX;
  59573. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  59574. shadowOffsetX: number;
  59575. private _shadowOffsetY;
  59576. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  59577. shadowOffsetY: number;
  59578. private _shadowBlur;
  59579. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  59580. shadowBlur: number;
  59581. private _shadowColor;
  59582. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  59583. shadowColor: string;
  59584. /** Gets or sets the cursor to use when the control is hovered */
  59585. hoverCursor: string;
  59586. /** @hidden */
  59587. protected _linkOffsetX: ValueAndUnit;
  59588. /** @hidden */
  59589. protected _linkOffsetY: ValueAndUnit;
  59590. /** Gets the control type name */
  59591. readonly typeName: string;
  59592. /**
  59593. * Get the current class name of the control.
  59594. * @returns current class name
  59595. */
  59596. getClassName(): string;
  59597. /**
  59598. * An event triggered when the pointer move over the control.
  59599. */
  59600. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  59601. /**
  59602. * An event triggered when the pointer move out of the control.
  59603. */
  59604. onPointerOutObservable: BABYLON.Observable<Control>;
  59605. /**
  59606. * An event triggered when the pointer taps the control
  59607. */
  59608. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  59609. /**
  59610. * An event triggered when pointer up
  59611. */
  59612. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  59613. /**
  59614. * An event triggered when a control is clicked on
  59615. */
  59616. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  59617. /**
  59618. * An event triggered when pointer enters the control
  59619. */
  59620. onPointerEnterObservable: BABYLON.Observable<Control>;
  59621. /**
  59622. * An event triggered when the control is marked as dirty
  59623. */
  59624. onDirtyObservable: BABYLON.Observable<Control>;
  59625. /**
  59626. * An event triggered before drawing the control
  59627. */
  59628. onBeforeDrawObservable: BABYLON.Observable<Control>;
  59629. /**
  59630. * An event triggered after the control was drawn
  59631. */
  59632. onAfterDrawObservable: BABYLON.Observable<Control>;
  59633. /**
  59634. * Get the hosting AdvancedDynamicTexture
  59635. */
  59636. readonly host: AdvancedDynamicTexture;
  59637. /** Gets or set information about font offsets (used to render and align text) */
  59638. fontOffset: {
  59639. ascent: number;
  59640. height: number;
  59641. descent: number;
  59642. };
  59643. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  59644. alpha: number;
  59645. /**
  59646. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  59647. */
  59648. isHighlighted: boolean;
  59649. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  59650. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59651. */
  59652. scaleX: number;
  59653. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  59654. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59655. */
  59656. scaleY: number;
  59657. /** Gets or sets the rotation angle (0 by default)
  59658. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59659. */
  59660. rotation: number;
  59661. /** Gets or sets the transformation center on Y axis (0 by default)
  59662. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59663. */
  59664. transformCenterY: number;
  59665. /** Gets or sets the transformation center on X axis (0 by default)
  59666. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59667. */
  59668. transformCenterX: number;
  59669. /**
  59670. * Gets or sets the horizontal alignment
  59671. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59672. */
  59673. horizontalAlignment: number;
  59674. /**
  59675. * Gets or sets the vertical alignment
  59676. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59677. */
  59678. verticalAlignment: number;
  59679. /**
  59680. * Gets or sets control width
  59681. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59682. */
  59683. width: string | number;
  59684. /**
  59685. * Gets or sets the control width in pixel
  59686. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59687. */
  59688. widthInPixels: number;
  59689. /**
  59690. * Gets or sets control height
  59691. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59692. */
  59693. height: string | number;
  59694. /**
  59695. * Gets or sets control height in pixel
  59696. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59697. */
  59698. heightInPixels: number;
  59699. /** Gets or set font family */
  59700. fontFamily: string;
  59701. /** Gets or sets font style */
  59702. fontStyle: string;
  59703. /** Gets or sets font weight */
  59704. fontWeight: string;
  59705. /**
  59706. * Gets or sets style
  59707. * @see http://doc.babylonjs.com/how_to/gui#styles
  59708. */
  59709. style: BABYLON.Nullable<Style>;
  59710. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  59711. /** Gets or sets font size in pixels */
  59712. fontSizeInPixels: number;
  59713. /** Gets or sets font size */
  59714. fontSize: string | number;
  59715. /** Gets or sets foreground color */
  59716. color: string;
  59717. /** Gets or sets z index which is used to reorder controls on the z axis */
  59718. zIndex: number;
  59719. /** Gets or sets a boolean indicating if the control can be rendered */
  59720. notRenderable: boolean;
  59721. /** Gets or sets a boolean indicating if the control is visible */
  59722. isVisible: boolean;
  59723. /** Gets a boolean indicating that the control needs to update its rendering */
  59724. readonly isDirty: boolean;
  59725. /**
  59726. * Gets the current linked mesh (or null if none)
  59727. */
  59728. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59729. /**
  59730. * Gets or sets a value indicating the padding to use on the left of the control
  59731. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59732. */
  59733. paddingLeft: string | number;
  59734. /**
  59735. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  59736. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59737. */
  59738. paddingLeftInPixels: number;
  59739. /**
  59740. * Gets or sets a value indicating the padding to use on the right of the control
  59741. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59742. */
  59743. paddingRight: string | number;
  59744. /**
  59745. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  59746. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59747. */
  59748. paddingRightInPixels: number;
  59749. /**
  59750. * Gets or sets a value indicating the padding to use on the top of the control
  59751. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59752. */
  59753. paddingTop: string | number;
  59754. /**
  59755. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  59756. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59757. */
  59758. paddingTopInPixels: number;
  59759. /**
  59760. * Gets or sets a value indicating the padding to use on the bottom of the control
  59761. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59762. */
  59763. paddingBottom: string | number;
  59764. /**
  59765. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  59766. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59767. */
  59768. paddingBottomInPixels: number;
  59769. /**
  59770. * Gets or sets a value indicating the left coordinate of the control
  59771. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59772. */
  59773. left: string | number;
  59774. /**
  59775. * Gets or sets a value indicating the left coordinate in pixels of the control
  59776. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59777. */
  59778. leftInPixels: number;
  59779. /**
  59780. * Gets or sets a value indicating the top coordinate of the control
  59781. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59782. */
  59783. top: string | number;
  59784. /**
  59785. * Gets or sets a value indicating the top coordinate in pixels of the control
  59786. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59787. */
  59788. topInPixels: number;
  59789. /**
  59790. * Gets or sets a value indicating the offset on X axis to the linked mesh
  59791. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59792. */
  59793. linkOffsetX: string | number;
  59794. /**
  59795. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  59796. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59797. */
  59798. linkOffsetXInPixels: number;
  59799. /**
  59800. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  59801. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59802. */
  59803. linkOffsetY: string | number;
  59804. /**
  59805. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  59806. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59807. */
  59808. linkOffsetYInPixels: number;
  59809. /** Gets the center coordinate on X axis */
  59810. readonly centerX: number;
  59811. /** Gets the center coordinate on Y axis */
  59812. readonly centerY: number;
  59813. /** Gets or sets if control is Enabled*/
  59814. isEnabled: boolean;
  59815. /** Gets or sets background color of control if it's disabled*/
  59816. disabledColor: string;
  59817. /**
  59818. * Creates a new control
  59819. * @param name defines the name of the control
  59820. */
  59821. constructor(
  59822. /** defines the name of the control */
  59823. name?: string | undefined);
  59824. /** @hidden */
  59825. protected _getTypeName(): string;
  59826. /**
  59827. * Gets the first ascendant in the hierarchy of the given type
  59828. * @param className defines the required type
  59829. * @returns the ascendant or null if not found
  59830. */
  59831. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  59832. /** @hidden */ private _resetFontCache(): void;
  59833. /**
  59834. * Determines if a container is an ascendant of the current control
  59835. * @param container defines the container to look for
  59836. * @returns true if the container is one of the ascendant of the control
  59837. */
  59838. isAscendant(container: Control): boolean;
  59839. /**
  59840. * Gets coordinates in local control space
  59841. * @param globalCoordinates defines the coordinates to transform
  59842. * @returns the new coordinates in local space
  59843. */
  59844. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59845. /**
  59846. * Gets coordinates in local control space
  59847. * @param globalCoordinates defines the coordinates to transform
  59848. * @param result defines the target vector2 where to store the result
  59849. * @returns the current control
  59850. */
  59851. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  59852. /**
  59853. * Gets coordinates in parent local control space
  59854. * @param globalCoordinates defines the coordinates to transform
  59855. * @returns the new coordinates in parent local space
  59856. */
  59857. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59858. /**
  59859. * Move the current control to a vector3 position projected onto the screen.
  59860. * @param position defines the target position
  59861. * @param scene defines the hosting scene
  59862. */
  59863. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  59864. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  59865. /**
  59866. * Will return all controls that have this control as ascendant
  59867. * @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
  59868. * @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
  59869. * @return all child controls
  59870. */
  59871. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59872. /**
  59873. * Link current control with a target mesh
  59874. * @param mesh defines the mesh to link with
  59875. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59876. */
  59877. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  59878. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  59879. /** @hidden */ private _offsetLeft(offset: number): void;
  59880. /** @hidden */ private _offsetTop(offset: number): void;
  59881. /** @hidden */ private _markMatrixAsDirty(): void;
  59882. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  59883. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  59884. /** @hidden */
  59885. protected invalidateRect(): void;
  59886. /** @hidden */ private _markAsDirty(force?: boolean): void;
  59887. /** @hidden */ private _markAllAsDirty(): void;
  59888. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  59889. /** @hidden */
  59890. protected _transform(context?: CanvasRenderingContext2D): void;
  59891. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  59892. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  59893. /** @hidden */
  59894. protected _applyStates(context: CanvasRenderingContext2D): void;
  59895. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  59896. /** @hidden */
  59897. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59898. protected _evaluateClippingState(parentMeasure: Measure): void;
  59899. /** @hidden */ private _measure(): void;
  59900. /** @hidden */
  59901. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59902. /** @hidden */
  59903. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59904. /** @hidden */
  59905. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59906. /** @hidden */
  59907. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  59908. private static _ClipMeasure;
  59909. private _tmpMeasureA;
  59910. private _clip;
  59911. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  59912. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  59913. /**
  59914. * Tests if a given coordinates belong to the current control
  59915. * @param x defines x coordinate to test
  59916. * @param y defines y coordinate to test
  59917. * @returns true if the coordinates are inside the control
  59918. */
  59919. contains(x: number, y: number): boolean;
  59920. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  59921. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  59922. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  59923. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  59924. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  59925. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59926. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59927. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  59928. private _prepareFont;
  59929. /** Releases associated resources */
  59930. dispose(): void;
  59931. private static _HORIZONTAL_ALIGNMENT_LEFT;
  59932. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  59933. private static _HORIZONTAL_ALIGNMENT_CENTER;
  59934. private static _VERTICAL_ALIGNMENT_TOP;
  59935. private static _VERTICAL_ALIGNMENT_BOTTOM;
  59936. private static _VERTICAL_ALIGNMENT_CENTER;
  59937. /** HORIZONTAL_ALIGNMENT_LEFT */
  59938. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  59939. /** HORIZONTAL_ALIGNMENT_RIGHT */
  59940. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  59941. /** HORIZONTAL_ALIGNMENT_CENTER */
  59942. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  59943. /** VERTICAL_ALIGNMENT_TOP */
  59944. static readonly VERTICAL_ALIGNMENT_TOP: number;
  59945. /** VERTICAL_ALIGNMENT_BOTTOM */
  59946. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  59947. /** VERTICAL_ALIGNMENT_CENTER */
  59948. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  59949. private static _FontHeightSizes;
  59950. /** @hidden */ private static _GetFontOffset(font: string): {
  59951. ascent: number;
  59952. height: number;
  59953. descent: number;
  59954. };
  59955. /**
  59956. * Creates a stack panel that can be used to render headers
  59957. * @param control defines the control to associate with the header
  59958. * @param text defines the text of the header
  59959. * @param size defines the size of the header
  59960. * @param options defines options used to configure the header
  59961. * @returns a new StackPanel
  59962. * @ignore
  59963. * @hidden
  59964. */
  59965. static AddHeader: (control: Control, text: string, size: string | number, options: {
  59966. isHorizontal: boolean;
  59967. controlFirst: boolean;
  59968. }) => any;
  59969. /** @hidden */
  59970. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  59971. }
  59972. }
  59973. declare module BABYLON.GUI {
  59974. /**
  59975. * Root class for 2D containers
  59976. * @see http://doc.babylonjs.com/how_to/gui#containers
  59977. */
  59978. export class Container extends Control {
  59979. name?: string | undefined;
  59980. /** @hidden */
  59981. protected _children: Control[];
  59982. /** @hidden */
  59983. protected _measureForChildren: Measure;
  59984. /** @hidden */
  59985. protected _background: string;
  59986. /** @hidden */
  59987. protected _adaptWidthToChildren: boolean;
  59988. /** @hidden */
  59989. protected _adaptHeightToChildren: boolean;
  59990. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  59991. adaptHeightToChildren: boolean;
  59992. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  59993. adaptWidthToChildren: boolean;
  59994. /** Gets or sets background color */
  59995. background: string;
  59996. /** Gets the list of children */
  59997. readonly children: Control[];
  59998. /**
  59999. * Creates a new Container
  60000. * @param name defines the name of the container
  60001. */
  60002. constructor(name?: string | undefined);
  60003. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  60004. /**
  60005. * Gets a child using its name
  60006. * @param name defines the child name to look for
  60007. * @returns the child control if found
  60008. */
  60009. getChildByName(name: string): BABYLON.Nullable<Control>;
  60010. /**
  60011. * Gets a child using its type and its name
  60012. * @param name defines the child name to look for
  60013. * @param type defines the child type to look for
  60014. * @returns the child control if found
  60015. */
  60016. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60017. /**
  60018. * Search for a specific control in children
  60019. * @param control defines the control to look for
  60020. * @returns true if the control is in child list
  60021. */
  60022. containsControl(control: Control): boolean;
  60023. /**
  60024. * Adds a new control to the current container
  60025. * @param control defines the control to add
  60026. * @returns the current container
  60027. */
  60028. addControl(control: BABYLON.Nullable<Control>): Container;
  60029. /**
  60030. * Removes all controls from the current container
  60031. * @returns the current container
  60032. */
  60033. clearControls(): Container;
  60034. /**
  60035. * Removes a control from the current container
  60036. * @param control defines the control to remove
  60037. * @returns the current container
  60038. */
  60039. removeControl(control: Control): Container;
  60040. /** @hidden */ private _reOrderControl(control: Control): void;
  60041. /** @hidden */ private _offsetLeft(offset: number): void;
  60042. /** @hidden */ private _offsetTop(offset: number): void;
  60043. /** @hidden */ private _markAllAsDirty(): void;
  60044. /** @hidden */
  60045. protected _localDraw(context: CanvasRenderingContext2D): void;
  60046. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  60047. /** @hidden */
  60048. protected _beforeLayout(): void;
  60049. /** @hidden */
  60050. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60051. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60052. protected _postMeasure(): void;
  60053. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60054. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60055. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60056. /** @hidden */
  60057. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60058. /** Releases associated resources */
  60059. dispose(): void;
  60060. }
  60061. }
  60062. declare module BABYLON.GUI {
  60063. /** Class used to create rectangle container */
  60064. export class Rectangle extends Container {
  60065. name?: string | undefined;
  60066. private _thickness;
  60067. private _cornerRadius;
  60068. /** Gets or sets border thickness */
  60069. thickness: number;
  60070. /** Gets or sets the corner radius angle */
  60071. cornerRadius: number;
  60072. /**
  60073. * Creates a new Rectangle
  60074. * @param name defines the control name
  60075. */
  60076. constructor(name?: string | undefined);
  60077. protected _getTypeName(): string;
  60078. protected _localDraw(context: CanvasRenderingContext2D): void;
  60079. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60080. private _drawRoundedRect;
  60081. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60082. }
  60083. }
  60084. declare module BABYLON.GUI {
  60085. /**
  60086. * Enum that determines the text-wrapping mode to use.
  60087. */
  60088. export enum TextWrapping {
  60089. /**
  60090. * Clip the text when it's larger than Control.width; this is the default mode.
  60091. */
  60092. Clip = 0,
  60093. /**
  60094. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60095. */
  60096. WordWrap = 1,
  60097. /**
  60098. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60099. */
  60100. Ellipsis = 2
  60101. }
  60102. /**
  60103. * Class used to create text block control
  60104. */
  60105. export class TextBlock extends Control {
  60106. /**
  60107. * Defines the name of the control
  60108. */
  60109. name?: string | undefined;
  60110. private _text;
  60111. private _textWrapping;
  60112. private _textHorizontalAlignment;
  60113. private _textVerticalAlignment;
  60114. private _lines;
  60115. private _resizeToFit;
  60116. private _lineSpacing;
  60117. private _outlineWidth;
  60118. private _outlineColor;
  60119. /**
  60120. * An event triggered after the text is changed
  60121. */
  60122. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60123. /**
  60124. * An event triggered after the text was broken up into lines
  60125. */
  60126. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60127. /**
  60128. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60129. */
  60130. readonly lines: any[];
  60131. /**
  60132. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60133. */
  60134. /**
  60135. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60136. */
  60137. resizeToFit: boolean;
  60138. /**
  60139. * Gets or sets a boolean indicating if text must be wrapped
  60140. */
  60141. /**
  60142. * Gets or sets a boolean indicating if text must be wrapped
  60143. */
  60144. textWrapping: TextWrapping | boolean;
  60145. /**
  60146. * Gets or sets text to display
  60147. */
  60148. /**
  60149. * Gets or sets text to display
  60150. */
  60151. text: string;
  60152. /**
  60153. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60154. */
  60155. /**
  60156. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60157. */
  60158. textHorizontalAlignment: number;
  60159. /**
  60160. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60161. */
  60162. /**
  60163. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60164. */
  60165. textVerticalAlignment: number;
  60166. /**
  60167. * Gets or sets line spacing value
  60168. */
  60169. /**
  60170. * Gets or sets line spacing value
  60171. */
  60172. lineSpacing: string | number;
  60173. /**
  60174. * Gets or sets outlineWidth of the text to display
  60175. */
  60176. /**
  60177. * Gets or sets outlineWidth of the text to display
  60178. */
  60179. outlineWidth: number;
  60180. /**
  60181. * Gets or sets outlineColor of the text to display
  60182. */
  60183. /**
  60184. * Gets or sets outlineColor of the text to display
  60185. */
  60186. outlineColor: string;
  60187. /**
  60188. * Creates a new TextBlock object
  60189. * @param name defines the name of the control
  60190. * @param text defines the text to display (emptry string by default)
  60191. */
  60192. constructor(
  60193. /**
  60194. * Defines the name of the control
  60195. */
  60196. name?: string | undefined, text?: string);
  60197. protected _getTypeName(): string;
  60198. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60199. private _drawText;
  60200. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60201. protected _applyStates(context: CanvasRenderingContext2D): void;
  60202. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60203. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60204. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60205. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60206. protected _renderLines(context: CanvasRenderingContext2D): void;
  60207. /**
  60208. * Given a width constraint applied on the text block, find the expected height
  60209. * @returns expected height
  60210. */
  60211. computeExpectedHeight(): number;
  60212. dispose(): void;
  60213. }
  60214. }
  60215. declare module BABYLON.GUI {
  60216. /**
  60217. * Class used to create 2D images
  60218. */
  60219. export class Image extends Control {
  60220. name?: string | undefined;
  60221. private static _WorkingCanvas;
  60222. private _domImage;
  60223. private _imageWidth;
  60224. private _imageHeight;
  60225. private _loaded;
  60226. private _stretch;
  60227. private _source;
  60228. private _autoScale;
  60229. private _sourceLeft;
  60230. private _sourceTop;
  60231. private _sourceWidth;
  60232. private _sourceHeight;
  60233. private _cellWidth;
  60234. private _cellHeight;
  60235. private _cellId;
  60236. private _populateNinePatchSlicesFromImage;
  60237. private _sliceLeft;
  60238. private _sliceRight;
  60239. private _sliceTop;
  60240. private _sliceBottom;
  60241. private _detectPointerOnOpaqueOnly;
  60242. /**
  60243. * BABYLON.Observable notified when the content is loaded
  60244. */
  60245. onImageLoadedObservable: BABYLON.Observable<Image>;
  60246. /**
  60247. * Gets a boolean indicating that the content is loaded
  60248. */
  60249. readonly isLoaded: boolean;
  60250. /**
  60251. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60252. */
  60253. populateNinePatchSlicesFromImage: boolean;
  60254. /**
  60255. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60256. * Beware using this as this will comsume more memory as the image has to be stored twice
  60257. */
  60258. detectPointerOnOpaqueOnly: boolean;
  60259. /**
  60260. * Gets or sets the left value for slicing (9-patch)
  60261. */
  60262. sliceLeft: number;
  60263. /**
  60264. * Gets or sets the right value for slicing (9-patch)
  60265. */
  60266. sliceRight: number;
  60267. /**
  60268. * Gets or sets the top value for slicing (9-patch)
  60269. */
  60270. sliceTop: number;
  60271. /**
  60272. * Gets or sets the bottom value for slicing (9-patch)
  60273. */
  60274. sliceBottom: number;
  60275. /**
  60276. * Gets or sets the left coordinate in the source image
  60277. */
  60278. sourceLeft: number;
  60279. /**
  60280. * Gets or sets the top coordinate in the source image
  60281. */
  60282. sourceTop: number;
  60283. /**
  60284. * Gets or sets the width to capture in the source image
  60285. */
  60286. sourceWidth: number;
  60287. /**
  60288. * Gets or sets the height to capture in the source image
  60289. */
  60290. sourceHeight: number;
  60291. /**
  60292. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60293. * @see http://doc.babylonjs.com/how_to/gui#image
  60294. */
  60295. autoScale: boolean;
  60296. /** Gets or sets the streching mode used by the image */
  60297. stretch: number;
  60298. /**
  60299. * Gets or sets the internal DOM image used to render the control
  60300. */
  60301. domImage: HTMLImageElement;
  60302. private _onImageLoaded;
  60303. private _extractNinePatchSliceDataFromImage;
  60304. /**
  60305. * Gets or sets image source url
  60306. */
  60307. source: BABYLON.Nullable<string>;
  60308. /**
  60309. * Gets or sets the cell width to use when animation sheet is enabled
  60310. * @see http://doc.babylonjs.com/how_to/gui#image
  60311. */
  60312. cellWidth: number;
  60313. /**
  60314. * Gets or sets the cell height to use when animation sheet is enabled
  60315. * @see http://doc.babylonjs.com/how_to/gui#image
  60316. */
  60317. cellHeight: number;
  60318. /**
  60319. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60320. * @see http://doc.babylonjs.com/how_to/gui#image
  60321. */
  60322. cellId: number;
  60323. /**
  60324. * Creates a new Image
  60325. * @param name defines the control name
  60326. * @param url defines the image url
  60327. */
  60328. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60329. /**
  60330. * Tests if a given coordinates belong to the current control
  60331. * @param x defines x coordinate to test
  60332. * @param y defines y coordinate to test
  60333. * @returns true if the coordinates are inside the control
  60334. */
  60335. contains(x: number, y: number): boolean;
  60336. protected _getTypeName(): string;
  60337. /** Force the control to synchronize with its content */
  60338. synchronizeSizeWithContent(): void;
  60339. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60340. private _prepareWorkingCanvasForOpaqueDetection;
  60341. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  60342. private _renderCornerPatch;
  60343. private _renderNinePatch;
  60344. dispose(): void;
  60345. /** STRETCH_NONE */
  60346. static readonly STRETCH_NONE: number;
  60347. /** STRETCH_FILL */
  60348. static readonly STRETCH_FILL: number;
  60349. /** STRETCH_UNIFORM */
  60350. static readonly STRETCH_UNIFORM: number;
  60351. /** STRETCH_EXTEND */
  60352. static readonly STRETCH_EXTEND: number;
  60353. /** NINE_PATCH */
  60354. static readonly STRETCH_NINE_PATCH: number;
  60355. }
  60356. }
  60357. declare module BABYLON.GUI {
  60358. /**
  60359. * Class used to create 2D buttons
  60360. */
  60361. export class Button extends Rectangle {
  60362. name?: string | undefined;
  60363. /**
  60364. * Function called to generate a pointer enter animation
  60365. */
  60366. pointerEnterAnimation: () => void;
  60367. /**
  60368. * Function called to generate a pointer out animation
  60369. */
  60370. pointerOutAnimation: () => void;
  60371. /**
  60372. * Function called to generate a pointer down animation
  60373. */
  60374. pointerDownAnimation: () => void;
  60375. /**
  60376. * Function called to generate a pointer up animation
  60377. */
  60378. pointerUpAnimation: () => void;
  60379. private _image;
  60380. /**
  60381. * Returns the image part of the button (if any)
  60382. */
  60383. readonly image: BABYLON.Nullable<Image>;
  60384. private _textBlock;
  60385. /**
  60386. * Returns the image part of the button (if any)
  60387. */
  60388. readonly textBlock: BABYLON.Nullable<TextBlock>;
  60389. /**
  60390. * Creates a new Button
  60391. * @param name defines the name of the button
  60392. */
  60393. constructor(name?: string | undefined);
  60394. protected _getTypeName(): string;
  60395. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60396. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  60397. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  60398. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60399. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60400. /**
  60401. * Creates a new button made with an image and a text
  60402. * @param name defines the name of the button
  60403. * @param text defines the text of the button
  60404. * @param imageUrl defines the url of the image
  60405. * @returns a new Button
  60406. */
  60407. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  60408. /**
  60409. * Creates a new button made with an image
  60410. * @param name defines the name of the button
  60411. * @param imageUrl defines the url of the image
  60412. * @returns a new Button
  60413. */
  60414. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  60415. /**
  60416. * Creates a new button made with a text
  60417. * @param name defines the name of the button
  60418. * @param text defines the text of the button
  60419. * @returns a new Button
  60420. */
  60421. static CreateSimpleButton(name: string, text: string): Button;
  60422. /**
  60423. * Creates a new button made with an image and a centered text
  60424. * @param name defines the name of the button
  60425. * @param text defines the text of the button
  60426. * @param imageUrl defines the url of the image
  60427. * @returns a new Button
  60428. */
  60429. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  60430. }
  60431. }
  60432. declare module BABYLON.GUI {
  60433. /**
  60434. * Class used to create a 2D stack panel container
  60435. */
  60436. export class StackPanel extends Container {
  60437. name?: string | undefined;
  60438. private _isVertical;
  60439. private _manualWidth;
  60440. private _manualHeight;
  60441. private _doNotTrackManualChanges;
  60442. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  60443. isVertical: boolean;
  60444. /**
  60445. * Gets or sets panel width.
  60446. * This value should not be set when in horizontal mode as it will be computed automatically
  60447. */
  60448. width: string | number;
  60449. /**
  60450. * Gets or sets panel height.
  60451. * This value should not be set when in vertical mode as it will be computed automatically
  60452. */
  60453. height: string | number;
  60454. /**
  60455. * Creates a new StackPanel
  60456. * @param name defines control name
  60457. */
  60458. constructor(name?: string | undefined);
  60459. protected _getTypeName(): string;
  60460. /** @hidden */
  60461. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60462. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60463. protected _postMeasure(): void;
  60464. }
  60465. }
  60466. declare module BABYLON.GUI {
  60467. /**
  60468. * Class used to represent a 2D checkbox
  60469. */
  60470. export class Checkbox extends Control {
  60471. name?: string | undefined;
  60472. private _isChecked;
  60473. private _background;
  60474. private _checkSizeRatio;
  60475. private _thickness;
  60476. /** Gets or sets border thickness */
  60477. thickness: number;
  60478. /**
  60479. * BABYLON.Observable raised when isChecked property changes
  60480. */
  60481. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60482. /** Gets or sets a value indicating the ratio between overall size and check size */
  60483. checkSizeRatio: number;
  60484. /** Gets or sets background color */
  60485. background: string;
  60486. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60487. isChecked: boolean;
  60488. /**
  60489. * Creates a new CheckBox
  60490. * @param name defines the control name
  60491. */
  60492. constructor(name?: string | undefined);
  60493. protected _getTypeName(): string;
  60494. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60495. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60496. /**
  60497. * Utility function to easily create a checkbox with a header
  60498. * @param title defines the label to use for the header
  60499. * @param onValueChanged defines the callback to call when value changes
  60500. * @returns a StackPanel containing the checkbox and a textBlock
  60501. */
  60502. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  60503. }
  60504. }
  60505. declare module BABYLON.GUI {
  60506. /**
  60507. * Class used to store key control properties
  60508. */
  60509. export class KeyPropertySet {
  60510. /** Width */
  60511. width?: string;
  60512. /** Height */
  60513. height?: string;
  60514. /** Left padding */
  60515. paddingLeft?: string;
  60516. /** Right padding */
  60517. paddingRight?: string;
  60518. /** Top padding */
  60519. paddingTop?: string;
  60520. /** Bottom padding */
  60521. paddingBottom?: string;
  60522. /** Foreground color */
  60523. color?: string;
  60524. /** Background color */
  60525. background?: string;
  60526. }
  60527. /**
  60528. * Class used to create virtual keyboard
  60529. */
  60530. export class VirtualKeyboard extends StackPanel {
  60531. /** BABYLON.Observable raised when a key is pressed */
  60532. onKeyPressObservable: BABYLON.Observable<string>;
  60533. /** Gets or sets default key button width */
  60534. defaultButtonWidth: string;
  60535. /** Gets or sets default key button height */
  60536. defaultButtonHeight: string;
  60537. /** Gets or sets default key button left padding */
  60538. defaultButtonPaddingLeft: string;
  60539. /** Gets or sets default key button right padding */
  60540. defaultButtonPaddingRight: string;
  60541. /** Gets or sets default key button top padding */
  60542. defaultButtonPaddingTop: string;
  60543. /** Gets or sets default key button bottom padding */
  60544. defaultButtonPaddingBottom: string;
  60545. /** Gets or sets default key button foreground color */
  60546. defaultButtonColor: string;
  60547. /** Gets or sets default key button background color */
  60548. defaultButtonBackground: string;
  60549. /** Gets or sets shift button foreground color */
  60550. shiftButtonColor: string;
  60551. /** Gets or sets shift button thickness*/
  60552. selectedShiftThickness: number;
  60553. /** Gets shift key state */
  60554. shiftState: number;
  60555. protected _getTypeName(): string;
  60556. private _createKey;
  60557. /**
  60558. * Adds a new row of keys
  60559. * @param keys defines the list of keys to add
  60560. * @param propertySets defines the associated property sets
  60561. */
  60562. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  60563. /**
  60564. * Set the shift key to a specific state
  60565. * @param shiftState defines the new shift state
  60566. */
  60567. applyShiftState(shiftState: number): void;
  60568. private _currentlyConnectedInputText;
  60569. private _connectedInputTexts;
  60570. private _onKeyPressObserver;
  60571. /** Gets the input text control currently attached to the keyboard */
  60572. readonly connectedInputText: BABYLON.Nullable<InputText>;
  60573. /**
  60574. * Connects the keyboard with an input text control
  60575. *
  60576. * @param input defines the target control
  60577. */
  60578. connect(input: InputText): void;
  60579. /**
  60580. * Disconnects the keyboard from connected InputText controls
  60581. *
  60582. * @param input optionally defines a target control, otherwise all are disconnected
  60583. */
  60584. disconnect(input?: InputText): void;
  60585. private _removeConnectedInputObservables;
  60586. /**
  60587. * Release all resources
  60588. */
  60589. dispose(): void;
  60590. /**
  60591. * Creates a new keyboard using a default layout
  60592. *
  60593. * @param name defines control name
  60594. * @returns a new VirtualKeyboard
  60595. */
  60596. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  60597. }
  60598. }
  60599. declare module BABYLON.GUI {
  60600. /**
  60601. * Class used to create input text control
  60602. */
  60603. export class InputText extends Control implements IFocusableControl {
  60604. name?: string | undefined;
  60605. private _text;
  60606. private _placeholderText;
  60607. private _background;
  60608. private _focusedBackground;
  60609. private _focusedColor;
  60610. private _placeholderColor;
  60611. private _thickness;
  60612. private _margin;
  60613. private _autoStretchWidth;
  60614. private _maxWidth;
  60615. private _isFocused;
  60616. private _blinkTimeout;
  60617. private _blinkIsEven;
  60618. private _cursorOffset;
  60619. private _scrollLeft;
  60620. private _textWidth;
  60621. private _clickedCoordinate;
  60622. private _deadKey;
  60623. private _addKey;
  60624. private _currentKey;
  60625. private _isTextHighlightOn;
  60626. private _textHighlightColor;
  60627. private _highligherOpacity;
  60628. private _highlightedText;
  60629. private _startHighlightIndex;
  60630. private _endHighlightIndex;
  60631. private _cursorIndex;
  60632. private _onFocusSelectAll;
  60633. private _isPointerDown;
  60634. private _onClipboardObserver;
  60635. private _onPointerDblTapObserver;
  60636. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  60637. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  60638. promptMessage: string;
  60639. /** BABYLON.Observable raised when the text changes */
  60640. onTextChangedObservable: BABYLON.Observable<InputText>;
  60641. /** BABYLON.Observable raised just before an entered character is to be added */
  60642. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  60643. /** BABYLON.Observable raised when the control gets the focus */
  60644. onFocusObservable: BABYLON.Observable<InputText>;
  60645. /** BABYLON.Observable raised when the control loses the focus */
  60646. onBlurObservable: BABYLON.Observable<InputText>;
  60647. /**Observable raised when the text is highlighted */
  60648. onTextHighlightObservable: BABYLON.Observable<InputText>;
  60649. /**Observable raised when copy event is triggered */
  60650. onTextCopyObservable: BABYLON.Observable<InputText>;
  60651. /** BABYLON.Observable raised when cut event is triggered */
  60652. onTextCutObservable: BABYLON.Observable<InputText>;
  60653. /** BABYLON.Observable raised when paste event is triggered */
  60654. onTextPasteObservable: BABYLON.Observable<InputText>;
  60655. /** BABYLON.Observable raised when a key event was processed */
  60656. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  60657. /** Gets or sets the maximum width allowed by the control */
  60658. maxWidth: string | number;
  60659. /** Gets the maximum width allowed by the control in pixels */
  60660. readonly maxWidthInPixels: number;
  60661. /** Gets or sets the text highlighter transparency; default: 0.4 */
  60662. highligherOpacity: number;
  60663. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  60664. onFocusSelectAll: boolean;
  60665. /** Gets or sets the text hightlight color */
  60666. textHighlightColor: string;
  60667. /** Gets or sets control margin */
  60668. margin: string;
  60669. /** Gets control margin in pixels */
  60670. readonly marginInPixels: number;
  60671. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  60672. autoStretchWidth: boolean;
  60673. /** Gets or sets border thickness */
  60674. thickness: number;
  60675. /** Gets or sets the background color when focused */
  60676. focusedBackground: string;
  60677. /** Gets or sets the background color when focused */
  60678. focusedColor: string;
  60679. /** Gets or sets the background color */
  60680. background: string;
  60681. /** Gets or sets the placeholder color */
  60682. placeholderColor: string;
  60683. /** Gets or sets the text displayed when the control is empty */
  60684. placeholderText: string;
  60685. /** Gets or sets the dead key flag */
  60686. deadKey: boolean;
  60687. /** Gets or sets the highlight text */
  60688. highlightedText: string;
  60689. /** Gets or sets if the current key should be added */
  60690. addKey: boolean;
  60691. /** Gets or sets the value of the current key being entered */
  60692. currentKey: string;
  60693. /** Gets or sets the text displayed in the control */
  60694. text: string;
  60695. /** Gets or sets control width */
  60696. width: string | number;
  60697. /**
  60698. * Creates a new InputText
  60699. * @param name defines the control name
  60700. * @param text defines the text of the control
  60701. */
  60702. constructor(name?: string | undefined, text?: string);
  60703. /** @hidden */
  60704. onBlur(): void;
  60705. /** @hidden */
  60706. onFocus(): void;
  60707. protected _getTypeName(): string;
  60708. /**
  60709. * Function called to get the list of controls that should not steal the focus from this control
  60710. * @returns an array of controls
  60711. */
  60712. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60713. /** @hidden */
  60714. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  60715. /** @hidden */
  60716. private _updateValueFromCursorIndex;
  60717. /** @hidden */
  60718. private _processDblClick;
  60719. /** @hidden */
  60720. private _selectAllText;
  60721. /**
  60722. * Handles the keyboard event
  60723. * @param evt Defines the KeyboardEvent
  60724. */
  60725. processKeyboard(evt: KeyboardEvent): void;
  60726. /** @hidden */
  60727. private _onCopyText;
  60728. /** @hidden */
  60729. private _onCutText;
  60730. /** @hidden */
  60731. 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;
  60732. protected _beforeRenderText(text: string): string;
  60733. dispose(): void;
  60734. }
  60735. }
  60736. declare module BABYLON.GUI {
  60737. /**
  60738. * Class used to create a 2D grid container
  60739. */
  60740. export class Grid extends Container {
  60741. name?: string | undefined;
  60742. private _rowDefinitions;
  60743. private _columnDefinitions;
  60744. private _cells;
  60745. private _childControls;
  60746. /**
  60747. * Gets the number of columns
  60748. */
  60749. readonly columnCount: number;
  60750. /**
  60751. * Gets the number of rows
  60752. */
  60753. readonly rowCount: number;
  60754. /** Gets the list of children */
  60755. readonly children: Control[];
  60756. /** Gets the list of cells (e.g. the containers) */
  60757. readonly cells: {
  60758. [key: string]: Container;
  60759. };
  60760. /**
  60761. * Gets the definition of a specific row
  60762. * @param index defines the index of the row
  60763. * @returns the row definition
  60764. */
  60765. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60766. /**
  60767. * Gets the definition of a specific column
  60768. * @param index defines the index of the column
  60769. * @returns the column definition
  60770. */
  60771. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60772. /**
  60773. * Adds a new row to the grid
  60774. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60775. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  60776. * @returns the current grid
  60777. */
  60778. addRowDefinition(height: number, isPixel?: boolean): Grid;
  60779. /**
  60780. * Adds a new column to the grid
  60781. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60782. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60783. * @returns the current grid
  60784. */
  60785. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  60786. /**
  60787. * Update a row definition
  60788. * @param index defines the index of the row to update
  60789. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60790. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  60791. * @returns the current grid
  60792. */
  60793. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  60794. /**
  60795. * Update a column definition
  60796. * @param index defines the index of the column to update
  60797. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60798. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60799. * @returns the current grid
  60800. */
  60801. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  60802. /**
  60803. * Gets the list of children stored in a specific cell
  60804. * @param row defines the row to check
  60805. * @param column defines the column to check
  60806. * @returns the list of controls
  60807. */
  60808. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  60809. /**
  60810. * Gets a string representing the child cell info (row x column)
  60811. * @param child defines the control to get info from
  60812. * @returns a string containing the child cell info (row x column)
  60813. */
  60814. getChildCellInfo(child: Control): string;
  60815. private _removeCell;
  60816. private _offsetCell;
  60817. /**
  60818. * Remove a column definition at specified index
  60819. * @param index defines the index of the column to remove
  60820. * @returns the current grid
  60821. */
  60822. removeColumnDefinition(index: number): Grid;
  60823. /**
  60824. * Remove a row definition at specified index
  60825. * @param index defines the index of the row to remove
  60826. * @returns the current grid
  60827. */
  60828. removeRowDefinition(index: number): Grid;
  60829. /**
  60830. * Adds a new control to the current grid
  60831. * @param control defines the control to add
  60832. * @param row defines the row where to add the control (0 by default)
  60833. * @param column defines the column where to add the control (0 by default)
  60834. * @returns the current grid
  60835. */
  60836. addControl(control: Control, row?: number, column?: number): Grid;
  60837. /**
  60838. * Removes a control from the current container
  60839. * @param control defines the control to remove
  60840. * @returns the current container
  60841. */
  60842. removeControl(control: Control): Container;
  60843. /**
  60844. * Creates a new Grid
  60845. * @param name defines control name
  60846. */
  60847. constructor(name?: string | undefined);
  60848. protected _getTypeName(): string;
  60849. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  60850. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60851. /** Releases associated resources */
  60852. dispose(): void;
  60853. }
  60854. }
  60855. declare module BABYLON.GUI {
  60856. /** Class used to create color pickers */
  60857. export class ColorPicker extends Control {
  60858. name?: string | undefined;
  60859. private static _Epsilon;
  60860. private _colorWheelCanvas;
  60861. private _value;
  60862. private _tmpColor;
  60863. private _pointerStartedOnSquare;
  60864. private _pointerStartedOnWheel;
  60865. private _squareLeft;
  60866. private _squareTop;
  60867. private _squareSize;
  60868. private _h;
  60869. private _s;
  60870. private _v;
  60871. private _lastPointerDownID;
  60872. /**
  60873. * BABYLON.Observable raised when the value changes
  60874. */
  60875. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  60876. /** Gets or sets the color of the color picker */
  60877. value: BABYLON.Color3;
  60878. /**
  60879. * Gets or sets control width
  60880. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60881. */
  60882. width: string | number;
  60883. /**
  60884. * Gets or sets control height
  60885. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60886. */
  60887. /** Gets or sets control height */
  60888. height: string | number;
  60889. /** Gets or sets control size */
  60890. size: string | number;
  60891. /**
  60892. * Creates a new ColorPicker
  60893. * @param name defines the control name
  60894. */
  60895. constructor(name?: string | undefined);
  60896. protected _getTypeName(): string;
  60897. /** @hidden */
  60898. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60899. private _updateSquareProps;
  60900. private _drawGradientSquare;
  60901. private _drawCircle;
  60902. private _createColorWheelCanvas;
  60903. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60904. private _pointerIsDown;
  60905. private _updateValueFromPointer;
  60906. private _isPointOnSquare;
  60907. 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;
  60908. /**
  60909. * This function expands the color picker by creating a color picker dialog with manual
  60910. * color value input and the ability to save colors into an array to be used later in
  60911. * subsequent launches of the dialogue.
  60912. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  60913. * @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.
  60914. * @returns picked color as a hex string and the saved colors array as hex strings.
  60915. */
  60916. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  60917. pickerWidth?: string;
  60918. pickerHeight?: string;
  60919. headerHeight?: string;
  60920. lastColor?: string;
  60921. swatchLimit?: number;
  60922. numSwatchesPerLine?: number;
  60923. savedColors?: Array<string>;
  60924. }): Promise<{
  60925. savedColors?: string[];
  60926. pickedColor: string;
  60927. }>;
  60928. }
  60929. }
  60930. declare module BABYLON.GUI {
  60931. /** Class used to create 2D ellipse containers */
  60932. export class Ellipse extends Container {
  60933. name?: string | undefined;
  60934. private _thickness;
  60935. /** Gets or sets border thickness */
  60936. thickness: number;
  60937. /**
  60938. * Creates a new Ellipse
  60939. * @param name defines the control name
  60940. */
  60941. constructor(name?: string | undefined);
  60942. protected _getTypeName(): string;
  60943. protected _localDraw(context: CanvasRenderingContext2D): void;
  60944. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60945. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60946. }
  60947. }
  60948. declare module BABYLON.GUI {
  60949. /**
  60950. * Class used to create a password control
  60951. */
  60952. export class InputPassword extends InputText {
  60953. protected _beforeRenderText(text: string): string;
  60954. }
  60955. }
  60956. declare module BABYLON.GUI {
  60957. /** Class used to render 2D lines */
  60958. export class Line extends Control {
  60959. name?: string | undefined;
  60960. private _lineWidth;
  60961. private _x1;
  60962. private _y1;
  60963. private _x2;
  60964. private _y2;
  60965. private _dash;
  60966. private _connectedControl;
  60967. private _connectedControlDirtyObserver;
  60968. /** Gets or sets the dash pattern */
  60969. dash: Array<number>;
  60970. /** Gets or sets the control connected with the line end */
  60971. connectedControl: Control;
  60972. /** Gets or sets start coordinates on X axis */
  60973. x1: string | number;
  60974. /** Gets or sets start coordinates on Y axis */
  60975. y1: string | number;
  60976. /** Gets or sets end coordinates on X axis */
  60977. x2: string | number;
  60978. /** Gets or sets end coordinates on Y axis */
  60979. y2: string | number;
  60980. /** Gets or sets line width */
  60981. lineWidth: number;
  60982. /** Gets or sets horizontal alignment */
  60983. horizontalAlignment: number;
  60984. /** Gets or sets vertical alignment */
  60985. verticalAlignment: number;
  60986. private readonly _effectiveX2;
  60987. private readonly _effectiveY2;
  60988. /**
  60989. * Creates a new Line
  60990. * @param name defines the control name
  60991. */
  60992. constructor(name?: string | undefined);
  60993. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  60994. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60995. /**
  60996. * Move one end of the line given 3D cartesian coordinates.
  60997. * @param position Targeted world position
  60998. * @param scene BABYLON.Scene
  60999. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61000. */
  61001. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61002. /**
  61003. * Move one end of the line to a position in screen absolute space.
  61004. * @param projectedPosition Position in screen absolute space (X, Y)
  61005. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61006. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61007. }
  61008. }
  61009. declare module BABYLON.GUI {
  61010. /**
  61011. * Class used to store a point for a MultiLine object.
  61012. * The point can be pure 2D coordinates, a mesh or a control
  61013. */
  61014. export class MultiLinePoint {
  61015. private _multiLine;
  61016. private _x;
  61017. private _y;
  61018. private _control;
  61019. private _mesh;
  61020. private _controlObserver;
  61021. private _meshObserver;
  61022. /** @hidden */ private _point: BABYLON.Vector2;
  61023. /**
  61024. * Creates a new MultiLinePoint
  61025. * @param multiLine defines the source MultiLine object
  61026. */
  61027. constructor(multiLine: MultiLine);
  61028. /** Gets or sets x coordinate */
  61029. x: string | number;
  61030. /** Gets or sets y coordinate */
  61031. y: string | number;
  61032. /** Gets or sets the control associated with this point */
  61033. control: BABYLON.Nullable<Control>;
  61034. /** Gets or sets the mesh associated with this point */
  61035. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61036. /** Resets links */
  61037. resetLinks(): void;
  61038. /**
  61039. * Gets a translation vector
  61040. * @returns the translation vector
  61041. */
  61042. translate(): BABYLON.Vector2;
  61043. private _translatePoint;
  61044. /** Release associated resources */
  61045. dispose(): void;
  61046. }
  61047. }
  61048. declare module BABYLON.GUI {
  61049. /**
  61050. * Class used to create multi line control
  61051. */
  61052. export class MultiLine extends Control {
  61053. name?: string | undefined;
  61054. private _lineWidth;
  61055. private _dash;
  61056. private _points;
  61057. private _minX;
  61058. private _minY;
  61059. private _maxX;
  61060. private _maxY;
  61061. /**
  61062. * Creates a new MultiLine
  61063. * @param name defines the control name
  61064. */
  61065. constructor(name?: string | undefined);
  61066. /** Gets or sets dash pattern */
  61067. dash: Array<number>;
  61068. /**
  61069. * Gets point stored at specified index
  61070. * @param index defines the index to look for
  61071. * @returns the requested point if found
  61072. */
  61073. getAt(index: number): MultiLinePoint;
  61074. /** Function called when a point is updated */
  61075. onPointUpdate: () => void;
  61076. /**
  61077. * Adds new points to the point collection
  61078. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61079. * @returns the list of created MultiLinePoint
  61080. */
  61081. add(...items: (AbstractMesh | Control | {
  61082. x: string | number;
  61083. y: string | number;
  61084. })[]): MultiLinePoint[];
  61085. /**
  61086. * Adds a new point to the point collection
  61087. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61088. * @returns the created MultiLinePoint
  61089. */
  61090. push(item?: (AbstractMesh | Control | {
  61091. x: string | number;
  61092. y: string | number;
  61093. })): MultiLinePoint;
  61094. /**
  61095. * Remove a specific value or point from the active point collection
  61096. * @param value defines the value or point to remove
  61097. */
  61098. remove(value: number | MultiLinePoint): void;
  61099. /**
  61100. * Resets this object to initial state (no point)
  61101. */
  61102. reset(): void;
  61103. /**
  61104. * Resets all links
  61105. */
  61106. resetLinks(): void;
  61107. /** Gets or sets line width */
  61108. lineWidth: number;
  61109. horizontalAlignment: number;
  61110. verticalAlignment: number;
  61111. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61112. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  61113. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61114. dispose(): void;
  61115. }
  61116. }
  61117. declare module BABYLON.GUI {
  61118. /**
  61119. * Class used to create radio button controls
  61120. */
  61121. export class RadioButton extends Control {
  61122. name?: string | undefined;
  61123. private _isChecked;
  61124. private _background;
  61125. private _checkSizeRatio;
  61126. private _thickness;
  61127. /** Gets or sets border thickness */
  61128. thickness: number;
  61129. /** Gets or sets group name */
  61130. group: string;
  61131. /** BABYLON.Observable raised when isChecked is changed */
  61132. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61133. /** Gets or sets a value indicating the ratio between overall size and check size */
  61134. checkSizeRatio: number;
  61135. /** Gets or sets background color */
  61136. background: string;
  61137. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61138. isChecked: boolean;
  61139. /**
  61140. * Creates a new RadioButton
  61141. * @param name defines the control name
  61142. */
  61143. constructor(name?: string | undefined);
  61144. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61145. /**
  61146. * Utility function to easily create a radio button with a header
  61147. * @param title defines the label to use for the header
  61148. * @param group defines the group to use for the radio button
  61149. * @param isChecked defines the initial state of the radio button
  61150. * @param onValueChanged defines the callback to call when value changes
  61151. * @returns a StackPanel containing the radio button and a textBlock
  61152. */
  61153. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61154. }
  61155. }
  61156. declare module BABYLON.GUI {
  61157. /**
  61158. * Class used to create slider controls
  61159. */
  61160. export class BaseSlider extends Control {
  61161. name?: string | undefined;
  61162. protected _thumbWidth: ValueAndUnit;
  61163. private _minimum;
  61164. private _maximum;
  61165. private _value;
  61166. private _isVertical;
  61167. protected _barOffset: ValueAndUnit;
  61168. private _isThumbClamped;
  61169. protected _displayThumb: boolean;
  61170. private _step;
  61171. private _lastPointerDownID;
  61172. protected _effectiveBarOffset: number;
  61173. protected _renderLeft: number;
  61174. protected _renderTop: number;
  61175. protected _renderWidth: number;
  61176. protected _renderHeight: number;
  61177. protected _backgroundBoxLength: number;
  61178. protected _backgroundBoxThickness: number;
  61179. protected _effectiveThumbThickness: number;
  61180. /** BABYLON.Observable raised when the sldier value changes */
  61181. onValueChangedObservable: BABYLON.Observable<number>;
  61182. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61183. displayThumb: boolean;
  61184. /** Gets or sets a step to apply to values (0 by default) */
  61185. step: number;
  61186. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61187. barOffset: string | number;
  61188. /** Gets main bar offset in pixels*/
  61189. readonly barOffsetInPixels: number;
  61190. /** Gets or sets thumb width */
  61191. thumbWidth: string | number;
  61192. /** Gets thumb width in pixels */
  61193. readonly thumbWidthInPixels: number;
  61194. /** Gets or sets minimum value */
  61195. minimum: number;
  61196. /** Gets or sets maximum value */
  61197. maximum: number;
  61198. /** Gets or sets current value */
  61199. value: number;
  61200. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61201. isVertical: boolean;
  61202. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61203. isThumbClamped: boolean;
  61204. /**
  61205. * Creates a new BaseSlider
  61206. * @param name defines the control name
  61207. */
  61208. constructor(name?: string | undefined);
  61209. protected _getTypeName(): string;
  61210. protected _getThumbPosition(): number;
  61211. protected _getThumbThickness(type: string): number;
  61212. protected _prepareRenderingData(type: string): void;
  61213. private _pointerIsDown;
  61214. /** @hidden */
  61215. 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;
  61216. }
  61217. }
  61218. declare module BABYLON.GUI {
  61219. /**
  61220. * Class used to create slider controls
  61221. */
  61222. export class Slider extends BaseSlider {
  61223. name?: string | undefined;
  61224. private _background;
  61225. private _borderColor;
  61226. private _isThumbCircle;
  61227. protected _displayValueBar: boolean;
  61228. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61229. displayValueBar: boolean;
  61230. /** Gets or sets border color */
  61231. borderColor: string;
  61232. /** Gets or sets background color */
  61233. background: string;
  61234. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61235. isThumbCircle: boolean;
  61236. /**
  61237. * Creates a new Slider
  61238. * @param name defines the control name
  61239. */
  61240. constructor(name?: string | undefined);
  61241. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61242. }
  61243. }
  61244. declare module BABYLON.GUI {
  61245. /** Class used to create a RadioGroup
  61246. * which contains groups of radio buttons
  61247. */
  61248. export class SelectorGroup {
  61249. /** name of SelectorGroup */
  61250. name: string;
  61251. private _groupPanel;
  61252. private _selectors;
  61253. private _groupHeader;
  61254. /**
  61255. * Creates a new SelectorGroup
  61256. * @param name of group, used as a group heading
  61257. */
  61258. constructor(
  61259. /** name of SelectorGroup */
  61260. name: string);
  61261. /** Gets the groupPanel of the SelectorGroup */
  61262. readonly groupPanel: StackPanel;
  61263. /** Gets the selectors array */
  61264. readonly selectors: StackPanel[];
  61265. /** Gets and sets the group header */
  61266. header: string;
  61267. /** @hidden */
  61268. private _addGroupHeader;
  61269. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  61270. /** Removes the selector at the given position
  61271. * @param selectorNb the position of the selector within the group
  61272. */
  61273. removeSelector(selectorNb: number): void;
  61274. }
  61275. /** Class used to create a CheckboxGroup
  61276. * which contains groups of checkbox buttons
  61277. */
  61278. export class CheckboxGroup extends SelectorGroup {
  61279. /** Adds a checkbox as a control
  61280. * @param text is the label for the selector
  61281. * @param func is the function called when the Selector is checked
  61282. * @param checked is true when Selector is checked
  61283. */
  61284. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61285. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61286. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61287. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61288. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61289. }
  61290. /** Class used to create a RadioGroup
  61291. * which contains groups of radio buttons
  61292. */
  61293. export class RadioGroup extends SelectorGroup {
  61294. private _selectNb;
  61295. /** Adds a radio button as a control
  61296. * @param label is the label for the selector
  61297. * @param func is the function called when the Selector is checked
  61298. * @param checked is true when Selector is checked
  61299. */
  61300. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61301. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61302. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61303. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61304. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61305. }
  61306. /** Class used to create a SliderGroup
  61307. * which contains groups of slider buttons
  61308. */
  61309. export class SliderGroup extends SelectorGroup {
  61310. /**
  61311. * Adds a slider to the SelectorGroup
  61312. * @param label is the label for the SliderBar
  61313. * @param func is the function called when the Slider moves
  61314. * @param unit is a string describing the units used, eg degrees or metres
  61315. * @param min is the minimum value for the Slider
  61316. * @param max is the maximum value for the Slider
  61317. * @param value is the start value for the Slider between min and max
  61318. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  61319. */
  61320. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  61321. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61322. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61323. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61324. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61325. }
  61326. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  61327. * @see http://doc.babylonjs.com/how_to/selector
  61328. */
  61329. export class SelectionPanel extends Rectangle {
  61330. /** name of SelectionPanel */
  61331. name: string;
  61332. /** an array of SelectionGroups */
  61333. groups: SelectorGroup[];
  61334. private _panel;
  61335. private _buttonColor;
  61336. private _buttonBackground;
  61337. private _headerColor;
  61338. private _barColor;
  61339. private _barHeight;
  61340. private _spacerHeight;
  61341. private _labelColor;
  61342. private _groups;
  61343. private _bars;
  61344. /**
  61345. * Creates a new SelectionPanel
  61346. * @param name of SelectionPanel
  61347. * @param groups is an array of SelectionGroups
  61348. */
  61349. constructor(
  61350. /** name of SelectionPanel */
  61351. name: string,
  61352. /** an array of SelectionGroups */
  61353. groups?: SelectorGroup[]);
  61354. protected _getTypeName(): string;
  61355. /** Gets or sets the headerColor */
  61356. headerColor: string;
  61357. private _setHeaderColor;
  61358. /** Gets or sets the button color */
  61359. buttonColor: string;
  61360. private _setbuttonColor;
  61361. /** Gets or sets the label color */
  61362. labelColor: string;
  61363. private _setLabelColor;
  61364. /** Gets or sets the button background */
  61365. buttonBackground: string;
  61366. private _setButtonBackground;
  61367. /** Gets or sets the color of separator bar */
  61368. barColor: string;
  61369. private _setBarColor;
  61370. /** Gets or sets the height of separator bar */
  61371. barHeight: string;
  61372. private _setBarHeight;
  61373. /** Gets or sets the height of spacers*/
  61374. spacerHeight: string;
  61375. private _setSpacerHeight;
  61376. /** Adds a bar between groups */
  61377. private _addSpacer;
  61378. /** Add a group to the selection panel
  61379. * @param group is the selector group to add
  61380. */
  61381. addGroup(group: SelectorGroup): void;
  61382. /** Remove the group from the given position
  61383. * @param groupNb is the position of the group in the list
  61384. */
  61385. removeGroup(groupNb: number): void;
  61386. /** Change a group header label
  61387. * @param label is the new group header label
  61388. * @param groupNb is the number of the group to relabel
  61389. * */
  61390. setHeaderName(label: string, groupNb: number): void;
  61391. /** Change selector label to the one given
  61392. * @param label is the new selector label
  61393. * @param groupNb is the number of the groupcontaining the selector
  61394. * @param selectorNb is the number of the selector within a group to relabel
  61395. * */
  61396. relabel(label: string, groupNb: number, selectorNb: number): void;
  61397. /** For a given group position remove the selector at the given position
  61398. * @param groupNb is the number of the group to remove the selector from
  61399. * @param selectorNb is the number of the selector within the group
  61400. */
  61401. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  61402. /** For a given group position of correct type add a checkbox button
  61403. * @param groupNb is the number of the group to remove the selector from
  61404. * @param label is the label for the selector
  61405. * @param func is the function called when the Selector is checked
  61406. * @param checked is true when Selector is checked
  61407. */
  61408. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61409. /** For a given group position of correct type add a radio button
  61410. * @param groupNb is the number of the group to remove the selector from
  61411. * @param label is the label for the selector
  61412. * @param func is the function called when the Selector is checked
  61413. * @param checked is true when Selector is checked
  61414. */
  61415. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61416. /**
  61417. * For a given slider group add a slider
  61418. * @param groupNb is the number of the group to add the slider to
  61419. * @param label is the label for the Slider
  61420. * @param func is the function called when the Slider moves
  61421. * @param unit is a string describing the units used, eg degrees or metres
  61422. * @param min is the minimum value for the Slider
  61423. * @param max is the maximum value for the Slider
  61424. * @param value is the start value for the Slider between min and max
  61425. * @param onVal is the function used to format the value displayed, eg radians to degrees
  61426. */
  61427. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  61428. }
  61429. }
  61430. declare module BABYLON.GUI {
  61431. /**
  61432. * Class used to hold a the container for ScrollViewer
  61433. * @hidden
  61434. */
  61435. export class _ScrollViewerWindow extends Container {
  61436. parentClientWidth: number;
  61437. parentClientHeight: number;
  61438. /**
  61439. * Creates a new ScrollViewerWindow
  61440. * @param name of ScrollViewerWindow
  61441. */
  61442. constructor(name?: string);
  61443. protected _getTypeName(): string;
  61444. /** @hidden */
  61445. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61446. protected _postMeasure(): void;
  61447. }
  61448. }
  61449. declare module BABYLON.GUI {
  61450. /**
  61451. * Class used to create slider controls
  61452. */
  61453. export class ScrollBar extends BaseSlider {
  61454. name?: string | undefined;
  61455. private _background;
  61456. private _borderColor;
  61457. private _thumbMeasure;
  61458. /** Gets or sets border color */
  61459. borderColor: string;
  61460. /** Gets or sets background color */
  61461. background: string;
  61462. /**
  61463. * Creates a new Slider
  61464. * @param name defines the control name
  61465. */
  61466. constructor(name?: string | undefined);
  61467. protected _getTypeName(): string;
  61468. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  61469. private _first;
  61470. private _originX;
  61471. private _originY;
  61472. /** @hidden */
  61473. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61474. }
  61475. }
  61476. declare module BABYLON.GUI {
  61477. /**
  61478. * Class used to hold a viewer window and sliders in a grid
  61479. */
  61480. export class ScrollViewer extends Rectangle {
  61481. private _grid;
  61482. private _horizontalBarSpace;
  61483. private _verticalBarSpace;
  61484. private _dragSpace;
  61485. private _horizontalBar;
  61486. private _verticalBar;
  61487. private _barColor;
  61488. private _barBackground;
  61489. private _barSize;
  61490. private _endLeft;
  61491. private _endTop;
  61492. private _window;
  61493. private _pointerIsOver;
  61494. private _wheelPrecision;
  61495. private _onPointerObserver;
  61496. private _clientWidth;
  61497. private _clientHeight;
  61498. /**
  61499. * Gets the horizontal scrollbar
  61500. */
  61501. readonly horizontalBar: ScrollBar;
  61502. /**
  61503. * Gets the vertical scrollbar
  61504. */
  61505. readonly verticalBar: ScrollBar;
  61506. /**
  61507. * Adds a new control to the current container
  61508. * @param control defines the control to add
  61509. * @returns the current container
  61510. */
  61511. addControl(control: BABYLON.Nullable<Control>): Container;
  61512. /**
  61513. * Removes a control from the current container
  61514. * @param control defines the control to remove
  61515. * @returns the current container
  61516. */
  61517. removeControl(control: Control): Container;
  61518. /** Gets the list of children */
  61519. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  61520. /**
  61521. * Creates a new ScrollViewer
  61522. * @param name of ScrollViewer
  61523. */
  61524. constructor(name?: string);
  61525. /** Reset the scroll viewer window to initial size */
  61526. resetWindow(): void;
  61527. protected _getTypeName(): string;
  61528. private _buildClientSizes;
  61529. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61530. protected _postMeasure(): void;
  61531. /**
  61532. * Gets or sets the mouse wheel precision
  61533. * from 0 to 1 with a default value of 0.05
  61534. * */
  61535. wheelPrecision: number;
  61536. /** Gets or sets the bar color */
  61537. barColor: string;
  61538. /** Gets or sets the size of the bar */
  61539. barSize: number;
  61540. /** Gets or sets the bar background */
  61541. barBackground: string;
  61542. /** @hidden */
  61543. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  61544. /** @hidden */
  61545. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61546. /** Releases associated resources */
  61547. dispose(): void;
  61548. }
  61549. }
  61550. declare module BABYLON.GUI {
  61551. /** Class used to render a grid */
  61552. export class DisplayGrid extends Control {
  61553. name?: string | undefined;
  61554. private _cellWidth;
  61555. private _cellHeight;
  61556. private _minorLineTickness;
  61557. private _minorLineColor;
  61558. private _majorLineTickness;
  61559. private _majorLineColor;
  61560. private _majorLineFrequency;
  61561. private _background;
  61562. private _displayMajorLines;
  61563. private _displayMinorLines;
  61564. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  61565. displayMinorLines: boolean;
  61566. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  61567. displayMajorLines: boolean;
  61568. /** Gets or sets background color (Black by default) */
  61569. background: string;
  61570. /** Gets or sets the width of each cell (20 by default) */
  61571. cellWidth: number;
  61572. /** Gets or sets the height of each cell (20 by default) */
  61573. cellHeight: number;
  61574. /** Gets or sets the tickness of minor lines (1 by default) */
  61575. minorLineTickness: number;
  61576. /** Gets or sets the color of minor lines (DarkGray by default) */
  61577. minorLineColor: string;
  61578. /** Gets or sets the tickness of major lines (2 by default) */
  61579. majorLineTickness: number;
  61580. /** Gets or sets the color of major lines (White by default) */
  61581. majorLineColor: string;
  61582. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  61583. majorLineFrequency: number;
  61584. /**
  61585. * Creates a new GridDisplayRectangle
  61586. * @param name defines the control name
  61587. */
  61588. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  61589. protected _getTypeName(): string;
  61590. }
  61591. }
  61592. declare module BABYLON.GUI {
  61593. /**
  61594. * Class used to create slider controls based on images
  61595. */
  61596. export class ImageBasedSlider extends BaseSlider {
  61597. name?: string | undefined;
  61598. private _backgroundImage;
  61599. private _thumbImage;
  61600. private _valueBarImage;
  61601. private _tempMeasure;
  61602. displayThumb: boolean;
  61603. /**
  61604. * Gets or sets the image used to render the background
  61605. */
  61606. backgroundImage: Image;
  61607. /**
  61608. * Gets or sets the image used to render the value bar
  61609. */
  61610. valueBarImage: Image;
  61611. /**
  61612. * Gets or sets the image used to render the thumb
  61613. */
  61614. thumbImage: Image;
  61615. /**
  61616. * Creates a new ImageBasedSlider
  61617. * @param name defines the control name
  61618. */
  61619. constructor(name?: string | undefined);
  61620. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61621. }
  61622. }
  61623. declare module BABYLON.GUI {
  61624. /**
  61625. * Forcing an export so that this code will execute
  61626. * @hidden
  61627. */
  61628. const name = "Statics";
  61629. }
  61630. declare module BABYLON.GUI {
  61631. /**
  61632. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  61633. */
  61634. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  61635. /**
  61636. * Define the instrumented AdvancedDynamicTexture.
  61637. */
  61638. texture: AdvancedDynamicTexture;
  61639. private _captureRenderTime;
  61640. private _renderTime;
  61641. private _captureLayoutTime;
  61642. private _layoutTime;
  61643. private _onBeginRenderObserver;
  61644. private _onEndRenderObserver;
  61645. private _onBeginLayoutObserver;
  61646. private _onEndLayoutObserver;
  61647. /**
  61648. * Gets the perf counter used to capture render time
  61649. */
  61650. readonly renderTimeCounter: BABYLON.PerfCounter;
  61651. /**
  61652. * Gets the perf counter used to capture layout time
  61653. */
  61654. readonly layoutTimeCounter: BABYLON.PerfCounter;
  61655. /**
  61656. * Enable or disable the render time capture
  61657. */
  61658. captureRenderTime: boolean;
  61659. /**
  61660. * Enable or disable the layout time capture
  61661. */
  61662. captureLayoutTime: boolean;
  61663. /**
  61664. * Instantiates a new advanced dynamic texture instrumentation.
  61665. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  61666. * @param texture Defines the AdvancedDynamicTexture to instrument
  61667. */
  61668. constructor(
  61669. /**
  61670. * Define the instrumented AdvancedDynamicTexture.
  61671. */
  61672. texture: AdvancedDynamicTexture);
  61673. /**
  61674. * Dispose and release associated resources.
  61675. */
  61676. dispose(): void;
  61677. }
  61678. }
  61679. declare module BABYLON.GUI {
  61680. /**
  61681. * Class used to create containers for controls
  61682. */
  61683. export class Container3D extends Control3D {
  61684. private _blockLayout;
  61685. /**
  61686. * Gets the list of child controls
  61687. */
  61688. protected _children: Control3D[];
  61689. /**
  61690. * Gets the list of child controls
  61691. */
  61692. readonly children: Array<Control3D>;
  61693. /**
  61694. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  61695. * This is helpful to optimize layout operation when adding multiple children in a row
  61696. */
  61697. blockLayout: boolean;
  61698. /**
  61699. * Creates a new container
  61700. * @param name defines the container name
  61701. */
  61702. constructor(name?: string);
  61703. /**
  61704. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  61705. * @returns the current container
  61706. */
  61707. updateLayout(): Container3D;
  61708. /**
  61709. * Gets a boolean indicating if the given control is in the children of this control
  61710. * @param control defines the control to check
  61711. * @returns true if the control is in the child list
  61712. */
  61713. containsControl(control: Control3D): boolean;
  61714. /**
  61715. * Adds a control to the children of this control
  61716. * @param control defines the control to add
  61717. * @returns the current container
  61718. */
  61719. addControl(control: Control3D): Container3D;
  61720. /**
  61721. * This function will be called everytime a new control is added
  61722. */
  61723. protected _arrangeChildren(): void;
  61724. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61725. /**
  61726. * Removes a control from the children of this control
  61727. * @param control defines the control to remove
  61728. * @returns the current container
  61729. */
  61730. removeControl(control: Control3D): Container3D;
  61731. protected _getTypeName(): string;
  61732. /**
  61733. * Releases all associated resources
  61734. */
  61735. dispose(): void;
  61736. /** Control rotation will remain unchanged */
  61737. static readonly UNSET_ORIENTATION: number;
  61738. /** Control will rotate to make it look at sphere central axis */
  61739. static readonly FACEORIGIN_ORIENTATION: number;
  61740. /** Control will rotate to make it look back at sphere central axis */
  61741. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  61742. /** Control will rotate to look at z axis (0, 0, 1) */
  61743. static readonly FACEFORWARD_ORIENTATION: number;
  61744. /** Control will rotate to look at negative z axis (0, 0, -1) */
  61745. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  61746. }
  61747. }
  61748. declare module BABYLON.GUI {
  61749. /**
  61750. * Class used to manage 3D user interface
  61751. * @see http://doc.babylonjs.com/how_to/gui3d
  61752. */
  61753. export class GUI3DManager implements BABYLON.IDisposable {
  61754. private _scene;
  61755. private _sceneDisposeObserver;
  61756. private _utilityLayer;
  61757. private _rootContainer;
  61758. private _pointerObserver;
  61759. private _pointerOutObserver;
  61760. /** @hidden */ private _lastPickedControl: Control3D;
  61761. /** @hidden */ private _lastControlOver: {
  61762. [pointerId: number]: Control3D;
  61763. };
  61764. /** @hidden */ private _lastControlDown: {
  61765. [pointerId: number]: Control3D;
  61766. };
  61767. /**
  61768. * BABYLON.Observable raised when the point picked by the pointer events changed
  61769. */
  61770. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  61771. /** @hidden */ private _sharedMaterials: {
  61772. [key: string]: BABYLON.Material;
  61773. };
  61774. /** Gets the hosting scene */
  61775. readonly scene: BABYLON.Scene;
  61776. /** Gets associated utility layer */
  61777. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  61778. /**
  61779. * Creates a new GUI3DManager
  61780. * @param scene
  61781. */
  61782. constructor(scene?: BABYLON.Scene);
  61783. private _handlePointerOut;
  61784. private _doPicking;
  61785. /**
  61786. * Gets the root container
  61787. */
  61788. readonly rootContainer: Container3D;
  61789. /**
  61790. * Gets a boolean indicating if the given control is in the root child list
  61791. * @param control defines the control to check
  61792. * @returns true if the control is in the root child list
  61793. */
  61794. containsControl(control: Control3D): boolean;
  61795. /**
  61796. * Adds a control to the root child list
  61797. * @param control defines the control to add
  61798. * @returns the current manager
  61799. */
  61800. addControl(control: Control3D): GUI3DManager;
  61801. /**
  61802. * Removes a control from the root child list
  61803. * @param control defines the control to remove
  61804. * @returns the current container
  61805. */
  61806. removeControl(control: Control3D): GUI3DManager;
  61807. /**
  61808. * Releases all associated resources
  61809. */
  61810. dispose(): void;
  61811. }
  61812. }
  61813. declare module BABYLON.GUI {
  61814. /**
  61815. * Class used to transport BABYLON.Vector3 information for pointer events
  61816. */
  61817. export class Vector3WithInfo extends BABYLON.Vector3 {
  61818. /** defines the current mouse button index */
  61819. buttonIndex: number;
  61820. /**
  61821. * Creates a new Vector3WithInfo
  61822. * @param source defines the vector3 data to transport
  61823. * @param buttonIndex defines the current mouse button index
  61824. */
  61825. constructor(source: BABYLON.Vector3,
  61826. /** defines the current mouse button index */
  61827. buttonIndex?: number);
  61828. }
  61829. }
  61830. declare module BABYLON.GUI {
  61831. /**
  61832. * Class used as base class for controls
  61833. */
  61834. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  61835. /** Defines the control name */
  61836. name?: string | undefined;
  61837. /** @hidden */ private _host: GUI3DManager;
  61838. private _node;
  61839. private _downCount;
  61840. private _enterCount;
  61841. private _downPointerIds;
  61842. private _isVisible;
  61843. /** Gets or sets the control position in world space */
  61844. position: BABYLON.Vector3;
  61845. /** Gets or sets the control scaling in world space */
  61846. scaling: BABYLON.Vector3;
  61847. /** Callback used to start pointer enter animation */
  61848. pointerEnterAnimation: () => void;
  61849. /** Callback used to start pointer out animation */
  61850. pointerOutAnimation: () => void;
  61851. /** Callback used to start pointer down animation */
  61852. pointerDownAnimation: () => void;
  61853. /** Callback used to start pointer up animation */
  61854. pointerUpAnimation: () => void;
  61855. /**
  61856. * An event triggered when the pointer move over the control
  61857. */
  61858. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  61859. /**
  61860. * An event triggered when the pointer move out of the control
  61861. */
  61862. onPointerOutObservable: BABYLON.Observable<Control3D>;
  61863. /**
  61864. * An event triggered when the pointer taps the control
  61865. */
  61866. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  61867. /**
  61868. * An event triggered when pointer is up
  61869. */
  61870. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  61871. /**
  61872. * An event triggered when a control is clicked on (with a mouse)
  61873. */
  61874. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  61875. /**
  61876. * An event triggered when pointer enters the control
  61877. */
  61878. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  61879. /**
  61880. * Gets or sets the parent container
  61881. */
  61882. parent: BABYLON.Nullable<Container3D>;
  61883. private _behaviors;
  61884. /**
  61885. * Gets the list of attached behaviors
  61886. * @see http://doc.babylonjs.com/features/behaviour
  61887. */
  61888. readonly behaviors: BABYLON.Behavior<Control3D>[];
  61889. /**
  61890. * Attach a behavior to the control
  61891. * @see http://doc.babylonjs.com/features/behaviour
  61892. * @param behavior defines the behavior to attach
  61893. * @returns the current control
  61894. */
  61895. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  61896. /**
  61897. * Remove an attached behavior
  61898. * @see http://doc.babylonjs.com/features/behaviour
  61899. * @param behavior defines the behavior to attach
  61900. * @returns the current control
  61901. */
  61902. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  61903. /**
  61904. * Gets an attached behavior by name
  61905. * @param name defines the name of the behavior to look for
  61906. * @see http://doc.babylonjs.com/features/behaviour
  61907. * @returns null if behavior was not found else the requested behavior
  61908. */
  61909. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  61910. /** Gets or sets a boolean indicating if the control is visible */
  61911. isVisible: boolean;
  61912. /**
  61913. * Creates a new control
  61914. * @param name defines the control name
  61915. */
  61916. constructor(
  61917. /** Defines the control name */
  61918. name?: string | undefined);
  61919. /**
  61920. * Gets a string representing the class name
  61921. */
  61922. readonly typeName: string;
  61923. /**
  61924. * Get the current class name of the control.
  61925. * @returns current class name
  61926. */
  61927. getClassName(): string;
  61928. protected _getTypeName(): string;
  61929. /**
  61930. * Gets the transform node used by this control
  61931. */
  61932. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  61933. /**
  61934. * Gets the mesh used to render this control
  61935. */
  61936. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61937. /**
  61938. * Link the control as child of the given node
  61939. * @param node defines the node to link to. Use null to unlink the control
  61940. * @returns the current control
  61941. */
  61942. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  61943. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  61944. /**
  61945. * Node creation.
  61946. * Can be overriden by children
  61947. * @param scene defines the scene where the node must be attached
  61948. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  61949. */
  61950. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61951. /**
  61952. * Affect a material to the given mesh
  61953. * @param mesh defines the mesh which will represent the control
  61954. */
  61955. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  61956. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  61957. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  61958. /** @hidden */ private _onPointerOut(target: Control3D): void;
  61959. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  61960. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61961. /** @hidden */
  61962. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61963. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  61964. /** @hidden */ private _disposeNode(): void;
  61965. /**
  61966. * Releases all associated resources
  61967. */
  61968. dispose(): void;
  61969. }
  61970. }
  61971. declare module BABYLON.GUI {
  61972. /**
  61973. * Class used as a root to all buttons
  61974. */
  61975. export class AbstractButton3D extends Control3D {
  61976. /**
  61977. * Creates a new button
  61978. * @param name defines the control name
  61979. */
  61980. constructor(name?: string);
  61981. protected _getTypeName(): string;
  61982. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61983. }
  61984. }
  61985. declare module BABYLON.GUI {
  61986. /**
  61987. * Class used to create a button in 3D
  61988. */
  61989. export class Button3D extends AbstractButton3D {
  61990. /** @hidden */
  61991. protected _currentMaterial: BABYLON.Material;
  61992. private _facadeTexture;
  61993. private _content;
  61994. private _contentResolution;
  61995. private _contentScaleRatio;
  61996. /**
  61997. * Gets or sets the texture resolution used to render content (512 by default)
  61998. */
  61999. contentResolution: BABYLON.int;
  62000. /**
  62001. * Gets or sets the texture scale ratio used to render content (2 by default)
  62002. */
  62003. contentScaleRatio: number;
  62004. protected _disposeFacadeTexture(): void;
  62005. protected _resetContent(): void;
  62006. /**
  62007. * Creates a new button
  62008. * @param name defines the control name
  62009. */
  62010. constructor(name?: string);
  62011. /**
  62012. * Gets or sets the GUI 2D content used to display the button's facade
  62013. */
  62014. content: Control;
  62015. /**
  62016. * Apply the facade texture (created from the content property).
  62017. * This function can be overloaded by child classes
  62018. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62019. */
  62020. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62021. protected _getTypeName(): string;
  62022. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62023. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62024. /**
  62025. * Releases all associated resources
  62026. */
  62027. dispose(): void;
  62028. }
  62029. }
  62030. declare module BABYLON.GUI {
  62031. /**
  62032. * Abstract class used to create a container panel deployed on the surface of a volume
  62033. */
  62034. export abstract class VolumeBasedPanel extends Container3D {
  62035. private _columns;
  62036. private _rows;
  62037. private _rowThenColum;
  62038. private _orientation;
  62039. protected _cellWidth: number;
  62040. protected _cellHeight: number;
  62041. /**
  62042. * Gets or sets the distance between elements
  62043. */
  62044. margin: number;
  62045. /**
  62046. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62047. * | Value | Type | Description |
  62048. * | ----- | ----------------------------------- | ----------- |
  62049. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62050. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62051. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62052. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62053. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62054. */
  62055. orientation: number;
  62056. /**
  62057. * Gets or sets the number of columns requested (10 by default).
  62058. * The panel will automatically compute the number of rows based on number of child controls.
  62059. */
  62060. columns: BABYLON.int;
  62061. /**
  62062. * Gets or sets a the number of rows requested.
  62063. * The panel will automatically compute the number of columns based on number of child controls.
  62064. */
  62065. rows: BABYLON.int;
  62066. /**
  62067. * Creates new VolumeBasedPanel
  62068. */
  62069. constructor();
  62070. protected _arrangeChildren(): void;
  62071. /** Child classes must implement this function to provide correct control positioning */
  62072. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62073. /** Child classes can implement this function to provide additional processing */
  62074. protected _finalProcessing(): void;
  62075. }
  62076. }
  62077. declare module BABYLON.GUI {
  62078. /**
  62079. * Class used to create a container panel deployed on the surface of a cylinder
  62080. */
  62081. export class CylinderPanel extends VolumeBasedPanel {
  62082. private _radius;
  62083. /**
  62084. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62085. */
  62086. radius: BABYLON.float;
  62087. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62088. private _cylindricalMapping;
  62089. }
  62090. }
  62091. declare module BABYLON.GUI {
  62092. /** @hidden */
  62093. export var fluentVertexShader: {
  62094. name: string;
  62095. shader: string;
  62096. };
  62097. }
  62098. declare module BABYLON.GUI {
  62099. /** @hidden */
  62100. export var fluentPixelShader: {
  62101. name: string;
  62102. shader: string;
  62103. };
  62104. }
  62105. declare module BABYLON.GUI {
  62106. /** @hidden */
  62107. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62108. INNERGLOW: boolean;
  62109. BORDER: boolean;
  62110. HOVERLIGHT: boolean;
  62111. TEXTURE: boolean;
  62112. constructor();
  62113. }
  62114. /**
  62115. * Class used to render controls with fluent desgin
  62116. */
  62117. export class FluentMaterial extends BABYLON.PushMaterial {
  62118. /**
  62119. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62120. */
  62121. innerGlowColorIntensity: number;
  62122. /**
  62123. * Gets or sets the inner glow color (white by default)
  62124. */
  62125. innerGlowColor: BABYLON.Color3;
  62126. /**
  62127. * Gets or sets alpha value (default is 1.0)
  62128. */
  62129. alpha: number;
  62130. /**
  62131. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62132. */
  62133. albedoColor: BABYLON.Color3;
  62134. /**
  62135. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62136. */
  62137. renderBorders: boolean;
  62138. /**
  62139. * Gets or sets border width (default is 0.5)
  62140. */
  62141. borderWidth: number;
  62142. /**
  62143. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62144. */
  62145. edgeSmoothingValue: number;
  62146. /**
  62147. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62148. */
  62149. borderMinValue: number;
  62150. /**
  62151. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62152. */
  62153. renderHoverLight: boolean;
  62154. /**
  62155. * Gets or sets the radius used to render the hover light (default is 1.0)
  62156. */
  62157. hoverRadius: number;
  62158. /**
  62159. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62160. */
  62161. hoverColor: BABYLON.Color4;
  62162. /**
  62163. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62164. */
  62165. hoverPosition: BABYLON.Vector3;
  62166. private _albedoTexture;
  62167. /** Gets or sets the texture to use for albedo color */
  62168. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62169. /**
  62170. * Creates a new Fluent material
  62171. * @param name defines the name of the material
  62172. * @param scene defines the hosting scene
  62173. */
  62174. constructor(name: string, scene: BABYLON.Scene);
  62175. needAlphaBlending(): boolean;
  62176. needAlphaTesting(): boolean;
  62177. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62178. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62179. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62180. getActiveTextures(): BABYLON.BaseTexture[];
  62181. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62182. dispose(forceDisposeEffect?: boolean): void;
  62183. clone(name: string): FluentMaterial;
  62184. serialize(): any;
  62185. getClassName(): string;
  62186. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62187. }
  62188. }
  62189. declare module BABYLON.GUI {
  62190. /**
  62191. * Class used to create a holographic button in 3D
  62192. */
  62193. export class HolographicButton extends Button3D {
  62194. private _backPlate;
  62195. private _textPlate;
  62196. private _frontPlate;
  62197. private _text;
  62198. private _imageUrl;
  62199. private _shareMaterials;
  62200. private _frontMaterial;
  62201. private _backMaterial;
  62202. private _plateMaterial;
  62203. private _pickedPointObserver;
  62204. private _tooltipFade;
  62205. private _tooltipTextBlock;
  62206. private _tooltipTexture;
  62207. private _tooltipMesh;
  62208. private _tooltipHoverObserver;
  62209. private _tooltipOutObserver;
  62210. private _disposeTooltip;
  62211. /**
  62212. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62213. */
  62214. tooltipText: BABYLON.Nullable<string>;
  62215. /**
  62216. * Gets or sets text for the button
  62217. */
  62218. text: string;
  62219. /**
  62220. * Gets or sets the image url for the button
  62221. */
  62222. imageUrl: string;
  62223. /**
  62224. * Gets the back material used by this button
  62225. */
  62226. readonly backMaterial: FluentMaterial;
  62227. /**
  62228. * Gets the front material used by this button
  62229. */
  62230. readonly frontMaterial: FluentMaterial;
  62231. /**
  62232. * Gets the plate material used by this button
  62233. */
  62234. readonly plateMaterial: BABYLON.StandardMaterial;
  62235. /**
  62236. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62237. */
  62238. readonly shareMaterials: boolean;
  62239. /**
  62240. * Creates a new button
  62241. * @param name defines the control name
  62242. */
  62243. constructor(name?: string, shareMaterials?: boolean);
  62244. protected _getTypeName(): string;
  62245. private _rebuildContent;
  62246. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62247. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62248. private _createBackMaterial;
  62249. private _createFrontMaterial;
  62250. private _createPlateMaterial;
  62251. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62252. /**
  62253. * Releases all associated resources
  62254. */
  62255. dispose(): void;
  62256. }
  62257. }
  62258. declare module BABYLON.GUI {
  62259. /**
  62260. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62261. */
  62262. export class MeshButton3D extends Button3D {
  62263. /** @hidden */
  62264. protected _currentMesh: BABYLON.Mesh;
  62265. /**
  62266. * Creates a new 3D button based on a mesh
  62267. * @param mesh mesh to become a 3D button
  62268. * @param name defines the control name
  62269. */
  62270. constructor(mesh: BABYLON.Mesh, name?: string);
  62271. protected _getTypeName(): string;
  62272. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62273. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62274. }
  62275. }
  62276. declare module BABYLON.GUI {
  62277. /**
  62278. * Class used to create a container panel deployed on the surface of a plane
  62279. */
  62280. export class PlanePanel extends VolumeBasedPanel {
  62281. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62282. }
  62283. }
  62284. declare module BABYLON.GUI {
  62285. /**
  62286. * Class used to create a container panel where items get randomized planar mapping
  62287. */
  62288. export class ScatterPanel extends VolumeBasedPanel {
  62289. private _iteration;
  62290. /**
  62291. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  62292. */
  62293. iteration: BABYLON.float;
  62294. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62295. private _scatterMapping;
  62296. protected _finalProcessing(): void;
  62297. }
  62298. }
  62299. declare module BABYLON.GUI {
  62300. /**
  62301. * Class used to create a container panel deployed on the surface of a sphere
  62302. */
  62303. export class SpherePanel extends VolumeBasedPanel {
  62304. private _radius;
  62305. /**
  62306. * Gets or sets the radius of the sphere where to project controls (5 by default)
  62307. */
  62308. radius: BABYLON.float;
  62309. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62310. private _sphericalMapping;
  62311. }
  62312. }
  62313. declare module BABYLON.GUI {
  62314. /**
  62315. * Class used to create a stack panel in 3D on XY plane
  62316. */
  62317. export class StackPanel3D extends Container3D {
  62318. private _isVertical;
  62319. /**
  62320. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  62321. */
  62322. isVertical: boolean;
  62323. /**
  62324. * Gets or sets the distance between elements
  62325. */
  62326. margin: number;
  62327. /**
  62328. * Creates new StackPanel
  62329. * @param isVertical
  62330. */
  62331. constructor(isVertical?: boolean);
  62332. protected _arrangeChildren(): void;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * Mode that determines the coordinate system to use.
  62338. */
  62339. export enum GLTFLoaderCoordinateSystemMode {
  62340. /**
  62341. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  62342. */
  62343. AUTO = 0,
  62344. /**
  62345. * Sets the useRightHandedSystem flag on the scene.
  62346. */
  62347. FORCE_RIGHT_HANDED = 1
  62348. }
  62349. /**
  62350. * Mode that determines what animations will start.
  62351. */
  62352. export enum GLTFLoaderAnimationStartMode {
  62353. /**
  62354. * No animation will start.
  62355. */
  62356. NONE = 0,
  62357. /**
  62358. * The first animation will start.
  62359. */
  62360. FIRST = 1,
  62361. /**
  62362. * All animations will start.
  62363. */
  62364. ALL = 2
  62365. }
  62366. /**
  62367. * Interface that contains the data for the glTF asset.
  62368. */
  62369. export interface IGLTFLoaderData {
  62370. /**
  62371. * Object that represents the glTF JSON.
  62372. */
  62373. json: Object;
  62374. /**
  62375. * The BIN chunk of a binary glTF.
  62376. */
  62377. bin: Nullable<ArrayBufferView>;
  62378. }
  62379. /**
  62380. * Interface for extending the loader.
  62381. */
  62382. export interface IGLTFLoaderExtension {
  62383. /**
  62384. * The name of this extension.
  62385. */
  62386. readonly name: string;
  62387. /**
  62388. * Defines whether this extension is enabled.
  62389. */
  62390. enabled: boolean;
  62391. }
  62392. /**
  62393. * Loader state.
  62394. */
  62395. export enum GLTFLoaderState {
  62396. /**
  62397. * The asset is loading.
  62398. */
  62399. LOADING = 0,
  62400. /**
  62401. * The asset is ready for rendering.
  62402. */
  62403. READY = 1,
  62404. /**
  62405. * The asset is completely loaded.
  62406. */
  62407. COMPLETE = 2
  62408. }
  62409. /** @hidden */
  62410. export interface IGLTFLoader extends IDisposable {
  62411. readonly state: Nullable<GLTFLoaderState>;
  62412. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  62413. meshes: AbstractMesh[];
  62414. particleSystems: IParticleSystem[];
  62415. skeletons: Skeleton[];
  62416. animationGroups: AnimationGroup[];
  62417. }>;
  62418. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  62419. }
  62420. /**
  62421. * File loader for loading glTF files into a scene.
  62422. */
  62423. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  62424. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62425. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62426. /**
  62427. * Raised when the asset has been parsed
  62428. */
  62429. onParsedObservable: Observable<IGLTFLoaderData>;
  62430. private _onParsedObserver;
  62431. /**
  62432. * Raised when the asset has been parsed
  62433. */
  62434. onParsed: (loaderData: IGLTFLoaderData) => void;
  62435. /**
  62436. * 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.
  62437. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  62438. * Defaults to true.
  62439. * @hidden
  62440. */
  62441. static IncrementalLoading: boolean;
  62442. /**
  62443. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  62444. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  62445. * @hidden
  62446. */
  62447. static HomogeneousCoordinates: boolean;
  62448. /**
  62449. * The coordinate system mode. Defaults to AUTO.
  62450. */
  62451. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  62452. /**
  62453. * The animation start mode. Defaults to FIRST.
  62454. */
  62455. animationStartMode: GLTFLoaderAnimationStartMode;
  62456. /**
  62457. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  62458. */
  62459. compileMaterials: boolean;
  62460. /**
  62461. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  62462. */
  62463. useClipPlane: boolean;
  62464. /**
  62465. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  62466. */
  62467. compileShadowGenerators: boolean;
  62468. /**
  62469. * Defines if the Alpha blended materials are only applied as coverage.
  62470. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  62471. * If true, no extra effects are applied to transparent pixels.
  62472. */
  62473. transparencyAsCoverage: boolean;
  62474. /**
  62475. * Function called before loading a url referenced by the asset.
  62476. */
  62477. preprocessUrlAsync: (url: string) => Promise<string>;
  62478. /**
  62479. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62480. */
  62481. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  62482. private _onMeshLoadedObserver;
  62483. /**
  62484. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62485. */
  62486. onMeshLoaded: (mesh: AbstractMesh) => void;
  62487. /**
  62488. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  62489. */
  62490. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  62491. private _onTextureLoadedObserver;
  62492. /**
  62493. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  62494. */
  62495. onTextureLoaded: (texture: BaseTexture) => void;
  62496. /**
  62497. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  62498. */
  62499. readonly onMaterialLoadedObservable: Observable<Material>;
  62500. private _onMaterialLoadedObserver;
  62501. /**
  62502. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  62503. */
  62504. onMaterialLoaded: (material: Material) => void;
  62505. /**
  62506. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  62507. */
  62508. readonly onCameraLoadedObservable: Observable<Camera>;
  62509. private _onCameraLoadedObserver;
  62510. /**
  62511. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  62512. */
  62513. onCameraLoaded: (camera: Camera) => void;
  62514. /**
  62515. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  62516. * For assets with LODs, raised when all of the LODs are complete.
  62517. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62518. */
  62519. readonly onCompleteObservable: Observable<void>;
  62520. private _onCompleteObserver;
  62521. /**
  62522. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  62523. * For assets with LODs, raised when all of the LODs are complete.
  62524. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62525. */
  62526. onComplete: () => void;
  62527. /**
  62528. * Observable raised when an error occurs.
  62529. */
  62530. readonly onErrorObservable: Observable<any>;
  62531. private _onErrorObserver;
  62532. /**
  62533. * Callback raised when an error occurs.
  62534. */
  62535. onError: (reason: any) => void;
  62536. /**
  62537. * Observable raised after the loader is disposed.
  62538. */
  62539. readonly onDisposeObservable: Observable<void>;
  62540. private _onDisposeObserver;
  62541. /**
  62542. * Callback raised after the loader is disposed.
  62543. */
  62544. onDispose: () => void;
  62545. /**
  62546. * Observable raised after a loader extension is created.
  62547. * Set additional options for a loader extension in this event.
  62548. */
  62549. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  62550. private _onExtensionLoadedObserver;
  62551. /**
  62552. * Callback raised after a loader extension is created.
  62553. */
  62554. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  62555. /**
  62556. * Defines if the loader logging is enabled.
  62557. */
  62558. loggingEnabled: boolean;
  62559. /**
  62560. * Defines if the loader should capture performance counters.
  62561. */
  62562. capturePerformanceCounters: boolean;
  62563. /**
  62564. * Defines if the loader should validate the asset.
  62565. */
  62566. validate: boolean;
  62567. /**
  62568. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  62569. */
  62570. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  62571. private _onValidatedObserver;
  62572. /**
  62573. * Callback raised after a loader extension is created.
  62574. */
  62575. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  62576. private _loader;
  62577. /**
  62578. * Name of the loader ("gltf")
  62579. */
  62580. name: string;
  62581. /**
  62582. * Supported file extensions of the loader (.gltf, .glb)
  62583. */
  62584. extensions: ISceneLoaderPluginExtensions;
  62585. /**
  62586. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  62587. */
  62588. dispose(): void;
  62589. /** @hidden */ private _clear(): void;
  62590. /**
  62591. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  62592. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  62593. * @param scene the scene the meshes should be added to
  62594. * @param data the glTF data to load
  62595. * @param rootUrl root url to load from
  62596. * @param onProgress event that fires when loading progress has occured
  62597. * @param fileName Defines the name of the file to load
  62598. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  62599. */
  62600. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  62601. meshes: AbstractMesh[];
  62602. particleSystems: IParticleSystem[];
  62603. skeletons: Skeleton[];
  62604. animationGroups: AnimationGroup[];
  62605. }>;
  62606. /**
  62607. * Imports all objects from the loaded glTF data and adds them to the scene
  62608. * @param scene the scene the objects should be added to
  62609. * @param data the glTF data to load
  62610. * @param rootUrl root url to load from
  62611. * @param onProgress event that fires when loading progress has occured
  62612. * @param fileName Defines the name of the file to load
  62613. * @returns a promise which completes when objects have been loaded to the scene
  62614. */
  62615. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  62616. /**
  62617. * Load into an asset container.
  62618. * @param scene The scene to load into
  62619. * @param data The data to import
  62620. * @param rootUrl The root url for scene and resources
  62621. * @param onProgress The callback when the load progresses
  62622. * @param fileName Defines the name of the file to load
  62623. * @returns The loaded asset container
  62624. */
  62625. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  62626. /**
  62627. * If the data string can be loaded directly.
  62628. * @param data string contianing the file data
  62629. * @returns if the data can be loaded directly
  62630. */
  62631. canDirectLoad(data: string): boolean;
  62632. /**
  62633. * Rewrites a url by combining a root url and response url.
  62634. */
  62635. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  62636. /**
  62637. * Instantiates a glTF file loader plugin.
  62638. * @returns the created plugin
  62639. */
  62640. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  62641. /**
  62642. * The loader state or null if the loader is not active.
  62643. */
  62644. readonly loaderState: Nullable<GLTFLoaderState>;
  62645. /**
  62646. * Returns a promise that resolves when the asset is completely loaded.
  62647. * @returns a promise that resolves when the asset is completely loaded.
  62648. */
  62649. whenCompleteAsync(): Promise<void>;
  62650. private _parseAsync;
  62651. private _validateAsync;
  62652. private _getLoader;
  62653. private _unpackBinary;
  62654. private _unpackBinaryV1;
  62655. private _unpackBinaryV2;
  62656. private static _parseVersion;
  62657. private static _compareVersion;
  62658. private static _decodeBufferToText;
  62659. private static readonly _logSpaces;
  62660. private _logIndentLevel;
  62661. private _loggingEnabled;
  62662. /** @hidden */ private _log: (message: string) => void;
  62663. /** @hidden */ private _logOpen(message: string): void;
  62664. /** @hidden */ private _logClose(): void;
  62665. private _logEnabled;
  62666. private _logDisabled;
  62667. private _capturePerformanceCounters;
  62668. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  62669. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  62670. private _startPerformanceCounterEnabled;
  62671. private _startPerformanceCounterDisabled;
  62672. private _endPerformanceCounterEnabled;
  62673. private _endPerformanceCounterDisabled;
  62674. }
  62675. }
  62676. declare module BABYLON.GLTF1 {
  62677. /**
  62678. * Enums
  62679. * @hidden
  62680. */
  62681. export enum EComponentType {
  62682. BYTE = 5120,
  62683. UNSIGNED_BYTE = 5121,
  62684. SHORT = 5122,
  62685. UNSIGNED_SHORT = 5123,
  62686. FLOAT = 5126
  62687. }
  62688. /** @hidden */
  62689. export enum EShaderType {
  62690. FRAGMENT = 35632,
  62691. VERTEX = 35633
  62692. }
  62693. /** @hidden */
  62694. export enum EParameterType {
  62695. BYTE = 5120,
  62696. UNSIGNED_BYTE = 5121,
  62697. SHORT = 5122,
  62698. UNSIGNED_SHORT = 5123,
  62699. INT = 5124,
  62700. UNSIGNED_INT = 5125,
  62701. FLOAT = 5126,
  62702. FLOAT_VEC2 = 35664,
  62703. FLOAT_VEC3 = 35665,
  62704. FLOAT_VEC4 = 35666,
  62705. INT_VEC2 = 35667,
  62706. INT_VEC3 = 35668,
  62707. INT_VEC4 = 35669,
  62708. BOOL = 35670,
  62709. BOOL_VEC2 = 35671,
  62710. BOOL_VEC3 = 35672,
  62711. BOOL_VEC4 = 35673,
  62712. FLOAT_MAT2 = 35674,
  62713. FLOAT_MAT3 = 35675,
  62714. FLOAT_MAT4 = 35676,
  62715. SAMPLER_2D = 35678
  62716. }
  62717. /** @hidden */
  62718. export enum ETextureWrapMode {
  62719. CLAMP_TO_EDGE = 33071,
  62720. MIRRORED_REPEAT = 33648,
  62721. REPEAT = 10497
  62722. }
  62723. /** @hidden */
  62724. export enum ETextureFilterType {
  62725. NEAREST = 9728,
  62726. LINEAR = 9728,
  62727. NEAREST_MIPMAP_NEAREST = 9984,
  62728. LINEAR_MIPMAP_NEAREST = 9985,
  62729. NEAREST_MIPMAP_LINEAR = 9986,
  62730. LINEAR_MIPMAP_LINEAR = 9987
  62731. }
  62732. /** @hidden */
  62733. export enum ETextureFormat {
  62734. ALPHA = 6406,
  62735. RGB = 6407,
  62736. RGBA = 6408,
  62737. LUMINANCE = 6409,
  62738. LUMINANCE_ALPHA = 6410
  62739. }
  62740. /** @hidden */
  62741. export enum ECullingType {
  62742. FRONT = 1028,
  62743. BACK = 1029,
  62744. FRONT_AND_BACK = 1032
  62745. }
  62746. /** @hidden */
  62747. export enum EBlendingFunction {
  62748. ZERO = 0,
  62749. ONE = 1,
  62750. SRC_COLOR = 768,
  62751. ONE_MINUS_SRC_COLOR = 769,
  62752. DST_COLOR = 774,
  62753. ONE_MINUS_DST_COLOR = 775,
  62754. SRC_ALPHA = 770,
  62755. ONE_MINUS_SRC_ALPHA = 771,
  62756. DST_ALPHA = 772,
  62757. ONE_MINUS_DST_ALPHA = 773,
  62758. CONSTANT_COLOR = 32769,
  62759. ONE_MINUS_CONSTANT_COLOR = 32770,
  62760. CONSTANT_ALPHA = 32771,
  62761. ONE_MINUS_CONSTANT_ALPHA = 32772,
  62762. SRC_ALPHA_SATURATE = 776
  62763. }
  62764. /** @hidden */
  62765. export interface IGLTFProperty {
  62766. extensions?: {
  62767. [key: string]: any;
  62768. };
  62769. extras?: Object;
  62770. }
  62771. /** @hidden */
  62772. export interface IGLTFChildRootProperty extends IGLTFProperty {
  62773. name?: string;
  62774. }
  62775. /** @hidden */
  62776. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  62777. bufferView: string;
  62778. byteOffset: number;
  62779. byteStride: number;
  62780. count: number;
  62781. type: string;
  62782. componentType: EComponentType;
  62783. max?: number[];
  62784. min?: number[];
  62785. name?: string;
  62786. }
  62787. /** @hidden */
  62788. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  62789. buffer: string;
  62790. byteOffset: number;
  62791. byteLength: number;
  62792. byteStride: number;
  62793. target?: number;
  62794. }
  62795. /** @hidden */
  62796. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  62797. uri: string;
  62798. byteLength?: number;
  62799. type?: string;
  62800. }
  62801. /** @hidden */
  62802. export interface IGLTFShader extends IGLTFChildRootProperty {
  62803. uri: string;
  62804. type: EShaderType;
  62805. }
  62806. /** @hidden */
  62807. export interface IGLTFProgram extends IGLTFChildRootProperty {
  62808. attributes: string[];
  62809. fragmentShader: string;
  62810. vertexShader: string;
  62811. }
  62812. /** @hidden */
  62813. export interface IGLTFTechniqueParameter {
  62814. type: number;
  62815. count?: number;
  62816. semantic?: string;
  62817. node?: string;
  62818. value?: number | boolean | string | Array<any>;
  62819. source?: string;
  62820. babylonValue?: any;
  62821. }
  62822. /** @hidden */
  62823. export interface IGLTFTechniqueCommonProfile {
  62824. lightingModel: string;
  62825. texcoordBindings: Object;
  62826. parameters?: Array<any>;
  62827. }
  62828. /** @hidden */
  62829. export interface IGLTFTechniqueStatesFunctions {
  62830. blendColor?: number[];
  62831. blendEquationSeparate?: number[];
  62832. blendFuncSeparate?: number[];
  62833. colorMask: boolean[];
  62834. cullFace: number[];
  62835. }
  62836. /** @hidden */
  62837. export interface IGLTFTechniqueStates {
  62838. enable: number[];
  62839. functions: IGLTFTechniqueStatesFunctions;
  62840. }
  62841. /** @hidden */
  62842. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  62843. parameters: {
  62844. [key: string]: IGLTFTechniqueParameter;
  62845. };
  62846. program: string;
  62847. attributes: {
  62848. [key: string]: string;
  62849. };
  62850. uniforms: {
  62851. [key: string]: string;
  62852. };
  62853. states: IGLTFTechniqueStates;
  62854. }
  62855. /** @hidden */
  62856. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  62857. technique?: string;
  62858. values: string[];
  62859. }
  62860. /** @hidden */
  62861. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  62862. attributes: {
  62863. [key: string]: string;
  62864. };
  62865. indices: string;
  62866. material: string;
  62867. mode?: number;
  62868. }
  62869. /** @hidden */
  62870. export interface IGLTFMesh extends IGLTFChildRootProperty {
  62871. primitives: IGLTFMeshPrimitive[];
  62872. }
  62873. /** @hidden */
  62874. export interface IGLTFImage extends IGLTFChildRootProperty {
  62875. uri: string;
  62876. }
  62877. /** @hidden */
  62878. export interface IGLTFSampler extends IGLTFChildRootProperty {
  62879. magFilter?: number;
  62880. minFilter?: number;
  62881. wrapS?: number;
  62882. wrapT?: number;
  62883. }
  62884. /** @hidden */
  62885. export interface IGLTFTexture extends IGLTFChildRootProperty {
  62886. sampler: string;
  62887. source: string;
  62888. format?: ETextureFormat;
  62889. internalFormat?: ETextureFormat;
  62890. target?: number;
  62891. type?: number;
  62892. babylonTexture?: Texture;
  62893. }
  62894. /** @hidden */
  62895. export interface IGLTFAmbienLight {
  62896. color?: number[];
  62897. }
  62898. /** @hidden */
  62899. export interface IGLTFDirectionalLight {
  62900. color?: number[];
  62901. }
  62902. /** @hidden */
  62903. export interface IGLTFPointLight {
  62904. color?: number[];
  62905. constantAttenuation?: number;
  62906. linearAttenuation?: number;
  62907. quadraticAttenuation?: number;
  62908. }
  62909. /** @hidden */
  62910. export interface IGLTFSpotLight {
  62911. color?: number[];
  62912. constantAttenuation?: number;
  62913. fallOfAngle?: number;
  62914. fallOffExponent?: number;
  62915. linearAttenuation?: number;
  62916. quadraticAttenuation?: number;
  62917. }
  62918. /** @hidden */
  62919. export interface IGLTFLight extends IGLTFChildRootProperty {
  62920. type: string;
  62921. }
  62922. /** @hidden */
  62923. export interface IGLTFCameraOrthographic {
  62924. xmag: number;
  62925. ymag: number;
  62926. zfar: number;
  62927. znear: number;
  62928. }
  62929. /** @hidden */
  62930. export interface IGLTFCameraPerspective {
  62931. aspectRatio: number;
  62932. yfov: number;
  62933. zfar: number;
  62934. znear: number;
  62935. }
  62936. /** @hidden */
  62937. export interface IGLTFCamera extends IGLTFChildRootProperty {
  62938. type: string;
  62939. }
  62940. /** @hidden */
  62941. export interface IGLTFAnimationChannelTarget {
  62942. id: string;
  62943. path: string;
  62944. }
  62945. /** @hidden */
  62946. export interface IGLTFAnimationChannel {
  62947. sampler: string;
  62948. target: IGLTFAnimationChannelTarget;
  62949. }
  62950. /** @hidden */
  62951. export interface IGLTFAnimationSampler {
  62952. input: string;
  62953. output: string;
  62954. interpolation?: string;
  62955. }
  62956. /** @hidden */
  62957. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  62958. channels?: IGLTFAnimationChannel[];
  62959. parameters?: {
  62960. [key: string]: string;
  62961. };
  62962. samplers?: {
  62963. [key: string]: IGLTFAnimationSampler;
  62964. };
  62965. }
  62966. /** @hidden */
  62967. export interface IGLTFNodeInstanceSkin {
  62968. skeletons: string[];
  62969. skin: string;
  62970. meshes: string[];
  62971. }
  62972. /** @hidden */
  62973. export interface IGLTFSkins extends IGLTFChildRootProperty {
  62974. bindShapeMatrix: number[];
  62975. inverseBindMatrices: string;
  62976. jointNames: string[];
  62977. babylonSkeleton?: Skeleton;
  62978. }
  62979. /** @hidden */
  62980. export interface IGLTFNode extends IGLTFChildRootProperty {
  62981. camera?: string;
  62982. children: string[];
  62983. skin?: string;
  62984. jointName?: string;
  62985. light?: string;
  62986. matrix: number[];
  62987. mesh?: string;
  62988. meshes?: string[];
  62989. rotation?: number[];
  62990. scale?: number[];
  62991. translation?: number[];
  62992. babylonNode?: Node;
  62993. }
  62994. /** @hidden */
  62995. export interface IGLTFScene extends IGLTFChildRootProperty {
  62996. nodes: string[];
  62997. }
  62998. /** @hidden */
  62999. export interface IGLTFRuntime {
  63000. extensions: {
  63001. [key: string]: any;
  63002. };
  63003. accessors: {
  63004. [key: string]: IGLTFAccessor;
  63005. };
  63006. buffers: {
  63007. [key: string]: IGLTFBuffer;
  63008. };
  63009. bufferViews: {
  63010. [key: string]: IGLTFBufferView;
  63011. };
  63012. meshes: {
  63013. [key: string]: IGLTFMesh;
  63014. };
  63015. lights: {
  63016. [key: string]: IGLTFLight;
  63017. };
  63018. cameras: {
  63019. [key: string]: IGLTFCamera;
  63020. };
  63021. nodes: {
  63022. [key: string]: IGLTFNode;
  63023. };
  63024. images: {
  63025. [key: string]: IGLTFImage;
  63026. };
  63027. textures: {
  63028. [key: string]: IGLTFTexture;
  63029. };
  63030. shaders: {
  63031. [key: string]: IGLTFShader;
  63032. };
  63033. programs: {
  63034. [key: string]: IGLTFProgram;
  63035. };
  63036. samplers: {
  63037. [key: string]: IGLTFSampler;
  63038. };
  63039. techniques: {
  63040. [key: string]: IGLTFTechnique;
  63041. };
  63042. materials: {
  63043. [key: string]: IGLTFMaterial;
  63044. };
  63045. animations: {
  63046. [key: string]: IGLTFAnimation;
  63047. };
  63048. skins: {
  63049. [key: string]: IGLTFSkins;
  63050. };
  63051. currentScene?: Object;
  63052. scenes: {
  63053. [key: string]: IGLTFScene;
  63054. };
  63055. extensionsUsed: string[];
  63056. extensionsRequired?: string[];
  63057. buffersCount: number;
  63058. shaderscount: number;
  63059. scene: Scene;
  63060. rootUrl: string;
  63061. loadedBufferCount: number;
  63062. loadedBufferViews: {
  63063. [name: string]: ArrayBufferView;
  63064. };
  63065. loadedShaderCount: number;
  63066. importOnlyMeshes: boolean;
  63067. importMeshesNames?: string[];
  63068. dummyNodes: Node[];
  63069. }
  63070. /** @hidden */
  63071. export interface INodeToRoot {
  63072. bone: Bone;
  63073. node: IGLTFNode;
  63074. id: string;
  63075. }
  63076. /** @hidden */
  63077. export interface IJointNode {
  63078. node: IGLTFNode;
  63079. id: string;
  63080. }
  63081. }
  63082. declare module BABYLON.GLTF1 {
  63083. /**
  63084. * Utils functions for GLTF
  63085. * @hidden
  63086. */
  63087. export class GLTFUtils {
  63088. /**
  63089. * Sets the given "parameter" matrix
  63090. * @param scene: the Scene object
  63091. * @param source: the source node where to pick the matrix
  63092. * @param parameter: the GLTF technique parameter
  63093. * @param uniformName: the name of the shader's uniform
  63094. * @param shaderMaterial: the shader material
  63095. */
  63096. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63097. /**
  63098. * Sets the given "parameter" matrix
  63099. * @param shaderMaterial: the shader material
  63100. * @param uniform: the name of the shader's uniform
  63101. * @param value: the value of the uniform
  63102. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63103. */
  63104. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63105. /**
  63106. * Returns the wrap mode of the texture
  63107. * @param mode: the mode value
  63108. */
  63109. static GetWrapMode(mode: number): number;
  63110. /**
  63111. * Returns the byte stride giving an accessor
  63112. * @param accessor: the GLTF accessor objet
  63113. */
  63114. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63115. /**
  63116. * Returns the texture filter mode giving a mode value
  63117. * @param mode: the filter mode value
  63118. */
  63119. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63120. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63121. /**
  63122. * Returns a buffer from its accessor
  63123. * @param gltfRuntime: the GLTF runtime
  63124. * @param accessor: the GLTF accessor
  63125. */
  63126. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63127. /**
  63128. * Decodes a buffer view into a string
  63129. * @param view: the buffer view
  63130. */
  63131. static DecodeBufferToText(view: ArrayBufferView): string;
  63132. /**
  63133. * Returns the default material of gltf. Related to
  63134. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63135. * @param scene: the Babylon.js scene
  63136. */
  63137. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63138. private static _DefaultMaterial;
  63139. }
  63140. }
  63141. declare module BABYLON.GLTF1 {
  63142. /**
  63143. * Implementation of the base glTF spec
  63144. * @hidden
  63145. */
  63146. export class GLTFLoaderBase {
  63147. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63148. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63149. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63150. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63151. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63152. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63153. }
  63154. /**
  63155. * glTF V1 Loader
  63156. * @hidden
  63157. */
  63158. export class GLTFLoader implements IGLTFLoader {
  63159. static Extensions: {
  63160. [name: string]: GLTFLoaderExtension;
  63161. };
  63162. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63163. state: Nullable<GLTFLoaderState>;
  63164. dispose(): void;
  63165. private _importMeshAsync;
  63166. /**
  63167. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63168. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63169. * @param scene the scene the meshes should be added to
  63170. * @param data gltf data containing information of the meshes in a loaded file
  63171. * @param rootUrl root url to load from
  63172. * @param onProgress event that fires when loading progress has occured
  63173. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63174. */
  63175. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63176. meshes: AbstractMesh[];
  63177. particleSystems: IParticleSystem[];
  63178. skeletons: Skeleton[];
  63179. animationGroups: AnimationGroup[];
  63180. }>;
  63181. private _loadAsync;
  63182. /**
  63183. * Imports all objects from a loaded gltf file and adds them to the scene
  63184. * @param scene the scene the objects should be added to
  63185. * @param data gltf data containing information of the meshes in a loaded file
  63186. * @param rootUrl root url to load from
  63187. * @param onProgress event that fires when loading progress has occured
  63188. * @returns a promise which completes when objects have been loaded to the scene
  63189. */
  63190. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63191. private _loadShadersAsync;
  63192. private _loadBuffersAsync;
  63193. private _createNodes;
  63194. }
  63195. /** @hidden */
  63196. export abstract class GLTFLoaderExtension {
  63197. private _name;
  63198. constructor(name: string);
  63199. readonly name: string;
  63200. /**
  63201. * Defines an override for loading the runtime
  63202. * Return true to stop further extensions from loading the runtime
  63203. */
  63204. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63205. /**
  63206. * Defines an onverride for creating gltf runtime
  63207. * Return true to stop further extensions from creating the runtime
  63208. */
  63209. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63210. /**
  63211. * Defines an override for loading buffers
  63212. * Return true to stop further extensions from loading this buffer
  63213. */
  63214. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63215. /**
  63216. * Defines an override for loading texture buffers
  63217. * Return true to stop further extensions from loading this texture data
  63218. */
  63219. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63220. /**
  63221. * Defines an override for creating textures
  63222. * Return true to stop further extensions from loading this texture
  63223. */
  63224. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63225. /**
  63226. * Defines an override for loading shader strings
  63227. * Return true to stop further extensions from loading this shader data
  63228. */
  63229. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63230. /**
  63231. * Defines an override for loading materials
  63232. * Return true to stop further extensions from loading this material
  63233. */
  63234. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63235. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63236. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63237. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63238. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63239. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63240. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63241. private static LoadTextureBufferAsync;
  63242. private static CreateTextureAsync;
  63243. private static ApplyExtensions;
  63244. }
  63245. }
  63246. declare module BABYLON.GLTF1 {
  63247. /** @hidden */
  63248. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63249. private _bin;
  63250. constructor();
  63251. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63252. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63253. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63254. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63255. }
  63256. }
  63257. declare module BABYLON.GLTF1 {
  63258. /** @hidden */
  63259. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63260. constructor();
  63261. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63262. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63263. private _loadTexture;
  63264. }
  63265. }
  63266. declare module BABYLON.GLTF2.Loader {
  63267. /**
  63268. * Loader interface with an index field.
  63269. */
  63270. export interface IArrayItem {
  63271. /**
  63272. * The index of this item in the array.
  63273. */
  63274. index: number;
  63275. }
  63276. /**
  63277. * Loader interface with additional members.
  63278. */
  63279. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  63280. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63281. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  63282. }
  63283. /**
  63284. * Loader interface with additional members.
  63285. */
  63286. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  63287. }
  63288. /** @hidden */
  63289. export interface _IAnimationSamplerData {
  63290. input: Float32Array;
  63291. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  63292. output: Float32Array;
  63293. }
  63294. /**
  63295. * Loader interface with additional members.
  63296. */
  63297. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  63298. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  63299. }
  63300. /**
  63301. * Loader interface with additional members.
  63302. */
  63303. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  63304. channels: IAnimationChannel[];
  63305. samplers: IAnimationSampler[];
  63306. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  63307. }
  63308. /**
  63309. * Loader interface with additional members.
  63310. */
  63311. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  63312. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63313. }
  63314. /**
  63315. * Loader interface with additional members.
  63316. */
  63317. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  63318. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63319. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  63320. }
  63321. /**
  63322. * Loader interface with additional members.
  63323. */
  63324. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  63325. }
  63326. /**
  63327. * Loader interface with additional members.
  63328. */
  63329. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  63330. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63331. }
  63332. /**
  63333. * Loader interface with additional members.
  63334. */
  63335. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  63336. }
  63337. /**
  63338. * Loader interface with additional members.
  63339. */
  63340. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  63341. }
  63342. /**
  63343. * Loader interface with additional members.
  63344. */
  63345. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  63346. baseColorTexture?: ITextureInfo;
  63347. metallicRoughnessTexture?: ITextureInfo;
  63348. }
  63349. /**
  63350. * Loader interface with additional members.
  63351. */
  63352. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  63353. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63354. normalTexture?: IMaterialNormalTextureInfo;
  63355. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63356. emissiveTexture?: ITextureInfo;
  63357. /** @hidden */ private _data?: {
  63358. [babylonDrawMode: number]: {
  63359. babylonMaterial: Material;
  63360. babylonMeshes: AbstractMesh[];
  63361. promise: Promise<void>;
  63362. };
  63363. };
  63364. }
  63365. /**
  63366. * Loader interface with additional members.
  63367. */
  63368. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  63369. primitives: IMeshPrimitive[];
  63370. }
  63371. /**
  63372. * Loader interface with additional members.
  63373. */
  63374. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  63375. /** @hidden */ private _instanceData?: {
  63376. babylonSourceMesh: Mesh;
  63377. promise: Promise<any>;
  63378. };
  63379. }
  63380. /**
  63381. * Loader interface with additional members.
  63382. */
  63383. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  63384. /**
  63385. * The parent glTF node.
  63386. */
  63387. parent?: INode;
  63388. /** @hidden */ private _babylonTransformNode?: TransformNode;
  63389. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  63390. /** @hidden */ private _babylonBones?: Bone[];
  63391. /** @hidden */ private _numMorphTargets?: number;
  63392. }
  63393. /** @hidden */
  63394. export interface _ISamplerData {
  63395. noMipMaps: boolean;
  63396. samplingMode: number;
  63397. wrapU: number;
  63398. wrapV: number;
  63399. }
  63400. /**
  63401. * Loader interface with additional members.
  63402. */
  63403. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  63404. /** @hidden */ private _data?: _ISamplerData;
  63405. }
  63406. /**
  63407. * Loader interface with additional members.
  63408. */
  63409. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  63410. }
  63411. /**
  63412. * Loader interface with additional members.
  63413. */
  63414. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  63415. /** @hidden */ private _data?: {
  63416. babylonSkeleton: Skeleton;
  63417. promise: Promise<void>;
  63418. };
  63419. }
  63420. /**
  63421. * Loader interface with additional members.
  63422. */
  63423. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  63424. }
  63425. /**
  63426. * Loader interface with additional members.
  63427. */
  63428. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  63429. }
  63430. /**
  63431. * Loader interface with additional members.
  63432. */
  63433. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  63434. accessors?: IAccessor[];
  63435. animations?: IAnimation[];
  63436. buffers?: IBuffer[];
  63437. bufferViews?: IBufferView[];
  63438. cameras?: ICamera[];
  63439. images?: IImage[];
  63440. materials?: IMaterial[];
  63441. meshes?: IMesh[];
  63442. nodes?: INode[];
  63443. samplers?: ISampler[];
  63444. scenes?: IScene[];
  63445. skins?: ISkin[];
  63446. textures?: ITexture[];
  63447. }
  63448. }
  63449. declare module BABYLON.GLTF2 {
  63450. /**
  63451. * Interface for a glTF loader extension.
  63452. */
  63453. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  63454. /**
  63455. * Called after the loader state changes to LOADING.
  63456. */
  63457. onLoading?(): void;
  63458. /**
  63459. * Called after the loader state changes to READY.
  63460. */
  63461. onReady?(): void;
  63462. /**
  63463. * Define this method to modify the default behavior when loading scenes.
  63464. * @param context The context when loading the asset
  63465. * @param scene The glTF scene property
  63466. * @returns A promise that resolves when the load is complete or null if not handled
  63467. */
  63468. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  63469. /**
  63470. * Define this method to modify the default behavior when loading nodes.
  63471. * @param context The context when loading the asset
  63472. * @param node The glTF node property
  63473. * @param assign A function called synchronously after parsing the glTF properties
  63474. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  63475. */
  63476. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63477. /**
  63478. * Define this method to modify the default behavior when loading cameras.
  63479. * @param context The context when loading the asset
  63480. * @param camera The glTF camera property
  63481. * @param assign A function called synchronously after parsing the glTF properties
  63482. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  63483. */
  63484. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  63485. /**
  63486. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  63487. * @param context The context when loading the asset
  63488. * @param primitive The glTF mesh primitive property
  63489. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  63490. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63491. /**
  63492. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63493. * @param context The context when loading the asset
  63494. * @param name The mesh name when loading the asset
  63495. * @param node The glTF node when loading the asset
  63496. * @param mesh The glTF mesh when loading the asset
  63497. * @param primitive The glTF mesh primitive property
  63498. * @param assign A function called synchronously after parsing the glTF properties
  63499. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63500. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63501. /**
  63502. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  63503. * @param context The context when loading the asset
  63504. * @param material The glTF material property
  63505. * @param assign A function called synchronously after parsing the glTF properties
  63506. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  63507. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  63508. /**
  63509. * Define this method to modify the default behavior when creating materials.
  63510. * @param context The context when loading the asset
  63511. * @param material The glTF material property
  63512. * @param babylonDrawMode The draw mode for the Babylon material
  63513. * @returns The Babylon material or null if not handled
  63514. */
  63515. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  63516. /**
  63517. * Define this method to modify the default behavior when loading material properties.
  63518. * @param context The context when loading the asset
  63519. * @param material The glTF material property
  63520. * @param babylonMaterial The Babylon material
  63521. * @returns A promise that resolves when the load is complete or null if not handled
  63522. */
  63523. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63524. /**
  63525. * Define this method to modify the default behavior when loading texture infos.
  63526. * @param context The context when loading the asset
  63527. * @param textureInfo The glTF texture info property
  63528. * @param assign A function called synchronously after parsing the glTF properties
  63529. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  63530. */
  63531. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63532. /**
  63533. * Define this method to modify the default behavior when loading animations.
  63534. * @param context The context when loading the asset
  63535. * @param animation The glTF animation property
  63536. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  63537. */
  63538. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  63539. /**
  63540. * @hidden Define this method to modify the default behavior when loading skins.
  63541. * @param context The context when loading the asset
  63542. * @param node The glTF node property
  63543. * @param skin The glTF skin property
  63544. * @returns A promise that resolves when the load is complete or null if not handled
  63545. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  63546. /**
  63547. * @hidden Define this method to modify the default behavior when loading uris.
  63548. * @param context The context when loading the asset
  63549. * @param property The glTF property associated with the uri
  63550. * @param uri The uri to load
  63551. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  63552. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  63553. }
  63554. }
  63555. declare module BABYLON.GLTF2 {
  63556. /**
  63557. * Helper class for working with arrays when loading the glTF asset
  63558. */
  63559. export class ArrayItem {
  63560. /**
  63561. * Gets an item from the given array.
  63562. * @param context The context when loading the asset
  63563. * @param array The array to get the item from
  63564. * @param index The index to the array
  63565. * @returns The array item
  63566. */
  63567. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  63568. /**
  63569. * Assign an `index` field to each item of the given array.
  63570. * @param array The array of items
  63571. */
  63572. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  63573. }
  63574. /**
  63575. * The glTF 2.0 loader
  63576. */
  63577. export class GLTFLoader implements IGLTFLoader {
  63578. /** @hidden */ private _completePromises: Promise<any>[];
  63579. private _disposed;
  63580. private _parent;
  63581. private _state;
  63582. private _extensions;
  63583. private _rootUrl;
  63584. private _fileName;
  63585. private _uniqueRootUrl;
  63586. private _gltf;
  63587. private _babylonScene;
  63588. private _rootBabylonMesh;
  63589. private _defaultBabylonMaterialData;
  63590. private _progressCallback?;
  63591. private _requests;
  63592. private static readonly _DefaultSampler;
  63593. private static _ExtensionNames;
  63594. private static _ExtensionFactories;
  63595. /**
  63596. * Registers a loader extension.
  63597. * @param name The name of the loader extension.
  63598. * @param factory The factory function that creates the loader extension.
  63599. */
  63600. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  63601. /**
  63602. * Unregisters a loader extension.
  63603. * @param name The name of the loader extenion.
  63604. * @returns A boolean indicating whether the extension has been unregistered
  63605. */
  63606. static UnregisterExtension(name: string): boolean;
  63607. /**
  63608. * Gets the loader state.
  63609. */
  63610. readonly state: Nullable<GLTFLoaderState>;
  63611. /**
  63612. * The glTF object parsed from the JSON.
  63613. */
  63614. readonly gltf: IGLTF;
  63615. /**
  63616. * The Babylon scene when loading the asset.
  63617. */
  63618. readonly babylonScene: Scene;
  63619. /**
  63620. * The root Babylon mesh when loading the asset.
  63621. */
  63622. readonly rootBabylonMesh: Mesh;
  63623. /** @hidden */
  63624. constructor(parent: GLTFFileLoader);
  63625. /** @hidden */
  63626. dispose(): void;
  63627. /** @hidden */
  63628. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63629. meshes: AbstractMesh[];
  63630. particleSystems: IParticleSystem[];
  63631. skeletons: Skeleton[];
  63632. animationGroups: AnimationGroup[];
  63633. }>;
  63634. /** @hidden */
  63635. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63636. private _loadAsync;
  63637. private _loadData;
  63638. private _setupData;
  63639. private _loadExtensions;
  63640. private _checkExtensions;
  63641. private _setState;
  63642. private _createRootNode;
  63643. /**
  63644. * Loads a glTF scene.
  63645. * @param context The context when loading the asset
  63646. * @param scene The glTF scene property
  63647. * @returns A promise that resolves when the load is complete
  63648. */
  63649. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  63650. private _forEachPrimitive;
  63651. private _getMeshes;
  63652. private _getSkeletons;
  63653. private _getAnimationGroups;
  63654. private _startAnimations;
  63655. /**
  63656. * Loads a glTF node.
  63657. * @param context The context when loading the asset
  63658. * @param node The glTF node property
  63659. * @param assign A function called synchronously after parsing the glTF properties
  63660. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  63661. */
  63662. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  63663. private _loadMeshAsync;
  63664. /**
  63665. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63666. * @param context The context when loading the asset
  63667. * @param name The mesh name when loading the asset
  63668. * @param node The glTF node when loading the asset
  63669. * @param mesh The glTF mesh when loading the asset
  63670. * @param primitive The glTF mesh primitive property
  63671. * @param assign A function called synchronously after parsing the glTF properties
  63672. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63673. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63674. private _loadVertexDataAsync;
  63675. private _createMorphTargets;
  63676. private _loadMorphTargetsAsync;
  63677. private _loadMorphTargetVertexDataAsync;
  63678. private static _LoadTransform;
  63679. private _loadSkinAsync;
  63680. private _loadBones;
  63681. private _loadBone;
  63682. private _loadSkinInverseBindMatricesDataAsync;
  63683. private _updateBoneMatrices;
  63684. private _getNodeMatrix;
  63685. /**
  63686. * Loads a glTF camera.
  63687. * @param context The context when loading the asset
  63688. * @param camera The glTF camera property
  63689. * @param assign A function called synchronously after parsing the glTF properties
  63690. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  63691. */
  63692. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  63693. private _loadAnimationsAsync;
  63694. /**
  63695. * Loads a glTF animation.
  63696. * @param context The context when loading the asset
  63697. * @param animation The glTF animation property
  63698. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  63699. */
  63700. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  63701. /**
  63702. * @hidden Loads a glTF animation channel.
  63703. * @param context The context when loading the asset
  63704. * @param animationContext The context of the animation when loading the asset
  63705. * @param animation The glTF animation property
  63706. * @param channel The glTF animation channel property
  63707. * @param babylonAnimationGroup The babylon animation group property
  63708. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  63709. * @returns A void promise when the channel load is complete
  63710. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  63711. private _loadAnimationSamplerAsync;
  63712. private _loadBufferAsync;
  63713. /**
  63714. * Loads a glTF buffer view.
  63715. * @param context The context when loading the asset
  63716. * @param bufferView The glTF buffer view property
  63717. * @returns A promise that resolves with the loaded data when the load is complete
  63718. */
  63719. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  63720. private _loadIndicesAccessorAsync;
  63721. private _loadFloatAccessorAsync;
  63722. private _loadVertexBufferViewAsync;
  63723. private _loadVertexAccessorAsync;
  63724. private _loadMaterialMetallicRoughnessPropertiesAsync;
  63725. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  63726. private _createDefaultMaterial;
  63727. /**
  63728. * Creates a Babylon material from a glTF material.
  63729. * @param context The context when loading the asset
  63730. * @param material The glTF material property
  63731. * @param babylonDrawMode The draw mode for the Babylon material
  63732. * @returns The Babylon material
  63733. */
  63734. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  63735. /**
  63736. * Loads properties from a glTF material into a Babylon material.
  63737. * @param context The context when loading the asset
  63738. * @param material The glTF material property
  63739. * @param babylonMaterial The Babylon material
  63740. * @returns A promise that resolves when the load is complete
  63741. */
  63742. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63743. /**
  63744. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  63745. * @param context The context when loading the asset
  63746. * @param material The glTF material property
  63747. * @param babylonMaterial The Babylon material
  63748. * @returns A promise that resolves when the load is complete
  63749. */
  63750. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63751. /**
  63752. * Loads the alpha properties from a glTF material into a Babylon material.
  63753. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  63754. * @param context The context when loading the asset
  63755. * @param material The glTF material property
  63756. * @param babylonMaterial The Babylon material
  63757. */
  63758. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  63759. /**
  63760. * Loads a glTF texture info.
  63761. * @param context The context when loading the asset
  63762. * @param textureInfo The glTF texture info property
  63763. * @param assign A function called synchronously after parsing the glTF properties
  63764. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  63765. */
  63766. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  63767. private _loadTextureAsync;
  63768. private _loadSampler;
  63769. /**
  63770. * Loads a glTF image.
  63771. * @param context The context when loading the asset
  63772. * @param image The glTF image property
  63773. * @returns A promise that resolves with the loaded data when the load is complete
  63774. */
  63775. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  63776. /**
  63777. * Loads a glTF uri.
  63778. * @param context The context when loading the asset
  63779. * @param property The glTF property associated with the uri
  63780. * @param uri The base64 or relative uri
  63781. * @returns A promise that resolves with the loaded data when the load is complete
  63782. */
  63783. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  63784. private _onProgress;
  63785. /**
  63786. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  63787. * @param babylonObject the Babylon object with metadata
  63788. * @param pointer the JSON pointer
  63789. */
  63790. static AddPointerMetadata(babylonObject: {
  63791. metadata: any;
  63792. }, pointer: string): void;
  63793. private static _GetTextureWrapMode;
  63794. private static _GetTextureSamplingMode;
  63795. private static _GetTypedArray;
  63796. private static _GetNumComponents;
  63797. private static _ValidateUri;
  63798. private static _GetDrawMode;
  63799. private _compileMaterialsAsync;
  63800. private _compileShadowGeneratorsAsync;
  63801. private _forEachExtensions;
  63802. private _applyExtensions;
  63803. private _extensionsOnLoading;
  63804. private _extensionsOnReady;
  63805. private _extensionsLoadSceneAsync;
  63806. private _extensionsLoadNodeAsync;
  63807. private _extensionsLoadCameraAsync;
  63808. private _extensionsLoadVertexDataAsync;
  63809. private _extensionsLoadMeshPrimitiveAsync;
  63810. private _extensionsLoadMaterialAsync;
  63811. private _extensionsCreateMaterial;
  63812. private _extensionsLoadMaterialPropertiesAsync;
  63813. private _extensionsLoadTextureInfoAsync;
  63814. private _extensionsLoadAnimationAsync;
  63815. private _extensionsLoadSkinAsync;
  63816. private _extensionsLoadUriAsync;
  63817. /**
  63818. * Helper method called by a loader extension to load an glTF extension.
  63819. * @param context The context when loading the asset
  63820. * @param property The glTF property to load the extension from
  63821. * @param extensionName The name of the extension to load
  63822. * @param actionAsync The action to run
  63823. * @returns The promise returned by actionAsync or null if the extension does not exist
  63824. */
  63825. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63826. /**
  63827. * Helper method called by a loader extension to load a glTF extra.
  63828. * @param context The context when loading the asset
  63829. * @param property The glTF property to load the extra from
  63830. * @param extensionName The name of the extension to load
  63831. * @param actionAsync The action to run
  63832. * @returns The promise returned by actionAsync or null if the extra does not exist
  63833. */
  63834. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63835. /**
  63836. * Increments the indentation level and logs a message.
  63837. * @param message The message to log
  63838. */
  63839. logOpen(message: string): void;
  63840. /**
  63841. * Decrements the indentation level.
  63842. */
  63843. logClose(): void;
  63844. /**
  63845. * Logs a message
  63846. * @param message The message to log
  63847. */
  63848. log(message: string): void;
  63849. /**
  63850. * Starts a performance counter.
  63851. * @param counterName The name of the performance counter
  63852. */
  63853. startPerformanceCounter(counterName: string): void;
  63854. /**
  63855. * Ends a performance counter.
  63856. * @param counterName The name of the performance counter
  63857. */
  63858. endPerformanceCounter(counterName: string): void;
  63859. }
  63860. }
  63861. declare module BABYLON.GLTF2.Loader.Extensions {
  63862. /**
  63863. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  63864. */
  63865. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  63866. /** The name of this extension. */
  63867. readonly name: string;
  63868. /** Defines whether this extension is enabled. */
  63869. enabled: boolean;
  63870. private _loader;
  63871. private _lights?;
  63872. /** @hidden */
  63873. constructor(loader: GLTFLoader);
  63874. /** @hidden */
  63875. dispose(): void;
  63876. /** @hidden */
  63877. onLoading(): void;
  63878. /** @hidden */
  63879. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  63880. private _loadLightAsync;
  63881. }
  63882. }
  63883. declare module BABYLON.GLTF2.Loader.Extensions {
  63884. /**
  63885. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  63886. */
  63887. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  63888. /** The name of this extension. */
  63889. readonly name: string;
  63890. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  63891. dracoCompression?: DracoCompression;
  63892. /** Defines whether this extension is enabled. */
  63893. enabled: boolean;
  63894. private _loader;
  63895. /** @hidden */
  63896. constructor(loader: GLTFLoader);
  63897. /** @hidden */
  63898. dispose(): void;
  63899. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63900. }
  63901. }
  63902. declare module BABYLON.GLTF2.Loader.Extensions {
  63903. /**
  63904. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  63905. */
  63906. export class KHR_lights implements IGLTFLoaderExtension {
  63907. /** The name of this extension. */
  63908. readonly name: string;
  63909. /** Defines whether this extension is enabled. */
  63910. enabled: boolean;
  63911. private _loader;
  63912. private _lights?;
  63913. /** @hidden */
  63914. constructor(loader: GLTFLoader);
  63915. /** @hidden */
  63916. dispose(): void;
  63917. /** @hidden */
  63918. onLoading(): void;
  63919. /** @hidden */
  63920. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63921. }
  63922. }
  63923. declare module BABYLON.GLTF2.Loader.Extensions {
  63924. /**
  63925. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  63926. */
  63927. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  63928. /** The name of this extension. */
  63929. readonly name: string;
  63930. /** Defines whether this extension is enabled. */
  63931. enabled: boolean;
  63932. private _loader;
  63933. /** @hidden */
  63934. constructor(loader: GLTFLoader);
  63935. /** @hidden */
  63936. dispose(): void;
  63937. /** @hidden */
  63938. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63939. private _loadSpecularGlossinessPropertiesAsync;
  63940. }
  63941. }
  63942. declare module BABYLON.GLTF2.Loader.Extensions {
  63943. /**
  63944. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  63945. */
  63946. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  63947. /** The name of this extension. */
  63948. readonly name: string;
  63949. /** Defines whether this extension is enabled. */
  63950. enabled: boolean;
  63951. private _loader;
  63952. /** @hidden */
  63953. constructor(loader: GLTFLoader);
  63954. /** @hidden */
  63955. dispose(): void;
  63956. /** @hidden */
  63957. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63958. private _loadUnlitPropertiesAsync;
  63959. }
  63960. }
  63961. declare module BABYLON.GLTF2.Loader.Extensions {
  63962. /**
  63963. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  63964. */
  63965. export class KHR_texture_transform implements IGLTFLoaderExtension {
  63966. /** The name of this extension. */
  63967. readonly name: string;
  63968. /** Defines whether this extension is enabled. */
  63969. enabled: boolean;
  63970. private _loader;
  63971. /** @hidden */
  63972. constructor(loader: GLTFLoader);
  63973. /** @hidden */
  63974. dispose(): void;
  63975. /** @hidden */
  63976. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63977. }
  63978. }
  63979. declare module BABYLON.GLTF2.Loader.Extensions {
  63980. /**
  63981. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  63982. */
  63983. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  63984. /** The name of this extension. */
  63985. readonly name: string;
  63986. /** Defines whether this extension is enabled. */
  63987. enabled: boolean;
  63988. private _loader;
  63989. private _clips;
  63990. private _emitters;
  63991. /** @hidden */
  63992. constructor(loader: GLTFLoader);
  63993. /** @hidden */
  63994. dispose(): void;
  63995. /** @hidden */
  63996. onLoading(): void;
  63997. /** @hidden */
  63998. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  63999. /** @hidden */
  64000. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64001. /** @hidden */
  64002. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64003. private _loadClipAsync;
  64004. private _loadEmitterAsync;
  64005. private _getEventAction;
  64006. private _loadAnimationEventAsync;
  64007. }
  64008. }
  64009. declare module BABYLON.GLTF2.Loader.Extensions {
  64010. /**
  64011. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64012. */
  64013. export class MSFT_lod implements IGLTFLoaderExtension {
  64014. /** The name of this extension. */
  64015. readonly name: string;
  64016. /** Defines whether this extension is enabled. */
  64017. enabled: boolean;
  64018. /**
  64019. * Maximum number of LODs to load, starting from the lowest LOD.
  64020. */
  64021. maxLODsToLoad: number;
  64022. /**
  64023. * Observable raised when all node LODs of one level are loaded.
  64024. * The event data is the index of the loaded LOD starting from zero.
  64025. * Dispose the loader to cancel the loading of the next level of LODs.
  64026. */
  64027. onNodeLODsLoadedObservable: Observable<number>;
  64028. /**
  64029. * Observable raised when all material LODs of one level are loaded.
  64030. * The event data is the index of the loaded LOD starting from zero.
  64031. * Dispose the loader to cancel the loading of the next level of LODs.
  64032. */
  64033. onMaterialLODsLoadedObservable: Observable<number>;
  64034. private _loader;
  64035. private _nodeIndexLOD;
  64036. private _nodeSignalLODs;
  64037. private _nodePromiseLODs;
  64038. private _materialIndexLOD;
  64039. private _materialSignalLODs;
  64040. private _materialPromiseLODs;
  64041. /** @hidden */
  64042. constructor(loader: GLTFLoader);
  64043. /** @hidden */
  64044. dispose(): void;
  64045. /** @hidden */
  64046. onReady(): void;
  64047. /** @hidden */
  64048. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64049. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64050. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64051. /**
  64052. * Gets an array of LOD properties from lowest to highest.
  64053. */
  64054. private _getLODs;
  64055. private _disposeUnusedMaterials;
  64056. }
  64057. }
  64058. declare module BABYLON.GLTF2.Loader.Extensions {
  64059. /** @hidden */
  64060. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64061. readonly name: string;
  64062. enabled: boolean;
  64063. private _loader;
  64064. constructor(loader: GLTFLoader);
  64065. dispose(): void;
  64066. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64067. }
  64068. }
  64069. declare module BABYLON.GLTF2.Loader.Extensions {
  64070. /** @hidden */
  64071. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64072. readonly name: string;
  64073. enabled: boolean;
  64074. private _loader;
  64075. constructor(loader: GLTFLoader);
  64076. dispose(): void;
  64077. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. /**
  64082. * Class reading and parsing the MTL file bundled with the obj file.
  64083. */
  64084. export class MTLFileLoader {
  64085. /**
  64086. * All material loaded from the mtl will be set here
  64087. */
  64088. materials: StandardMaterial[];
  64089. /**
  64090. * This function will read the mtl file and create each material described inside
  64091. * This function could be improve by adding :
  64092. * -some component missing (Ni, Tf...)
  64093. * -including the specific options available
  64094. *
  64095. * @param scene defines the scene the material will be created in
  64096. * @param data defines the mtl data to parse
  64097. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64098. */
  64099. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64100. /**
  64101. * Gets the texture for the material.
  64102. *
  64103. * If the material is imported from input file,
  64104. * We sanitize the url to ensure it takes the textre from aside the material.
  64105. *
  64106. * @param rootUrl The root url to load from
  64107. * @param value The value stored in the mtl
  64108. * @return The Texture
  64109. */
  64110. private static _getTexture;
  64111. }
  64112. /**
  64113. * Options for loading OBJ/MTL files
  64114. */
  64115. type MeshLoadOptions = {
  64116. /**
  64117. * Defines if UVs are optimized by default during load.
  64118. */
  64119. OptimizeWithUV: boolean;
  64120. /**
  64121. * Defines custom scaling of UV coordinates of loaded meshes.
  64122. */
  64123. UVScaling: Vector2;
  64124. /**
  64125. * Invert model on y-axis (does a model scaling inversion)
  64126. */
  64127. InvertY: boolean;
  64128. /**
  64129. * Invert Y-Axis of referenced textures on load
  64130. */
  64131. InvertTextureY: boolean;
  64132. /**
  64133. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64134. */
  64135. ImportVertexColors: boolean;
  64136. /**
  64137. * Compute the normals for the model, even if normals are present in the file.
  64138. */
  64139. ComputeNormals: boolean;
  64140. /**
  64141. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64142. */
  64143. SkipMaterials: boolean;
  64144. /**
  64145. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64146. */
  64147. MaterialLoadingFailsSilently: boolean;
  64148. };
  64149. /**
  64150. * OBJ file type loader.
  64151. * This is a babylon scene loader plugin.
  64152. */
  64153. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64154. /**
  64155. * Defines if UVs are optimized by default during load.
  64156. */
  64157. static OPTIMIZE_WITH_UV: boolean;
  64158. /**
  64159. * Invert model on y-axis (does a model scaling inversion)
  64160. */
  64161. static INVERT_Y: boolean;
  64162. /**
  64163. * Invert Y-Axis of referenced textures on load
  64164. */
  64165. static INVERT_TEXTURE_Y: boolean;
  64166. /**
  64167. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64168. */
  64169. static IMPORT_VERTEX_COLORS: boolean;
  64170. /**
  64171. * Compute the normals for the model, even if normals are present in the file.
  64172. */
  64173. static COMPUTE_NORMALS: boolean;
  64174. /**
  64175. * Defines custom scaling of UV coordinates of loaded meshes.
  64176. */
  64177. static UV_SCALING: Vector2;
  64178. /**
  64179. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64180. */
  64181. static SKIP_MATERIALS: boolean;
  64182. /**
  64183. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64184. *
  64185. * Defaults to true for backwards compatibility.
  64186. */
  64187. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64188. /**
  64189. * Defines the name of the plugin.
  64190. */
  64191. name: string;
  64192. /**
  64193. * Defines the extension the plugin is able to load.
  64194. */
  64195. extensions: string;
  64196. /** @hidden */
  64197. obj: RegExp;
  64198. /** @hidden */
  64199. group: RegExp;
  64200. /** @hidden */
  64201. mtllib: RegExp;
  64202. /** @hidden */
  64203. usemtl: RegExp;
  64204. /** @hidden */
  64205. smooth: RegExp;
  64206. /** @hidden */
  64207. vertexPattern: RegExp;
  64208. /** @hidden */
  64209. normalPattern: RegExp;
  64210. /** @hidden */
  64211. uvPattern: RegExp;
  64212. /** @hidden */
  64213. facePattern1: RegExp;
  64214. /** @hidden */
  64215. facePattern2: RegExp;
  64216. /** @hidden */
  64217. facePattern3: RegExp;
  64218. /** @hidden */
  64219. facePattern4: RegExp;
  64220. /** @hidden */
  64221. facePattern5: RegExp;
  64222. private _meshLoadOptions;
  64223. /**
  64224. * Creates loader for .OBJ files
  64225. *
  64226. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64227. */
  64228. constructor(meshLoadOptions?: MeshLoadOptions);
  64229. private static readonly currentMeshLoadOptions;
  64230. /**
  64231. * Calls synchronously the MTL file attached to this obj.
  64232. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64233. * Without this function materials are not displayed in the first frame (but displayed after).
  64234. * In consequence it is impossible to get material information in your HTML file
  64235. *
  64236. * @param url The URL of the MTL file
  64237. * @param rootUrl
  64238. * @param onSuccess Callback function to be called when the MTL file is loaded
  64239. * @private
  64240. */
  64241. private _loadMTL;
  64242. /**
  64243. * Instantiates a OBJ file loader plugin.
  64244. * @returns the created plugin
  64245. */
  64246. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64247. /**
  64248. * If the data string can be loaded directly.
  64249. *
  64250. * @param data string containing the file data
  64251. * @returns if the data can be loaded directly
  64252. */
  64253. canDirectLoad(data: string): boolean;
  64254. /**
  64255. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  64256. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64257. * @param scene the scene the meshes should be added to
  64258. * @param data the OBJ data to load
  64259. * @param rootUrl root url to load from
  64260. * @param onProgress event that fires when loading progress has occured
  64261. * @param fileName Defines the name of the file to load
  64262. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64263. */
  64264. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64265. meshes: AbstractMesh[];
  64266. particleSystems: IParticleSystem[];
  64267. skeletons: Skeleton[];
  64268. animationGroups: AnimationGroup[];
  64269. }>;
  64270. /**
  64271. * Imports all objects from the loaded OBJ data and adds them to the scene
  64272. * @param scene the scene the objects should be added to
  64273. * @param data the OBJ data to load
  64274. * @param rootUrl root url to load from
  64275. * @param onProgress event that fires when loading progress has occured
  64276. * @param fileName Defines the name of the file to load
  64277. * @returns a promise which completes when objects have been loaded to the scene
  64278. */
  64279. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64280. /**
  64281. * Load into an asset container.
  64282. * @param scene The scene to load into
  64283. * @param data The data to import
  64284. * @param rootUrl The root url for scene and resources
  64285. * @param onProgress The callback when the load progresses
  64286. * @param fileName Defines the name of the file to load
  64287. * @returns The loaded asset container
  64288. */
  64289. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64290. /**
  64291. * Read the OBJ file and create an Array of meshes.
  64292. * Each mesh contains all information given by the OBJ and the MTL file.
  64293. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  64294. *
  64295. * @param meshesNames
  64296. * @param scene Scene The scene where are displayed the data
  64297. * @param data String The content of the obj file
  64298. * @param rootUrl String The path to the folder
  64299. * @returns Array<AbstractMesh>
  64300. * @private
  64301. */
  64302. private _parseSolid;
  64303. }
  64304. }
  64305. declare module BABYLON {
  64306. /**
  64307. * STL file type loader.
  64308. * This is a babylon scene loader plugin.
  64309. */
  64310. export class STLFileLoader implements ISceneLoaderPlugin {
  64311. /** @hidden */
  64312. solidPattern: RegExp;
  64313. /** @hidden */
  64314. facetsPattern: RegExp;
  64315. /** @hidden */
  64316. normalPattern: RegExp;
  64317. /** @hidden */
  64318. vertexPattern: RegExp;
  64319. /**
  64320. * Defines the name of the plugin.
  64321. */
  64322. name: string;
  64323. /**
  64324. * Defines the extensions the stl loader is able to load.
  64325. * force data to come in as an ArrayBuffer
  64326. * we'll convert to string if it looks like it's an ASCII .stl
  64327. */
  64328. extensions: ISceneLoaderPluginExtensions;
  64329. /**
  64330. * Import meshes into a scene.
  64331. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  64332. * @param scene The scene to import into
  64333. * @param data The data to import
  64334. * @param rootUrl The root url for scene and resources
  64335. * @param meshes The meshes array to import into
  64336. * @param particleSystems The particle systems array to import into
  64337. * @param skeletons The skeletons array to import into
  64338. * @param onError The callback when import fails
  64339. * @returns True if successful or false otherwise
  64340. */
  64341. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  64342. /**
  64343. * Load into a scene.
  64344. * @param scene The scene to load into
  64345. * @param data The data to import
  64346. * @param rootUrl The root url for scene and resources
  64347. * @param onError The callback when import fails
  64348. * @returns true if successful or false otherwise
  64349. */
  64350. load(scene: Scene, data: any, rootUrl: string): boolean;
  64351. /**
  64352. * Load into an asset container.
  64353. * @param scene The scene to load into
  64354. * @param data The data to import
  64355. * @param rootUrl The root url for scene and resources
  64356. * @param onError The callback when import fails
  64357. * @returns The loaded asset container
  64358. */
  64359. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  64360. private _isBinary;
  64361. private _parseBinary;
  64362. private _parseASCII;
  64363. }
  64364. }
  64365. declare module BABYLON {
  64366. /**
  64367. * Class for generating OBJ data from a Babylon scene.
  64368. */
  64369. export class OBJExport {
  64370. /**
  64371. * Exports the geometry of a Mesh array in .OBJ file format (text)
  64372. * @param mesh defines the list of meshes to serialize
  64373. * @param materials defines if materials should be exported
  64374. * @param matlibname defines the name of the associated mtl file
  64375. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  64376. * @returns the OBJ content
  64377. */
  64378. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  64379. /**
  64380. * Exports the material(s) of a mesh in .MTL file format (text)
  64381. * @param mesh defines the mesh to extract the material from
  64382. * @returns the mtl content
  64383. */
  64384. static MTL(mesh: Mesh): string;
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /** @hidden */
  64389. export var __IGLTFExporterExtension: number;
  64390. /**
  64391. * Interface for extending the exporter
  64392. * @hidden
  64393. */
  64394. export interface IGLTFExporterExtension {
  64395. /**
  64396. * The name of this extension
  64397. */
  64398. readonly name: string;
  64399. /**
  64400. * Defines whether this extension is enabled
  64401. */
  64402. enabled: boolean;
  64403. /**
  64404. * Defines whether this extension is required
  64405. */
  64406. required: boolean;
  64407. }
  64408. }
  64409. declare module BABYLON.GLTF2.Exporter {
  64410. /** @hidden */
  64411. export var __IGLTFExporterExtensionV2: number;
  64412. /**
  64413. * Interface for a glTF exporter extension
  64414. * @hidden
  64415. */
  64416. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  64417. /**
  64418. * Define this method to modify the default behavior before exporting a texture
  64419. * @param context The context when loading the asset
  64420. * @param babylonTexture The glTF texture info property
  64421. * @param mimeType The mime-type of the generated image
  64422. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  64423. */
  64424. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64425. /**
  64426. * Define this method to modify the default behavior when exporting texture info
  64427. * @param context The context when loading the asset
  64428. * @param meshPrimitive glTF mesh primitive
  64429. * @param babylonSubMesh Babylon submesh
  64430. * @param binaryWriter glTF serializer binary writer instance
  64431. * @returns nullable IMeshPrimitive promise
  64432. */
  64433. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  64434. /**
  64435. * Define this method to modify the default behavior when exporting a node
  64436. * @param context The context when exporting the node
  64437. * @param node glTF node
  64438. * @param babylonNode BabylonJS node
  64439. * @returns nullable INode promise
  64440. */
  64441. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64442. /**
  64443. * Called after the exporter state changes to EXPORTING
  64444. */
  64445. onExporting?(): void;
  64446. }
  64447. }
  64448. declare module BABYLON.GLTF2.Exporter {
  64449. /**
  64450. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  64451. * @hidden
  64452. */
  64453. export class _GLTFMaterialExporter {
  64454. /**
  64455. * Represents the dielectric specular values for R, G and B
  64456. */
  64457. private static readonly _DielectricSpecular;
  64458. /**
  64459. * Allows the maximum specular power to be defined for material calculations
  64460. */
  64461. private static readonly _MaxSpecularPower;
  64462. /**
  64463. * Mapping to store textures
  64464. */
  64465. private _textureMap;
  64466. /**
  64467. * Numeric tolerance value
  64468. */
  64469. private static readonly _Epsilon;
  64470. /**
  64471. * Reference to the glTF Exporter
  64472. */
  64473. private _exporter;
  64474. constructor(exporter: _Exporter);
  64475. /**
  64476. * Specifies if two colors are approximately equal in value
  64477. * @param color1 first color to compare to
  64478. * @param color2 second color to compare to
  64479. * @param epsilon threshold value
  64480. */
  64481. private static FuzzyEquals;
  64482. /**
  64483. * Gets the materials from a Babylon scene and converts them to glTF materials
  64484. * @param scene babylonjs scene
  64485. * @param mimeType texture mime type
  64486. * @param images array of images
  64487. * @param textures array of textures
  64488. * @param materials array of materials
  64489. * @param imageData mapping of texture names to base64 textures
  64490. * @param hasTextureCoords specifies if texture coordinates are present on the material
  64491. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64492. /**
  64493. * Makes a copy of the glTF material without the texture parameters
  64494. * @param originalMaterial original glTF material
  64495. * @returns glTF material without texture parameters
  64496. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  64497. /**
  64498. * Specifies if the material has any texture parameters present
  64499. * @param material glTF Material
  64500. * @returns boolean specifying if texture parameters are present
  64501. */ private _hasTexturesPresent(material: IMaterial): boolean;
  64502. /**
  64503. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  64504. * @param babylonStandardMaterial
  64505. * @returns glTF Metallic Roughness Material representation
  64506. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  64507. /**
  64508. * Computes the metallic factor
  64509. * @param diffuse diffused value
  64510. * @param specular specular value
  64511. * @param oneMinusSpecularStrength one minus the specular strength
  64512. * @returns metallic value
  64513. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  64514. /**
  64515. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  64516. * @param glTFMaterial glTF material
  64517. * @param babylonMaterial Babylon material
  64518. */
  64519. private static _SetAlphaMode;
  64520. /**
  64521. * Converts a Babylon Standard Material to a glTF Material
  64522. * @param babylonStandardMaterial BJS Standard Material
  64523. * @param mimeType mime type to use for the textures
  64524. * @param images array of glTF image interfaces
  64525. * @param textures array of glTF texture interfaces
  64526. * @param materials array of glTF material interfaces
  64527. * @param imageData map of image file name to data
  64528. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64529. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64530. /**
  64531. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64532. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  64533. * @param mimeType mime type to use for the textures
  64534. * @param images array of glTF image interfaces
  64535. * @param textures array of glTF texture interfaces
  64536. * @param materials array of glTF material interfaces
  64537. * @param imageData map of image file name to data
  64538. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64539. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64540. /**
  64541. * Converts an image typed array buffer to a base64 image
  64542. * @param buffer typed array buffer
  64543. * @param width width of the image
  64544. * @param height height of the image
  64545. * @param mimeType mimetype of the image
  64546. * @returns base64 image string
  64547. */
  64548. private _createBase64FromCanvasAsync;
  64549. /**
  64550. * Generates a white texture based on the specified width and height
  64551. * @param width width of the texture in pixels
  64552. * @param height height of the texture in pixels
  64553. * @param scene babylonjs scene
  64554. * @returns white texture
  64555. */
  64556. private _createWhiteTexture;
  64557. /**
  64558. * 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
  64559. * @param texture1 first texture to resize
  64560. * @param texture2 second texture to resize
  64561. * @param scene babylonjs scene
  64562. * @returns resized textures or null
  64563. */
  64564. private _resizeTexturesToSameDimensions;
  64565. /**
  64566. * Converts an array of pixels to a Float32Array
  64567. * Throws an error if the pixel format is not supported
  64568. * @param pixels - array buffer containing pixel values
  64569. * @returns Float32 of pixels
  64570. */
  64571. private _convertPixelArrayToFloat32;
  64572. /**
  64573. * Convert Specular Glossiness Textures to Metallic Roughness
  64574. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  64575. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  64576. * @param diffuseTexture texture used to store diffuse information
  64577. * @param specularGlossinessTexture texture used to store specular and glossiness information
  64578. * @param factors specular glossiness material factors
  64579. * @param mimeType the mime type to use for the texture
  64580. * @returns pbr metallic roughness interface or null
  64581. */
  64582. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  64583. /**
  64584. * Converts specular glossiness material properties to metallic roughness
  64585. * @param specularGlossiness interface with specular glossiness material properties
  64586. * @returns interface with metallic roughness material properties
  64587. */
  64588. private _convertSpecularGlossinessToMetallicRoughness;
  64589. /**
  64590. * Calculates the surface reflectance, independent of lighting conditions
  64591. * @param color Color source to calculate brightness from
  64592. * @returns number representing the perceived brightness, or zero if color is undefined
  64593. */
  64594. private _getPerceivedBrightness;
  64595. /**
  64596. * Returns the maximum color component value
  64597. * @param color
  64598. * @returns maximum color component value, or zero if color is null or undefined
  64599. */
  64600. private _getMaxComponent;
  64601. /**
  64602. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  64603. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64604. * @param mimeType mime type to use for the textures
  64605. * @param images array of glTF image interfaces
  64606. * @param textures array of glTF texture interfaces
  64607. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64608. * @param imageData map of image file name to data
  64609. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64610. * @returns glTF PBR Metallic Roughness factors
  64611. */
  64612. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  64613. private _getGLTFTextureSampler;
  64614. private _getGLTFTextureWrapMode;
  64615. private _getGLTFTextureWrapModesSampler;
  64616. /**
  64617. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  64618. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64619. * @param mimeType mime type to use for the textures
  64620. * @param images array of glTF image interfaces
  64621. * @param textures array of glTF texture interfaces
  64622. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64623. * @param imageData map of image file name to data
  64624. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64625. * @returns glTF PBR Metallic Roughness factors
  64626. */
  64627. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  64628. /**
  64629. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64630. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64631. * @param mimeType mime type to use for the textures
  64632. * @param images array of glTF image interfaces
  64633. * @param textures array of glTF texture interfaces
  64634. * @param materials array of glTF material interfaces
  64635. * @param imageData map of image file name to data
  64636. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64637. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64638. private setMetallicRoughnessPbrMaterial;
  64639. private getPixelsFromTexture;
  64640. /**
  64641. * Extracts a texture from a Babylon texture into file data and glTF data
  64642. * @param babylonTexture Babylon texture to extract
  64643. * @param mimeType Mime Type of the babylonTexture
  64644. * @return glTF texture info, or null if the texture format is not supported
  64645. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  64646. /**
  64647. * Builds a texture from base64 string
  64648. * @param base64Texture base64 texture string
  64649. * @param baseTextureName Name to use for the texture
  64650. * @param mimeType image mime type for the texture
  64651. * @param images array of images
  64652. * @param textures array of textures
  64653. * @param imageData map of image data
  64654. * @returns glTF texture info, or null if the texture format is not supported
  64655. */
  64656. private _getTextureInfoFromBase64;
  64657. }
  64658. }
  64659. declare module BABYLON {
  64660. /**
  64661. * Class for holding and downloading glTF file data
  64662. */
  64663. export class GLTFData {
  64664. /**
  64665. * Object which contains the file name as the key and its data as the value
  64666. */
  64667. glTFFiles: {
  64668. [fileName: string]: string | Blob;
  64669. };
  64670. /**
  64671. * Initializes the glTF file object
  64672. */
  64673. constructor();
  64674. /**
  64675. * Downloads the glTF data as files based on their names and data
  64676. */
  64677. downloadFiles(): void;
  64678. }
  64679. }
  64680. declare module BABYLON {
  64681. /**
  64682. * Holds a collection of exporter options and parameters
  64683. */
  64684. export interface IExportOptions {
  64685. /**
  64686. * Function which indicates whether a babylon node should be exported or not
  64687. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  64688. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  64689. */
  64690. shouldExportNode?(node: Node): boolean;
  64691. /**
  64692. * The sample rate to bake animation curves
  64693. */
  64694. animationSampleRate?: number;
  64695. /**
  64696. * Begin serialization without waiting for the scene to be ready
  64697. */
  64698. exportWithoutWaitingForScene?: boolean;
  64699. }
  64700. /**
  64701. * Class for generating glTF data from a Babylon scene.
  64702. */
  64703. export class GLTF2Export {
  64704. /**
  64705. * Exports the geometry of the scene to .gltf file format asynchronously
  64706. * @param scene Babylon scene with scene hierarchy information
  64707. * @param filePrefix File prefix to use when generating the glTF file
  64708. * @param options Exporter options
  64709. * @returns Returns an object with a .gltf file and associates texture names
  64710. * as keys and their data and paths as values
  64711. */
  64712. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64713. private static _PreExportAsync;
  64714. private static _PostExportAsync;
  64715. /**
  64716. * Exports the geometry of the scene to .glb file format asychronously
  64717. * @param scene Babylon scene with scene hierarchy information
  64718. * @param filePrefix File prefix to use when generating glb file
  64719. * @param options Exporter options
  64720. * @returns Returns an object with a .glb filename as key and data as value
  64721. */
  64722. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64723. }
  64724. }
  64725. declare module BABYLON.GLTF2.Exporter {
  64726. /**
  64727. * @hidden
  64728. */
  64729. export class _GLTFUtilities {
  64730. /**
  64731. * Creates a buffer view based on the supplied arguments
  64732. * @param bufferIndex index value of the specified buffer
  64733. * @param byteOffset byte offset value
  64734. * @param byteLength byte length of the bufferView
  64735. * @param byteStride byte distance between conequential elements
  64736. * @param name name of the buffer view
  64737. * @returns bufferView for glTF
  64738. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  64739. /**
  64740. * Creates an accessor based on the supplied arguments
  64741. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  64742. * @param name The name of the accessor
  64743. * @param type The type of the accessor
  64744. * @param componentType The datatype of components in the attribute
  64745. * @param count The number of attributes referenced by this accessor
  64746. * @param byteOffset The offset relative to the start of the bufferView in bytes
  64747. * @param min Minimum value of each component in this attribute
  64748. * @param max Maximum value of each component in this attribute
  64749. * @returns accessor for glTF
  64750. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  64751. /**
  64752. * Calculates the minimum and maximum values of an array of position floats
  64753. * @param positions Positions array of a mesh
  64754. * @param vertexStart Starting vertex offset to calculate min and max values
  64755. * @param vertexCount Number of vertices to check for min and max values
  64756. * @returns min number array and max number array
  64757. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  64758. min: number[];
  64759. max: number[];
  64760. };
  64761. /**
  64762. * Converts a new right-handed Vector3
  64763. * @param vector vector3 array
  64764. * @returns right-handed Vector3
  64765. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  64766. /**
  64767. * Converts a Vector3 to right-handed
  64768. * @param vector Vector3 to convert to right-handed
  64769. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  64770. /**
  64771. * Converts a three element number array to right-handed
  64772. * @param vector number array to convert to right-handed
  64773. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  64774. /**
  64775. * Converts a new right-handed Vector3
  64776. * @param vector vector3 array
  64777. * @returns right-handed Vector3
  64778. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  64779. /**
  64780. * Converts a Vector3 to right-handed
  64781. * @param vector Vector3 to convert to right-handed
  64782. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  64783. /**
  64784. * Converts a three element number array to right-handed
  64785. * @param vector number array to convert to right-handed
  64786. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  64787. /**
  64788. * Converts a Vector4 to right-handed
  64789. * @param vector Vector4 to convert to right-handed
  64790. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  64791. /**
  64792. * Converts a Vector4 to right-handed
  64793. * @param vector Vector4 to convert to right-handed
  64794. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  64795. /**
  64796. * Converts a Quaternion to right-handed
  64797. * @param quaternion Source quaternion to convert to right-handed
  64798. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  64799. /**
  64800. * Converts a Quaternion to right-handed
  64801. * @param quaternion Source quaternion to convert to right-handed
  64802. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  64803. }
  64804. }
  64805. declare module BABYLON.GLTF2.Exporter {
  64806. /**
  64807. * Converts Babylon Scene into glTF 2.0.
  64808. * @hidden
  64809. */
  64810. export class _Exporter {
  64811. /**
  64812. * Stores the glTF to export
  64813. */ private _glTF: IGLTF;
  64814. /**
  64815. * Stores all generated buffer views, which represents views into the main glTF buffer data
  64816. */ private _bufferViews: IBufferView[];
  64817. /**
  64818. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  64819. */ private _accessors: IAccessor[];
  64820. /**
  64821. * Stores all the generated nodes, which contains transform and/or mesh information per node
  64822. */
  64823. private _nodes;
  64824. /**
  64825. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  64826. */
  64827. private _scenes;
  64828. /**
  64829. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  64830. */
  64831. private _meshes;
  64832. /**
  64833. * Stores all the generated material information, which represents the appearance of each primitive
  64834. */ private _materials: IMaterial[]; private _materialMap: {
  64835. [materialID: number]: number;
  64836. };
  64837. /**
  64838. * Stores all the generated texture information, which is referenced by glTF materials
  64839. */ private _textures: ITexture[];
  64840. /**
  64841. * Stores all the generated image information, which is referenced by glTF textures
  64842. */ private _images: IImage[];
  64843. /**
  64844. * Stores all the texture samplers
  64845. */ private _samplers: ISampler[];
  64846. /**
  64847. * Stores all the generated animation samplers, which is referenced by glTF animations
  64848. */
  64849. /**
  64850. * Stores the animations for glTF models
  64851. */
  64852. private _animations;
  64853. /**
  64854. * Stores the total amount of bytes stored in the glTF buffer
  64855. */
  64856. private _totalByteLength;
  64857. /**
  64858. * Stores a reference to the Babylon scene containing the source geometry and material information
  64859. */ private _babylonScene: Scene;
  64860. /**
  64861. * Stores a map of the image data, where the key is the file name and the value
  64862. * is the image data
  64863. */ private _imageData: {
  64864. [fileName: string]: {
  64865. data: Uint8Array;
  64866. mimeType: ImageMimeType;
  64867. };
  64868. };
  64869. /**
  64870. * Stores a map of the unique id of a node to its index in the node array
  64871. */
  64872. private _nodeMap;
  64873. /**
  64874. * Specifies if the Babylon scene should be converted to right-handed on export
  64875. */ private _convertToRightHandedSystem: boolean;
  64876. /**
  64877. * Baked animation sample rate
  64878. */
  64879. private _animationSampleRate;
  64880. /**
  64881. * Callback which specifies if a node should be exported or not
  64882. */
  64883. private _shouldExportNode;
  64884. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  64885. private _extensions;
  64886. private static _ExtensionNames;
  64887. private static _ExtensionFactories;
  64888. 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>>;
  64889. private _forEachExtensions;
  64890. private _extensionsOnExporting;
  64891. /**
  64892. * Load glTF serializer extensions
  64893. */
  64894. private _loadExtensions;
  64895. /**
  64896. * Creates a glTF Exporter instance, which can accept optional exporter options
  64897. * @param babylonScene Babylon scene object
  64898. * @param options Options to modify the behavior of the exporter
  64899. */
  64900. constructor(babylonScene: Scene, options?: IExportOptions);
  64901. /**
  64902. * Registers a glTF exporter extension
  64903. * @param name Name of the extension to export
  64904. * @param factory The factory function that creates the exporter extension
  64905. */
  64906. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  64907. /**
  64908. * Un-registers an exporter extension
  64909. * @param name The name fo the exporter extension
  64910. * @returns A boolean indicating whether the extension has been un-registered
  64911. */
  64912. static UnregisterExtension(name: string): boolean;
  64913. /**
  64914. * Lazy load a local engine with premultiplied alpha set to false
  64915. */ private _getLocalEngine(): Engine;
  64916. private reorderIndicesBasedOnPrimitiveMode;
  64917. /**
  64918. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  64919. * clock-wise during export to glTF
  64920. * @param submesh BabylonJS submesh
  64921. * @param primitiveMode Primitive mode of the mesh
  64922. * @param sideOrientation the winding order of the submesh
  64923. * @param vertexBufferKind The type of vertex attribute
  64924. * @param meshAttributeArray The vertex attribute data
  64925. * @param byteOffset The offset to the binary data
  64926. * @param binaryWriter The binary data for the glTF file
  64927. */
  64928. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  64929. /**
  64930. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  64931. * clock-wise during export to glTF
  64932. * @param submesh BabylonJS submesh
  64933. * @param primitiveMode Primitive mode of the mesh
  64934. * @param sideOrientation the winding order of the submesh
  64935. * @param vertexBufferKind The type of vertex attribute
  64936. * @param meshAttributeArray The vertex attribute data
  64937. * @param byteOffset The offset to the binary data
  64938. * @param binaryWriter The binary data for the glTF file
  64939. */
  64940. private reorderTriangleFillMode;
  64941. /**
  64942. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  64943. * clock-wise during export to glTF
  64944. * @param submesh BabylonJS submesh
  64945. * @param primitiveMode Primitive mode of the mesh
  64946. * @param sideOrientation the winding order of the submesh
  64947. * @param vertexBufferKind The type of vertex attribute
  64948. * @param meshAttributeArray The vertex attribute data
  64949. * @param byteOffset The offset to the binary data
  64950. * @param binaryWriter The binary data for the glTF file
  64951. */
  64952. private reorderTriangleStripDrawMode;
  64953. /**
  64954. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  64955. * clock-wise during export to glTF
  64956. * @param submesh BabylonJS submesh
  64957. * @param primitiveMode Primitive mode of the mesh
  64958. * @param sideOrientation the winding order of the submesh
  64959. * @param vertexBufferKind The type of vertex attribute
  64960. * @param meshAttributeArray The vertex attribute data
  64961. * @param byteOffset The offset to the binary data
  64962. * @param binaryWriter The binary data for the glTF file
  64963. */
  64964. private reorderTriangleFanMode;
  64965. /**
  64966. * Writes the vertex attribute data to binary
  64967. * @param vertices The vertices to write to the binary writer
  64968. * @param byteOffset The offset into the binary writer to overwrite binary data
  64969. * @param vertexAttributeKind The vertex attribute type
  64970. * @param meshAttributeArray The vertex attribute data
  64971. * @param binaryWriter The writer containing the binary data
  64972. */
  64973. private writeVertexAttributeData;
  64974. /**
  64975. * Writes mesh attribute data to a data buffer
  64976. * Returns the bytelength of the data
  64977. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  64978. * @param meshAttributeArray Array containing the attribute data
  64979. * @param binaryWriter The buffer to write the binary data to
  64980. * @param indices Used to specify the order of the vertex data
  64981. */
  64982. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  64983. /**
  64984. * Generates glTF json data
  64985. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  64986. * @param glTFPrefix Text to use when prefixing a glTF file
  64987. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  64988. * @returns json data as string
  64989. */
  64990. private generateJSON;
  64991. /**
  64992. * Generates data for .gltf and .bin files based on the glTF prefix string
  64993. * @param glTFPrefix Text to use when prefixing a glTF file
  64994. * @returns GLTFData with glTF file data
  64995. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  64996. /**
  64997. * Creates a binary buffer for glTF
  64998. * @returns array buffer for binary data
  64999. */
  65000. private _generateBinaryAsync;
  65001. /**
  65002. * Pads the number to a multiple of 4
  65003. * @param num number to pad
  65004. * @returns padded number
  65005. */
  65006. private _getPadding;
  65007. /**
  65008. * Generates a glb file from the json and binary data
  65009. * Returns an object with the glb file name as the key and data as the value
  65010. * @param glTFPrefix
  65011. * @returns object with glb filename as key and data as value
  65012. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65013. /**
  65014. * Sets the TRS for each node
  65015. * @param node glTF Node for storing the transformation data
  65016. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65017. */
  65018. private setNodeTransformation;
  65019. private getVertexBufferFromMesh;
  65020. /**
  65021. * Creates a bufferview based on the vertices type for the Babylon mesh
  65022. * @param kind Indicates the type of vertices data
  65023. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65024. * @param binaryWriter The buffer to write the bufferview data to
  65025. */
  65026. private createBufferViewKind;
  65027. /**
  65028. * The primitive mode of the Babylon mesh
  65029. * @param babylonMesh The BabylonJS mesh
  65030. */
  65031. private getMeshPrimitiveMode;
  65032. /**
  65033. * Sets the primitive mode of the glTF mesh primitive
  65034. * @param meshPrimitive glTF mesh primitive
  65035. * @param primitiveMode The primitive mode
  65036. */
  65037. private setPrimitiveMode;
  65038. /**
  65039. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65040. * @param meshPrimitive glTF mesh primitive
  65041. * @param attributeKind vertex attribute
  65042. * @returns boolean specifying if uv coordinates are present
  65043. */
  65044. private setAttributeKind;
  65045. /**
  65046. * Sets data for the primitive attributes of each submesh
  65047. * @param mesh glTF Mesh object to store the primitive attribute information
  65048. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65049. * @param binaryWriter Buffer to write the attribute data to
  65050. */
  65051. private setPrimitiveAttributesAsync;
  65052. /**
  65053. * Creates a glTF scene based on the array of meshes
  65054. * Returns the the total byte offset
  65055. * @param babylonScene Babylon scene to get the mesh data from
  65056. * @param binaryWriter Buffer to write binary data to
  65057. */
  65058. private createSceneAsync;
  65059. /**
  65060. * Creates a mapping of Node unique id to node index and handles animations
  65061. * @param babylonScene Babylon Scene
  65062. * @param nodes Babylon transform nodes
  65063. * @param shouldExportNode Callback specifying if a transform node should be exported
  65064. * @param binaryWriter Buffer to write binary data to
  65065. * @returns Node mapping of unique id to index
  65066. */
  65067. private createNodeMapAndAnimationsAsync;
  65068. /**
  65069. * Creates a glTF node from a Babylon mesh
  65070. * @param babylonMesh Source Babylon mesh
  65071. * @param binaryWriter Buffer for storing geometry data
  65072. * @returns glTF node
  65073. */
  65074. private createNodeAsync;
  65075. }
  65076. /**
  65077. * @hidden
  65078. *
  65079. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65080. */
  65081. export class _BinaryWriter {
  65082. /**
  65083. * Array buffer which stores all binary data
  65084. */
  65085. private _arrayBuffer;
  65086. /**
  65087. * View of the array buffer
  65088. */
  65089. private _dataView;
  65090. /**
  65091. * byte offset of data in array buffer
  65092. */
  65093. private _byteOffset;
  65094. /**
  65095. * Initialize binary writer with an initial byte length
  65096. * @param byteLength Initial byte length of the array buffer
  65097. */
  65098. constructor(byteLength: number);
  65099. /**
  65100. * Resize the array buffer to the specified byte length
  65101. * @param byteLength
  65102. */
  65103. private resizeBuffer;
  65104. /**
  65105. * Get an array buffer with the length of the byte offset
  65106. * @returns ArrayBuffer resized to the byte offset
  65107. */
  65108. getArrayBuffer(): ArrayBuffer;
  65109. /**
  65110. * Get the byte offset of the array buffer
  65111. * @returns byte offset
  65112. */
  65113. getByteOffset(): number;
  65114. /**
  65115. * Stores an UInt8 in the array buffer
  65116. * @param entry
  65117. * @param byteOffset If defined, specifies where to set the value as an offset.
  65118. */
  65119. setUInt8(entry: number, byteOffset?: number): void;
  65120. /**
  65121. * Gets an UInt32 in the array buffer
  65122. * @param entry
  65123. * @param byteOffset If defined, specifies where to set the value as an offset.
  65124. */
  65125. getUInt32(byteOffset: number): number;
  65126. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65127. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65128. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65129. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65130. /**
  65131. * Stores a Float32 in the array buffer
  65132. * @param entry
  65133. */
  65134. setFloat32(entry: number, byteOffset?: number): void;
  65135. /**
  65136. * Stores an UInt32 in the array buffer
  65137. * @param entry
  65138. * @param byteOffset If defined, specifies where to set the value as an offset.
  65139. */
  65140. setUInt32(entry: number, byteOffset?: number): void;
  65141. }
  65142. }
  65143. declare module BABYLON.GLTF2.Exporter {
  65144. /**
  65145. * @hidden
  65146. * Interface to store animation data.
  65147. */
  65148. export interface _IAnimationData {
  65149. /**
  65150. * Keyframe data.
  65151. */
  65152. inputs: number[];
  65153. /**
  65154. * Value data.
  65155. */
  65156. outputs: number[][];
  65157. /**
  65158. * Animation interpolation data.
  65159. */
  65160. samplerInterpolation: AnimationSamplerInterpolation;
  65161. /**
  65162. * Minimum keyframe value.
  65163. */
  65164. inputsMin: number;
  65165. /**
  65166. * Maximum keyframe value.
  65167. */
  65168. inputsMax: number;
  65169. }
  65170. /**
  65171. * @hidden
  65172. */
  65173. export interface _IAnimationInfo {
  65174. /**
  65175. * The target channel for the animation
  65176. */
  65177. animationChannelTargetPath: AnimationChannelTargetPath;
  65178. /**
  65179. * The glTF accessor type for the data.
  65180. */
  65181. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65182. /**
  65183. * Specifies if quaternions should be used.
  65184. */
  65185. useQuaternion: boolean;
  65186. }
  65187. /**
  65188. * @hidden
  65189. * Utility class for generating glTF animation data from BabylonJS.
  65190. */
  65191. export class _GLTFAnimation {
  65192. /**
  65193. * @ignore
  65194. *
  65195. * Creates glTF channel animation from BabylonJS animation.
  65196. * @param babylonTransformNode - BabylonJS mesh.
  65197. * @param animation - animation.
  65198. * @param animationChannelTargetPath - The target animation channel.
  65199. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65200. * @param useQuaternion - Specifies if quaternions are used.
  65201. * @returns nullable IAnimationData
  65202. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65203. private static _DeduceAnimationInfo;
  65204. /**
  65205. * @ignore
  65206. * Create node animations from the transform node animations
  65207. * @param babylonNode
  65208. * @param runtimeGLTFAnimation
  65209. * @param idleGLTFAnimations
  65210. * @param nodeMap
  65211. * @param nodes
  65212. * @param binaryWriter
  65213. * @param bufferViews
  65214. * @param accessors
  65215. * @param convertToRightHandedSystem
  65216. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  65217. [key: number]: number;
  65218. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65219. /**
  65220. * @ignore
  65221. * Create node animations from the animation groups
  65222. * @param babylonScene
  65223. * @param glTFAnimations
  65224. * @param nodeMap
  65225. * @param nodes
  65226. * @param binaryWriter
  65227. * @param bufferViews
  65228. * @param accessors
  65229. * @param convertToRightHandedSystem
  65230. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  65231. [key: number]: number;
  65232. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65233. private static AddAnimation;
  65234. /**
  65235. * Create a baked animation
  65236. * @param babylonTransformNode BabylonJS mesh
  65237. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  65238. * @param animationChannelTargetPath animation target channel
  65239. * @param minFrame minimum animation frame
  65240. * @param maxFrame maximum animation frame
  65241. * @param fps frames per second of the animation
  65242. * @param inputs input key frames of the animation
  65243. * @param outputs output key frame data of the animation
  65244. * @param convertToRightHandedSystem converts the values to right-handed
  65245. * @param useQuaternion specifies if quaternions should be used
  65246. */
  65247. private static _CreateBakedAnimation;
  65248. private static _ConvertFactorToVector3OrQuaternion;
  65249. private static _SetInterpolatedValue;
  65250. /**
  65251. * Creates linear animation from the animation key frames
  65252. * @param babylonTransformNode BabylonJS mesh
  65253. * @param animation BabylonJS animation
  65254. * @param animationChannelTargetPath The target animation channel
  65255. * @param frameDelta The difference between the last and first frame of the animation
  65256. * @param inputs Array to store the key frame times
  65257. * @param outputs Array to store the key frame data
  65258. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65259. * @param useQuaternion Specifies if quaternions are used in the animation
  65260. */
  65261. private static _CreateLinearOrStepAnimation;
  65262. /**
  65263. * Creates cubic spline animation from the animation key frames
  65264. * @param babylonTransformNode BabylonJS mesh
  65265. * @param animation BabylonJS animation
  65266. * @param animationChannelTargetPath The target animation channel
  65267. * @param frameDelta The difference between the last and first frame of the animation
  65268. * @param inputs Array to store the key frame times
  65269. * @param outputs Array to store the key frame data
  65270. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65271. * @param useQuaternion Specifies if quaternions are used in the animation
  65272. */
  65273. private static _CreateCubicSplineAnimation;
  65274. private static _GetBasePositionRotationOrScale;
  65275. /**
  65276. * Adds a key frame value
  65277. * @param keyFrame
  65278. * @param animation
  65279. * @param outputs
  65280. * @param animationChannelTargetPath
  65281. * @param basePositionRotationOrScale
  65282. * @param convertToRightHandedSystem
  65283. * @param useQuaternion
  65284. */
  65285. private static _AddKeyframeValue;
  65286. /**
  65287. * Determine the interpolation based on the key frames
  65288. * @param keyFrames
  65289. * @param animationChannelTargetPath
  65290. * @param useQuaternion
  65291. */
  65292. private static _DeduceInterpolation;
  65293. /**
  65294. * Adds an input tangent or output tangent to the output data
  65295. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  65296. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  65297. * @param outputs The animation data by keyframe
  65298. * @param animationChannelTargetPath The target animation channel
  65299. * @param interpolation The interpolation type
  65300. * @param keyFrame The key frame with the animation data
  65301. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  65302. * @param useQuaternion Specifies if quaternions are used
  65303. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  65304. */
  65305. private static AddSplineTangent;
  65306. /**
  65307. * Get the minimum and maximum key frames' frame values
  65308. * @param keyFrames animation key frames
  65309. * @returns the minimum and maximum key frame value
  65310. */
  65311. private static calculateMinMaxKeyFrames;
  65312. }
  65313. }
  65314. declare module BABYLON.GLTF2.Exporter {
  65315. /** @hidden */
  65316. export var textureTransformPixelShader: {
  65317. name: string;
  65318. shader: string;
  65319. };
  65320. }
  65321. declare module BABYLON.GLTF2.Exporter.Extensions {
  65322. /**
  65323. * @hidden
  65324. */
  65325. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  65326. /** Name of this extension */
  65327. readonly name: string;
  65328. /** Defines whether this extension is enabled */
  65329. enabled: boolean;
  65330. /** Defines whether this extension is required */
  65331. required: boolean;
  65332. /** Reference to the glTF exporter */
  65333. private _exporter;
  65334. constructor(exporter: _Exporter);
  65335. dispose(): void;
  65336. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65337. /**
  65338. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  65339. * @param babylonTexture
  65340. * @param offset
  65341. * @param rotation
  65342. * @param scale
  65343. * @param scene
  65344. */
  65345. private _textureTransformTextureAsync;
  65346. }
  65347. }
  65348. declare module BABYLON.GLTF2.Exporter.Extensions {
  65349. /**
  65350. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  65351. */
  65352. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  65353. /** The name of this extension. */
  65354. readonly name: string;
  65355. /** Defines whether this extension is enabled. */
  65356. enabled: boolean;
  65357. /** Defines whether this extension is required */
  65358. required: boolean;
  65359. /** Reference to the glTF exporter */
  65360. private _exporter;
  65361. private _lights;
  65362. /** @hidden */
  65363. constructor(exporter: _Exporter);
  65364. /** @hidden */
  65365. dispose(): void;
  65366. /** @hidden */
  65367. onExporting(): void;
  65368. /**
  65369. * Define this method to modify the default behavior when exporting a node
  65370. * @param context The context when exporting the node
  65371. * @param node glTF node
  65372. * @param babylonNode BabylonJS node
  65373. * @returns nullable INode promise
  65374. */
  65375. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65376. }
  65377. }
  65378. declare module BABYLON {
  65379. /**
  65380. * Class for generating STL data from a Babylon scene.
  65381. */
  65382. export class STLExport {
  65383. /**
  65384. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  65385. * @param meshes list defines the mesh to serialize
  65386. * @param download triggers the automatic download of the file.
  65387. * @param fileName changes the downloads fileName.
  65388. * @param binary changes the STL to a binary type.
  65389. * @param isLittleEndian toggle for binary type exporter.
  65390. * @returns the STL as UTF8 string
  65391. */
  65392. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  65393. }
  65394. }
  65395. /**
  65396. * @ignoreChildren
  65397. * @ignore
  65398. */
  65399. declare module "babylonjs-gltf2interface" {
  65400. export = BABYLON.GLTF2;
  65401. }
  65402. /**
  65403. * Module for glTF 2.0 Interface
  65404. * @ignoreChildren
  65405. * @ignore
  65406. */
  65407. declare module BABYLON.GLTF2 {
  65408. /**
  65409. * The datatype of the components in the attribute
  65410. */
  65411. const enum AccessorComponentType {
  65412. /**
  65413. * Byte
  65414. */
  65415. BYTE = 5120,
  65416. /**
  65417. * Unsigned Byte
  65418. */
  65419. UNSIGNED_BYTE = 5121,
  65420. /**
  65421. * Short
  65422. */
  65423. SHORT = 5122,
  65424. /**
  65425. * Unsigned Short
  65426. */
  65427. UNSIGNED_SHORT = 5123,
  65428. /**
  65429. * Unsigned Int
  65430. */
  65431. UNSIGNED_INT = 5125,
  65432. /**
  65433. * Float
  65434. */
  65435. FLOAT = 5126,
  65436. }
  65437. /**
  65438. * Specifies if the attirbute is a scalar, vector, or matrix
  65439. */
  65440. const enum AccessorType {
  65441. /**
  65442. * Scalar
  65443. */
  65444. SCALAR = "SCALAR",
  65445. /**
  65446. * Vector2
  65447. */
  65448. VEC2 = "VEC2",
  65449. /**
  65450. * Vector3
  65451. */
  65452. VEC3 = "VEC3",
  65453. /**
  65454. * Vector4
  65455. */
  65456. VEC4 = "VEC4",
  65457. /**
  65458. * Matrix2x2
  65459. */
  65460. MAT2 = "MAT2",
  65461. /**
  65462. * Matrix3x3
  65463. */
  65464. MAT3 = "MAT3",
  65465. /**
  65466. * Matrix4x4
  65467. */
  65468. MAT4 = "MAT4",
  65469. }
  65470. /**
  65471. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65472. */
  65473. const enum AnimationChannelTargetPath {
  65474. /**
  65475. * Translation
  65476. */
  65477. TRANSLATION = "translation",
  65478. /**
  65479. * Rotation
  65480. */
  65481. ROTATION = "rotation",
  65482. /**
  65483. * Scale
  65484. */
  65485. SCALE = "scale",
  65486. /**
  65487. * Weights
  65488. */
  65489. WEIGHTS = "weights",
  65490. }
  65491. /**
  65492. * Interpolation algorithm
  65493. */
  65494. const enum AnimationSamplerInterpolation {
  65495. /**
  65496. * The animated values are linearly interpolated between keyframes
  65497. */
  65498. LINEAR = "LINEAR",
  65499. /**
  65500. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  65501. */
  65502. STEP = "STEP",
  65503. /**
  65504. * The animation's interpolation is computed using a cubic spline with specified tangents
  65505. */
  65506. CUBICSPLINE = "CUBICSPLINE",
  65507. }
  65508. /**
  65509. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65510. */
  65511. const enum CameraType {
  65512. /**
  65513. * A perspective camera containing properties to create a perspective projection matrix
  65514. */
  65515. PERSPECTIVE = "perspective",
  65516. /**
  65517. * An orthographic camera containing properties to create an orthographic projection matrix
  65518. */
  65519. ORTHOGRAPHIC = "orthographic",
  65520. }
  65521. /**
  65522. * The mime-type of the image
  65523. */
  65524. const enum ImageMimeType {
  65525. /**
  65526. * JPEG Mime-type
  65527. */
  65528. JPEG = "image/jpeg",
  65529. /**
  65530. * PNG Mime-type
  65531. */
  65532. PNG = "image/png",
  65533. }
  65534. /**
  65535. * The alpha rendering mode of the material
  65536. */
  65537. const enum MaterialAlphaMode {
  65538. /**
  65539. * The alpha value is ignored and the rendered output is fully opaque
  65540. */
  65541. OPAQUE = "OPAQUE",
  65542. /**
  65543. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  65544. */
  65545. MASK = "MASK",
  65546. /**
  65547. * 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)
  65548. */
  65549. BLEND = "BLEND",
  65550. }
  65551. /**
  65552. * The type of the primitives to render
  65553. */
  65554. const enum MeshPrimitiveMode {
  65555. /**
  65556. * Points
  65557. */
  65558. POINTS = 0,
  65559. /**
  65560. * Lines
  65561. */
  65562. LINES = 1,
  65563. /**
  65564. * Line Loop
  65565. */
  65566. LINE_LOOP = 2,
  65567. /**
  65568. * Line Strip
  65569. */
  65570. LINE_STRIP = 3,
  65571. /**
  65572. * Triangles
  65573. */
  65574. TRIANGLES = 4,
  65575. /**
  65576. * Triangle Strip
  65577. */
  65578. TRIANGLE_STRIP = 5,
  65579. /**
  65580. * Triangle Fan
  65581. */
  65582. TRIANGLE_FAN = 6,
  65583. }
  65584. /**
  65585. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  65586. */
  65587. const enum TextureMagFilter {
  65588. /**
  65589. * Nearest
  65590. */
  65591. NEAREST = 9728,
  65592. /**
  65593. * Linear
  65594. */
  65595. LINEAR = 9729,
  65596. }
  65597. /**
  65598. * Minification filter. All valid values correspond to WebGL enums
  65599. */
  65600. const enum TextureMinFilter {
  65601. /**
  65602. * Nearest
  65603. */
  65604. NEAREST = 9728,
  65605. /**
  65606. * Linear
  65607. */
  65608. LINEAR = 9729,
  65609. /**
  65610. * Nearest Mip-Map Nearest
  65611. */
  65612. NEAREST_MIPMAP_NEAREST = 9984,
  65613. /**
  65614. * Linear Mipmap Nearest
  65615. */
  65616. LINEAR_MIPMAP_NEAREST = 9985,
  65617. /**
  65618. * Nearest Mipmap Linear
  65619. */
  65620. NEAREST_MIPMAP_LINEAR = 9986,
  65621. /**
  65622. * Linear Mipmap Linear
  65623. */
  65624. LINEAR_MIPMAP_LINEAR = 9987,
  65625. }
  65626. /**
  65627. * S (U) wrapping mode. All valid values correspond to WebGL enums
  65628. */
  65629. const enum TextureWrapMode {
  65630. /**
  65631. * Clamp to Edge
  65632. */
  65633. CLAMP_TO_EDGE = 33071,
  65634. /**
  65635. * Mirrored Repeat
  65636. */
  65637. MIRRORED_REPEAT = 33648,
  65638. /**
  65639. * Repeat
  65640. */
  65641. REPEAT = 10497,
  65642. }
  65643. /**
  65644. * glTF Property
  65645. */
  65646. interface IProperty {
  65647. /**
  65648. * Dictionary object with extension-specific objects
  65649. */
  65650. extensions?: {
  65651. [key: string]: any;
  65652. };
  65653. /**
  65654. * Application-Specific data
  65655. */
  65656. extras?: any;
  65657. }
  65658. /**
  65659. * glTF Child of Root Property
  65660. */
  65661. interface IChildRootProperty extends IProperty {
  65662. /**
  65663. * The user-defined name of this object
  65664. */
  65665. name?: string;
  65666. }
  65667. /**
  65668. * Indices of those attributes that deviate from their initialization value
  65669. */
  65670. interface IAccessorSparseIndices extends IProperty {
  65671. /**
  65672. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65673. */
  65674. bufferView: number;
  65675. /**
  65676. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65677. */
  65678. byteOffset?: number;
  65679. /**
  65680. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  65681. */
  65682. componentType: AccessorComponentType;
  65683. }
  65684. /**
  65685. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  65686. */
  65687. interface IAccessorSparseValues extends IProperty {
  65688. /**
  65689. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65690. */
  65691. bufferView: number;
  65692. /**
  65693. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65694. */
  65695. byteOffset?: number;
  65696. }
  65697. /**
  65698. * Sparse storage of attributes that deviate from their initialization value
  65699. */
  65700. interface IAccessorSparse extends IProperty {
  65701. /**
  65702. * The number of attributes encoded in this sparse accessor
  65703. */
  65704. count: number;
  65705. /**
  65706. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  65707. */
  65708. indices: IAccessorSparseIndices;
  65709. /**
  65710. * 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
  65711. */
  65712. values: IAccessorSparseValues;
  65713. }
  65714. /**
  65715. * 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
  65716. */
  65717. interface IAccessor extends IChildRootProperty {
  65718. /**
  65719. * The index of the bufferview
  65720. */
  65721. bufferView?: number;
  65722. /**
  65723. * The offset relative to the start of the bufferView in bytes
  65724. */
  65725. byteOffset?: number;
  65726. /**
  65727. * The datatype of components in the attribute
  65728. */
  65729. componentType: AccessorComponentType;
  65730. /**
  65731. * Specifies whether integer data values should be normalized
  65732. */
  65733. normalized?: boolean;
  65734. /**
  65735. * The number of attributes referenced by this accessor
  65736. */
  65737. count: number;
  65738. /**
  65739. * Specifies if the attribute is a scalar, vector, or matrix
  65740. */
  65741. type: AccessorType;
  65742. /**
  65743. * Maximum value of each component in this attribute
  65744. */
  65745. max?: number[];
  65746. /**
  65747. * Minimum value of each component in this attribute
  65748. */
  65749. min?: number[];
  65750. /**
  65751. * Sparse storage of attributes that deviate from their initialization value
  65752. */
  65753. sparse?: IAccessorSparse;
  65754. }
  65755. /**
  65756. * Targets an animation's sampler at a node's property
  65757. */
  65758. interface IAnimationChannel extends IProperty {
  65759. /**
  65760. * The index of a sampler in this animation used to compute the value for the target
  65761. */
  65762. sampler: number;
  65763. /**
  65764. * The index of the node and TRS property to target
  65765. */
  65766. target: IAnimationChannelTarget;
  65767. }
  65768. /**
  65769. * The index of the node and TRS property that an animation channel targets
  65770. */
  65771. interface IAnimationChannelTarget extends IProperty {
  65772. /**
  65773. * The index of the node to target
  65774. */
  65775. node: number;
  65776. /**
  65777. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65778. */
  65779. path: AnimationChannelTargetPath;
  65780. }
  65781. /**
  65782. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  65783. */
  65784. interface IAnimationSampler extends IProperty {
  65785. /**
  65786. * The index of an accessor containing keyframe input values, e.g., time
  65787. */
  65788. input: number;
  65789. /**
  65790. * Interpolation algorithm
  65791. */
  65792. interpolation?: AnimationSamplerInterpolation;
  65793. /**
  65794. * The index of an accessor, containing keyframe output values
  65795. */
  65796. output: number;
  65797. }
  65798. /**
  65799. * A keyframe animation
  65800. */
  65801. interface IAnimation extends IChildRootProperty {
  65802. /**
  65803. * An array of channels, each of which targets an animation's sampler at a node's property
  65804. */
  65805. channels: IAnimationChannel[];
  65806. /**
  65807. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  65808. */
  65809. samplers: IAnimationSampler[];
  65810. }
  65811. /**
  65812. * Metadata about the glTF asset
  65813. */
  65814. interface IAsset extends IChildRootProperty {
  65815. /**
  65816. * A copyright message suitable for display to credit the content creator
  65817. */
  65818. copyright?: string;
  65819. /**
  65820. * Tool that generated this glTF model. Useful for debugging
  65821. */
  65822. generator?: string;
  65823. /**
  65824. * The glTF version that this asset targets
  65825. */
  65826. version: string;
  65827. /**
  65828. * The minimum glTF version that this asset targets
  65829. */
  65830. minVersion?: string;
  65831. }
  65832. /**
  65833. * A buffer points to binary geometry, animation, or skins
  65834. */
  65835. interface IBuffer extends IChildRootProperty {
  65836. /**
  65837. * 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
  65838. */
  65839. uri?: string;
  65840. /**
  65841. * The length of the buffer in bytes
  65842. */
  65843. byteLength: number;
  65844. }
  65845. /**
  65846. * A view into a buffer generally representing a subset of the buffer
  65847. */
  65848. interface IBufferView extends IChildRootProperty {
  65849. /**
  65850. * The index of the buffer
  65851. */
  65852. buffer: number;
  65853. /**
  65854. * The offset into the buffer in bytes
  65855. */
  65856. byteOffset?: number;
  65857. /**
  65858. * The lenth of the bufferView in bytes
  65859. */
  65860. byteLength: number;
  65861. /**
  65862. * The stride, in bytes
  65863. */
  65864. byteStride?: number;
  65865. }
  65866. /**
  65867. * An orthographic camera containing properties to create an orthographic projection matrix
  65868. */
  65869. interface ICameraOrthographic extends IProperty {
  65870. /**
  65871. * The floating-point horizontal magnification of the view. Must not be zero
  65872. */
  65873. xmag: number;
  65874. /**
  65875. * The floating-point vertical magnification of the view. Must not be zero
  65876. */
  65877. ymag: number;
  65878. /**
  65879. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  65880. */
  65881. zfar: number;
  65882. /**
  65883. * The floating-point distance to the near clipping plane
  65884. */
  65885. znear: number;
  65886. }
  65887. /**
  65888. * A perspective camera containing properties to create a perspective projection matrix
  65889. */
  65890. interface ICameraPerspective extends IProperty {
  65891. /**
  65892. * The floating-point aspect ratio of the field of view
  65893. */
  65894. aspectRatio?: number;
  65895. /**
  65896. * The floating-point vertical field of view in radians
  65897. */
  65898. yfov: number;
  65899. /**
  65900. * The floating-point distance to the far clipping plane
  65901. */
  65902. zfar?: number;
  65903. /**
  65904. * The floating-point distance to the near clipping plane
  65905. */
  65906. znear: number;
  65907. }
  65908. /**
  65909. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65910. */
  65911. interface ICamera extends IChildRootProperty {
  65912. /**
  65913. * An orthographic camera containing properties to create an orthographic projection matrix
  65914. */
  65915. orthographic?: ICameraOrthographic;
  65916. /**
  65917. * A perspective camera containing properties to create a perspective projection matrix
  65918. */
  65919. perspective?: ICameraPerspective;
  65920. /**
  65921. * Specifies if the camera uses a perspective or orthographic projection
  65922. */
  65923. type: CameraType;
  65924. }
  65925. /**
  65926. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  65927. */
  65928. interface IImage extends IChildRootProperty {
  65929. /**
  65930. * 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
  65931. */
  65932. uri?: string;
  65933. /**
  65934. * The image's MIME type
  65935. */
  65936. mimeType?: ImageMimeType;
  65937. /**
  65938. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  65939. */
  65940. bufferView?: number;
  65941. }
  65942. /**
  65943. * Material Normal Texture Info
  65944. */
  65945. interface IMaterialNormalTextureInfo extends ITextureInfo {
  65946. /**
  65947. * The scalar multiplier applied to each normal vector of the normal texture
  65948. */
  65949. scale?: number;
  65950. }
  65951. /**
  65952. * Material Occlusion Texture Info
  65953. */
  65954. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  65955. /**
  65956. * A scalar multiplier controlling the amount of occlusion applied
  65957. */
  65958. strength?: number;
  65959. }
  65960. /**
  65961. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  65962. */
  65963. interface IMaterialPbrMetallicRoughness {
  65964. /**
  65965. * The material's base color factor
  65966. */
  65967. baseColorFactor?: number[];
  65968. /**
  65969. * The base color texture
  65970. */
  65971. baseColorTexture?: ITextureInfo;
  65972. /**
  65973. * The metalness of the material
  65974. */
  65975. metallicFactor?: number;
  65976. /**
  65977. * The roughness of the material
  65978. */
  65979. roughnessFactor?: number;
  65980. /**
  65981. * The metallic-roughness texture
  65982. */
  65983. metallicRoughnessTexture?: ITextureInfo;
  65984. }
  65985. /**
  65986. * The material appearance of a primitive
  65987. */
  65988. interface IMaterial extends IChildRootProperty {
  65989. /**
  65990. * 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
  65991. */
  65992. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65993. /**
  65994. * The normal map texture
  65995. */
  65996. normalTexture?: IMaterialNormalTextureInfo;
  65997. /**
  65998. * The occlusion map texture
  65999. */
  66000. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66001. /**
  66002. * The emissive map texture
  66003. */
  66004. emissiveTexture?: ITextureInfo;
  66005. /**
  66006. * 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
  66007. */
  66008. emissiveFactor?: number[];
  66009. /**
  66010. * The alpha rendering mode of the material
  66011. */
  66012. alphaMode?: MaterialAlphaMode;
  66013. /**
  66014. * The alpha cutoff value of the material
  66015. */
  66016. alphaCutoff?: number;
  66017. /**
  66018. * Specifies whether the material is double sided
  66019. */
  66020. doubleSided?: boolean;
  66021. }
  66022. /**
  66023. * Geometry to be rendered with the given material
  66024. */
  66025. interface IMeshPrimitive extends IProperty {
  66026. /**
  66027. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66028. */
  66029. attributes: {
  66030. [name: string]: number;
  66031. };
  66032. /**
  66033. * The index of the accessor that contains the indices
  66034. */
  66035. indices?: number;
  66036. /**
  66037. * The index of the material to apply to this primitive when rendering
  66038. */
  66039. material?: number;
  66040. /**
  66041. * The type of primitives to render. All valid values correspond to WebGL enums
  66042. */
  66043. mode?: MeshPrimitiveMode;
  66044. /**
  66045. * 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
  66046. */
  66047. targets?: {
  66048. [name: string]: number;
  66049. }[];
  66050. }
  66051. /**
  66052. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66053. */
  66054. interface IMesh extends IChildRootProperty {
  66055. /**
  66056. * An array of primitives, each defining geometry to be rendered with a material
  66057. */
  66058. primitives: IMeshPrimitive[];
  66059. /**
  66060. * Array of weights to be applied to the Morph Targets
  66061. */
  66062. weights?: number[];
  66063. }
  66064. /**
  66065. * A node in the node hierarchy
  66066. */
  66067. interface INode extends IChildRootProperty {
  66068. /**
  66069. * The index of the camera referenced by this node
  66070. */
  66071. camera?: number;
  66072. /**
  66073. * The indices of this node's children
  66074. */
  66075. children?: number[];
  66076. /**
  66077. * The index of the skin referenced by this node
  66078. */
  66079. skin?: number;
  66080. /**
  66081. * A floating-point 4x4 transformation matrix stored in column-major order
  66082. */
  66083. matrix?: number[];
  66084. /**
  66085. * The index of the mesh in this node
  66086. */
  66087. mesh?: number;
  66088. /**
  66089. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66090. */
  66091. rotation?: number[];
  66092. /**
  66093. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66094. */
  66095. scale?: number[];
  66096. /**
  66097. * The node's translation along the x, y, and z axes
  66098. */
  66099. translation?: number[];
  66100. /**
  66101. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66102. */
  66103. weights?: number[];
  66104. }
  66105. /**
  66106. * Texture sampler properties for filtering and wrapping modes
  66107. */
  66108. interface ISampler extends IChildRootProperty {
  66109. /**
  66110. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66111. */
  66112. magFilter?: TextureMagFilter;
  66113. /**
  66114. * Minification filter. All valid values correspond to WebGL enums
  66115. */
  66116. minFilter?: TextureMinFilter;
  66117. /**
  66118. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66119. */
  66120. wrapS?: TextureWrapMode;
  66121. /**
  66122. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66123. */
  66124. wrapT?: TextureWrapMode;
  66125. }
  66126. /**
  66127. * The root nodes of a scene
  66128. */
  66129. interface IScene extends IChildRootProperty {
  66130. /**
  66131. * The indices of each root node
  66132. */
  66133. nodes: number[];
  66134. }
  66135. /**
  66136. * Joints and matrices defining a skin
  66137. */
  66138. interface ISkin extends IChildRootProperty {
  66139. /**
  66140. * 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
  66141. */
  66142. inverseBindMatrices?: number;
  66143. /**
  66144. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66145. */
  66146. skeleton?: number;
  66147. /**
  66148. * 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)
  66149. */
  66150. joints: number[];
  66151. }
  66152. /**
  66153. * A texture and its sampler
  66154. */
  66155. interface ITexture extends IChildRootProperty {
  66156. /**
  66157. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66158. */
  66159. sampler?: number;
  66160. /**
  66161. * The index of the image used by this texture
  66162. */
  66163. source: number;
  66164. }
  66165. /**
  66166. * Reference to a texture
  66167. */
  66168. interface ITextureInfo extends IProperty {
  66169. /**
  66170. * The index of the texture
  66171. */
  66172. index: number;
  66173. /**
  66174. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66175. */
  66176. texCoord?: number;
  66177. }
  66178. /**
  66179. * The root object for a glTF asset
  66180. */
  66181. interface IGLTF extends IProperty {
  66182. /**
  66183. * An array of accessors. An accessor is a typed view into a bufferView
  66184. */
  66185. accessors?: IAccessor[];
  66186. /**
  66187. * An array of keyframe animations
  66188. */
  66189. animations?: IAnimation[];
  66190. /**
  66191. * Metadata about the glTF asset
  66192. */
  66193. asset: IAsset;
  66194. /**
  66195. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66196. */
  66197. buffers?: IBuffer[];
  66198. /**
  66199. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66200. */
  66201. bufferViews?: IBufferView[];
  66202. /**
  66203. * An array of cameras
  66204. */
  66205. cameras?: ICamera[];
  66206. /**
  66207. * Names of glTF extensions used somewhere in this asset
  66208. */
  66209. extensionsUsed?: string[];
  66210. /**
  66211. * Names of glTF extensions required to properly load this asset
  66212. */
  66213. extensionsRequired?: string[];
  66214. /**
  66215. * An array of images. An image defines data used to create a texture
  66216. */
  66217. images?: IImage[];
  66218. /**
  66219. * An array of materials. A material defines the appearance of a primitive
  66220. */
  66221. materials?: IMaterial[];
  66222. /**
  66223. * An array of meshes. A mesh is a set of primitives to be rendered
  66224. */
  66225. meshes?: IMesh[];
  66226. /**
  66227. * An array of nodes
  66228. */
  66229. nodes?: INode[];
  66230. /**
  66231. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  66232. */
  66233. samplers?: ISampler[];
  66234. /**
  66235. * The index of the default scene
  66236. */
  66237. scene?: number;
  66238. /**
  66239. * An array of scenes
  66240. */
  66241. scenes?: IScene[];
  66242. /**
  66243. * An array of skins. A skin is defined by joints and matrices
  66244. */
  66245. skins?: ISkin[];
  66246. /**
  66247. * An array of textures
  66248. */
  66249. textures?: ITexture[];
  66250. }
  66251. /**
  66252. * The glTF validation results
  66253. */
  66254. interface IGLTFValidationResults {
  66255. info: {
  66256. generator: string;
  66257. hasAnimations: boolean;
  66258. hasDefaultScene: boolean;
  66259. hasMaterials: boolean;
  66260. hasMorphTargets: boolean;
  66261. hasSkins: boolean;
  66262. hasTextures: boolean;
  66263. maxAttributesUsed: number;
  66264. primitivesCount: number
  66265. };
  66266. issues: {
  66267. messages: Array<string>;
  66268. numErrors: number;
  66269. numHints: number;
  66270. numInfos: number;
  66271. numWarnings: number;
  66272. truncated: boolean
  66273. };
  66274. mimeType: string;
  66275. uri: string;
  66276. validatedAt: string;
  66277. validatorVersion: string;
  66278. }
  66279. /**
  66280. * The glTF validation options
  66281. */
  66282. interface IGLTFValidationOptions {
  66283. uri?: string;
  66284. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  66285. validateAccessorData?: boolean;
  66286. maxIssues?: number;
  66287. ignoredIssues?: Array<string>;
  66288. severityOverrides?: Object;
  66289. }
  66290. /**
  66291. * The glTF validator object
  66292. */
  66293. interface IGLTFValidator {
  66294. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66295. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66296. }
  66297. }
  66298. declare module BABYLON {
  66299. /** @hidden */
  66300. export var cellPixelShader: {
  66301. name: string;
  66302. shader: string;
  66303. };
  66304. }
  66305. declare module BABYLON {
  66306. /** @hidden */
  66307. export var cellVertexShader: {
  66308. name: string;
  66309. shader: string;
  66310. };
  66311. }
  66312. declare module BABYLON {
  66313. export class CellMaterial extends BABYLON.PushMaterial {
  66314. private _diffuseTexture;
  66315. diffuseTexture: BABYLON.BaseTexture;
  66316. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  66317. computeHighLevel: boolean;
  66318. private _disableLighting;
  66319. disableLighting: boolean;
  66320. private _maxSimultaneousLights;
  66321. maxSimultaneousLights: number;
  66322. private _renderId;
  66323. constructor(name: string, scene: BABYLON.Scene);
  66324. needAlphaBlending(): boolean;
  66325. needAlphaTesting(): boolean;
  66326. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66327. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66328. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66329. getAnimatables(): BABYLON.IAnimatable[];
  66330. getActiveTextures(): BABYLON.BaseTexture[];
  66331. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66332. dispose(forceDisposeEffect?: boolean): void;
  66333. getClassName(): string;
  66334. clone(name: string): CellMaterial;
  66335. serialize(): any;
  66336. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  66337. }
  66338. }
  66339. declare module BABYLON {
  66340. export class CustomShaderStructure {
  66341. FragmentStore: string;
  66342. VertexStore: string;
  66343. constructor();
  66344. }
  66345. export class ShaderSpecialParts {
  66346. constructor();
  66347. Fragment_Begin: string;
  66348. Fragment_Definitions: string;
  66349. Fragment_MainBegin: string;
  66350. Fragment_Custom_Diffuse: string;
  66351. Fragment_Before_Lights: string;
  66352. Fragment_Before_Fog: string;
  66353. Fragment_Custom_Alpha: string;
  66354. Fragment_Before_FragColor: string;
  66355. Vertex_Begin: string;
  66356. Vertex_Definitions: string;
  66357. Vertex_MainBegin: string;
  66358. Vertex_Before_PositionUpdated: string;
  66359. Vertex_Before_NormalUpdated: string;
  66360. Vertex_MainEnd: string;
  66361. }
  66362. export class CustomMaterial extends BABYLON.StandardMaterial {
  66363. static ShaderIndexer: number;
  66364. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  66365. FragmentShader: string;
  66366. VertexShader: string;
  66367. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66368. ReviewUniform(name: string, arr: string[]): string[];
  66369. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  66370. constructor(name: string, scene: BABYLON.Scene);
  66371. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  66372. Fragment_Begin(shaderPart: string): CustomMaterial;
  66373. Fragment_Definitions(shaderPart: string): CustomMaterial;
  66374. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  66375. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  66376. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  66377. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  66378. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  66379. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  66380. Vertex_Begin(shaderPart: string): CustomMaterial;
  66381. Vertex_Definitions(shaderPart: string): CustomMaterial;
  66382. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  66383. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  66384. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  66385. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  66386. }
  66387. }
  66388. declare module BABYLON {
  66389. export class ShaderAlebdoParts {
  66390. constructor();
  66391. Fragment_Begin: string;
  66392. Fragment_Definitions: string;
  66393. Fragment_MainBegin: string;
  66394. Fragment_Custom_Albedo: string;
  66395. Fragment_Before_Lights: string;
  66396. Fragment_Custom_MetallicRoughness: string;
  66397. Fragment_Custom_MicroSurface: string;
  66398. Fragment_Before_Fog: string;
  66399. Fragment_Custom_Alpha: string;
  66400. Fragment_Before_FragColor: string;
  66401. Vertex_Begin: string;
  66402. Vertex_Definitions: string;
  66403. Vertex_MainBegin: string;
  66404. Vertex_Before_PositionUpdated: string;
  66405. Vertex_Before_NormalUpdated: string;
  66406. Vertex_MainEnd: string;
  66407. }
  66408. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  66409. static ShaderIndexer: number;
  66410. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  66411. FragmentShader: string;
  66412. VertexShader: string;
  66413. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66414. ReviewUniform(name: string, arr: string[]): string[];
  66415. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  66416. constructor(name: string, scene: BABYLON.Scene);
  66417. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  66418. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  66419. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  66420. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  66421. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  66422. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  66423. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  66424. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  66425. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  66426. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  66427. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  66428. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  66429. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  66430. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  66431. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  66432. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  66433. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  66434. }
  66435. }
  66436. declare module BABYLON {
  66437. /** @hidden */
  66438. export var firePixelShader: {
  66439. name: string;
  66440. shader: string;
  66441. };
  66442. }
  66443. declare module BABYLON {
  66444. /** @hidden */
  66445. export var fireVertexShader: {
  66446. name: string;
  66447. shader: string;
  66448. };
  66449. }
  66450. declare module BABYLON {
  66451. export class FireMaterial extends BABYLON.PushMaterial {
  66452. private _diffuseTexture;
  66453. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66454. private _distortionTexture;
  66455. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66456. private _opacityTexture;
  66457. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66458. diffuseColor: BABYLON.Color3;
  66459. speed: number;
  66460. private _scaledDiffuse;
  66461. private _renderId;
  66462. private _lastTime;
  66463. constructor(name: string, scene: BABYLON.Scene);
  66464. needAlphaBlending(): boolean;
  66465. needAlphaTesting(): boolean;
  66466. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66467. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66468. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66469. getAnimatables(): BABYLON.IAnimatable[];
  66470. getActiveTextures(): BABYLON.BaseTexture[];
  66471. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66472. getClassName(): string;
  66473. dispose(forceDisposeEffect?: boolean): void;
  66474. clone(name: string): FireMaterial;
  66475. serialize(): any;
  66476. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  66477. }
  66478. }
  66479. declare module BABYLON {
  66480. /** @hidden */
  66481. export var furPixelShader: {
  66482. name: string;
  66483. shader: string;
  66484. };
  66485. }
  66486. declare module BABYLON {
  66487. /** @hidden */
  66488. export var furVertexShader: {
  66489. name: string;
  66490. shader: string;
  66491. };
  66492. }
  66493. declare module BABYLON {
  66494. export class FurMaterial extends BABYLON.PushMaterial {
  66495. private _diffuseTexture;
  66496. diffuseTexture: BABYLON.BaseTexture;
  66497. private _heightTexture;
  66498. heightTexture: BABYLON.BaseTexture;
  66499. diffuseColor: BABYLON.Color3;
  66500. furLength: number;
  66501. furAngle: number;
  66502. furColor: BABYLON.Color3;
  66503. furOffset: number;
  66504. furSpacing: number;
  66505. furGravity: BABYLON.Vector3;
  66506. furSpeed: number;
  66507. furDensity: number;
  66508. furOcclusion: number;
  66509. furTexture: BABYLON.DynamicTexture;
  66510. private _disableLighting;
  66511. disableLighting: boolean;
  66512. private _maxSimultaneousLights;
  66513. maxSimultaneousLights: number;
  66514. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  66515. private _renderId;
  66516. private _furTime;
  66517. constructor(name: string, scene: BABYLON.Scene);
  66518. furTime: number;
  66519. needAlphaBlending(): boolean;
  66520. needAlphaTesting(): boolean;
  66521. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66522. updateFur(): void;
  66523. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66524. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66525. getAnimatables(): BABYLON.IAnimatable[];
  66526. getActiveTextures(): BABYLON.BaseTexture[];
  66527. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66528. dispose(forceDisposeEffect?: boolean): void;
  66529. clone(name: string): FurMaterial;
  66530. serialize(): any;
  66531. getClassName(): string;
  66532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  66533. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  66534. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  66535. }
  66536. }
  66537. declare module BABYLON {
  66538. /** @hidden */
  66539. export var gradientPixelShader: {
  66540. name: string;
  66541. shader: string;
  66542. };
  66543. }
  66544. declare module BABYLON {
  66545. /** @hidden */
  66546. export var gradientVertexShader: {
  66547. name: string;
  66548. shader: string;
  66549. };
  66550. }
  66551. declare module BABYLON {
  66552. export class GradientMaterial extends BABYLON.PushMaterial {
  66553. private _maxSimultaneousLights;
  66554. maxSimultaneousLights: number;
  66555. topColor: BABYLON.Color3;
  66556. topColorAlpha: number;
  66557. bottomColor: BABYLON.Color3;
  66558. bottomColorAlpha: number;
  66559. offset: number;
  66560. scale: number;
  66561. smoothness: number;
  66562. private _disableLighting;
  66563. disableLighting: boolean;
  66564. private _renderId;
  66565. constructor(name: string, scene: BABYLON.Scene);
  66566. needAlphaBlending(): boolean;
  66567. needAlphaTesting(): boolean;
  66568. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66569. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66570. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66571. getAnimatables(): BABYLON.IAnimatable[];
  66572. dispose(forceDisposeEffect?: boolean): void;
  66573. clone(name: string): GradientMaterial;
  66574. serialize(): any;
  66575. getClassName(): string;
  66576. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  66577. }
  66578. }
  66579. declare module BABYLON {
  66580. /** @hidden */
  66581. export var gridPixelShader: {
  66582. name: string;
  66583. shader: string;
  66584. };
  66585. }
  66586. declare module BABYLON {
  66587. /** @hidden */
  66588. export var gridVertexShader: {
  66589. name: string;
  66590. shader: string;
  66591. };
  66592. }
  66593. declare module BABYLON {
  66594. /**
  66595. * The grid materials allows you to wrap any shape with a grid.
  66596. * Colors are customizable.
  66597. */
  66598. export class GridMaterial extends BABYLON.PushMaterial {
  66599. /**
  66600. * Main color of the grid (e.g. between lines)
  66601. */
  66602. mainColor: BABYLON.Color3;
  66603. /**
  66604. * Color of the grid lines.
  66605. */
  66606. lineColor: BABYLON.Color3;
  66607. /**
  66608. * The scale of the grid compared to unit.
  66609. */
  66610. gridRatio: number;
  66611. /**
  66612. * Allows setting an offset for the grid lines.
  66613. */
  66614. gridOffset: BABYLON.Vector3;
  66615. /**
  66616. * The frequency of thicker lines.
  66617. */
  66618. majorUnitFrequency: number;
  66619. /**
  66620. * The visibility of minor units in the grid.
  66621. */
  66622. minorUnitVisibility: number;
  66623. /**
  66624. * The grid opacity outside of the lines.
  66625. */
  66626. opacity: number;
  66627. /**
  66628. * Determine RBG output is premultiplied by alpha value.
  66629. */
  66630. preMultiplyAlpha: boolean;
  66631. private _opacityTexture;
  66632. opacityTexture: BABYLON.BaseTexture;
  66633. private _gridControl;
  66634. private _renderId;
  66635. /**
  66636. * constructor
  66637. * @param name The name given to the material in order to identify it afterwards.
  66638. * @param scene The scene the material is used in.
  66639. */
  66640. constructor(name: string, scene: BABYLON.Scene);
  66641. /**
  66642. * Returns wehter or not the grid requires alpha blending.
  66643. */
  66644. needAlphaBlending(): boolean;
  66645. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66646. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66647. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66648. /**
  66649. * Dispose the material and its associated resources.
  66650. * @param forceDisposeEffect will also dispose the used effect when true
  66651. */
  66652. dispose(forceDisposeEffect?: boolean): void;
  66653. clone(name: string): GridMaterial;
  66654. serialize(): any;
  66655. getClassName(): string;
  66656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  66657. }
  66658. }
  66659. declare module BABYLON {
  66660. /** @hidden */
  66661. export var lavaPixelShader: {
  66662. name: string;
  66663. shader: string;
  66664. };
  66665. }
  66666. declare module BABYLON {
  66667. /** @hidden */
  66668. export var lavaVertexShader: {
  66669. name: string;
  66670. shader: string;
  66671. };
  66672. }
  66673. declare module BABYLON {
  66674. export class LavaMaterial extends BABYLON.PushMaterial {
  66675. private _diffuseTexture;
  66676. diffuseTexture: BABYLON.BaseTexture;
  66677. noiseTexture: BABYLON.BaseTexture;
  66678. fogColor: BABYLON.Color3;
  66679. speed: number;
  66680. movingSpeed: number;
  66681. lowFrequencySpeed: number;
  66682. fogDensity: number;
  66683. private _lastTime;
  66684. diffuseColor: BABYLON.Color3;
  66685. private _disableLighting;
  66686. disableLighting: boolean;
  66687. private _unlit;
  66688. unlit: boolean;
  66689. private _maxSimultaneousLights;
  66690. maxSimultaneousLights: number;
  66691. private _scaledDiffuse;
  66692. private _renderId;
  66693. constructor(name: string, scene: BABYLON.Scene);
  66694. needAlphaBlending(): boolean;
  66695. needAlphaTesting(): boolean;
  66696. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66697. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66698. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66699. getAnimatables(): BABYLON.IAnimatable[];
  66700. getActiveTextures(): BABYLON.BaseTexture[];
  66701. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66702. dispose(forceDisposeEffect?: boolean): void;
  66703. clone(name: string): LavaMaterial;
  66704. serialize(): any;
  66705. getClassName(): string;
  66706. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  66707. }
  66708. }
  66709. declare module BABYLON {
  66710. /** @hidden */
  66711. export var mixPixelShader: {
  66712. name: string;
  66713. shader: string;
  66714. };
  66715. }
  66716. declare module BABYLON {
  66717. /** @hidden */
  66718. export var mixVertexShader: {
  66719. name: string;
  66720. shader: string;
  66721. };
  66722. }
  66723. declare module BABYLON {
  66724. export class MixMaterial extends BABYLON.PushMaterial {
  66725. /**
  66726. * Mix textures
  66727. */
  66728. private _mixTexture1;
  66729. mixTexture1: BABYLON.BaseTexture;
  66730. private _mixTexture2;
  66731. mixTexture2: BABYLON.BaseTexture;
  66732. /**
  66733. * Diffuse textures
  66734. */
  66735. private _diffuseTexture1;
  66736. diffuseTexture1: BABYLON.Texture;
  66737. private _diffuseTexture2;
  66738. diffuseTexture2: BABYLON.Texture;
  66739. private _diffuseTexture3;
  66740. diffuseTexture3: BABYLON.Texture;
  66741. private _diffuseTexture4;
  66742. diffuseTexture4: BABYLON.Texture;
  66743. private _diffuseTexture5;
  66744. diffuseTexture5: BABYLON.Texture;
  66745. private _diffuseTexture6;
  66746. diffuseTexture6: BABYLON.Texture;
  66747. private _diffuseTexture7;
  66748. diffuseTexture7: BABYLON.Texture;
  66749. private _diffuseTexture8;
  66750. diffuseTexture8: BABYLON.Texture;
  66751. /**
  66752. * Uniforms
  66753. */
  66754. diffuseColor: BABYLON.Color3;
  66755. specularColor: BABYLON.Color3;
  66756. specularPower: number;
  66757. private _disableLighting;
  66758. disableLighting: boolean;
  66759. private _maxSimultaneousLights;
  66760. maxSimultaneousLights: number;
  66761. private _renderId;
  66762. constructor(name: string, scene: BABYLON.Scene);
  66763. needAlphaBlending(): boolean;
  66764. needAlphaTesting(): boolean;
  66765. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66766. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66767. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66768. getAnimatables(): BABYLON.IAnimatable[];
  66769. getActiveTextures(): BABYLON.BaseTexture[];
  66770. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66771. dispose(forceDisposeEffect?: boolean): void;
  66772. clone(name: string): MixMaterial;
  66773. serialize(): any;
  66774. getClassName(): string;
  66775. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  66776. }
  66777. }
  66778. declare module BABYLON {
  66779. /** @hidden */
  66780. export var normalPixelShader: {
  66781. name: string;
  66782. shader: string;
  66783. };
  66784. }
  66785. declare module BABYLON {
  66786. /** @hidden */
  66787. export var normalVertexShader: {
  66788. name: string;
  66789. shader: string;
  66790. };
  66791. }
  66792. declare module BABYLON {
  66793. export class NormalMaterial extends BABYLON.PushMaterial {
  66794. private _diffuseTexture;
  66795. diffuseTexture: BABYLON.BaseTexture;
  66796. diffuseColor: BABYLON.Color3;
  66797. private _disableLighting;
  66798. disableLighting: boolean;
  66799. private _maxSimultaneousLights;
  66800. maxSimultaneousLights: number;
  66801. private _renderId;
  66802. constructor(name: string, scene: BABYLON.Scene);
  66803. needAlphaBlending(): boolean;
  66804. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66805. needAlphaTesting(): boolean;
  66806. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66807. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66808. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66809. getAnimatables(): BABYLON.IAnimatable[];
  66810. getActiveTextures(): BABYLON.BaseTexture[];
  66811. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66812. dispose(forceDisposeEffect?: boolean): void;
  66813. clone(name: string): NormalMaterial;
  66814. serialize(): any;
  66815. getClassName(): string;
  66816. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  66817. }
  66818. }
  66819. declare module BABYLON {
  66820. /** @hidden */
  66821. export var shadowOnlyPixelShader: {
  66822. name: string;
  66823. shader: string;
  66824. };
  66825. }
  66826. declare module BABYLON {
  66827. /** @hidden */
  66828. export var shadowOnlyVertexShader: {
  66829. name: string;
  66830. shader: string;
  66831. };
  66832. }
  66833. declare module BABYLON {
  66834. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  66835. private _renderId;
  66836. private _activeLight;
  66837. constructor(name: string, scene: BABYLON.Scene);
  66838. shadowColor: BABYLON.Color3;
  66839. needAlphaBlending(): boolean;
  66840. needAlphaTesting(): boolean;
  66841. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66842. activeLight: BABYLON.IShadowLight;
  66843. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66844. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66845. clone(name: string): ShadowOnlyMaterial;
  66846. serialize(): any;
  66847. getClassName(): string;
  66848. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  66849. }
  66850. }
  66851. declare module BABYLON {
  66852. /** @hidden */
  66853. export var simplePixelShader: {
  66854. name: string;
  66855. shader: string;
  66856. };
  66857. }
  66858. declare module BABYLON {
  66859. /** @hidden */
  66860. export var simpleVertexShader: {
  66861. name: string;
  66862. shader: string;
  66863. };
  66864. }
  66865. declare module BABYLON {
  66866. export class SimpleMaterial extends BABYLON.PushMaterial {
  66867. private _diffuseTexture;
  66868. diffuseTexture: BABYLON.BaseTexture;
  66869. diffuseColor: BABYLON.Color3;
  66870. private _disableLighting;
  66871. disableLighting: boolean;
  66872. private _maxSimultaneousLights;
  66873. maxSimultaneousLights: number;
  66874. private _renderId;
  66875. constructor(name: string, scene: BABYLON.Scene);
  66876. needAlphaBlending(): boolean;
  66877. needAlphaTesting(): boolean;
  66878. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66879. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66880. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66881. getAnimatables(): BABYLON.IAnimatable[];
  66882. getActiveTextures(): BABYLON.BaseTexture[];
  66883. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66884. dispose(forceDisposeEffect?: boolean): void;
  66885. clone(name: string): SimpleMaterial;
  66886. serialize(): any;
  66887. getClassName(): string;
  66888. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  66889. }
  66890. }
  66891. declare module BABYLON {
  66892. /** @hidden */
  66893. export var skyPixelShader: {
  66894. name: string;
  66895. shader: string;
  66896. };
  66897. }
  66898. declare module BABYLON {
  66899. /** @hidden */
  66900. export var skyVertexShader: {
  66901. name: string;
  66902. shader: string;
  66903. };
  66904. }
  66905. declare module BABYLON {
  66906. /**
  66907. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  66908. * @see https://doc.babylonjs.com/extensions/sky
  66909. */
  66910. export class SkyMaterial extends BABYLON.PushMaterial {
  66911. /**
  66912. * Defines the overall luminance of sky in interval ]0, 1[.
  66913. */
  66914. luminance: number;
  66915. /**
  66916. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  66917. */
  66918. turbidity: number;
  66919. /**
  66920. * Defines the sky appearance (light intensity).
  66921. */
  66922. rayleigh: number;
  66923. /**
  66924. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  66925. */
  66926. mieCoefficient: number;
  66927. /**
  66928. * Defines the amount of haze particles following the Mie scattering theory.
  66929. */
  66930. mieDirectionalG: number;
  66931. /**
  66932. * Defines the distance of the sun according to the active scene camera.
  66933. */
  66934. distance: number;
  66935. /**
  66936. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  66937. * "inclined".
  66938. */
  66939. inclination: number;
  66940. /**
  66941. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  66942. * an object direction and a reference direction.
  66943. */
  66944. azimuth: number;
  66945. /**
  66946. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  66947. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  66948. */
  66949. sunPosition: BABYLON.Vector3;
  66950. /**
  66951. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  66952. * .sunPosition property.
  66953. */
  66954. useSunPosition: boolean;
  66955. /**
  66956. * Defines an offset vector used to get a horizon offset.
  66957. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  66958. */
  66959. cameraOffset: BABYLON.Vector3;
  66960. private _cameraPosition;
  66961. private _renderId;
  66962. /**
  66963. * Instantiates a new sky material.
  66964. * This material allows to create dynamic and texture free
  66965. * effects for skyboxes by taking care of the atmosphere state.
  66966. * @see https://doc.babylonjs.com/extensions/sky
  66967. * @param name Define the name of the material in the scene
  66968. * @param scene Define the scene the material belong to
  66969. */
  66970. constructor(name: string, scene: BABYLON.Scene);
  66971. /**
  66972. * Specifies if the material will require alpha blending
  66973. * @returns a boolean specifying if alpha blending is needed
  66974. */
  66975. needAlphaBlending(): boolean;
  66976. /**
  66977. * Specifies if this material should be rendered in alpha test mode
  66978. * @returns false as the sky material doesn't need alpha testing.
  66979. */
  66980. needAlphaTesting(): boolean;
  66981. /**
  66982. * Get the texture used for alpha test purpose.
  66983. * @returns null as the sky material has no texture.
  66984. */
  66985. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66986. /**
  66987. * Get if the submesh is ready to be used and all its information available.
  66988. * Child classes can use it to update shaders
  66989. * @param mesh defines the mesh to check
  66990. * @param subMesh defines which submesh to check
  66991. * @param useInstances specifies that instances should be used
  66992. * @returns a boolean indicating that the submesh is ready or not
  66993. */
  66994. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66995. /**
  66996. * Binds the submesh to this material by preparing the effect and shader to draw
  66997. * @param world defines the world transformation matrix
  66998. * @param mesh defines the mesh containing the submesh
  66999. * @param subMesh defines the submesh to bind the material to
  67000. */
  67001. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67002. /**
  67003. * Get the list of animatables in the material.
  67004. * @returns the list of animatables object used in the material
  67005. */
  67006. getAnimatables(): BABYLON.IAnimatable[];
  67007. /**
  67008. * Disposes the material
  67009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67010. */
  67011. dispose(forceDisposeEffect?: boolean): void;
  67012. /**
  67013. * Makes a duplicate of the material, and gives it a new name
  67014. * @param name defines the new name for the duplicated material
  67015. * @returns the cloned material
  67016. */
  67017. clone(name: string): SkyMaterial;
  67018. /**
  67019. * Serializes this material in a JSON representation
  67020. * @returns the serialized material object
  67021. */
  67022. serialize(): any;
  67023. /**
  67024. * Gets the current class name of the material e.g. "SkyMaterial"
  67025. * Mainly use in serialization.
  67026. * @returns the class name
  67027. */
  67028. getClassName(): string;
  67029. /**
  67030. * Creates a sky material from parsed material data
  67031. * @param source defines the JSON representation of the material
  67032. * @param scene defines the hosting scene
  67033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67034. * @returns a new sky material
  67035. */
  67036. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67037. }
  67038. }
  67039. declare module BABYLON {
  67040. /** @hidden */
  67041. export var terrainPixelShader: {
  67042. name: string;
  67043. shader: string;
  67044. };
  67045. }
  67046. declare module BABYLON {
  67047. /** @hidden */
  67048. export var terrainVertexShader: {
  67049. name: string;
  67050. shader: string;
  67051. };
  67052. }
  67053. declare module BABYLON {
  67054. export class TerrainMaterial extends BABYLON.PushMaterial {
  67055. private _mixTexture;
  67056. mixTexture: BABYLON.BaseTexture;
  67057. private _diffuseTexture1;
  67058. diffuseTexture1: BABYLON.Texture;
  67059. private _diffuseTexture2;
  67060. diffuseTexture2: BABYLON.Texture;
  67061. private _diffuseTexture3;
  67062. diffuseTexture3: BABYLON.Texture;
  67063. private _bumpTexture1;
  67064. bumpTexture1: BABYLON.Texture;
  67065. private _bumpTexture2;
  67066. bumpTexture2: BABYLON.Texture;
  67067. private _bumpTexture3;
  67068. bumpTexture3: BABYLON.Texture;
  67069. diffuseColor: BABYLON.Color3;
  67070. specularColor: BABYLON.Color3;
  67071. specularPower: number;
  67072. private _disableLighting;
  67073. disableLighting: boolean;
  67074. private _maxSimultaneousLights;
  67075. maxSimultaneousLights: number;
  67076. private _renderId;
  67077. constructor(name: string, scene: BABYLON.Scene);
  67078. needAlphaBlending(): boolean;
  67079. needAlphaTesting(): boolean;
  67080. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67081. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67082. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67083. getAnimatables(): BABYLON.IAnimatable[];
  67084. getActiveTextures(): BABYLON.BaseTexture[];
  67085. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67086. dispose(forceDisposeEffect?: boolean): void;
  67087. clone(name: string): TerrainMaterial;
  67088. serialize(): any;
  67089. getClassName(): string;
  67090. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67091. }
  67092. }
  67093. declare module BABYLON {
  67094. /** @hidden */
  67095. export var triplanarPixelShader: {
  67096. name: string;
  67097. shader: string;
  67098. };
  67099. }
  67100. declare module BABYLON {
  67101. /** @hidden */
  67102. export var triplanarVertexShader: {
  67103. name: string;
  67104. shader: string;
  67105. };
  67106. }
  67107. declare module BABYLON {
  67108. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67109. mixTexture: BABYLON.BaseTexture;
  67110. private _diffuseTextureX;
  67111. diffuseTextureX: BABYLON.BaseTexture;
  67112. private _diffuseTextureY;
  67113. diffuseTextureY: BABYLON.BaseTexture;
  67114. private _diffuseTextureZ;
  67115. diffuseTextureZ: BABYLON.BaseTexture;
  67116. private _normalTextureX;
  67117. normalTextureX: BABYLON.BaseTexture;
  67118. private _normalTextureY;
  67119. normalTextureY: BABYLON.BaseTexture;
  67120. private _normalTextureZ;
  67121. normalTextureZ: BABYLON.BaseTexture;
  67122. tileSize: number;
  67123. diffuseColor: BABYLON.Color3;
  67124. specularColor: BABYLON.Color3;
  67125. specularPower: number;
  67126. private _disableLighting;
  67127. disableLighting: boolean;
  67128. private _maxSimultaneousLights;
  67129. maxSimultaneousLights: number;
  67130. private _renderId;
  67131. constructor(name: string, scene: BABYLON.Scene);
  67132. needAlphaBlending(): boolean;
  67133. needAlphaTesting(): boolean;
  67134. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67135. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67136. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67137. getAnimatables(): BABYLON.IAnimatable[];
  67138. getActiveTextures(): BABYLON.BaseTexture[];
  67139. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67140. dispose(forceDisposeEffect?: boolean): void;
  67141. clone(name: string): TriPlanarMaterial;
  67142. serialize(): any;
  67143. getClassName(): string;
  67144. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67145. }
  67146. }
  67147. declare module BABYLON {
  67148. /** @hidden */
  67149. export var waterPixelShader: {
  67150. name: string;
  67151. shader: string;
  67152. };
  67153. }
  67154. declare module BABYLON {
  67155. /** @hidden */
  67156. export var waterVertexShader: {
  67157. name: string;
  67158. shader: string;
  67159. };
  67160. }
  67161. declare module BABYLON {
  67162. export class WaterMaterial extends BABYLON.PushMaterial {
  67163. renderTargetSize: BABYLON.Vector2;
  67164. private _bumpTexture;
  67165. bumpTexture: BABYLON.BaseTexture;
  67166. diffuseColor: BABYLON.Color3;
  67167. specularColor: BABYLON.Color3;
  67168. specularPower: number;
  67169. private _disableLighting;
  67170. disableLighting: boolean;
  67171. private _maxSimultaneousLights;
  67172. maxSimultaneousLights: number;
  67173. /**
  67174. * @param {number}: Represents the wind force
  67175. */
  67176. windForce: number;
  67177. /**
  67178. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67179. */
  67180. windDirection: BABYLON.Vector2;
  67181. /**
  67182. * @param {number}: Wave height, represents the height of the waves
  67183. */
  67184. waveHeight: number;
  67185. /**
  67186. * @param {number}: Bump height, represents the bump height related to the bump map
  67187. */
  67188. bumpHeight: number;
  67189. /**
  67190. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67191. */
  67192. private _bumpSuperimpose;
  67193. bumpSuperimpose: boolean;
  67194. /**
  67195. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  67196. */
  67197. private _fresnelSeparate;
  67198. fresnelSeparate: boolean;
  67199. /**
  67200. * @param {boolean}: bump Waves modify the reflection.
  67201. */
  67202. private _bumpAffectsReflection;
  67203. bumpAffectsReflection: boolean;
  67204. /**
  67205. * @param {number}: The water color blended with the refraction (near)
  67206. */
  67207. waterColor: BABYLON.Color3;
  67208. /**
  67209. * @param {number}: The blend factor related to the water color
  67210. */
  67211. colorBlendFactor: number;
  67212. /**
  67213. * @param {number}: The water color blended with the reflection (far)
  67214. */
  67215. waterColor2: BABYLON.Color3;
  67216. /**
  67217. * @param {number}: The blend factor related to the water color (reflection, far)
  67218. */
  67219. colorBlendFactor2: number;
  67220. /**
  67221. * @param {number}: Represents the maximum length of a wave
  67222. */
  67223. waveLength: number;
  67224. /**
  67225. * @param {number}: Defines the waves speed
  67226. */
  67227. waveSpeed: number;
  67228. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  67229. private _mesh;
  67230. private _refractionRTT;
  67231. private _reflectionRTT;
  67232. private _reflectionTransform;
  67233. private _lastTime;
  67234. private _lastDeltaTime;
  67235. private _renderId;
  67236. private _useLogarithmicDepth;
  67237. private _waitingRenderList;
  67238. /**
  67239. * Gets a boolean indicating that current material needs to register RTT
  67240. */
  67241. readonly hasRenderTargetTextures: boolean;
  67242. /**
  67243. * Constructor
  67244. */
  67245. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  67246. useLogarithmicDepth: boolean;
  67247. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67248. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67249. addToRenderList(node: any): void;
  67250. enableRenderTargets(enable: boolean): void;
  67251. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  67252. readonly renderTargetsEnabled: boolean;
  67253. needAlphaBlending(): boolean;
  67254. needAlphaTesting(): boolean;
  67255. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67256. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67257. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67258. private _createRenderTargets;
  67259. getAnimatables(): BABYLON.IAnimatable[];
  67260. getActiveTextures(): BABYLON.BaseTexture[];
  67261. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67262. dispose(forceDisposeEffect?: boolean): void;
  67263. clone(name: string): WaterMaterial;
  67264. serialize(): any;
  67265. getClassName(): string;
  67266. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  67267. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  67268. }
  67269. }
  67270. declare module BABYLON {
  67271. /** @hidden */
  67272. export var asciiartPixelShader: {
  67273. name: string;
  67274. shader: string;
  67275. };
  67276. }
  67277. declare module BABYLON {
  67278. /**
  67279. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  67280. *
  67281. * It basically takes care rendering the font front the given font size to a texture.
  67282. * This is used later on in the postprocess.
  67283. */
  67284. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  67285. private _font;
  67286. private _text;
  67287. private _charSize;
  67288. /**
  67289. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67290. */
  67291. readonly charSize: number;
  67292. /**
  67293. * Create a new instance of the Ascii Art FontTexture class
  67294. * @param name the name of the texture
  67295. * @param font the font to use, use the W3C CSS notation
  67296. * @param text the caracter set to use in the rendering.
  67297. * @param scene the scene that owns the texture
  67298. */
  67299. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67300. /**
  67301. * Gets the max char width of a font.
  67302. * @param font the font to use, use the W3C CSS notation
  67303. * @return the max char width
  67304. */
  67305. private getFontWidth;
  67306. /**
  67307. * Gets the max char height of a font.
  67308. * @param font the font to use, use the W3C CSS notation
  67309. * @return the max char height
  67310. */
  67311. private getFontHeight;
  67312. /**
  67313. * Clones the current AsciiArtTexture.
  67314. * @return the clone of the texture.
  67315. */
  67316. clone(): AsciiArtFontTexture;
  67317. /**
  67318. * Parses a json object representing the texture and returns an instance of it.
  67319. * @param source the source JSON representation
  67320. * @param scene the scene to create the texture for
  67321. * @return the parsed texture
  67322. */
  67323. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  67324. }
  67325. /**
  67326. * Option available in the Ascii Art Post Process.
  67327. */
  67328. export interface IAsciiArtPostProcessOptions {
  67329. /**
  67330. * The font to use following the w3c font definition.
  67331. */
  67332. font?: string;
  67333. /**
  67334. * The character set to use in the postprocess.
  67335. */
  67336. characterSet?: string;
  67337. /**
  67338. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67339. * This number is defined between 0 and 1;
  67340. */
  67341. mixToTile?: number;
  67342. /**
  67343. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67344. * This number is defined between 0 and 1;
  67345. */
  67346. mixToNormal?: number;
  67347. }
  67348. /**
  67349. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  67350. *
  67351. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67352. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  67353. */
  67354. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  67355. /**
  67356. * The font texture used to render the char in the post process.
  67357. */
  67358. private _asciiArtFontTexture;
  67359. /**
  67360. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67361. * This number is defined between 0 and 1;
  67362. */
  67363. mixToTile: number;
  67364. /**
  67365. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67366. * This number is defined between 0 and 1;
  67367. */
  67368. mixToNormal: number;
  67369. /**
  67370. * Instantiates a new Ascii Art Post Process.
  67371. * @param name the name to give to the postprocess
  67372. * @camera the camera to apply the post process to.
  67373. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  67374. */
  67375. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  67376. }
  67377. }
  67378. declare module BABYLON {
  67379. /** @hidden */
  67380. export var digitalrainPixelShader: {
  67381. name: string;
  67382. shader: string;
  67383. };
  67384. }
  67385. declare module BABYLON {
  67386. /**
  67387. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  67388. *
  67389. * It basically takes care rendering the font front the given font size to a texture.
  67390. * This is used later on in the postprocess.
  67391. */
  67392. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  67393. private _font;
  67394. private _text;
  67395. private _charSize;
  67396. /**
  67397. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67398. */
  67399. readonly charSize: number;
  67400. /**
  67401. * Create a new instance of the Digital Rain FontTexture class
  67402. * @param name the name of the texture
  67403. * @param font the font to use, use the W3C CSS notation
  67404. * @param text the caracter set to use in the rendering.
  67405. * @param scene the scene that owns the texture
  67406. */
  67407. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67408. /**
  67409. * Gets the max char width of a font.
  67410. * @param font the font to use, use the W3C CSS notation
  67411. * @return the max char width
  67412. */
  67413. private getFontWidth;
  67414. /**
  67415. * Gets the max char height of a font.
  67416. * @param font the font to use, use the W3C CSS notation
  67417. * @return the max char height
  67418. */
  67419. private getFontHeight;
  67420. /**
  67421. * Clones the current DigitalRainFontTexture.
  67422. * @return the clone of the texture.
  67423. */
  67424. clone(): DigitalRainFontTexture;
  67425. /**
  67426. * Parses a json object representing the texture and returns an instance of it.
  67427. * @param source the source JSON representation
  67428. * @param scene the scene to create the texture for
  67429. * @return the parsed texture
  67430. */
  67431. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  67432. }
  67433. /**
  67434. * Option available in the Digital Rain Post Process.
  67435. */
  67436. export interface IDigitalRainPostProcessOptions {
  67437. /**
  67438. * The font to use following the w3c font definition.
  67439. */
  67440. font?: string;
  67441. /**
  67442. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67443. * This number is defined between 0 and 1;
  67444. */
  67445. mixToTile?: number;
  67446. /**
  67447. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67448. * This number is defined between 0 and 1;
  67449. */
  67450. mixToNormal?: number;
  67451. }
  67452. /**
  67453. * DigitalRainPostProcess helps rendering everithing in digital rain.
  67454. *
  67455. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67456. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  67457. */
  67458. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  67459. /**
  67460. * The font texture used to render the char in the post process.
  67461. */
  67462. private _digitalRainFontTexture;
  67463. /**
  67464. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67465. * This number is defined between 0 and 1;
  67466. */
  67467. mixToTile: number;
  67468. /**
  67469. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67470. * This number is defined between 0 and 1;
  67471. */
  67472. mixToNormal: number;
  67473. /**
  67474. * Instantiates a new Digital Rain Post Process.
  67475. * @param name the name to give to the postprocess
  67476. * @camera the camera to apply the post process to.
  67477. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  67478. */
  67479. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  67480. }
  67481. }
  67482. declare module BABYLON {
  67483. /** @hidden */
  67484. export var oceanPostProcessPixelShader: {
  67485. name: string;
  67486. shader: string;
  67487. };
  67488. }
  67489. declare module BABYLON {
  67490. /**
  67491. * Option available in the Ocean Post Process.
  67492. */
  67493. export interface IOceanPostProcessOptions {
  67494. /**
  67495. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67496. */
  67497. reflectionSize?: number | {
  67498. width: number;
  67499. height: number;
  67500. } | {
  67501. ratio: number;
  67502. };
  67503. /**
  67504. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67505. */
  67506. refractionSize?: number | {
  67507. width: number;
  67508. height: number;
  67509. } | {
  67510. ratio: number;
  67511. };
  67512. }
  67513. /**
  67514. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  67515. *
  67516. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67517. * Example usage:
  67518. * var pp = new OceanPostProcess("myOcean", camera);
  67519. * pp.reflectionEnabled = true;
  67520. * pp.refractionEnabled = true;
  67521. */
  67522. export class OceanPostProcess extends BABYLON.PostProcess {
  67523. /**
  67524. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  67525. */
  67526. /**
  67527. * Sets weither or not the real-time reflection is enabled on the ocean.
  67528. * Is set to true, the reflection mirror texture will be used as reflection texture.
  67529. */
  67530. reflectionEnabled: boolean;
  67531. /**
  67532. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  67533. */
  67534. /**
  67535. * Sets weither or not the real-time refraction is enabled on the ocean.
  67536. * Is set to true, the refraction render target texture will be used as refraction texture.
  67537. */
  67538. refractionEnabled: boolean;
  67539. /**
  67540. * Gets wether or not the post-processes is supported by the running hardware.
  67541. * This requires draw buffer supports.
  67542. */
  67543. readonly isSupported: boolean;
  67544. /**
  67545. * This is the reflection mirror texture used to display reflections on the ocean.
  67546. * By default, render list is empty.
  67547. */
  67548. reflectionTexture: BABYLON.MirrorTexture;
  67549. /**
  67550. * This is the refraction render target texture used to display refraction on the ocean.
  67551. * By default, render list is empty.
  67552. */
  67553. refractionTexture: BABYLON.RenderTargetTexture;
  67554. private _time;
  67555. private _cameraRotation;
  67556. private _cameraViewMatrix;
  67557. private _reflectionEnabled;
  67558. private _refractionEnabled;
  67559. private _geometryRenderer;
  67560. /**
  67561. * Instantiates a new Ocean Post Process.
  67562. * @param name the name to give to the postprocess.
  67563. * @camera the camera to apply the post process to.
  67564. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  67565. */
  67566. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  67567. /**
  67568. * Returns the appropriate defines according to the current configuration.
  67569. */
  67570. private _getDefines;
  67571. /**
  67572. * Computes the current camera rotation as the shader requires a camera rotation.
  67573. */
  67574. private _computeCameraRotation;
  67575. }
  67576. }
  67577. declare module BABYLON {
  67578. /** @hidden */
  67579. export var brickProceduralTexturePixelShader: {
  67580. name: string;
  67581. shader: string;
  67582. };
  67583. }
  67584. declare module BABYLON {
  67585. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  67586. private _numberOfBricksHeight;
  67587. private _numberOfBricksWidth;
  67588. private _jointColor;
  67589. private _brickColor;
  67590. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67591. updateShaderUniforms(): void;
  67592. numberOfBricksHeight: number;
  67593. numberOfBricksWidth: number;
  67594. jointColor: BABYLON.Color3;
  67595. brickColor: BABYLON.Color3;
  67596. /**
  67597. * Serializes this brick procedural texture
  67598. * @returns a serialized brick procedural texture object
  67599. */
  67600. serialize(): any;
  67601. /**
  67602. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  67603. * @param parsedTexture defines parsed texture data
  67604. * @param scene defines the current scene
  67605. * @param rootUrl defines the root URL containing brick procedural texture information
  67606. * @returns a parsed Brick Procedural BABYLON.Texture
  67607. */
  67608. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  67609. }
  67610. }
  67611. declare module BABYLON {
  67612. /** @hidden */
  67613. export var cloudProceduralTexturePixelShader: {
  67614. name: string;
  67615. shader: string;
  67616. };
  67617. }
  67618. declare module BABYLON {
  67619. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  67620. private _skyColor;
  67621. private _cloudColor;
  67622. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67623. updateShaderUniforms(): void;
  67624. skyColor: BABYLON.Color4;
  67625. cloudColor: BABYLON.Color4;
  67626. /**
  67627. * Serializes this cloud procedural texture
  67628. * @returns a serialized cloud procedural texture object
  67629. */
  67630. serialize(): any;
  67631. /**
  67632. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  67633. * @param parsedTexture defines parsed texture data
  67634. * @param scene defines the current scene
  67635. * @param rootUrl defines the root URL containing cloud procedural texture information
  67636. * @returns a parsed Cloud Procedural BABYLON.Texture
  67637. */
  67638. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  67639. }
  67640. }
  67641. declare module BABYLON {
  67642. /** @hidden */
  67643. export var fireProceduralTexturePixelShader: {
  67644. name: string;
  67645. shader: string;
  67646. };
  67647. }
  67648. declare module BABYLON {
  67649. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  67650. private _time;
  67651. private _speed;
  67652. private _autoGenerateTime;
  67653. private _fireColors;
  67654. private _alphaThreshold;
  67655. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67656. updateShaderUniforms(): void;
  67657. render(useCameraPostProcess?: boolean): void;
  67658. static readonly PurpleFireColors: BABYLON.Color3[];
  67659. static readonly GreenFireColors: BABYLON.Color3[];
  67660. static readonly RedFireColors: BABYLON.Color3[];
  67661. static readonly BlueFireColors: BABYLON.Color3[];
  67662. autoGenerateTime: boolean;
  67663. fireColors: BABYLON.Color3[];
  67664. time: number;
  67665. speed: BABYLON.Vector2;
  67666. alphaThreshold: number;
  67667. /**
  67668. * Serializes this fire procedural texture
  67669. * @returns a serialized fire procedural texture object
  67670. */
  67671. serialize(): any;
  67672. /**
  67673. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  67674. * @param parsedTexture defines parsed texture data
  67675. * @param scene defines the current scene
  67676. * @param rootUrl defines the root URL containing fire procedural texture information
  67677. * @returns a parsed Fire Procedural BABYLON.Texture
  67678. */
  67679. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  67680. }
  67681. }
  67682. declare module BABYLON {
  67683. /** @hidden */
  67684. export var grassProceduralTexturePixelShader: {
  67685. name: string;
  67686. shader: string;
  67687. };
  67688. }
  67689. declare module BABYLON {
  67690. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  67691. private _grassColors;
  67692. private _groundColor;
  67693. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67694. updateShaderUniforms(): void;
  67695. grassColors: BABYLON.Color3[];
  67696. groundColor: BABYLON.Color3;
  67697. /**
  67698. * Serializes this grass procedural texture
  67699. * @returns a serialized grass procedural texture object
  67700. */
  67701. serialize(): any;
  67702. /**
  67703. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  67704. * @param parsedTexture defines parsed texture data
  67705. * @param scene defines the current scene
  67706. * @param rootUrl defines the root URL containing grass procedural texture information
  67707. * @returns a parsed Grass Procedural BABYLON.Texture
  67708. */
  67709. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  67710. }
  67711. }
  67712. declare module BABYLON {
  67713. /** @hidden */
  67714. export var marbleProceduralTexturePixelShader: {
  67715. name: string;
  67716. shader: string;
  67717. };
  67718. }
  67719. declare module BABYLON {
  67720. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  67721. private _numberOfTilesHeight;
  67722. private _numberOfTilesWidth;
  67723. private _amplitude;
  67724. private _jointColor;
  67725. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67726. updateShaderUniforms(): void;
  67727. numberOfTilesHeight: number;
  67728. amplitude: number;
  67729. numberOfTilesWidth: number;
  67730. jointColor: BABYLON.Color3;
  67731. /**
  67732. * Serializes this marble procedural texture
  67733. * @returns a serialized marble procedural texture object
  67734. */
  67735. serialize(): any;
  67736. /**
  67737. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  67738. * @param parsedTexture defines parsed texture data
  67739. * @param scene defines the current scene
  67740. * @param rootUrl defines the root URL containing marble procedural texture information
  67741. * @returns a parsed Marble Procedural BABYLON.Texture
  67742. */
  67743. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  67744. }
  67745. }
  67746. declare module BABYLON {
  67747. /** @hidden */
  67748. export var normalMapProceduralTexturePixelShader: {
  67749. name: string;
  67750. shader: string;
  67751. };
  67752. }
  67753. declare module BABYLON {
  67754. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  67755. private _baseTexture;
  67756. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67757. updateShaderUniforms(): void;
  67758. render(useCameraPostProcess?: boolean): void;
  67759. resize(size: any, generateMipMaps: any): void;
  67760. baseTexture: BABYLON.Texture;
  67761. /**
  67762. * Serializes this normal map procedural texture
  67763. * @returns a serialized normal map procedural texture object
  67764. */
  67765. serialize(): any;
  67766. /**
  67767. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  67768. * @param parsedTexture defines parsed texture data
  67769. * @param scene defines the current scene
  67770. * @param rootUrl defines the root URL containing normal map procedural texture information
  67771. * @returns a parsed Normal Map Procedural BABYLON.Texture
  67772. */
  67773. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  67774. }
  67775. }
  67776. declare module BABYLON {
  67777. /** @hidden */
  67778. export var perlinNoiseProceduralTexturePixelShader: {
  67779. name: string;
  67780. shader: string;
  67781. };
  67782. }
  67783. declare module BABYLON {
  67784. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  67785. time: number;
  67786. timeScale: number;
  67787. translationSpeed: number;
  67788. private _currentTranslation;
  67789. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67790. updateShaderUniforms(): void;
  67791. render(useCameraPostProcess?: boolean): void;
  67792. resize(size: any, generateMipMaps: any): void;
  67793. /**
  67794. * Serializes this perlin noise procedural texture
  67795. * @returns a serialized perlin noise procedural texture object
  67796. */
  67797. serialize(): any;
  67798. /**
  67799. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  67800. * @param parsedTexture defines parsed texture data
  67801. * @param scene defines the current scene
  67802. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  67803. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  67804. */
  67805. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  67806. }
  67807. }
  67808. declare module BABYLON {
  67809. /** @hidden */
  67810. export var roadProceduralTexturePixelShader: {
  67811. name: string;
  67812. shader: string;
  67813. };
  67814. }
  67815. declare module BABYLON {
  67816. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  67817. private _roadColor;
  67818. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67819. updateShaderUniforms(): void;
  67820. roadColor: BABYLON.Color3;
  67821. /**
  67822. * Serializes this road procedural texture
  67823. * @returns a serialized road procedural texture object
  67824. */
  67825. serialize(): any;
  67826. /**
  67827. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  67828. * @param parsedTexture defines parsed texture data
  67829. * @param scene defines the current scene
  67830. * @param rootUrl defines the root URL containing road procedural texture information
  67831. * @returns a parsed Road Procedural BABYLON.Texture
  67832. */
  67833. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  67834. }
  67835. }
  67836. declare module BABYLON {
  67837. /** @hidden */
  67838. export var starfieldProceduralTexturePixelShader: {
  67839. name: string;
  67840. shader: string;
  67841. };
  67842. }
  67843. declare module BABYLON {
  67844. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  67845. private _time;
  67846. private _alpha;
  67847. private _beta;
  67848. private _zoom;
  67849. private _formuparam;
  67850. private _stepsize;
  67851. private _tile;
  67852. private _brightness;
  67853. private _darkmatter;
  67854. private _distfading;
  67855. private _saturation;
  67856. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67857. updateShaderUniforms(): void;
  67858. time: number;
  67859. alpha: number;
  67860. beta: number;
  67861. formuparam: number;
  67862. stepsize: number;
  67863. zoom: number;
  67864. tile: number;
  67865. brightness: number;
  67866. darkmatter: number;
  67867. distfading: number;
  67868. saturation: number;
  67869. /**
  67870. * Serializes this starfield procedural texture
  67871. * @returns a serialized starfield procedural texture object
  67872. */
  67873. serialize(): any;
  67874. /**
  67875. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  67876. * @param parsedTexture defines parsed texture data
  67877. * @param scene defines the current scene
  67878. * @param rootUrl defines the root URL containing startfield procedural texture information
  67879. * @returns a parsed Starfield Procedural BABYLON.Texture
  67880. */
  67881. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  67882. }
  67883. }
  67884. declare module BABYLON {
  67885. /** @hidden */
  67886. export var woodProceduralTexturePixelShader: {
  67887. name: string;
  67888. shader: string;
  67889. };
  67890. }
  67891. declare module BABYLON {
  67892. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  67893. private _ampScale;
  67894. private _woodColor;
  67895. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67896. updateShaderUniforms(): void;
  67897. ampScale: number;
  67898. woodColor: BABYLON.Color3;
  67899. /**
  67900. * Serializes this wood procedural texture
  67901. * @returns a serialized wood procedural texture object
  67902. */
  67903. serialize(): any;
  67904. /**
  67905. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  67906. * @param parsedTexture defines parsed texture data
  67907. * @param scene defines the current scene
  67908. * @param rootUrl defines the root URL containing wood procedural texture information
  67909. * @returns a parsed Wood Procedural BABYLON.Texture
  67910. */
  67911. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  67912. }
  67913. }