babylon.d.txt 2.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342
  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 the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * 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"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * 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)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * 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
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Adds the translation vector (using 3 floats) in the current matrix
  2941. * @param x defines the 1st component of the translation
  2942. * @param y defines the 2nd component of the translation
  2943. * @param z defines the 3rd component of the translation
  2944. * @returns the current updated matrix
  2945. */
  2946. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2947. /**
  2948. * Inserts the translation vector in the current matrix
  2949. * @param vector3 defines the translation to insert
  2950. * @returns the current updated matrix
  2951. */
  2952. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2953. /**
  2954. * Gets the translation value of the current matrix
  2955. * @returns a new Vector3 as the extracted translation from the matrix
  2956. */
  2957. getTranslation(): Vector3;
  2958. /**
  2959. * Fill a Vector3 with the extracted translation from the matrix
  2960. * @param result defines the Vector3 where to store the translation
  2961. * @returns the current matrix
  2962. */
  2963. getTranslationToRef(result: Vector3): Matrix;
  2964. /**
  2965. * Remove rotation and scaling part from the matrix
  2966. * @returns the updated matrix
  2967. */
  2968. removeRotationAndScaling(): Matrix;
  2969. /**
  2970. * Multiply two matrices
  2971. * @param other defines the second operand
  2972. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2973. */
  2974. multiply(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Copy the current matrix from the given one
  2977. * @param other defines the source matrix
  2978. * @returns the current updated matrix
  2979. */
  2980. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2981. /**
  2982. * Populates the given array from the starting index with the current matrix values
  2983. * @param array defines the target array
  2984. * @param offset defines the offset in the target array where to start storing values
  2985. * @returns the current matrix
  2986. */
  2987. copyToArray(array: Float32Array, offset?: number): Matrix;
  2988. /**
  2989. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2990. * @param other defines the second operand
  2991. * @param result defines the matrix where to store the multiplication
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2995. /**
  2996. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2997. * @param other defines the second operand
  2998. * @param result defines the array where to store the multiplication
  2999. * @param offset defines the offset in the target array where to start storing values
  3000. * @returns the current matrix
  3001. */
  3002. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3003. /**
  3004. * Check equality between this matrix and a second one
  3005. * @param value defines the second matrix to compare
  3006. * @returns true is the current matrix and the given one values are strictly equal
  3007. */
  3008. equals(value: DeepImmutable<Matrix>): boolean;
  3009. /**
  3010. * Clone the current matrix
  3011. * @returns a new matrix from the current matrix
  3012. */
  3013. clone(): Matrix;
  3014. /**
  3015. * Returns the name of the current matrix class
  3016. * @returns the string "Matrix"
  3017. */
  3018. getClassName(): string;
  3019. /**
  3020. * Gets the hash code of the current matrix
  3021. * @returns the hash code
  3022. */
  3023. getHashCode(): number;
  3024. /**
  3025. * Decomposes the current Matrix into a translation, rotation and scaling components
  3026. * @param scale defines the scale vector3 given as a reference to update
  3027. * @param rotation defines the rotation quaternion given as a reference to update
  3028. * @param translation defines the translation vector3 given as a reference to update
  3029. * @returns true if operation was successful
  3030. */
  3031. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3032. /**
  3033. * Gets specific row of the matrix
  3034. * @param index defines the number of the row to get
  3035. * @returns the index-th row of the current matrix as a new Vector4
  3036. */
  3037. getRow(index: number): Nullable<Vector4>;
  3038. /**
  3039. * Sets the index-th row of the current matrix to the vector4 values
  3040. * @param index defines the number of the row to set
  3041. * @param row defines the target vector4
  3042. * @returns the updated current matrix
  3043. */
  3044. setRow(index: number, row: Vector4): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix
  3047. * @returns the new transposed matrix
  3048. */
  3049. transpose(): Matrix;
  3050. /**
  3051. * Compute the transpose of the matrix and store it in a given matrix
  3052. * @param result defines the target matrix
  3053. * @returns the current matrix
  3054. */
  3055. transposeToRef(result: Matrix): Matrix;
  3056. /**
  3057. * Sets the index-th row of the current matrix with the given 4 x float values
  3058. * @param index defines the row index
  3059. * @param x defines the x component to set
  3060. * @param y defines the y component to set
  3061. * @param z defines the z component to set
  3062. * @param w defines the w component to set
  3063. * @returns the updated current matrix
  3064. */
  3065. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3066. /**
  3067. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3068. * @param scale defines the scale factor
  3069. * @returns a new matrix
  3070. */
  3071. scale(scale: number): Matrix;
  3072. /**
  3073. * Scale the current matrix values by a factor to a given result matrix
  3074. * @param scale defines the scale factor
  3075. * @param result defines the matrix to store the result
  3076. * @returns the current matrix
  3077. */
  3078. scaleToRef(scale: number, result: Matrix): Matrix;
  3079. /**
  3080. * Scale the current matrix values by a factor and add the result to a given matrix
  3081. * @param scale defines the scale factor
  3082. * @param result defines the Matrix to store the result
  3083. * @returns the current matrix
  3084. */
  3085. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3086. /**
  3087. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3088. * @param ref matrix to store the result
  3089. */
  3090. toNormalMatrix(ref: Matrix): void;
  3091. /**
  3092. * Gets only rotation part of the current matrix
  3093. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3094. */
  3095. getRotationMatrix(): Matrix;
  3096. /**
  3097. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3098. * @param result defines the target matrix to store data to
  3099. * @returns the current matrix
  3100. */
  3101. getRotationMatrixToRef(result: Matrix): Matrix;
  3102. /**
  3103. * Toggles model matrix from being right handed to left handed in place and vice versa
  3104. */
  3105. toggleModelMatrixHandInPlace(): void;
  3106. /**
  3107. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleProjectionMatrixHandInPlace(): void;
  3110. /**
  3111. * Creates a matrix from an array
  3112. * @param array defines the source array
  3113. * @param offset defines an offset in the source array
  3114. * @returns a new Matrix set from the starting index of the given array
  3115. */
  3116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3117. /**
  3118. * Copy the content of an array into a given matrix
  3119. * @param array defines the source array
  3120. * @param offset defines an offset in the source array
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3124. /**
  3125. * Stores an array into a matrix after having multiplied each component by a given factor
  3126. * @param array defines the source array
  3127. * @param offset defines the offset in the source array
  3128. * @param scale defines the scaling factor
  3129. * @param result defines the target matrix
  3130. */
  3131. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3132. /**
  3133. * Gets an identity matrix that must not be updated
  3134. */
  3135. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3136. /**
  3137. * Stores a list of values (16) inside a given matrix
  3138. * @param initialM11 defines 1st value of 1st row
  3139. * @param initialM12 defines 2nd value of 1st row
  3140. * @param initialM13 defines 3rd value of 1st row
  3141. * @param initialM14 defines 4th value of 1st row
  3142. * @param initialM21 defines 1st value of 2nd row
  3143. * @param initialM22 defines 2nd value of 2nd row
  3144. * @param initialM23 defines 3rd value of 2nd row
  3145. * @param initialM24 defines 4th value of 2nd row
  3146. * @param initialM31 defines 1st value of 3rd row
  3147. * @param initialM32 defines 2nd value of 3rd row
  3148. * @param initialM33 defines 3rd value of 3rd row
  3149. * @param initialM34 defines 4th value of 3rd row
  3150. * @param initialM41 defines 1st value of 4th row
  3151. * @param initialM42 defines 2nd value of 4th row
  3152. * @param initialM43 defines 3rd value of 4th row
  3153. * @param initialM44 defines 4th value of 4th row
  3154. * @param result defines the target matrix
  3155. */
  3156. 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;
  3157. /**
  3158. * Creates new matrix from a list of values (16)
  3159. * @param initialM11 defines 1st value of 1st row
  3160. * @param initialM12 defines 2nd value of 1st row
  3161. * @param initialM13 defines 3rd value of 1st row
  3162. * @param initialM14 defines 4th value of 1st row
  3163. * @param initialM21 defines 1st value of 2nd row
  3164. * @param initialM22 defines 2nd value of 2nd row
  3165. * @param initialM23 defines 3rd value of 2nd row
  3166. * @param initialM24 defines 4th value of 2nd row
  3167. * @param initialM31 defines 1st value of 3rd row
  3168. * @param initialM32 defines 2nd value of 3rd row
  3169. * @param initialM33 defines 3rd value of 3rd row
  3170. * @param initialM34 defines 4th value of 3rd row
  3171. * @param initialM41 defines 1st value of 4th row
  3172. * @param initialM42 defines 2nd value of 4th row
  3173. * @param initialM43 defines 3rd value of 4th row
  3174. * @param initialM44 defines 4th value of 4th row
  3175. * @returns the new matrix
  3176. */
  3177. 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;
  3178. /**
  3179. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @returns a new matrix
  3184. */
  3185. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3186. /**
  3187. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3188. * @param scale defines the scale vector3
  3189. * @param rotation defines the rotation quaternion
  3190. * @param translation defines the translation vector3
  3191. * @param result defines the target matrix
  3192. */
  3193. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a new identity matrix
  3196. * @returns a new identity matrix
  3197. */
  3198. static Identity(): Matrix;
  3199. /**
  3200. * Creates a new identity matrix and stores the result in a given matrix
  3201. * @param result defines the target matrix
  3202. */
  3203. static IdentityToRef(result: Matrix): void;
  3204. /**
  3205. * Creates a new zero matrix
  3206. * @returns a new zero matrix
  3207. */
  3208. static Zero(): Matrix;
  3209. /**
  3210. * Creates a new rotation matrix for "angle" radians around the X axis
  3211. * @param angle defines the angle (in radians) to use
  3212. * @return the new matrix
  3213. */
  3214. static RotationX(angle: number): Matrix;
  3215. /**
  3216. * Creates a new matrix as the invert of a given matrix
  3217. * @param source defines the source matrix
  3218. * @returns the new matrix
  3219. */
  3220. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3223. * @param angle defines the angle (in radians) to use
  3224. * @param result defines the target matrix
  3225. */
  3226. static RotationXToRef(angle: number, result: Matrix): void;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis
  3229. * @param angle defines the angle (in radians) to use
  3230. * @return the new matrix
  3231. */
  3232. static RotationY(angle: number): Matrix;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3235. * @param angle defines the angle (in radians) to use
  3236. * @param result defines the target matrix
  3237. */
  3238. static RotationYToRef(angle: number, result: Matrix): void;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis
  3241. * @param angle defines the angle (in radians) to use
  3242. * @return the new matrix
  3243. */
  3244. static RotationZ(angle: number): Matrix;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3247. * @param angle defines the angle (in radians) to use
  3248. * @param result defines the target matrix
  3249. */
  3250. static RotationZToRef(angle: number, result: Matrix): void;
  3251. /**
  3252. * Creates a new rotation matrix for "angle" radians around the given axis
  3253. * @param axis defines the axis to use
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3260. * @param axis defines the axis to use
  3261. * @param angle defines the angle (in radians) to use
  3262. * @param result defines the target matrix
  3263. */
  3264. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3265. /**
  3266. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3267. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3268. * @param from defines the vector to align
  3269. * @param to defines the vector to align to
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3273. /**
  3274. * Creates a rotation matrix
  3275. * @param yaw defines the yaw angle in radians (Y axis)
  3276. * @param pitch defines the pitch angle in radians (X axis)
  3277. * @param roll defines the roll angle in radians (X axis)
  3278. * @returns the new rotation matrix
  3279. */
  3280. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3281. /**
  3282. * Creates a rotation matrix and stores it in a given matrix
  3283. * @param yaw defines the yaw angle in radians (Y axis)
  3284. * @param pitch defines the pitch angle in radians (X axis)
  3285. * @param roll defines the roll angle in radians (X axis)
  3286. * @param result defines the target matrix
  3287. */
  3288. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3289. /**
  3290. * Creates a scaling matrix
  3291. * @param x defines the scale factor on X axis
  3292. * @param y defines the scale factor on Y axis
  3293. * @param z defines the scale factor on Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Scaling(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a scaling matrix and stores it in a given matrix
  3299. * @param x defines the scale factor on X axis
  3300. * @param y defines the scale factor on Y axis
  3301. * @param z defines the scale factor on Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Creates a translation matrix
  3307. * @param x defines the translation on X axis
  3308. * @param y defines the translation on Y axis
  3309. * @param z defines the translationon Z axis
  3310. * @returns the new matrix
  3311. */
  3312. static Translation(x: number, y: number, z: number): Matrix;
  3313. /**
  3314. * Creates a translation matrix and stores it in a given matrix
  3315. * @param x defines the translation on X axis
  3316. * @param y defines the translation on Y axis
  3317. * @param z defines the translationon Z axis
  3318. * @param result defines the target matrix
  3319. */
  3320. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3321. /**
  3322. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3323. * @param startValue defines the start value
  3324. * @param endValue defines the end value
  3325. * @param gradient defines the gradient factor
  3326. * @returns the new matrix
  3327. */
  3328. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3329. /**
  3330. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3331. * @param startValue defines the start value
  3332. * @param endValue defines the end value
  3333. * @param gradient defines the gradient factor
  3334. * @param result defines the Matrix object where to store data
  3335. */
  3336. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3337. /**
  3338. * Builds a new matrix whose values are computed by:
  3339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3342. * @param startValue defines the first matrix
  3343. * @param endValue defines the second matrix
  3344. * @param gradient defines the gradient between the two matrices
  3345. * @returns the new matrix
  3346. */
  3347. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3348. /**
  3349. * Update a matrix to values which are computed by:
  3350. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3351. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3352. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3353. * @param startValue defines the first matrix
  3354. * @param endValue defines the second matrix
  3355. * @param gradient defines the gradient between the two matrices
  3356. * @param result defines the target matrix
  3357. */
  3358. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3359. /**
  3360. * 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"
  3361. * This function works in left handed mode
  3362. * @param eye defines the final position of the entity
  3363. * @param target defines where the entity should look at
  3364. * @param up defines the up vector for the entity
  3365. * @returns the new matrix
  3366. */
  3367. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3368. /**
  3369. * 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".
  3370. * This function works in left handed mode
  3371. * @param eye defines the final position of the entity
  3372. * @param target defines where the entity should look at
  3373. * @param up defines the up vector for the entity
  3374. * @param result defines the target matrix
  3375. */
  3376. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3377. /**
  3378. * 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"
  3379. * This function works in right handed mode
  3380. * @param eye defines the final position of the entity
  3381. * @param target defines where the entity should look at
  3382. * @param up defines the up vector for the entity
  3383. * @returns the new matrix
  3384. */
  3385. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3386. /**
  3387. * 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".
  3388. * This function works in right handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @param result defines the target matrix
  3393. */
  3394. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3395. /**
  3396. * Create a left-handed orthographic projection matrix
  3397. * @param width defines the viewport width
  3398. * @param height defines the viewport height
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @returns a new matrix as a left-handed orthographic projection matrix
  3402. */
  3403. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3404. /**
  3405. * Store a left-handed orthographic projection to a given matrix
  3406. * @param width defines the viewport width
  3407. * @param height defines the viewport height
  3408. * @param znear defines the near clip plane
  3409. * @param zfar defines the far clip plane
  3410. * @param result defines the target matrix
  3411. */
  3412. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3413. /**
  3414. * Create a left-handed orthographic projection matrix
  3415. * @param left defines the viewport left coordinate
  3416. * @param right defines the viewport right coordinate
  3417. * @param bottom defines the viewport bottom coordinate
  3418. * @param top defines the viewport top coordinate
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a left-handed orthographic projection matrix
  3422. */
  3423. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Stores a left-handed orthographic projection into a given matrix
  3426. * @param left defines the viewport left coordinate
  3427. * @param right defines the viewport right coordinate
  3428. * @param bottom defines the viewport bottom coordinate
  3429. * @param top defines the viewport top coordinate
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @param result defines the target matrix
  3433. */
  3434. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3435. /**
  3436. * Creates a right-handed orthographic projection matrix
  3437. * @param left defines the viewport left coordinate
  3438. * @param right defines the viewport right coordinate
  3439. * @param bottom defines the viewport bottom coordinate
  3440. * @param top defines the viewport top coordinate
  3441. * @param znear defines the near clip plane
  3442. * @param zfar defines the far clip plane
  3443. * @returns a new matrix as a right-handed orthographic projection matrix
  3444. */
  3445. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3446. /**
  3447. * Stores a right-handed orthographic projection into a given matrix
  3448. * @param left defines the viewport left coordinate
  3449. * @param right defines the viewport right coordinate
  3450. * @param bottom defines the viewport bottom coordinate
  3451. * @param top defines the viewport top coordinate
  3452. * @param znear defines the near clip plane
  3453. * @param zfar defines the far clip plane
  3454. * @param result defines the target matrix
  3455. */
  3456. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3457. /**
  3458. * Creates a left-handed perspective projection matrix
  3459. * @param width defines the viewport width
  3460. * @param height defines the viewport height
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @returns a new matrix as a left-handed perspective projection matrix
  3464. */
  3465. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3466. /**
  3467. * Creates a left-handed perspective projection matrix
  3468. * @param fov defines the horizontal field of view
  3469. * @param aspect defines the aspect ratio
  3470. * @param znear defines the near clip plane
  3471. * @param zfar defines the far clip plane
  3472. * @returns a new matrix as a left-handed perspective projection matrix
  3473. */
  3474. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3475. /**
  3476. * Stores a left-handed perspective projection into a given matrix
  3477. * @param fov defines the horizontal field of view
  3478. * @param aspect defines the aspect ratio
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3483. */
  3484. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3485. /**
  3486. * Creates a right-handed perspective projection matrix
  3487. * @param fov defines the horizontal field of view
  3488. * @param aspect defines the aspect ratio
  3489. * @param znear defines the near clip plane
  3490. * @param zfar defines the far clip plane
  3491. * @returns a new matrix as a right-handed perspective projection matrix
  3492. */
  3493. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3494. /**
  3495. * Stores a right-handed perspective projection into a given matrix
  3496. * @param fov defines the horizontal field of view
  3497. * @param aspect defines the aspect ratio
  3498. * @param znear defines the near clip plane
  3499. * @param zfar defines the far clip plane
  3500. * @param result defines the target matrix
  3501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3502. */
  3503. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3504. /**
  3505. * Stores a perspective projection for WebVR info a given matrix
  3506. * @param fov defines the field of view
  3507. * @param znear defines the near clip plane
  3508. * @param zfar defines the far clip plane
  3509. * @param result defines the target matrix
  3510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3511. */
  3512. static PerspectiveFovWebVRToRef(fov: {
  3513. upDegrees: number;
  3514. downDegrees: number;
  3515. leftDegrees: number;
  3516. rightDegrees: number;
  3517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3518. /**
  3519. * Computes a complete transformation matrix
  3520. * @param viewport defines the viewport to use
  3521. * @param world defines the world matrix
  3522. * @param view defines the view matrix
  3523. * @param projection defines the projection matrix
  3524. * @param zmin defines the near clip plane
  3525. * @param zmax defines the far clip plane
  3526. * @returns the transformation matrix
  3527. */
  3528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3529. /**
  3530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3531. * @param matrix defines the matrix to use
  3532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3533. */
  3534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3535. /**
  3536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3537. * @param matrix defines the matrix to use
  3538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3539. */
  3540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3541. /**
  3542. * Compute the transpose of a given matrix
  3543. * @param matrix defines the matrix to transpose
  3544. * @returns the new matrix
  3545. */
  3546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3547. /**
  3548. * Compute the transpose of a matrix and store it in a target matrix
  3549. * @param matrix defines the matrix to transpose
  3550. * @param result defines the target matrix
  3551. */
  3552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3553. /**
  3554. * Computes a reflection matrix from a plane
  3555. * @param plane defines the reflection plane
  3556. * @returns a new matrix
  3557. */
  3558. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3559. /**
  3560. * Computes a reflection matrix from a plane
  3561. * @param plane defines the reflection plane
  3562. * @param result defines the target matrix
  3563. */
  3564. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3565. /**
  3566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3567. * @param xaxis defines the value of the 1st axis
  3568. * @param yaxis defines the value of the 2nd axis
  3569. * @param zaxis defines the value of the 3rd axis
  3570. * @param result defines the target matrix
  3571. */
  3572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3573. /**
  3574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3575. * @param quat defines the quaternion to use
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3579. }
  3580. /**
  3581. * Represens a plane by the equation ax + by + cz + d = 0
  3582. */
  3583. export class Plane {
  3584. /**
  3585. * Normal of the plane (a,b,c)
  3586. */
  3587. normal: Vector3;
  3588. /**
  3589. * d component of the plane
  3590. */
  3591. d: number;
  3592. /**
  3593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3594. * @param a a component of the plane
  3595. * @param b b component of the plane
  3596. * @param c c component of the plane
  3597. * @param d d component of the plane
  3598. */
  3599. constructor(a: number, b: number, c: number, d: number);
  3600. /**
  3601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3602. */
  3603. asArray(): number[];
  3604. /**
  3605. * @returns a new plane copied from the current Plane.
  3606. */
  3607. clone(): Plane;
  3608. /**
  3609. * @returns the string "Plane".
  3610. */
  3611. getClassName(): string;
  3612. /**
  3613. * @returns the Plane hash code.
  3614. */
  3615. getHashCode(): number;
  3616. /**
  3617. * Normalize the current Plane in place.
  3618. * @returns the updated Plane.
  3619. */
  3620. normalize(): Plane;
  3621. /**
  3622. * Applies a transformation the plane and returns the result
  3623. * @param transformation the transformation matrix to be applied to the plane
  3624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3625. */
  3626. transform(transformation: DeepImmutable<Matrix>): Plane;
  3627. /**
  3628. * Calcualtte the dot product between the point and the plane normal
  3629. * @param point point to calculate the dot product with
  3630. * @returns the dot product (float) of the point coordinates and the plane normal.
  3631. */
  3632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3633. /**
  3634. * Updates the current Plane from the plane defined by the three given points.
  3635. * @param point1 one of the points used to contruct the plane
  3636. * @param point2 one of the points used to contruct the plane
  3637. * @param point3 one of the points used to contruct the plane
  3638. * @returns the updated Plane.
  3639. */
  3640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3641. /**
  3642. * Checks if the plane is facing a given direction
  3643. * @param direction the direction to check if the plane is facing
  3644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3645. * @returns True is the vector "direction" is the same side than the plane normal.
  3646. */
  3647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3648. /**
  3649. * Calculates the distance to a point
  3650. * @param point point to calculate distance to
  3651. * @returns the signed distance (float) from the given point to the Plane.
  3652. */
  3653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3654. /**
  3655. * Creates a plane from an array
  3656. * @param array the array to create a plane from
  3657. * @returns a new Plane from the given array.
  3658. */
  3659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3660. /**
  3661. * Creates a plane from three points
  3662. * @param point1 point used to create the plane
  3663. * @param point2 point used to create the plane
  3664. * @param point3 point used to create the plane
  3665. * @returns a new Plane defined by the three given points.
  3666. */
  3667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Creates a plane from an origin point and a normal
  3670. * @param origin origin of the plane to be constructed
  3671. * @param normal normal of the plane to be constructed
  3672. * @returns a new Plane the normal vector to this plane at the given origin point.
  3673. * Note : the vector "normal" is updated because normalized.
  3674. */
  3675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3676. /**
  3677. * Calculates the distance from a plane and a point
  3678. * @param origin origin of the plane to be constructed
  3679. * @param normal normal of the plane to be constructed
  3680. * @param point point to calculate distance to
  3681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3682. */
  3683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3684. }
  3685. /**
  3686. * Class used to represent a viewport on screen
  3687. */
  3688. export class Viewport {
  3689. /** viewport left coordinate */
  3690. x: number;
  3691. /** viewport top coordinate */
  3692. y: number;
  3693. /**viewport width */
  3694. width: number;
  3695. /** viewport height */
  3696. height: number;
  3697. /**
  3698. * Creates a Viewport object located at (x, y) and sized (width, height)
  3699. * @param x defines viewport left coordinate
  3700. * @param y defines viewport top coordinate
  3701. * @param width defines the viewport width
  3702. * @param height defines the viewport height
  3703. */
  3704. constructor(
  3705. /** viewport left coordinate */
  3706. x: number,
  3707. /** viewport top coordinate */
  3708. y: number,
  3709. /**viewport width */
  3710. width: number,
  3711. /** viewport height */
  3712. height: number);
  3713. /**
  3714. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3715. * @param renderWidth defines the rendering width
  3716. * @param renderHeight defines the rendering height
  3717. * @returns a new Viewport
  3718. */
  3719. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3720. /**
  3721. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3722. * @param renderWidth defines the rendering width
  3723. * @param renderHeight defines the rendering height
  3724. * @param ref defines the target viewport
  3725. * @returns the current viewport
  3726. */
  3727. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3728. /**
  3729. * Returns a new Viewport copied from the current one
  3730. * @returns a new Viewport
  3731. */
  3732. clone(): Viewport;
  3733. }
  3734. /**
  3735. * Reprasents a camera frustum
  3736. */
  3737. export class Frustum {
  3738. /**
  3739. * Gets the planes representing the frustum
  3740. * @param transform matrix to be applied to the returned planes
  3741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3742. */
  3743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3744. /**
  3745. * Gets the near frustum plane transformed by the transform matrix
  3746. * @param transform transformation matrix to be applied to the resulting frustum plane
  3747. * @param frustumPlane the resuling frustum plane
  3748. */
  3749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3750. /**
  3751. * Gets the far frustum plane transformed by the transform matrix
  3752. * @param transform transformation matrix to be applied to the resulting frustum plane
  3753. * @param frustumPlane the resuling frustum plane
  3754. */
  3755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3756. /**
  3757. * Gets the left frustum plane transformed by the transform matrix
  3758. * @param transform transformation matrix to be applied to the resulting frustum plane
  3759. * @param frustumPlane the resuling frustum plane
  3760. */
  3761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3762. /**
  3763. * Gets the right frustum plane transformed by the transform matrix
  3764. * @param transform transformation matrix to be applied to the resulting frustum plane
  3765. * @param frustumPlane the resuling frustum plane
  3766. */
  3767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3768. /**
  3769. * Gets the top frustum plane transformed by the transform matrix
  3770. * @param transform transformation matrix to be applied to the resulting frustum plane
  3771. * @param frustumPlane the resuling frustum plane
  3772. */
  3773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3774. /**
  3775. * Gets the bottom frustum plane transformed by the transform matrix
  3776. * @param transform transformation matrix to be applied to the resulting frustum plane
  3777. * @param frustumPlane the resuling frustum plane
  3778. */
  3779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3780. /**
  3781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3782. * @param transform transformation matrix to be applied to the resulting frustum planes
  3783. * @param frustumPlanes the resuling frustum planes
  3784. */
  3785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3786. }
  3787. /** Defines supported spaces */
  3788. export enum Space {
  3789. /** Local (object) space */
  3790. LOCAL = 0,
  3791. /** World space */
  3792. WORLD = 1,
  3793. /** Bone space */
  3794. BONE = 2
  3795. }
  3796. /** Defines the 3 main axes */
  3797. export class Axis {
  3798. /** X axis */
  3799. static X: Vector3;
  3800. /** Y axis */
  3801. static Y: Vector3;
  3802. /** Z axis */
  3803. static Z: Vector3;
  3804. }
  3805. /** Class used to represent a Bezier curve */
  3806. export class BezierCurve {
  3807. /**
  3808. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3809. * @param t defines the time
  3810. * @param x1 defines the left coordinate on X axis
  3811. * @param y1 defines the left coordinate on Y axis
  3812. * @param x2 defines the right coordinate on X axis
  3813. * @param y2 defines the right coordinate on Y axis
  3814. * @returns the interpolated value
  3815. */
  3816. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3817. }
  3818. /**
  3819. * Defines potential orientation for back face culling
  3820. */
  3821. export enum Orientation {
  3822. /**
  3823. * Clockwise
  3824. */
  3825. CW = 0,
  3826. /** Counter clockwise */
  3827. CCW = 1
  3828. }
  3829. /**
  3830. * Defines angle representation
  3831. */
  3832. export class Angle {
  3833. private _radians;
  3834. /**
  3835. * Creates an Angle object of "radians" radians (float).
  3836. * @param radians the angle in radians
  3837. */
  3838. constructor(radians: number);
  3839. /**
  3840. * Get value in degrees
  3841. * @returns the Angle value in degrees (float)
  3842. */
  3843. degrees(): number;
  3844. /**
  3845. * Get value in radians
  3846. * @returns the Angle value in radians (float)
  3847. */
  3848. radians(): number;
  3849. /**
  3850. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3851. * @param a defines first vector
  3852. * @param b defines second vector
  3853. * @returns a new Angle
  3854. */
  3855. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3856. /**
  3857. * Gets a new Angle object from the given float in radians
  3858. * @param radians defines the angle value in radians
  3859. * @returns a new Angle
  3860. */
  3861. static FromRadians(radians: number): Angle;
  3862. /**
  3863. * Gets a new Angle object from the given float in degrees
  3864. * @param degrees defines the angle value in degrees
  3865. * @returns a new Angle
  3866. */
  3867. static FromDegrees(degrees: number): Angle;
  3868. }
  3869. /**
  3870. * This represents an arc in a 2d space.
  3871. */
  3872. export class Arc2 {
  3873. /** Defines the start point of the arc */
  3874. startPoint: Vector2;
  3875. /** Defines the mid point of the arc */
  3876. midPoint: Vector2;
  3877. /** Defines the end point of the arc */
  3878. endPoint: Vector2;
  3879. /**
  3880. * Defines the center point of the arc.
  3881. */
  3882. centerPoint: Vector2;
  3883. /**
  3884. * Defines the radius of the arc.
  3885. */
  3886. radius: number;
  3887. /**
  3888. * Defines the angle of the arc (from mid point to end point).
  3889. */
  3890. angle: Angle;
  3891. /**
  3892. * Defines the start angle of the arc (from start point to middle point).
  3893. */
  3894. startAngle: Angle;
  3895. /**
  3896. * Defines the orientation of the arc (clock wise/counter clock wise).
  3897. */
  3898. orientation: Orientation;
  3899. /**
  3900. * Creates an Arc object from the three given points : start, middle and end.
  3901. * @param startPoint Defines the start point of the arc
  3902. * @param midPoint Defines the midlle point of the arc
  3903. * @param endPoint Defines the end point of the arc
  3904. */
  3905. constructor(
  3906. /** Defines the start point of the arc */
  3907. startPoint: Vector2,
  3908. /** Defines the mid point of the arc */
  3909. midPoint: Vector2,
  3910. /** Defines the end point of the arc */
  3911. endPoint: Vector2);
  3912. }
  3913. /**
  3914. * Represents a 2D path made up of multiple 2D points
  3915. */
  3916. export class Path2 {
  3917. private _points;
  3918. private _length;
  3919. /**
  3920. * If the path start and end point are the same
  3921. */
  3922. closed: boolean;
  3923. /**
  3924. * Creates a Path2 object from the starting 2D coordinates x and y.
  3925. * @param x the starting points x value
  3926. * @param y the starting points y value
  3927. */
  3928. constructor(x: number, y: number);
  3929. /**
  3930. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3931. * @param x the added points x value
  3932. * @param y the added points y value
  3933. * @returns the updated Path2.
  3934. */
  3935. addLineTo(x: number, y: number): Path2;
  3936. /**
  3937. * 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.
  3938. * @param midX middle point x value
  3939. * @param midY middle point y value
  3940. * @param endX end point x value
  3941. * @param endY end point y value
  3942. * @param numberOfSegments (default: 36)
  3943. * @returns the updated Path2.
  3944. */
  3945. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3946. /**
  3947. * Closes the Path2.
  3948. * @returns the Path2.
  3949. */
  3950. close(): Path2;
  3951. /**
  3952. * Gets the sum of the distance between each sequential point in the path
  3953. * @returns the Path2 total length (float).
  3954. */
  3955. length(): number;
  3956. /**
  3957. * Gets the points which construct the path
  3958. * @returns the Path2 internal array of points.
  3959. */
  3960. getPoints(): Vector2[];
  3961. /**
  3962. * Retreives the point at the distance aways from the starting point
  3963. * @param normalizedLengthPosition the length along the path to retreive the point from
  3964. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3965. */
  3966. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3967. /**
  3968. * Creates a new path starting from an x and y position
  3969. * @param x starting x value
  3970. * @param y starting y value
  3971. * @returns a new Path2 starting at the coordinates (x, y).
  3972. */
  3973. static StartingAt(x: number, y: number): Path2;
  3974. }
  3975. /**
  3976. * Represents a 3D path made up of multiple 3D points
  3977. */
  3978. export class Path3D {
  3979. /**
  3980. * an array of Vector3, the curve axis of the Path3D
  3981. */
  3982. path: Vector3[];
  3983. private _curve;
  3984. private _distances;
  3985. private _tangents;
  3986. private _normals;
  3987. private _binormals;
  3988. private _raw;
  3989. /**
  3990. * new Path3D(path, normal, raw)
  3991. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3992. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3993. * @param path an array of Vector3, the curve axis of the Path3D
  3994. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3995. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3996. */
  3997. constructor(
  3998. /**
  3999. * an array of Vector3, the curve axis of the Path3D
  4000. */
  4001. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4002. /**
  4003. * Returns the Path3D array of successive Vector3 designing its curve.
  4004. * @returns the Path3D array of successive Vector3 designing its curve.
  4005. */
  4006. getCurve(): Vector3[];
  4007. /**
  4008. * Returns an array populated with tangent vectors on each Path3D curve point.
  4009. * @returns an array populated with tangent vectors on each Path3D curve point.
  4010. */
  4011. getTangents(): Vector3[];
  4012. /**
  4013. * Returns an array populated with normal vectors on each Path3D curve point.
  4014. * @returns an array populated with normal vectors on each Path3D curve point.
  4015. */
  4016. getNormals(): Vector3[];
  4017. /**
  4018. * Returns an array populated with binormal vectors on each Path3D curve point.
  4019. * @returns an array populated with binormal vectors on each Path3D curve point.
  4020. */
  4021. getBinormals(): Vector3[];
  4022. /**
  4023. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4024. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4025. */
  4026. getDistances(): number[];
  4027. /**
  4028. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4029. * @param path path which all values are copied into the curves points
  4030. * @param firstNormal which should be projected onto the curve
  4031. * @returns the same object updated.
  4032. */
  4033. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4034. private _compute;
  4035. private _getFirstNonNullVector;
  4036. private _getLastNonNullVector;
  4037. private _normalVector;
  4038. }
  4039. /**
  4040. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4041. * A Curve3 is designed from a series of successive Vector3.
  4042. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4043. */
  4044. export class Curve3 {
  4045. private _points;
  4046. private _length;
  4047. /**
  4048. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4049. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4050. * @param v1 (Vector3) the control point
  4051. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4052. * @param nbPoints (integer) the wanted number of points in the curve
  4053. * @returns the created Curve3
  4054. */
  4055. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4056. /**
  4057. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4058. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4059. * @param v1 (Vector3) the first control point
  4060. * @param v2 (Vector3) the second control point
  4061. * @param v3 (Vector3) the end point of the Cubic Bezier
  4062. * @param nbPoints (integer) the wanted number of points in the curve
  4063. * @returns the created Curve3
  4064. */
  4065. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4066. /**
  4067. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4068. * @param p1 (Vector3) the origin point of the Hermite Spline
  4069. * @param t1 (Vector3) the tangent vector at the origin point
  4070. * @param p2 (Vector3) the end point of the Hermite Spline
  4071. * @param t2 (Vector3) the tangent vector at the end point
  4072. * @param nbPoints (integer) the wanted number of points in the curve
  4073. * @returns the created Curve3
  4074. */
  4075. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4076. /**
  4077. * Returns a Curve3 object along a CatmullRom Spline curve :
  4078. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4079. * @param nbPoints (integer) the wanted number of points between each curve control points
  4080. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4081. * @returns the created Curve3
  4082. */
  4083. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4084. /**
  4085. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4086. * A Curve3 is designed from a series of successive Vector3.
  4087. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4088. * @param points points which make up the curve
  4089. */
  4090. constructor(points: Vector3[]);
  4091. /**
  4092. * @returns the Curve3 stored array of successive Vector3
  4093. */
  4094. getPoints(): Vector3[];
  4095. /**
  4096. * @returns the computed length (float) of the curve.
  4097. */
  4098. length(): number;
  4099. /**
  4100. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4101. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4102. * curveA and curveB keep unchanged.
  4103. * @param curve the curve to continue from this curve
  4104. * @returns the newly constructed curve
  4105. */
  4106. continue(curve: DeepImmutable<Curve3>): Curve3;
  4107. private _computeLength;
  4108. }
  4109. /**
  4110. * Contains position and normal vectors for a vertex
  4111. */
  4112. export class PositionNormalVertex {
  4113. /** the position of the vertex (defaut: 0,0,0) */
  4114. position: Vector3;
  4115. /** the normal of the vertex (defaut: 0,1,0) */
  4116. normal: Vector3;
  4117. /**
  4118. * Creates a PositionNormalVertex
  4119. * @param position the position of the vertex (defaut: 0,0,0)
  4120. * @param normal the normal of the vertex (defaut: 0,1,0)
  4121. */
  4122. constructor(
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position?: Vector3,
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal?: Vector3);
  4127. /**
  4128. * Clones the PositionNormalVertex
  4129. * @returns the cloned PositionNormalVertex
  4130. */
  4131. clone(): PositionNormalVertex;
  4132. }
  4133. /**
  4134. * Contains position, normal and uv vectors for a vertex
  4135. */
  4136. export class PositionNormalTextureVertex {
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position: Vector3;
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal: Vector3;
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv: Vector2;
  4143. /**
  4144. * Creates a PositionNormalTextureVertex
  4145. * @param position the position of the vertex (defaut: 0,0,0)
  4146. * @param normal the normal of the vertex (defaut: 0,1,0)
  4147. * @param uv the uv of the vertex (default: 0,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3,
  4154. /** the uv of the vertex (default: 0,0) */
  4155. uv?: Vector2);
  4156. /**
  4157. * Clones the PositionNormalTextureVertex
  4158. * @returns the cloned PositionNormalTextureVertex
  4159. */
  4160. clone(): PositionNormalTextureVertex;
  4161. }
  4162. /**
  4163. * @hidden
  4164. */
  4165. export class Tmp {
  4166. static Color3: Color3[];
  4167. static Color4: Color4[];
  4168. static Vector2: Vector2[];
  4169. static Vector3: Vector3[];
  4170. static Vector4: Vector4[];
  4171. static Quaternion: Quaternion[];
  4172. static Matrix: Matrix[];
  4173. }
  4174. }
  4175. declare module BABYLON {
  4176. /**
  4177. * Class used to enable access to offline support
  4178. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4179. */
  4180. export interface IOfflineProvider {
  4181. /**
  4182. * Gets a boolean indicating if scene must be saved in the database
  4183. */
  4184. enableSceneOffline: boolean;
  4185. /**
  4186. * Gets a boolean indicating if textures must be saved in the database
  4187. */
  4188. enableTexturesOffline: boolean;
  4189. /**
  4190. * Open the offline support and make it available
  4191. * @param successCallback defines the callback to call on success
  4192. * @param errorCallback defines the callback to call on error
  4193. */
  4194. open(successCallback: () => void, errorCallback: () => void): void;
  4195. /**
  4196. * Loads an image from the offline support
  4197. * @param url defines the url to load from
  4198. * @param image defines the target DOM image
  4199. */
  4200. loadImage(url: string, image: HTMLImageElement): void;
  4201. /**
  4202. * Loads a file from offline support
  4203. * @param url defines the URL to load from
  4204. * @param sceneLoaded defines a callback to call on success
  4205. * @param progressCallBack defines a callback to call when progress changed
  4206. * @param errorCallback defines a callback to call on error
  4207. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4208. */
  4209. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4210. }
  4211. }
  4212. declare module BABYLON {
  4213. /**
  4214. * A class serves as a medium between the observable and its observers
  4215. */
  4216. export class EventState {
  4217. /**
  4218. * Create a new EventState
  4219. * @param mask defines the mask associated with this state
  4220. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4221. * @param target defines the original target of the state
  4222. * @param currentTarget defines the current target of the state
  4223. */
  4224. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4225. /**
  4226. * Initialize the current event state
  4227. * @param mask defines the mask associated with this state
  4228. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4229. * @param target defines the original target of the state
  4230. * @param currentTarget defines the current target of the state
  4231. * @returns the current event state
  4232. */
  4233. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4234. /**
  4235. * An Observer can set this property to true to prevent subsequent observers of being notified
  4236. */
  4237. skipNextObservers: boolean;
  4238. /**
  4239. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4240. */
  4241. mask: number;
  4242. /**
  4243. * The object that originally notified the event
  4244. */
  4245. target?: any;
  4246. /**
  4247. * The current object in the bubbling phase
  4248. */
  4249. currentTarget?: any;
  4250. /**
  4251. * This will be populated with the return value of the last function that was executed.
  4252. * If it is the first function in the callback chain it will be the event data.
  4253. */
  4254. lastReturnValue?: any;
  4255. }
  4256. /**
  4257. * Represent an Observer registered to a given Observable object.
  4258. */
  4259. export class Observer<T> {
  4260. /**
  4261. * Defines the callback to call when the observer is notified
  4262. */
  4263. callback: (eventData: T, eventState: EventState) => void;
  4264. /**
  4265. * Defines the mask of the observer (used to filter notifications)
  4266. */
  4267. mask: number;
  4268. /**
  4269. * Defines the current scope used to restore the JS context
  4270. */
  4271. scope: any;
  4272. /** @hidden */ willBeUnregistered: boolean;
  4273. /**
  4274. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4275. */
  4276. unregisterOnNextCall: boolean;
  4277. /**
  4278. * Creates a new observer
  4279. * @param callback defines the callback to call when the observer is notified
  4280. * @param mask defines the mask of the observer (used to filter notifications)
  4281. * @param scope defines the current scope used to restore the JS context
  4282. */
  4283. constructor(
  4284. /**
  4285. * Defines the callback to call when the observer is notified
  4286. */
  4287. callback: (eventData: T, eventState: EventState) => void,
  4288. /**
  4289. * Defines the mask of the observer (used to filter notifications)
  4290. */
  4291. mask: number,
  4292. /**
  4293. * Defines the current scope used to restore the JS context
  4294. */
  4295. scope?: any);
  4296. }
  4297. /**
  4298. * Represent a list of observers registered to multiple Observables object.
  4299. */
  4300. export class MultiObserver<T> {
  4301. private _observers;
  4302. private _observables;
  4303. /**
  4304. * Release associated resources
  4305. */
  4306. dispose(): void;
  4307. /**
  4308. * Raise a callback when one of the observable will notify
  4309. * @param observables defines a list of observables to watch
  4310. * @param callback defines the callback to call on notification
  4311. * @param mask defines the mask used to filter notifications
  4312. * @param scope defines the current scope used to restore the JS context
  4313. * @returns the new MultiObserver
  4314. */
  4315. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4316. }
  4317. /**
  4318. * The Observable class is a simple implementation of the Observable pattern.
  4319. *
  4320. * 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.
  4321. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4322. * 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).
  4323. * 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.
  4324. */
  4325. export class Observable<T> {
  4326. private _observers;
  4327. private _eventState;
  4328. private _onObserverAdded;
  4329. /**
  4330. * Creates a new observable
  4331. * @param onObserverAdded defines a callback to call when a new observer is added
  4332. */
  4333. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4334. /**
  4335. * Create a new Observer with the specified callback
  4336. * @param callback the callback that will be executed for that Observer
  4337. * @param mask the mask used to filter observers
  4338. * @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.
  4339. * @param scope optional scope for the callback to be called from
  4340. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4341. * @returns the new observer created for the callback
  4342. */
  4343. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4344. /**
  4345. * Create a new Observer with the specified callback and unregisters after the next notification
  4346. * @param callback the callback that will be executed for that Observer
  4347. * @returns the new observer created for the callback
  4348. */
  4349. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4350. /**
  4351. * Remove an Observer from the Observable object
  4352. * @param observer the instance of the Observer to remove
  4353. * @returns false if it doesn't belong to this Observable
  4354. */
  4355. remove(observer: Nullable<Observer<T>>): boolean;
  4356. /**
  4357. * Remove a callback from the Observable object
  4358. * @param callback the callback to remove
  4359. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4360. * @returns false if it doesn't belong to this Observable
  4361. */
  4362. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4363. private _deferUnregister;
  4364. private _remove;
  4365. /**
  4366. * Moves the observable to the top of the observer list making it get called first when notified
  4367. * @param observer the observer to move
  4368. */
  4369. makeObserverTopPriority(observer: Observer<T>): void;
  4370. /**
  4371. * Moves the observable to the bottom of the observer list making it get called last when notified
  4372. * @param observer the observer to move
  4373. */
  4374. makeObserverBottomPriority(observer: Observer<T>): void;
  4375. /**
  4376. * Notify all Observers by calling their respective callback with the given data
  4377. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4378. * @param eventData defines the data to send to all observers
  4379. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4380. * @param target defines the original target of the state
  4381. * @param currentTarget defines the current target of the state
  4382. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4383. */
  4384. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4385. /**
  4386. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4387. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4388. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4389. * and it is crucial that all callbacks will be executed.
  4390. * The order of the callbacks is kept, callbacks are not executed parallel.
  4391. *
  4392. * @param eventData The data to be sent to each callback
  4393. * @param mask is used to filter observers defaults to -1
  4394. * @param target defines the callback target (see EventState)
  4395. * @param currentTarget defines he current object in the bubbling phase
  4396. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4397. */
  4398. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4399. /**
  4400. * Notify a specific observer
  4401. * @param observer defines the observer to notify
  4402. * @param eventData defines the data to be sent to each callback
  4403. * @param mask is used to filter observers defaults to -1
  4404. */
  4405. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4406. /**
  4407. * Gets a boolean indicating if the observable has at least one observer
  4408. * @returns true is the Observable has at least one Observer registered
  4409. */
  4410. hasObservers(): boolean;
  4411. /**
  4412. * Clear the list of observers
  4413. */
  4414. clear(): void;
  4415. /**
  4416. * Clone the current observable
  4417. * @returns a new observable
  4418. */
  4419. clone(): Observable<T>;
  4420. /**
  4421. * Does this observable handles observer registered with a given mask
  4422. * @param mask defines the mask to be tested
  4423. * @return whether or not one observer registered with the given mask is handeled
  4424. **/
  4425. hasSpecificMask(mask?: number): boolean;
  4426. }
  4427. }
  4428. declare module BABYLON {
  4429. /**
  4430. * Class used to help managing file picking and drag'n'drop
  4431. * File Storage
  4432. */
  4433. export class FilesInputStore {
  4434. /**
  4435. * List of files ready to be loaded
  4436. */
  4437. static FilesToLoad: {
  4438. [key: string]: File;
  4439. };
  4440. }
  4441. }
  4442. declare module BABYLON {
  4443. /** Defines the cross module used constants to avoid circular dependncies */
  4444. export class Constants {
  4445. /** Defines that alpha blending is disabled */
  4446. static readonly ALPHA_DISABLE: number;
  4447. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4448. static readonly ALPHA_ADD: number;
  4449. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4450. static readonly ALPHA_COMBINE: number;
  4451. /** Defines that alpha blending to DEST - SRC * DEST */
  4452. static readonly ALPHA_SUBTRACT: number;
  4453. /** Defines that alpha blending to SRC * DEST */
  4454. static readonly ALPHA_MULTIPLY: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4456. static readonly ALPHA_MAXIMIZED: number;
  4457. /** Defines that alpha blending to SRC + DEST */
  4458. static readonly ALPHA_ONEONE: number;
  4459. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4460. static readonly ALPHA_PREMULTIPLIED: number;
  4461. /**
  4462. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4463. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4464. */
  4465. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4466. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4467. static readonly ALPHA_INTERPOLATE: number;
  4468. /**
  4469. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4470. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4471. */
  4472. static readonly ALPHA_SCREENMODE: number;
  4473. /** Defines that the ressource is not delayed*/
  4474. static readonly DELAYLOADSTATE_NONE: number;
  4475. /** Defines that the ressource was successfully delay loaded */
  4476. static readonly DELAYLOADSTATE_LOADED: number;
  4477. /** Defines that the ressource is currently delay loading */
  4478. static readonly DELAYLOADSTATE_LOADING: number;
  4479. /** Defines that the ressource is delayed and has not started loading */
  4480. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4482. static readonly NEVER: number;
  4483. /** 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 */
  4484. static readonly ALWAYS: number;
  4485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4486. static readonly LESS: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4488. static readonly EQUAL: number;
  4489. /** 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 */
  4490. static readonly LEQUAL: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4492. static readonly GREATER: number;
  4493. /** 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 */
  4494. static readonly GEQUAL: number;
  4495. /** 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 */
  4496. static readonly NOTEQUAL: number;
  4497. /** Passed to stencilOperation to specify that stencil value must be kept */
  4498. static readonly KEEP: number;
  4499. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4500. static readonly REPLACE: number;
  4501. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4502. static readonly INCR: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4504. static readonly DECR: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4506. static readonly INVERT: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4508. static readonly INCR_WRAP: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4510. static readonly DECR_WRAP: number;
  4511. /** Texture is not repeating outside of 0..1 UVs */
  4512. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4513. /** Texture is repeating outside of 0..1 UVs */
  4514. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4515. /** Texture is repeating and mirrored */
  4516. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4517. /** ALPHA */
  4518. static readonly TEXTUREFORMAT_ALPHA: number;
  4519. /** LUMINANCE */
  4520. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4521. /** LUMINANCE_ALPHA */
  4522. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4523. /** RGB */
  4524. static readonly TEXTUREFORMAT_RGB: number;
  4525. /** RGBA */
  4526. static readonly TEXTUREFORMAT_RGBA: number;
  4527. /** RED */
  4528. static readonly TEXTUREFORMAT_RED: number;
  4529. /** RED (2nd reference) */
  4530. static readonly TEXTUREFORMAT_R: number;
  4531. /** RG */
  4532. static readonly TEXTUREFORMAT_RG: number;
  4533. /** RED_INTEGER */
  4534. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4535. /** RED_INTEGER (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4537. /** RG_INTEGER */
  4538. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4539. /** RGB_INTEGER */
  4540. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4541. /** RGBA_INTEGER */
  4542. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4543. /** UNSIGNED_BYTE */
  4544. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4545. /** UNSIGNED_BYTE (2nd reference) */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4547. /** FLOAT */
  4548. static readonly TEXTURETYPE_FLOAT: number;
  4549. /** HALF_FLOAT */
  4550. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4551. /** BYTE */
  4552. static readonly TEXTURETYPE_BYTE: number;
  4553. /** SHORT */
  4554. static readonly TEXTURETYPE_SHORT: number;
  4555. /** UNSIGNED_SHORT */
  4556. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4557. /** INT */
  4558. static readonly TEXTURETYPE_INT: number;
  4559. /** UNSIGNED_INT */
  4560. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4561. /** UNSIGNED_SHORT_4_4_4_4 */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4563. /** UNSIGNED_SHORT_5_5_5_1 */
  4564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4565. /** UNSIGNED_SHORT_5_6_5 */
  4566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4567. /** UNSIGNED_INT_2_10_10_10_REV */
  4568. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4569. /** UNSIGNED_INT_24_8 */
  4570. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4571. /** UNSIGNED_INT_10F_11F_11F_REV */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4573. /** UNSIGNED_INT_5_9_9_9_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4575. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4576. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4577. /** nearest is mag = nearest and min = nearest and mip = linear */
  4578. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4580. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4581. /** Trilinear is mag = linear and min = linear and mip = linear */
  4582. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4589. /** mag = nearest and min = nearest and mip = nearest */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4591. /** mag = nearest and min = linear and mip = nearest */
  4592. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4593. /** mag = nearest and min = linear and mip = linear */
  4594. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = linear and mip = none */
  4596. static readonly TEXTURE_NEAREST_LINEAR: number;
  4597. /** mag = nearest and min = nearest and mip = none */
  4598. static readonly TEXTURE_NEAREST_NEAREST: number;
  4599. /** mag = linear and min = nearest and mip = nearest */
  4600. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4601. /** mag = linear and min = nearest and mip = linear */
  4602. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4603. /** mag = linear and min = linear and mip = none */
  4604. static readonly TEXTURE_LINEAR_LINEAR: number;
  4605. /** mag = linear and min = nearest and mip = none */
  4606. static readonly TEXTURE_LINEAR_NEAREST: number;
  4607. /** Explicit coordinates mode */
  4608. static readonly TEXTURE_EXPLICIT_MODE: number;
  4609. /** Spherical coordinates mode */
  4610. static readonly TEXTURE_SPHERICAL_MODE: number;
  4611. /** Planar coordinates mode */
  4612. static readonly TEXTURE_PLANAR_MODE: number;
  4613. /** Cubic coordinates mode */
  4614. static readonly TEXTURE_CUBIC_MODE: number;
  4615. /** Projection coordinates mode */
  4616. static readonly TEXTURE_PROJECTION_MODE: number;
  4617. /** Skybox coordinates mode */
  4618. static readonly TEXTURE_SKYBOX_MODE: number;
  4619. /** Inverse Cubic coordinates mode */
  4620. static readonly TEXTURE_INVCUBIC_MODE: number;
  4621. /** Equirectangular coordinates mode */
  4622. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4623. /** Equirectangular Fixed coordinates mode */
  4624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4625. /** Equirectangular Fixed Mirrored coordinates mode */
  4626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4627. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4628. static readonly SCALEMODE_FLOOR: number;
  4629. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4630. static readonly SCALEMODE_NEAREST: number;
  4631. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4632. static readonly SCALEMODE_CEILING: number;
  4633. /**
  4634. * The dirty texture flag value
  4635. */
  4636. static readonly MATERIAL_TextureDirtyFlag: number;
  4637. /**
  4638. * The dirty light flag value
  4639. */
  4640. static readonly MATERIAL_LightDirtyFlag: number;
  4641. /**
  4642. * The dirty fresnel flag value
  4643. */
  4644. static readonly MATERIAL_FresnelDirtyFlag: number;
  4645. /**
  4646. * The dirty attribute flag value
  4647. */
  4648. static readonly MATERIAL_AttributesDirtyFlag: number;
  4649. /**
  4650. * The dirty misc flag value
  4651. */
  4652. static readonly MATERIAL_MiscDirtyFlag: number;
  4653. /**
  4654. * The all dirty flag value
  4655. */
  4656. static readonly MATERIAL_AllDirtyFlag: number;
  4657. /**
  4658. * Returns the triangle fill mode
  4659. */
  4660. static readonly MATERIAL_TriangleFillMode: number;
  4661. /**
  4662. * Returns the wireframe mode
  4663. */
  4664. static readonly MATERIAL_WireFrameFillMode: number;
  4665. /**
  4666. * Returns the point fill mode
  4667. */
  4668. static readonly MATERIAL_PointFillMode: number;
  4669. /**
  4670. * Returns the point list draw mode
  4671. */
  4672. static readonly MATERIAL_PointListDrawMode: number;
  4673. /**
  4674. * Returns the line list draw mode
  4675. */
  4676. static readonly MATERIAL_LineListDrawMode: number;
  4677. /**
  4678. * Returns the line loop draw mode
  4679. */
  4680. static readonly MATERIAL_LineLoopDrawMode: number;
  4681. /**
  4682. * Returns the line strip draw mode
  4683. */
  4684. static readonly MATERIAL_LineStripDrawMode: number;
  4685. /**
  4686. * Returns the triangle strip draw mode
  4687. */
  4688. static readonly MATERIAL_TriangleStripDrawMode: number;
  4689. /**
  4690. * Returns the triangle fan draw mode
  4691. */
  4692. static readonly MATERIAL_TriangleFanDrawMode: number;
  4693. /**
  4694. * Stores the clock-wise side orientation
  4695. */
  4696. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4697. /**
  4698. * Stores the counter clock-wise side orientation
  4699. */
  4700. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4701. /**
  4702. * Nothing
  4703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4704. */
  4705. static readonly ACTION_NothingTrigger: number;
  4706. /**
  4707. * On pick
  4708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4709. */
  4710. static readonly ACTION_OnPickTrigger: number;
  4711. /**
  4712. * On left pick
  4713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4714. */
  4715. static readonly ACTION_OnLeftPickTrigger: number;
  4716. /**
  4717. * On right pick
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnRightPickTrigger: number;
  4721. /**
  4722. * On center pick
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnCenterPickTrigger: number;
  4726. /**
  4727. * On pick down
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickDownTrigger: number;
  4731. /**
  4732. * On double pick
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnDoublePickTrigger: number;
  4736. /**
  4737. * On pick up
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickUpTrigger: number;
  4741. /**
  4742. * On pick out.
  4743. * This trigger will only be raised if you also declared a OnPickDown
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickOutTrigger: number;
  4747. /**
  4748. * On long press
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnLongPressTrigger: number;
  4752. /**
  4753. * On pointer over
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPointerOverTrigger: number;
  4757. /**
  4758. * On pointer out
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnPointerOutTrigger: number;
  4762. /**
  4763. * On every frame
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnEveryFrameTrigger: number;
  4767. /**
  4768. * On intersection enter
  4769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4770. */
  4771. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4772. /**
  4773. * On intersection exit
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnIntersectionExitTrigger: number;
  4777. /**
  4778. * On key down
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnKeyDownTrigger: number;
  4782. /**
  4783. * On key up
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnKeyUpTrigger: number;
  4787. /**
  4788. * Billboard mode will only apply to Y axis
  4789. */
  4790. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4791. /**
  4792. * Billboard mode will apply to all axes
  4793. */
  4794. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4795. /**
  4796. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4797. */
  4798. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4799. /**
  4800. * Gets or sets base Assets URL
  4801. */
  4802. static readonly PARTICLES_BaseAssetsUrl: string;
  4803. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4804. * Test order :
  4805. * Is the bounding sphere outside the frustum ?
  4806. * If not, are the bounding box vertices outside the frustum ?
  4807. * It not, then the cullable object is in the frustum.
  4808. */
  4809. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4810. /** Culling strategy : Bounding Sphere Only.
  4811. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4812. * It's also less accurate than the standard because some not visible objects can still be selected.
  4813. * Test : is the bounding sphere outside the frustum ?
  4814. * If not, then the cullable object is in the frustum.
  4815. */
  4816. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4817. /** Culling strategy : Optimistic Inclusion.
  4818. * This in an inclusion test first, then the standard exclusion test.
  4819. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4820. * 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.
  4821. * Anyway, it's as accurate as the standard strategy.
  4822. * Test :
  4823. * Is the cullable object bounding sphere center in the frustum ?
  4824. * If not, apply the default culling strategy.
  4825. */
  4826. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4827. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4828. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4829. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4830. * 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.
  4831. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4832. * Test :
  4833. * Is the cullable object bounding sphere center in the frustum ?
  4834. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4837. /**
  4838. * No logging while loading
  4839. */
  4840. static readonly SCENELOADER_NO_LOGGING: number;
  4841. /**
  4842. * Minimal logging while loading
  4843. */
  4844. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4845. /**
  4846. * Summary logging while loading
  4847. */
  4848. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4849. /**
  4850. * Detailled logging while loading
  4851. */
  4852. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4853. }
  4854. }
  4855. declare module BABYLON {
  4856. /**
  4857. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4858. * Babylon.js
  4859. */
  4860. export class DomManagement {
  4861. /**
  4862. * Checks if the window object exists
  4863. * @returns true if the window object exists
  4864. */
  4865. static IsWindowObjectExist(): boolean;
  4866. /**
  4867. * Extracts text content from a DOM element hierarchy
  4868. * @param element defines the root element
  4869. * @returns a string
  4870. */
  4871. static GetDOMTextContent(element: HTMLElement): string;
  4872. }
  4873. }
  4874. declare module BABYLON {
  4875. /**
  4876. * Logger used througouht the application to allow configuration of
  4877. * the log level required for the messages.
  4878. */
  4879. export class Logger {
  4880. /**
  4881. * No log
  4882. */
  4883. static readonly NoneLogLevel: number;
  4884. /**
  4885. * Only message logs
  4886. */
  4887. static readonly MessageLogLevel: number;
  4888. /**
  4889. * Only warning logs
  4890. */
  4891. static readonly WarningLogLevel: number;
  4892. /**
  4893. * Only error logs
  4894. */
  4895. static readonly ErrorLogLevel: number;
  4896. /**
  4897. * All logs
  4898. */
  4899. static readonly AllLogLevel: number;
  4900. private static _LogCache;
  4901. /**
  4902. * Gets a value indicating the number of loading errors
  4903. * @ignorenaming
  4904. */
  4905. static errorsCount: number;
  4906. /**
  4907. * Callback called when a new log is added
  4908. */
  4909. static OnNewCacheEntry: (entry: string) => void;
  4910. private static _AddLogEntry;
  4911. private static _FormatMessage;
  4912. private static _LogDisabled;
  4913. private static _LogEnabled;
  4914. private static _WarnDisabled;
  4915. private static _WarnEnabled;
  4916. private static _ErrorDisabled;
  4917. private static _ErrorEnabled;
  4918. /**
  4919. * Log a message to the console
  4920. */
  4921. static Log: (message: string) => void;
  4922. /**
  4923. * Write a warning message to the console
  4924. */
  4925. static Warn: (message: string) => void;
  4926. /**
  4927. * Write an error message to the console
  4928. */
  4929. static Error: (message: string) => void;
  4930. /**
  4931. * Gets current log cache (list of logs)
  4932. */
  4933. static readonly LogCache: string;
  4934. /**
  4935. * Clears the log cache
  4936. */
  4937. static ClearLogCache(): void;
  4938. /**
  4939. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4940. */
  4941. static LogLevels: number;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /** @hidden */
  4946. export class _TypeStore {
  4947. /** @hidden */
  4948. static RegisteredTypes: {
  4949. [key: string]: Object;
  4950. };
  4951. /** @hidden */
  4952. static GetClass(fqdn: string): any;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /**
  4957. * Class containing a set of static utilities functions for deep copy.
  4958. */
  4959. export class DeepCopier {
  4960. /**
  4961. * Tries to copy an object by duplicating every property
  4962. * @param source defines the source object
  4963. * @param destination defines the target object
  4964. * @param doNotCopyList defines a list of properties to avoid
  4965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4966. */
  4967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /**
  4972. * Class containing a set of static utilities functions for precision date
  4973. */
  4974. export class PrecisionDate {
  4975. /**
  4976. * Gets either window.performance.now() if supported or Date.now() else
  4977. */
  4978. static readonly Now: number;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /** @hidden */
  4983. export class _DevTools {
  4984. static WarnImport(name: string): string;
  4985. }
  4986. }
  4987. declare module BABYLON {
  4988. /**
  4989. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4990. */
  4991. export class WebRequest {
  4992. private _xhr;
  4993. /**
  4994. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4995. * i.e. when loading files, where the server/service expects an Authorization header
  4996. */
  4997. static CustomRequestHeaders: {
  4998. [key: string]: string;
  4999. };
  5000. /**
  5001. * Add callback functions in this array to update all the requests before they get sent to the network
  5002. */
  5003. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5004. private _injectCustomRequestHeaders;
  5005. /**
  5006. * Gets or sets a function to be called when loading progress changes
  5007. */
  5008. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5009. /**
  5010. * Returns client's state
  5011. */
  5012. readonly readyState: number;
  5013. /**
  5014. * Returns client's status
  5015. */
  5016. readonly status: number;
  5017. /**
  5018. * Returns client's status as a text
  5019. */
  5020. readonly statusText: string;
  5021. /**
  5022. * Returns client's response
  5023. */
  5024. readonly response: any;
  5025. /**
  5026. * Returns client's response url
  5027. */
  5028. readonly responseURL: string;
  5029. /**
  5030. * Returns client's response as text
  5031. */
  5032. readonly responseText: string;
  5033. /**
  5034. * Gets or sets the expected response type
  5035. */
  5036. responseType: XMLHttpRequestResponseType;
  5037. /** @hidden */
  5038. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5039. /** @hidden */
  5040. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5041. /**
  5042. * Cancels any network activity
  5043. */
  5044. abort(): void;
  5045. /**
  5046. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5047. * @param body defines an optional request body
  5048. */
  5049. send(body?: Document | BodyInit | null): void;
  5050. /**
  5051. * Sets the request method, request URL
  5052. * @param method defines the method to use (GET, POST, etc..)
  5053. * @param url defines the url to connect with
  5054. */
  5055. open(method: string, url: string): void;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to evalaute queries containing `and` and `or` operators
  5061. */
  5062. export class AndOrNotEvaluator {
  5063. /**
  5064. * Evaluate a query
  5065. * @param query defines the query to evaluate
  5066. * @param evaluateCallback defines the callback used to filter result
  5067. * @returns true if the query matches
  5068. */
  5069. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5070. private static _HandleParenthesisContent;
  5071. private static _SimplifyNegation;
  5072. }
  5073. }
  5074. declare module BABYLON {
  5075. /**
  5076. * Class used to store custom tags
  5077. */
  5078. export class Tags {
  5079. /**
  5080. * Adds support for tags on the given object
  5081. * @param obj defines the object to use
  5082. */
  5083. static EnableFor(obj: any): void;
  5084. /**
  5085. * Removes tags support
  5086. * @param obj defines the object to use
  5087. */
  5088. static DisableFor(obj: any): void;
  5089. /**
  5090. * Gets a boolean indicating if the given object has tags
  5091. * @param obj defines the object to use
  5092. * @returns a boolean
  5093. */
  5094. static HasTags(obj: any): boolean;
  5095. /**
  5096. * Gets the tags available on a given object
  5097. * @param obj defines the object to use
  5098. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5099. * @returns the tags
  5100. */
  5101. static GetTags(obj: any, asString?: boolean): any;
  5102. /**
  5103. * Adds tags to an object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5106. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5107. */
  5108. static AddTagsTo(obj: any, tagsString: string): void;
  5109. /**
  5110. * @hidden
  5111. */ private static _AddTagTo(obj: any, tag: string): void;
  5112. /**
  5113. * Removes specific tags from a specific object
  5114. * @param obj defines the object to use
  5115. * @param tagsString defines the tags to remove
  5116. */
  5117. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5118. /**
  5119. * @hidden
  5120. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5121. /**
  5122. * Defines if tags hosted on an object match a given query
  5123. * @param obj defines the object to use
  5124. * @param tagsQuery defines the tag query
  5125. * @returns a boolean
  5126. */
  5127. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. /**
  5132. * Manages the defines for the Material
  5133. */
  5134. export class MaterialDefines {
  5135. private _keys;
  5136. private _isDirty;
  5137. /** @hidden */ renderId: number;
  5138. /** @hidden */ areLightsDirty: boolean;
  5139. /** @hidden */ areAttributesDirty: boolean;
  5140. /** @hidden */ areTexturesDirty: boolean;
  5141. /** @hidden */ areFresnelDirty: boolean;
  5142. /** @hidden */ areMiscDirty: boolean;
  5143. /** @hidden */ areImageProcessingDirty: boolean;
  5144. /** @hidden */ normals: boolean;
  5145. /** @hidden */ uvs: boolean;
  5146. /** @hidden */ needNormals: boolean;
  5147. /** @hidden */ needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Class used to store and describe the pipeline context associated with an effect
  5217. */
  5218. export interface IPipelineContext {
  5219. /**
  5220. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5221. */
  5222. isAsync: boolean;
  5223. /**
  5224. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5225. */
  5226. isReady: boolean;
  5227. /** @hidden */ handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store gfx data (like WebGLBuffer)
  5233. */
  5234. export class DataBuffer {
  5235. /**
  5236. * Gets or sets the number of objects referencing this buffer
  5237. */
  5238. references: number;
  5239. /** Gets or sets the size of the underlying buffer */
  5240. capacity: number;
  5241. /**
  5242. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5243. */
  5244. is32Bits: boolean;
  5245. /**
  5246. * Gets the underlying buffer
  5247. */
  5248. readonly underlyingResource: any;
  5249. }
  5250. }
  5251. declare module BABYLON {
  5252. /**
  5253. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5254. */
  5255. export class PerformanceMonitor {
  5256. private _enabled;
  5257. private _rollingFrameTime;
  5258. private _lastFrameTimeMs;
  5259. /**
  5260. * constructor
  5261. * @param frameSampleSize The number of samples required to saturate the sliding window
  5262. */
  5263. constructor(frameSampleSize?: number);
  5264. /**
  5265. * Samples current frame
  5266. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5267. */
  5268. sampleFrame(timeMs?: number): void;
  5269. /**
  5270. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5271. */
  5272. readonly averageFrameTime: number;
  5273. /**
  5274. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5275. */
  5276. readonly averageFrameTimeVariance: number;
  5277. /**
  5278. * Returns the frame time of the most recent frame
  5279. */
  5280. readonly instantaneousFrameTime: number;
  5281. /**
  5282. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5283. */
  5284. readonly averageFPS: number;
  5285. /**
  5286. * Returns the average framerate in frames per second using the most recent frame time
  5287. */
  5288. readonly instantaneousFPS: number;
  5289. /**
  5290. * Returns true if enough samples have been taken to completely fill the sliding window
  5291. */
  5292. readonly isSaturated: boolean;
  5293. /**
  5294. * Enables contributions to the sliding window sample set
  5295. */
  5296. enable(): void;
  5297. /**
  5298. * Disables contributions to the sliding window sample set
  5299. * Samples will not be interpolated over the disabled period
  5300. */
  5301. disable(): void;
  5302. /**
  5303. * Returns true if sampling is enabled
  5304. */
  5305. readonly isEnabled: boolean;
  5306. /**
  5307. * Resets performance monitor
  5308. */
  5309. reset(): void;
  5310. }
  5311. /**
  5312. * RollingAverage
  5313. *
  5314. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5315. */
  5316. export class RollingAverage {
  5317. /**
  5318. * Current average
  5319. */
  5320. average: number;
  5321. /**
  5322. * Current variance
  5323. */
  5324. variance: number;
  5325. protected _samples: Array<number>;
  5326. protected _sampleCount: number;
  5327. protected _pos: number;
  5328. protected _m2: number;
  5329. /**
  5330. * constructor
  5331. * @param length The number of samples required to saturate the sliding window
  5332. */
  5333. constructor(length: number);
  5334. /**
  5335. * Adds a sample to the sample set
  5336. * @param v The sample value
  5337. */
  5338. add(v: number): void;
  5339. /**
  5340. * Returns previously added values or null if outside of history or outside the sliding window domain
  5341. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5342. * @return Value previously recorded with add() or null if outside of range
  5343. */
  5344. history(i: number): number;
  5345. /**
  5346. * Returns true if enough samples have been taken to completely fill the sliding window
  5347. * @return true if sample-set saturated
  5348. */
  5349. isSaturated(): boolean;
  5350. /**
  5351. * Resets the rolling average (equivalent to 0 samples taken so far)
  5352. */
  5353. reset(): void;
  5354. /**
  5355. * Wraps a value around the sample range boundaries
  5356. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5357. * @return Wrapped position in sample range
  5358. */
  5359. protected _wrapPosition(i: number): number;
  5360. }
  5361. }
  5362. declare module BABYLON {
  5363. /**
  5364. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5365. * The underlying implementation relies on an associative array to ensure the best performances.
  5366. * The value can be anything including 'null' but except 'undefined'
  5367. */
  5368. export class StringDictionary<T> {
  5369. /**
  5370. * This will clear this dictionary and copy the content from the 'source' one.
  5371. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5372. * @param source the dictionary to take the content from and copy to this dictionary
  5373. */
  5374. copyFrom(source: StringDictionary<T>): void;
  5375. /**
  5376. * Get a value based from its key
  5377. * @param key the given key to get the matching value from
  5378. * @return the value if found, otherwise undefined is returned
  5379. */
  5380. get(key: string): T | undefined;
  5381. /**
  5382. * Get a value from its key or add it if it doesn't exist.
  5383. * This method will ensure you that a given key/data will be present in the dictionary.
  5384. * @param key the given key to get the matching value from
  5385. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5386. * The factory will only be invoked if there's no data for the given key.
  5387. * @return the value corresponding to the key.
  5388. */
  5389. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5390. /**
  5391. * Get a value from its key if present in the dictionary otherwise add it
  5392. * @param key the key to get the value from
  5393. * @param val if there's no such key/value pair in the dictionary add it with this value
  5394. * @return the value corresponding to the key
  5395. */
  5396. getOrAdd(key: string, val: T): T;
  5397. /**
  5398. * Check if there's a given key in the dictionary
  5399. * @param key the key to check for
  5400. * @return true if the key is present, false otherwise
  5401. */
  5402. contains(key: string): boolean;
  5403. /**
  5404. * Add a new key and its corresponding value
  5405. * @param key the key to add
  5406. * @param value the value corresponding to the key
  5407. * @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
  5408. */
  5409. add(key: string, value: T): boolean;
  5410. /**
  5411. * Update a specific value associated to a key
  5412. * @param key defines the key to use
  5413. * @param value defines the value to store
  5414. * @returns true if the value was updated (or false if the key was not found)
  5415. */
  5416. set(key: string, value: T): boolean;
  5417. /**
  5418. * Get the element of the given key and remove it from the dictionary
  5419. * @param key defines the key to search
  5420. * @returns the value associated with the key or null if not found
  5421. */
  5422. getAndRemove(key: string): Nullable<T>;
  5423. /**
  5424. * Remove a key/value from the dictionary.
  5425. * @param key the key to remove
  5426. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5427. */
  5428. remove(key: string): boolean;
  5429. /**
  5430. * Clear the whole content of the dictionary
  5431. */
  5432. clear(): void;
  5433. /**
  5434. * Gets the current count
  5435. */
  5436. readonly count: number;
  5437. /**
  5438. * Execute a callback on each key/val of the dictionary.
  5439. * Note that you can remove any element in this dictionary in the callback implementation
  5440. * @param callback the callback to execute on a given key/value pair
  5441. */
  5442. forEach(callback: (key: string, val: T) => void): void;
  5443. /**
  5444. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5445. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5446. * Note that you can remove any element in this dictionary in the callback implementation
  5447. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5448. * @returns the first item
  5449. */
  5450. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5451. private _count;
  5452. private _data;
  5453. }
  5454. }
  5455. declare module BABYLON {
  5456. /**
  5457. * Helper class that provides a small promise polyfill
  5458. */
  5459. export class PromisePolyfill {
  5460. /**
  5461. * Static function used to check if the polyfill is required
  5462. * If this is the case then the function will inject the polyfill to window.Promise
  5463. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5464. */
  5465. static Apply(force?: boolean): void;
  5466. }
  5467. }
  5468. declare module BABYLON {
  5469. /**
  5470. * Class used to store data that will be store in GPU memory
  5471. */
  5472. export class Buffer {
  5473. private _engine;
  5474. private _buffer;
  5475. /** @hidden */ data: Nullable<DataArray>;
  5476. private _updatable;
  5477. private _instanced;
  5478. /**
  5479. * Gets the byte stride.
  5480. */
  5481. readonly byteStride: number;
  5482. /**
  5483. * Constructor
  5484. * @param engine the engine
  5485. * @param data the data to use for this buffer
  5486. * @param updatable whether the data is updatable
  5487. * @param stride the stride (optional)
  5488. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5489. * @param instanced whether the buffer is instanced (optional)
  5490. * @param useBytes set to true if the stride in in bytes (optional)
  5491. */
  5492. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5493. /**
  5494. * Create a new VertexBuffer based on the current buffer
  5495. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5496. * @param offset defines offset in the buffer (0 by default)
  5497. * @param size defines the size in floats of attributes (position is 3 for instance)
  5498. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5499. * @param instanced defines if the vertex buffer contains indexed data
  5500. * @param useBytes defines if the offset and stride are in bytes
  5501. * @returns the new vertex buffer
  5502. */
  5503. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5504. /**
  5505. * Gets a boolean indicating if the Buffer is updatable?
  5506. * @returns true if the buffer is updatable
  5507. */
  5508. isUpdatable(): boolean;
  5509. /**
  5510. * Gets current buffer's data
  5511. * @returns a DataArray or null
  5512. */
  5513. getData(): Nullable<DataArray>;
  5514. /**
  5515. * Gets underlying native buffer
  5516. * @returns underlying native buffer
  5517. */
  5518. getBuffer(): Nullable<DataBuffer>;
  5519. /**
  5520. * Gets the stride in float32 units (i.e. byte stride / 4).
  5521. * May not be an integer if the byte stride is not divisible by 4.
  5522. * DEPRECATED. Use byteStride instead.
  5523. * @returns the stride in float32 units
  5524. */
  5525. getStrideSize(): number;
  5526. /**
  5527. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5528. * @param data defines the data to store
  5529. */
  5530. create(data?: Nullable<DataArray>): void;
  5531. /** @hidden */ rebuild(): void;
  5532. /**
  5533. * Update current buffer data
  5534. * @param data defines the data to store
  5535. */
  5536. update(data: DataArray): void;
  5537. /**
  5538. * Updates the data directly.
  5539. * @param data the new data
  5540. * @param offset the new offset
  5541. * @param vertexCount the vertex count (optional)
  5542. * @param useBytes set to true if the offset is in bytes
  5543. */
  5544. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5545. /**
  5546. * Release all resources
  5547. */
  5548. dispose(): void;
  5549. }
  5550. /**
  5551. * Specialized buffer used to store vertex data
  5552. */
  5553. export class VertexBuffer {
  5554. /** @hidden */ buffer: Buffer;
  5555. private _kind;
  5556. private _size;
  5557. private _ownsBuffer;
  5558. private _instanced;
  5559. private _instanceDivisor;
  5560. /**
  5561. * The byte type.
  5562. */
  5563. static readonly BYTE: number;
  5564. /**
  5565. * The unsigned byte type.
  5566. */
  5567. static readonly UNSIGNED_BYTE: number;
  5568. /**
  5569. * The short type.
  5570. */
  5571. static readonly SHORT: number;
  5572. /**
  5573. * The unsigned short type.
  5574. */
  5575. static readonly UNSIGNED_SHORT: number;
  5576. /**
  5577. * The integer type.
  5578. */
  5579. static readonly INT: number;
  5580. /**
  5581. * The unsigned integer type.
  5582. */
  5583. static readonly UNSIGNED_INT: number;
  5584. /**
  5585. * The float type.
  5586. */
  5587. static readonly FLOAT: number;
  5588. /**
  5589. * Gets or sets the instance divisor when in instanced mode
  5590. */
  5591. instanceDivisor: number;
  5592. /**
  5593. * Gets the byte stride.
  5594. */
  5595. readonly byteStride: number;
  5596. /**
  5597. * Gets the byte offset.
  5598. */
  5599. readonly byteOffset: number;
  5600. /**
  5601. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5602. */
  5603. readonly normalized: boolean;
  5604. /**
  5605. * Gets the data type of each component in the array.
  5606. */
  5607. readonly type: number;
  5608. /**
  5609. * Constructor
  5610. * @param engine the engine
  5611. * @param data the data to use for this vertex buffer
  5612. * @param kind the vertex buffer kind
  5613. * @param updatable whether the data is updatable
  5614. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5615. * @param stride the stride (optional)
  5616. * @param instanced whether the buffer is instanced (optional)
  5617. * @param offset the offset of the data (optional)
  5618. * @param size the number of components (optional)
  5619. * @param type the type of the component (optional)
  5620. * @param normalized whether the data contains normalized data (optional)
  5621. * @param useBytes set to true if stride and offset are in bytes (optional)
  5622. */
  5623. 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);
  5624. /** @hidden */ rebuild(): void;
  5625. /**
  5626. * Returns the kind of the VertexBuffer (string)
  5627. * @returns a string
  5628. */
  5629. getKind(): string;
  5630. /**
  5631. * Gets a boolean indicating if the VertexBuffer is updatable?
  5632. * @returns true if the buffer is updatable
  5633. */
  5634. isUpdatable(): boolean;
  5635. /**
  5636. * Gets current buffer's data
  5637. * @returns a DataArray or null
  5638. */
  5639. getData(): Nullable<DataArray>;
  5640. /**
  5641. * Gets underlying native buffer
  5642. * @returns underlying native buffer
  5643. */
  5644. getBuffer(): Nullable<DataBuffer>;
  5645. /**
  5646. * Gets the stride in float32 units (i.e. byte stride / 4).
  5647. * May not be an integer if the byte stride is not divisible by 4.
  5648. * DEPRECATED. Use byteStride instead.
  5649. * @returns the stride in float32 units
  5650. */
  5651. getStrideSize(): number;
  5652. /**
  5653. * Returns the offset as a multiple of the type byte length.
  5654. * DEPRECATED. Use byteOffset instead.
  5655. * @returns the offset in bytes
  5656. */
  5657. getOffset(): number;
  5658. /**
  5659. * Returns the number of components per vertex attribute (integer)
  5660. * @returns the size in float
  5661. */
  5662. getSize(): number;
  5663. /**
  5664. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5665. * @returns true if this buffer is instanced
  5666. */
  5667. getIsInstanced(): boolean;
  5668. /**
  5669. * Returns the instancing divisor, zero for non-instanced (integer).
  5670. * @returns a number
  5671. */
  5672. getInstanceDivisor(): number;
  5673. /**
  5674. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5675. * @param data defines the data to store
  5676. */
  5677. create(data?: DataArray): void;
  5678. /**
  5679. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5680. * This function will create a new buffer if the current one is not updatable
  5681. * @param data defines the data to store
  5682. */
  5683. update(data: DataArray): void;
  5684. /**
  5685. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5686. * Returns the directly updated WebGLBuffer.
  5687. * @param data the new data
  5688. * @param offset the new offset
  5689. * @param useBytes set to true if the offset is in bytes
  5690. */
  5691. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5692. /**
  5693. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5694. */
  5695. dispose(): void;
  5696. /**
  5697. * Enumerates each value of this vertex buffer as numbers.
  5698. * @param count the number of values to enumerate
  5699. * @param callback the callback function called for each value
  5700. */
  5701. forEach(count: number, callback: (value: number, index: number) => void): void;
  5702. /**
  5703. * Positions
  5704. */
  5705. static readonly PositionKind: string;
  5706. /**
  5707. * Normals
  5708. */
  5709. static readonly NormalKind: string;
  5710. /**
  5711. * Tangents
  5712. */
  5713. static readonly TangentKind: string;
  5714. /**
  5715. * Texture coordinates
  5716. */
  5717. static readonly UVKind: string;
  5718. /**
  5719. * Texture coordinates 2
  5720. */
  5721. static readonly UV2Kind: string;
  5722. /**
  5723. * Texture coordinates 3
  5724. */
  5725. static readonly UV3Kind: string;
  5726. /**
  5727. * Texture coordinates 4
  5728. */
  5729. static readonly UV4Kind: string;
  5730. /**
  5731. * Texture coordinates 5
  5732. */
  5733. static readonly UV5Kind: string;
  5734. /**
  5735. * Texture coordinates 6
  5736. */
  5737. static readonly UV6Kind: string;
  5738. /**
  5739. * Colors
  5740. */
  5741. static readonly ColorKind: string;
  5742. /**
  5743. * Matrix indices (for bones)
  5744. */
  5745. static readonly MatricesIndicesKind: string;
  5746. /**
  5747. * Matrix weights (for bones)
  5748. */
  5749. static readonly MatricesWeightsKind: string;
  5750. /**
  5751. * Additional matrix indices (for bones)
  5752. */
  5753. static readonly MatricesIndicesExtraKind: string;
  5754. /**
  5755. * Additional matrix weights (for bones)
  5756. */
  5757. static readonly MatricesWeightsExtraKind: string;
  5758. /**
  5759. * Deduces the stride given a kind.
  5760. * @param kind The kind string to deduce
  5761. * @returns The deduced stride
  5762. */
  5763. static DeduceStride(kind: string): number;
  5764. /**
  5765. * Gets the byte length of the given type.
  5766. * @param type the type
  5767. * @returns the number of bytes
  5768. */
  5769. static GetTypeByteLength(type: number): number;
  5770. /**
  5771. * Enumerates each value of the given parameters as numbers.
  5772. * @param data the data to enumerate
  5773. * @param byteOffset the byte offset of the data
  5774. * @param byteStride the byte stride of the data
  5775. * @param componentCount the number of components per element
  5776. * @param componentType the type of the component
  5777. * @param count the total number of components
  5778. * @param normalized whether the data is normalized
  5779. * @param callback the callback function called for each value
  5780. */
  5781. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5782. private static _GetFloatValue;
  5783. }
  5784. }
  5785. declare module BABYLON {
  5786. /**
  5787. * Class representing spherical harmonics coefficients to the 3rd degree
  5788. */
  5789. export class SphericalHarmonics {
  5790. /**
  5791. * Defines whether or not the harmonics have been prescaled for rendering.
  5792. */
  5793. preScaled: boolean;
  5794. /**
  5795. * The l0,0 coefficients of the spherical harmonics
  5796. */
  5797. l00: Vector3;
  5798. /**
  5799. * The l1,-1 coefficients of the spherical harmonics
  5800. */
  5801. l1_1: Vector3;
  5802. /**
  5803. * The l1,0 coefficients of the spherical harmonics
  5804. */
  5805. l10: Vector3;
  5806. /**
  5807. * The l1,1 coefficients of the spherical harmonics
  5808. */
  5809. l11: Vector3;
  5810. /**
  5811. * The l2,-2 coefficients of the spherical harmonics
  5812. */
  5813. l2_2: Vector3;
  5814. /**
  5815. * The l2,-1 coefficients of the spherical harmonics
  5816. */
  5817. l2_1: Vector3;
  5818. /**
  5819. * The l2,0 coefficients of the spherical harmonics
  5820. */
  5821. l20: Vector3;
  5822. /**
  5823. * The l2,1 coefficients of the spherical harmonics
  5824. */
  5825. l21: Vector3;
  5826. /**
  5827. * The l2,2 coefficients of the spherical harmonics
  5828. */
  5829. l22: Vector3;
  5830. /**
  5831. * Adds a light to the spherical harmonics
  5832. * @param direction the direction of the light
  5833. * @param color the color of the light
  5834. * @param deltaSolidAngle the delta solid angle of the light
  5835. */
  5836. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5837. /**
  5838. * Scales the spherical harmonics by the given amount
  5839. * @param scale the amount to scale
  5840. */
  5841. scaleInPlace(scale: number): void;
  5842. /**
  5843. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5844. *
  5845. * ```
  5846. * E_lm = A_l * L_lm
  5847. * ```
  5848. *
  5849. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5850. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5851. * the scaling factors are given in equation 9.
  5852. */
  5853. convertIncidentRadianceToIrradiance(): void;
  5854. /**
  5855. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5856. *
  5857. * ```
  5858. * L = (1/pi) * E * rho
  5859. * ```
  5860. *
  5861. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5862. */
  5863. convertIrradianceToLambertianRadiance(): void;
  5864. /**
  5865. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5866. * required operations at run time.
  5867. *
  5868. * This is simply done by scaling back the SH with Ylm constants parameter.
  5869. * The trigonometric part being applied by the shader at run time.
  5870. */
  5871. preScaleForRendering(): void;
  5872. /**
  5873. * Constructs a spherical harmonics from an array.
  5874. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5875. * @returns the spherical harmonics
  5876. */
  5877. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5878. /**
  5879. * Gets the spherical harmonics from polynomial
  5880. * @param polynomial the spherical polynomial
  5881. * @returns the spherical harmonics
  5882. */
  5883. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5884. }
  5885. /**
  5886. * Class representing spherical polynomial coefficients to the 3rd degree
  5887. */
  5888. export class SphericalPolynomial {
  5889. private _harmonics;
  5890. /**
  5891. * The spherical harmonics used to create the polynomials.
  5892. */
  5893. readonly preScaledHarmonics: SphericalHarmonics;
  5894. /**
  5895. * The x coefficients of the spherical polynomial
  5896. */
  5897. x: Vector3;
  5898. /**
  5899. * The y coefficients of the spherical polynomial
  5900. */
  5901. y: Vector3;
  5902. /**
  5903. * The z coefficients of the spherical polynomial
  5904. */
  5905. z: Vector3;
  5906. /**
  5907. * The xx coefficients of the spherical polynomial
  5908. */
  5909. xx: Vector3;
  5910. /**
  5911. * The yy coefficients of the spherical polynomial
  5912. */
  5913. yy: Vector3;
  5914. /**
  5915. * The zz coefficients of the spherical polynomial
  5916. */
  5917. zz: Vector3;
  5918. /**
  5919. * The xy coefficients of the spherical polynomial
  5920. */
  5921. xy: Vector3;
  5922. /**
  5923. * The yz coefficients of the spherical polynomial
  5924. */
  5925. yz: Vector3;
  5926. /**
  5927. * The zx coefficients of the spherical polynomial
  5928. */
  5929. zx: Vector3;
  5930. /**
  5931. * Adds an ambient color to the spherical polynomial
  5932. * @param color the color to add
  5933. */
  5934. addAmbient(color: Color3): void;
  5935. /**
  5936. * Scales the spherical polynomial by the given amount
  5937. * @param scale the amount to scale
  5938. */
  5939. scaleInPlace(scale: number): void;
  5940. /**
  5941. * Gets the spherical polynomial from harmonics
  5942. * @param harmonics the spherical harmonics
  5943. * @returns the spherical polynomial
  5944. */
  5945. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5946. /**
  5947. * Constructs a spherical polynomial from an array.
  5948. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5949. * @returns the spherical polynomial
  5950. */
  5951. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5952. }
  5953. }
  5954. declare module BABYLON {
  5955. /**
  5956. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5957. */
  5958. export interface CubeMapInfo {
  5959. /**
  5960. * The pixel array for the front face.
  5961. * This is stored in format, left to right, up to down format.
  5962. */
  5963. front: Nullable<ArrayBufferView>;
  5964. /**
  5965. * The pixel array for the back face.
  5966. * This is stored in format, left to right, up to down format.
  5967. */
  5968. back: Nullable<ArrayBufferView>;
  5969. /**
  5970. * The pixel array for the left face.
  5971. * This is stored in format, left to right, up to down format.
  5972. */
  5973. left: Nullable<ArrayBufferView>;
  5974. /**
  5975. * The pixel array for the right face.
  5976. * This is stored in format, left to right, up to down format.
  5977. */
  5978. right: Nullable<ArrayBufferView>;
  5979. /**
  5980. * The pixel array for the up face.
  5981. * This is stored in format, left to right, up to down format.
  5982. */
  5983. up: Nullable<ArrayBufferView>;
  5984. /**
  5985. * The pixel array for the down face.
  5986. * This is stored in format, left to right, up to down format.
  5987. */
  5988. down: Nullable<ArrayBufferView>;
  5989. /**
  5990. * The size of the cubemap stored.
  5991. *
  5992. * Each faces will be size * size pixels.
  5993. */
  5994. size: number;
  5995. /**
  5996. * The format of the texture.
  5997. *
  5998. * RGBA, RGB.
  5999. */
  6000. format: number;
  6001. /**
  6002. * The type of the texture data.
  6003. *
  6004. * UNSIGNED_INT, FLOAT.
  6005. */
  6006. type: number;
  6007. /**
  6008. * Specifies whether the texture is in gamma space.
  6009. */
  6010. gammaSpace: boolean;
  6011. }
  6012. /**
  6013. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6014. */
  6015. export class PanoramaToCubeMapTools {
  6016. private static FACE_FRONT;
  6017. private static FACE_BACK;
  6018. private static FACE_RIGHT;
  6019. private static FACE_LEFT;
  6020. private static FACE_DOWN;
  6021. private static FACE_UP;
  6022. /**
  6023. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6024. *
  6025. * @param float32Array The source data.
  6026. * @param inputWidth The width of the input panorama.
  6027. * @param inputHeight The height of the input panorama.
  6028. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6029. * @return The cubemap data
  6030. */
  6031. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6032. private static CreateCubemapTexture;
  6033. private static CalcProjectionSpherical;
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Helper class dealing with the extraction of spherical polynomial dataArray
  6039. * from a cube map.
  6040. */
  6041. export class CubeMapToSphericalPolynomialTools {
  6042. private static FileFaces;
  6043. /**
  6044. * Converts a texture to the according Spherical Polynomial data.
  6045. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6046. *
  6047. * @param texture The texture to extract the information from.
  6048. * @return The Spherical Polynomial data.
  6049. */
  6050. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6051. /**
  6052. * Converts a cubemap to the according Spherical Polynomial data.
  6053. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6054. *
  6055. * @param cubeInfo The Cube map to extract the information from.
  6056. * @return The Spherical Polynomial data.
  6057. */
  6058. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6064. * during the life time of the application.
  6065. */
  6066. export class EngineStore {
  6067. /** Gets the list of created engines */
  6068. static Instances: Engine[];
  6069. /**
  6070. * Gets the latest created engine
  6071. */
  6072. static readonly LastCreatedEngine: Nullable<Engine>;
  6073. /**
  6074. * Gets the latest created scene
  6075. */
  6076. static readonly LastCreatedScene: Nullable<Scene>;
  6077. }
  6078. }
  6079. declare module BABYLON {
  6080. /**
  6081. * Define options used to create a render target texture
  6082. */
  6083. export class RenderTargetCreationOptions {
  6084. /**
  6085. * Specifies is mipmaps must be generated
  6086. */
  6087. generateMipMaps?: boolean;
  6088. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6089. generateDepthBuffer?: boolean;
  6090. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6091. generateStencilBuffer?: boolean;
  6092. /** Defines texture type (int by default) */
  6093. type?: number;
  6094. /** Defines sampling mode (trilinear by default) */
  6095. samplingMode?: number;
  6096. /** Defines format (RGBA by default) */
  6097. format?: number;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * @hidden
  6103. **/
  6104. export class _AlphaState {
  6105. private _isAlphaBlendDirty;
  6106. private _isBlendFunctionParametersDirty;
  6107. private _isBlendEquationParametersDirty;
  6108. private _isBlendConstantsDirty;
  6109. private _alphaBlend;
  6110. private _blendFunctionParameters;
  6111. private _blendEquationParameters;
  6112. private _blendConstants;
  6113. /**
  6114. * Initializes the state.
  6115. */
  6116. constructor();
  6117. readonly isDirty: boolean;
  6118. alphaBlend: boolean;
  6119. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6120. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6121. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6122. reset(): void;
  6123. apply(gl: WebGLRenderingContext): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @hidden
  6129. **/
  6130. export class _DepthCullingState {
  6131. private _isDepthTestDirty;
  6132. private _isDepthMaskDirty;
  6133. private _isDepthFuncDirty;
  6134. private _isCullFaceDirty;
  6135. private _isCullDirty;
  6136. private _isZOffsetDirty;
  6137. private _isFrontFaceDirty;
  6138. private _depthTest;
  6139. private _depthMask;
  6140. private _depthFunc;
  6141. private _cull;
  6142. private _cullFace;
  6143. private _zOffset;
  6144. private _frontFace;
  6145. /**
  6146. * Initializes the state.
  6147. */
  6148. constructor();
  6149. readonly isDirty: boolean;
  6150. zOffset: number;
  6151. cullFace: Nullable<number>;
  6152. cull: Nullable<boolean>;
  6153. depthFunc: Nullable<number>;
  6154. depthMask: boolean;
  6155. depthTest: boolean;
  6156. frontFace: Nullable<number>;
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module BABYLON {
  6162. /**
  6163. * @hidden
  6164. **/
  6165. export class _StencilState {
  6166. /** 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 */
  6167. static readonly ALWAYS: number;
  6168. /** Passed to stencilOperation to specify that stencil value must be kept */
  6169. static readonly KEEP: number;
  6170. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6171. static readonly REPLACE: number;
  6172. private _isStencilTestDirty;
  6173. private _isStencilMaskDirty;
  6174. private _isStencilFuncDirty;
  6175. private _isStencilOpDirty;
  6176. private _stencilTest;
  6177. private _stencilMask;
  6178. private _stencilFunc;
  6179. private _stencilFuncRef;
  6180. private _stencilFuncMask;
  6181. private _stencilOpStencilFail;
  6182. private _stencilOpDepthFail;
  6183. private _stencilOpStencilDepthPass;
  6184. readonly isDirty: boolean;
  6185. stencilFunc: number;
  6186. stencilFuncRef: number;
  6187. stencilFuncMask: number;
  6188. stencilOpStencilFail: number;
  6189. stencilOpDepthFail: number;
  6190. stencilOpStencilDepthPass: number;
  6191. stencilMask: number;
  6192. stencilTest: boolean;
  6193. constructor();
  6194. reset(): void;
  6195. apply(gl: WebGLRenderingContext): void;
  6196. }
  6197. }
  6198. declare module BABYLON {
  6199. /**
  6200. * @hidden
  6201. **/
  6202. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6203. }
  6204. }
  6205. declare module BABYLON {
  6206. /**
  6207. * Class used to store data associated with WebGL texture data for the engine
  6208. * This class should not be used directly
  6209. */
  6210. export class InternalTexture {
  6211. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6212. /**
  6213. * The source of the texture data is unknown
  6214. */
  6215. static DATASOURCE_UNKNOWN: number;
  6216. /**
  6217. * Texture data comes from an URL
  6218. */
  6219. static DATASOURCE_URL: number;
  6220. /**
  6221. * Texture data is only used for temporary storage
  6222. */
  6223. static DATASOURCE_TEMP: number;
  6224. /**
  6225. * Texture data comes from raw data (ArrayBuffer)
  6226. */
  6227. static DATASOURCE_RAW: number;
  6228. /**
  6229. * Texture content is dynamic (video or dynamic texture)
  6230. */
  6231. static DATASOURCE_DYNAMIC: number;
  6232. /**
  6233. * Texture content is generated by rendering to it
  6234. */
  6235. static DATASOURCE_RENDERTARGET: number;
  6236. /**
  6237. * Texture content is part of a multi render target process
  6238. */
  6239. static DATASOURCE_MULTIRENDERTARGET: number;
  6240. /**
  6241. * Texture data comes from a cube data file
  6242. */
  6243. static DATASOURCE_CUBE: number;
  6244. /**
  6245. * Texture data comes from a raw cube data
  6246. */
  6247. static DATASOURCE_CUBERAW: number;
  6248. /**
  6249. * Texture data come from a prefiltered cube data file
  6250. */
  6251. static DATASOURCE_CUBEPREFILTERED: number;
  6252. /**
  6253. * Texture content is raw 3D data
  6254. */
  6255. static DATASOURCE_RAW3D: number;
  6256. /**
  6257. * Texture content is a depth texture
  6258. */
  6259. static DATASOURCE_DEPTHTEXTURE: number;
  6260. /**
  6261. * Texture data comes from a raw cube data encoded with RGBD
  6262. */
  6263. static DATASOURCE_CUBERAW_RGBD: number;
  6264. /**
  6265. * Defines if the texture is ready
  6266. */
  6267. isReady: boolean;
  6268. /**
  6269. * Defines if the texture is a cube texture
  6270. */
  6271. isCube: boolean;
  6272. /**
  6273. * Defines if the texture contains 3D data
  6274. */
  6275. is3D: boolean;
  6276. /**
  6277. * Defines if the texture contains multiview data
  6278. */
  6279. isMultiview: boolean;
  6280. /**
  6281. * Gets the URL used to load this texture
  6282. */
  6283. url: string;
  6284. /**
  6285. * Gets the sampling mode of the texture
  6286. */
  6287. samplingMode: number;
  6288. /**
  6289. * Gets a boolean indicating if the texture needs mipmaps generation
  6290. */
  6291. generateMipMaps: boolean;
  6292. /**
  6293. * Gets the number of samples used by the texture (WebGL2+ only)
  6294. */
  6295. samples: number;
  6296. /**
  6297. * Gets the type of the texture (int, float...)
  6298. */
  6299. type: number;
  6300. /**
  6301. * Gets the format of the texture (RGB, RGBA...)
  6302. */
  6303. format: number;
  6304. /**
  6305. * Observable called when the texture is loaded
  6306. */
  6307. onLoadedObservable: Observable<InternalTexture>;
  6308. /**
  6309. * Gets the width of the texture
  6310. */
  6311. width: number;
  6312. /**
  6313. * Gets the height of the texture
  6314. */
  6315. height: number;
  6316. /**
  6317. * Gets the depth of the texture
  6318. */
  6319. depth: number;
  6320. /**
  6321. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseWidth: number;
  6324. /**
  6325. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseHeight: number;
  6328. /**
  6329. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6330. */
  6331. baseDepth: number;
  6332. /**
  6333. * Gets a boolean indicating if the texture is inverted on Y axis
  6334. */
  6335. invertY: boolean;
  6336. /** @hidden */ invertVScale: boolean;
  6337. /** @hidden */ associatedChannel: number;
  6338. /** @hidden */ dataSource: number;
  6339. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6341. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6342. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6343. /** @hidden */ size: number;
  6344. /** @hidden */ extension: string;
  6345. /** @hidden */ files: Nullable<string[]>;
  6346. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  6347. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  6348. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6349. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6350. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6351. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6352. /** @hidden */ attachments: Nullable<number[]>;
  6353. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6354. /** @hidden */ cachedWrapU: Nullable<number>;
  6355. /** @hidden */ cachedWrapV: Nullable<number>;
  6356. /** @hidden */ cachedWrapR: Nullable<number>;
  6357. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6358. /** @hidden */ isDisabled: boolean;
  6359. /** @hidden */ compression: Nullable<string>;
  6360. /** @hidden */ generateStencilBuffer: boolean;
  6361. /** @hidden */ generateDepthBuffer: boolean;
  6362. /** @hidden */ comparisonFunction: number;
  6363. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6364. /** @hidden */ lodGenerationScale: number;
  6365. /** @hidden */ lodGenerationOffset: number;
  6366. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6367. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6368. /** @hidden */ lodTextureHigh: Nullable<BaseTexture>;
  6369. /** @hidden */ lodTextureMid: Nullable<BaseTexture>;
  6370. /** @hidden */ lodTextureLow: Nullable<BaseTexture>;
  6371. /** @hidden */ isRGBD: boolean;
  6372. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6373. /** @hidden */ references: number;
  6374. private _engine;
  6375. /**
  6376. * Gets the Engine the texture belongs to.
  6377. * @returns The babylon engine
  6378. */
  6379. getEngine(): Engine;
  6380. /**
  6381. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6382. */
  6383. readonly dataSource: number;
  6384. /**
  6385. * Creates a new InternalTexture
  6386. * @param engine defines the engine to use
  6387. * @param dataSource defines the type of data that will be used
  6388. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6389. */
  6390. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6391. /**
  6392. * Increments the number of references (ie. the number of Texture that point to it)
  6393. */
  6394. incrementReferences(): void;
  6395. /**
  6396. * Change the size of the texture (not the size of the content)
  6397. * @param width defines the new width
  6398. * @param height defines the new height
  6399. * @param depth defines the new depth (1 by default)
  6400. */
  6401. updateSize(width: int, height: int, depth?: int): void;
  6402. /** @hidden */ rebuild(): void;
  6403. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6404. /**
  6405. * Dispose the current allocated resources
  6406. */
  6407. dispose(): void;
  6408. }
  6409. }
  6410. declare module BABYLON {
  6411. /**
  6412. * This represents the main contract an easing function should follow.
  6413. * Easing functions are used throughout the animation system.
  6414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6415. */
  6416. export interface IEasingFunction {
  6417. /**
  6418. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6419. * of the easing function.
  6420. * The link below provides some of the most common examples of easing functions.
  6421. * @see https://easings.net/
  6422. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6423. * @returns the corresponding value on the curve defined by the easing function
  6424. */
  6425. ease(gradient: number): number;
  6426. }
  6427. /**
  6428. * Base class used for every default easing function.
  6429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6430. */
  6431. export class EasingFunction implements IEasingFunction {
  6432. /**
  6433. * Interpolation follows the mathematical formula associated with the easing function.
  6434. */
  6435. static readonly EASINGMODE_EASEIN: number;
  6436. /**
  6437. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6438. */
  6439. static readonly EASINGMODE_EASEOUT: number;
  6440. /**
  6441. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6442. */
  6443. static readonly EASINGMODE_EASEINOUT: number;
  6444. private _easingMode;
  6445. /**
  6446. * Sets the easing mode of the current function.
  6447. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6448. */
  6449. setEasingMode(easingMode: number): void;
  6450. /**
  6451. * Gets the current easing mode.
  6452. * @returns the easing mode
  6453. */
  6454. getEasingMode(): number;
  6455. /**
  6456. * @hidden
  6457. */
  6458. easeInCore(gradient: number): number;
  6459. /**
  6460. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6461. * of the easing function.
  6462. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6463. * @returns the corresponding value on the curve defined by the easing function
  6464. */
  6465. ease(gradient: number): number;
  6466. }
  6467. /**
  6468. * Easing function with a circle shape (see link below).
  6469. * @see https://easings.net/#easeInCirc
  6470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6471. */
  6472. export class CircleEase extends EasingFunction implements IEasingFunction {
  6473. /** @hidden */
  6474. easeInCore(gradient: number): number;
  6475. }
  6476. /**
  6477. * Easing function with a ease back shape (see link below).
  6478. * @see https://easings.net/#easeInBack
  6479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6480. */
  6481. export class BackEase extends EasingFunction implements IEasingFunction {
  6482. /** Defines the amplitude of the function */
  6483. amplitude: number;
  6484. /**
  6485. * Instantiates a back ease easing
  6486. * @see https://easings.net/#easeInBack
  6487. * @param amplitude Defines the amplitude of the function
  6488. */
  6489. constructor(
  6490. /** Defines the amplitude of the function */
  6491. amplitude?: number);
  6492. /** @hidden */
  6493. easeInCore(gradient: number): number;
  6494. }
  6495. /**
  6496. * Easing function with a bouncing shape (see link below).
  6497. * @see https://easings.net/#easeInBounce
  6498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6499. */
  6500. export class BounceEase extends EasingFunction implements IEasingFunction {
  6501. /** Defines the number of bounces */
  6502. bounces: number;
  6503. /** Defines the amplitude of the bounce */
  6504. bounciness: number;
  6505. /**
  6506. * Instantiates a bounce easing
  6507. * @see https://easings.net/#easeInBounce
  6508. * @param bounces Defines the number of bounces
  6509. * @param bounciness Defines the amplitude of the bounce
  6510. */
  6511. constructor(
  6512. /** Defines the number of bounces */
  6513. bounces?: number,
  6514. /** Defines the amplitude of the bounce */
  6515. bounciness?: number);
  6516. /** @hidden */
  6517. easeInCore(gradient: number): number;
  6518. }
  6519. /**
  6520. * Easing function with a power of 3 shape (see link below).
  6521. * @see https://easings.net/#easeInCubic
  6522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6523. */
  6524. export class CubicEase extends EasingFunction implements IEasingFunction {
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with an elastic shape (see link below).
  6530. * @see https://easings.net/#easeInElastic
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6534. /** Defines the number of oscillations*/
  6535. oscillations: number;
  6536. /** Defines the amplitude of the oscillations*/
  6537. springiness: number;
  6538. /**
  6539. * Instantiates an elastic easing function
  6540. * @see https://easings.net/#easeInElastic
  6541. * @param oscillations Defines the number of oscillations
  6542. * @param springiness Defines the amplitude of the oscillations
  6543. */
  6544. constructor(
  6545. /** Defines the number of oscillations*/
  6546. oscillations?: number,
  6547. /** Defines the amplitude of the oscillations*/
  6548. springiness?: number);
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with an exponential shape (see link below).
  6554. * @see https://easings.net/#easeInExpo
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6558. /** Defines the exponent of the function */
  6559. exponent: number;
  6560. /**
  6561. * Instantiates an exponential easing function
  6562. * @see https://easings.net/#easeInExpo
  6563. * @param exponent Defines the exponent of the function
  6564. */
  6565. constructor(
  6566. /** Defines the exponent of the function */
  6567. exponent?: number);
  6568. /** @hidden */
  6569. easeInCore(gradient: number): number;
  6570. }
  6571. /**
  6572. * Easing function with a power shape (see link below).
  6573. * @see https://easings.net/#easeInQuad
  6574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6575. */
  6576. export class PowerEase extends EasingFunction implements IEasingFunction {
  6577. /** Defines the power of the function */
  6578. power: number;
  6579. /**
  6580. * Instantiates an power base easing function
  6581. * @see https://easings.net/#easeInQuad
  6582. * @param power Defines the power of the function
  6583. */
  6584. constructor(
  6585. /** Defines the power of the function */
  6586. power?: number);
  6587. /** @hidden */
  6588. easeInCore(gradient: number): number;
  6589. }
  6590. /**
  6591. * Easing function with a power of 2 shape (see link below).
  6592. * @see https://easings.net/#easeInQuad
  6593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6594. */
  6595. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6596. /** @hidden */
  6597. easeInCore(gradient: number): number;
  6598. }
  6599. /**
  6600. * Easing function with a power of 4 shape (see link below).
  6601. * @see https://easings.net/#easeInQuart
  6602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6603. */
  6604. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6605. /** @hidden */
  6606. easeInCore(gradient: number): number;
  6607. }
  6608. /**
  6609. * Easing function with a power of 5 shape (see link below).
  6610. * @see https://easings.net/#easeInQuint
  6611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6612. */
  6613. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6614. /** @hidden */
  6615. easeInCore(gradient: number): number;
  6616. }
  6617. /**
  6618. * Easing function with a sin shape (see link below).
  6619. * @see https://easings.net/#easeInSine
  6620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6621. */
  6622. export class SineEase extends EasingFunction implements IEasingFunction {
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a bezier shape (see link below).
  6628. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6632. /** Defines the x component of the start tangent in the bezier curve */
  6633. x1: number;
  6634. /** Defines the y component of the start tangent in the bezier curve */
  6635. y1: number;
  6636. /** Defines the x component of the end tangent in the bezier curve */
  6637. x2: number;
  6638. /** Defines the y component of the end tangent in the bezier curve */
  6639. y2: number;
  6640. /**
  6641. * Instantiates a bezier function
  6642. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6643. * @param x1 Defines the x component of the start tangent in the bezier curve
  6644. * @param y1 Defines the y component of the start tangent in the bezier curve
  6645. * @param x2 Defines the x component of the end tangent in the bezier curve
  6646. * @param y2 Defines the y component of the end tangent in the bezier curve
  6647. */
  6648. constructor(
  6649. /** Defines the x component of the start tangent in the bezier curve */
  6650. x1?: number,
  6651. /** Defines the y component of the start tangent in the bezier curve */
  6652. y1?: number,
  6653. /** Defines the x component of the end tangent in the bezier curve */
  6654. x2?: number,
  6655. /** Defines the y component of the end tangent in the bezier curve */
  6656. y2?: number);
  6657. /** @hidden */
  6658. easeInCore(gradient: number): number;
  6659. }
  6660. }
  6661. declare module BABYLON {
  6662. /**
  6663. * Defines an interface which represents an animation key frame
  6664. */
  6665. export interface IAnimationKey {
  6666. /**
  6667. * Frame of the key frame
  6668. */
  6669. frame: number;
  6670. /**
  6671. * Value at the specifies key frame
  6672. */
  6673. value: any;
  6674. /**
  6675. * The input tangent for the cubic hermite spline
  6676. */
  6677. inTangent?: any;
  6678. /**
  6679. * The output tangent for the cubic hermite spline
  6680. */
  6681. outTangent?: any;
  6682. /**
  6683. * The animation interpolation type
  6684. */
  6685. interpolation?: AnimationKeyInterpolation;
  6686. }
  6687. /**
  6688. * Enum for the animation key frame interpolation type
  6689. */
  6690. export enum AnimationKeyInterpolation {
  6691. /**
  6692. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6693. */
  6694. STEP = 1
  6695. }
  6696. }
  6697. declare module BABYLON {
  6698. /**
  6699. * Represents the range of an animation
  6700. */
  6701. export class AnimationRange {
  6702. /**The name of the animation range**/
  6703. name: string;
  6704. /**The starting frame of the animation */
  6705. from: number;
  6706. /**The ending frame of the animation*/
  6707. to: number;
  6708. /**
  6709. * Initializes the range of an animation
  6710. * @param name The name of the animation range
  6711. * @param from The starting frame of the animation
  6712. * @param to The ending frame of the animation
  6713. */
  6714. constructor(
  6715. /**The name of the animation range**/
  6716. name: string,
  6717. /**The starting frame of the animation */
  6718. from: number,
  6719. /**The ending frame of the animation*/
  6720. to: number);
  6721. /**
  6722. * Makes a copy of the animation range
  6723. * @returns A copy of the animation range
  6724. */
  6725. clone(): AnimationRange;
  6726. }
  6727. }
  6728. declare module BABYLON {
  6729. /**
  6730. * Composed of a frame, and an action function
  6731. */
  6732. export class AnimationEvent {
  6733. /** The frame for which the event is triggered **/
  6734. frame: number;
  6735. /** The event to perform when triggered **/
  6736. action: (currentFrame: number) => void;
  6737. /** Specifies if the event should be triggered only once**/
  6738. onlyOnce?: boolean | undefined;
  6739. /**
  6740. * Specifies if the animation event is done
  6741. */
  6742. isDone: boolean;
  6743. /**
  6744. * Initializes the animation event
  6745. * @param frame The frame for which the event is triggered
  6746. * @param action The event to perform when triggered
  6747. * @param onlyOnce Specifies if the event should be triggered only once
  6748. */
  6749. constructor(
  6750. /** The frame for which the event is triggered **/
  6751. frame: number,
  6752. /** The event to perform when triggered **/
  6753. action: (currentFrame: number) => void,
  6754. /** Specifies if the event should be triggered only once**/
  6755. onlyOnce?: boolean | undefined);
  6756. /** @hidden */ clone(): AnimationEvent;
  6757. }
  6758. }
  6759. declare module BABYLON {
  6760. /**
  6761. * Interface used to define a behavior
  6762. */
  6763. export interface Behavior<T> {
  6764. /** gets or sets behavior's name */
  6765. name: string;
  6766. /**
  6767. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6768. */
  6769. init(): void;
  6770. /**
  6771. * Called when the behavior is attached to a target
  6772. * @param target defines the target where the behavior is attached to
  6773. */
  6774. attach(target: T): void;
  6775. /**
  6776. * Called when the behavior is detached from its target
  6777. */
  6778. detach(): void;
  6779. }
  6780. /**
  6781. * Interface implemented by classes supporting behaviors
  6782. */
  6783. export interface IBehaviorAware<T> {
  6784. /**
  6785. * Attach a behavior
  6786. * @param behavior defines the behavior to attach
  6787. * @returns the current host
  6788. */
  6789. addBehavior(behavior: Behavior<T>): T;
  6790. /**
  6791. * Remove a behavior from the current object
  6792. * @param behavior defines the behavior to detach
  6793. * @returns the current host
  6794. */
  6795. removeBehavior(behavior: Behavior<T>): T;
  6796. /**
  6797. * Gets a behavior using its name to search
  6798. * @param name defines the name to search
  6799. * @returns the behavior or null if not found
  6800. */
  6801. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /**
  6806. * @hidden
  6807. */
  6808. export class IntersectionInfo {
  6809. bu: Nullable<number>;
  6810. bv: Nullable<number>;
  6811. distance: number;
  6812. faceId: number;
  6813. subMeshId: number;
  6814. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * Class used to store bounding sphere information
  6820. */
  6821. export class BoundingSphere {
  6822. /**
  6823. * Gets the center of the bounding sphere in local space
  6824. */
  6825. readonly center: Vector3;
  6826. /**
  6827. * Radius of the bounding sphere in local space
  6828. */
  6829. radius: number;
  6830. /**
  6831. * Gets the center of the bounding sphere in world space
  6832. */
  6833. readonly centerWorld: Vector3;
  6834. /**
  6835. * Radius of the bounding sphere in world space
  6836. */
  6837. radiusWorld: number;
  6838. /**
  6839. * Gets the minimum vector in local space
  6840. */
  6841. readonly minimum: Vector3;
  6842. /**
  6843. * Gets the maximum vector in local space
  6844. */
  6845. readonly maximum: Vector3;
  6846. private _worldMatrix;
  6847. private static readonly TmpVector3;
  6848. /**
  6849. * Creates a new bounding sphere
  6850. * @param min defines the minimum vector (in local space)
  6851. * @param max defines the maximum vector (in local space)
  6852. * @param worldMatrix defines the new world matrix
  6853. */
  6854. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6855. /**
  6856. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6857. * @param min defines the new minimum vector (in local space)
  6858. * @param max defines the new maximum vector (in local space)
  6859. * @param worldMatrix defines the new world matrix
  6860. */
  6861. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Scale the current bounding sphere by applying a scale factor
  6864. * @param factor defines the scale factor to apply
  6865. * @returns the current bounding box
  6866. */
  6867. scale(factor: number): BoundingSphere;
  6868. /**
  6869. * Gets the world matrix of the bounding box
  6870. * @returns a matrix
  6871. */
  6872. getWorldMatrix(): DeepImmutable<Matrix>;
  6873. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6874. /**
  6875. * Tests if the bounding sphere is intersecting the frustum planes
  6876. * @param frustumPlanes defines the frustum planes to test
  6877. * @returns true if there is an intersection
  6878. */
  6879. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6880. /**
  6881. * Tests if the bounding sphere center is in between the frustum planes.
  6882. * Used for optimistic fast inclusion.
  6883. * @param frustumPlanes defines the frustum planes to test
  6884. * @returns true if the sphere center is in between the frustum planes
  6885. */
  6886. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6887. /**
  6888. * Tests if a point is inside the bounding sphere
  6889. * @param point defines the point to test
  6890. * @returns true if the point is inside the bounding sphere
  6891. */
  6892. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Checks if two sphere intersct
  6895. * @param sphere0 sphere 0
  6896. * @param sphere1 sphere 1
  6897. * @returns true if the speres intersect
  6898. */
  6899. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /**
  6904. * Class used to store bounding box information
  6905. */
  6906. export class BoundingBox implements ICullable {
  6907. /**
  6908. * Gets the 8 vectors representing the bounding box in local space
  6909. */
  6910. readonly vectors: Vector3[];
  6911. /**
  6912. * Gets the center of the bounding box in local space
  6913. */
  6914. readonly center: Vector3;
  6915. /**
  6916. * Gets the center of the bounding box in world space
  6917. */
  6918. readonly centerWorld: Vector3;
  6919. /**
  6920. * Gets the extend size in local space
  6921. */
  6922. readonly extendSize: Vector3;
  6923. /**
  6924. * Gets the extend size in world space
  6925. */
  6926. readonly extendSizeWorld: Vector3;
  6927. /**
  6928. * Gets the OBB (object bounding box) directions
  6929. */
  6930. readonly directions: Vector3[];
  6931. /**
  6932. * Gets the 8 vectors representing the bounding box in world space
  6933. */
  6934. readonly vectorsWorld: Vector3[];
  6935. /**
  6936. * Gets the minimum vector in world space
  6937. */
  6938. readonly minimumWorld: Vector3;
  6939. /**
  6940. * Gets the maximum vector in world space
  6941. */
  6942. readonly maximumWorld: Vector3;
  6943. /**
  6944. * Gets the minimum vector in local space
  6945. */
  6946. readonly minimum: Vector3;
  6947. /**
  6948. * Gets the maximum vector in local space
  6949. */
  6950. readonly maximum: Vector3;
  6951. private _worldMatrix;
  6952. private static readonly TmpVector3;
  6953. /**
  6954. * @hidden
  6955. */ tag: number;
  6956. /**
  6957. * Creates a new bounding box
  6958. * @param min defines the minimum vector (in local space)
  6959. * @param max defines the maximum vector (in local space)
  6960. * @param worldMatrix defines the new world matrix
  6961. */
  6962. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6963. /**
  6964. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6965. * @param min defines the new minimum vector (in local space)
  6966. * @param max defines the new maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6970. /**
  6971. * Scale the current bounding box by applying a scale factor
  6972. * @param factor defines the scale factor to apply
  6973. * @returns the current bounding box
  6974. */
  6975. scale(factor: number): BoundingBox;
  6976. /**
  6977. * Gets the world matrix of the bounding box
  6978. * @returns a matrix
  6979. */
  6980. getWorldMatrix(): DeepImmutable<Matrix>;
  6981. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6982. /**
  6983. * Tests if the bounding box is intersecting the frustum planes
  6984. * @param frustumPlanes defines the frustum planes to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6988. /**
  6989. * Tests if the bounding box is entirely inside the frustum planes
  6990. * @param frustumPlanes defines the frustum planes to test
  6991. * @returns true if there is an inclusion
  6992. */
  6993. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6994. /**
  6995. * Tests if a point is inside the bounding box
  6996. * @param point defines the point to test
  6997. * @returns true if the point is inside the bounding box
  6998. */
  6999. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7000. /**
  7001. * Tests if the bounding box intersects with a bounding sphere
  7002. * @param sphere defines the sphere to test
  7003. * @returns true if there is an intersection
  7004. */
  7005. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7006. /**
  7007. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7008. * @param min defines the min vector to use
  7009. * @param max defines the max vector to use
  7010. * @returns true if there is an intersection
  7011. */
  7012. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7013. /**
  7014. * Tests if two bounding boxes are intersections
  7015. * @param box0 defines the first box to test
  7016. * @param box1 defines the second box to test
  7017. * @returns true if there is an intersection
  7018. */
  7019. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7020. /**
  7021. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7022. * @param minPoint defines the minimum vector of the bounding box
  7023. * @param maxPoint defines the maximum vector of the bounding box
  7024. * @param sphereCenter defines the sphere center
  7025. * @param sphereRadius defines the sphere radius
  7026. * @returns true if there is an intersection
  7027. */
  7028. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7029. /**
  7030. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7031. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @return true if there is an inclusion
  7034. */
  7035. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7038. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7039. * @param frustumPlanes defines the frustum planes to test
  7040. * @return true if there is an intersection
  7041. */
  7042. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7043. }
  7044. }
  7045. declare module BABYLON {
  7046. /** @hidden */
  7047. export class Collider {
  7048. /** Define if a collision was found */
  7049. collisionFound: boolean;
  7050. /**
  7051. * Define last intersection point in local space
  7052. */
  7053. intersectionPoint: Vector3;
  7054. /**
  7055. * Define last collided mesh
  7056. */
  7057. collidedMesh: Nullable<AbstractMesh>;
  7058. private _collisionPoint;
  7059. private _planeIntersectionPoint;
  7060. private _tempVector;
  7061. private _tempVector2;
  7062. private _tempVector3;
  7063. private _tempVector4;
  7064. private _edge;
  7065. private _baseToVertex;
  7066. private _destinationPoint;
  7067. private _slidePlaneNormal;
  7068. private _displacementVector;
  7069. /** @hidden */ radius: Vector3;
  7070. /** @hidden */ retry: number;
  7071. private _velocity;
  7072. private _basePoint;
  7073. private _epsilon;
  7074. /** @hidden */ velocityWorldLength: number;
  7075. /** @hidden */ basePointWorld: Vector3;
  7076. private _velocityWorld;
  7077. private _normalizedVelocity;
  7078. /** @hidden */ initialVelocity: Vector3;
  7079. /** @hidden */ initialPosition: Vector3;
  7080. private _nearestDistance;
  7081. private _collisionMask;
  7082. collisionMask: number;
  7083. /**
  7084. * Gets the plane normal used to compute the sliding response (in local space)
  7085. */
  7086. readonly slidePlaneNormal: Vector3;
  7087. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7088. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7089. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7090. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7091. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7092. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7093. }
  7094. }
  7095. declare module BABYLON {
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. readonly minimum: Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. readonly maximum: Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. isLocked: boolean;
  7155. /**
  7156. * Updates the bounding sphere and box
  7157. * @param world world matrix to be used to update
  7158. */
  7159. update(world: DeepImmutable<Matrix>): void;
  7160. /**
  7161. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7162. * @param center New center of the bounding info
  7163. * @param extend New extend of the bounding info
  7164. * @returns the current bounding info
  7165. */
  7166. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7167. /**
  7168. * Scale the current bounding info by applying a scale factor
  7169. * @param factor defines the scale factor to apply
  7170. * @returns the current bounding info
  7171. */
  7172. scale(factor: number): BoundingInfo;
  7173. /**
  7174. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7175. * @param frustumPlanes defines the frustum to test
  7176. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7177. * @returns true if the bounding info is in the frustum planes
  7178. */
  7179. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7180. /**
  7181. * Gets the world distance between the min and max points of the bounding box
  7182. */
  7183. readonly diagonalLength: number;
  7184. /**
  7185. * Checks if a cullable object (mesh...) is in the camera frustum
  7186. * Unlike isInFrustum this cheks the full bounding box
  7187. * @param frustumPlanes Camera near/planes
  7188. * @returns true if the object is in frustum otherwise false
  7189. */
  7190. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7191. /** @hidden */ checkCollision(collider: Collider): boolean;
  7192. /**
  7193. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7194. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7195. * @param point the point to check intersection with
  7196. * @returns if the point intersects
  7197. */
  7198. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7199. /**
  7200. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7201. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7202. * @param boundingInfo the bounding info to check intersection with
  7203. * @param precise if the intersection should be done using OBB
  7204. * @returns if the bounding info intersects
  7205. */
  7206. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7207. }
  7208. }
  7209. declare module BABYLON {
  7210. /**
  7211. * Defines an array and its length.
  7212. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7213. */
  7214. export interface ISmartArrayLike<T> {
  7215. /**
  7216. * The data of the array.
  7217. */
  7218. data: Array<T>;
  7219. /**
  7220. * The active length of the array.
  7221. */
  7222. length: number;
  7223. }
  7224. /**
  7225. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7226. */
  7227. export class SmartArray<T> implements ISmartArrayLike<T> {
  7228. /**
  7229. * The full set of data from the array.
  7230. */
  7231. data: Array<T>;
  7232. /**
  7233. * The active length of the array.
  7234. */
  7235. length: number;
  7236. protected _id: number;
  7237. /**
  7238. * Instantiates a Smart Array.
  7239. * @param capacity defines the default capacity of the array.
  7240. */
  7241. constructor(capacity: number);
  7242. /**
  7243. * Pushes a value at the end of the active data.
  7244. * @param value defines the object to push in the array.
  7245. */
  7246. push(value: T): void;
  7247. /**
  7248. * Iterates over the active data and apply the lambda to them.
  7249. * @param func defines the action to apply on each value.
  7250. */
  7251. forEach(func: (content: T) => void): void;
  7252. /**
  7253. * Sorts the full sets of data.
  7254. * @param compareFn defines the comparison function to apply.
  7255. */
  7256. sort(compareFn: (a: T, b: T) => number): void;
  7257. /**
  7258. * Resets the active data to an empty array.
  7259. */
  7260. reset(): void;
  7261. /**
  7262. * Releases all the data from the array as well as the array.
  7263. */
  7264. dispose(): void;
  7265. /**
  7266. * Concats the active data with a given array.
  7267. * @param array defines the data to concatenate with.
  7268. */
  7269. concat(array: any): void;
  7270. /**
  7271. * Returns the position of a value in the active data.
  7272. * @param value defines the value to find the index for
  7273. * @returns the index if found in the active data otherwise -1
  7274. */
  7275. indexOf(value: T): number;
  7276. /**
  7277. * Returns whether an element is part of the active data.
  7278. * @param value defines the value to look for
  7279. * @returns true if found in the active data otherwise false
  7280. */
  7281. contains(value: T): boolean;
  7282. private static _GlobalId;
  7283. }
  7284. /**
  7285. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7286. * The data in this array can only be present once
  7287. */
  7288. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7289. private _duplicateId;
  7290. /**
  7291. * Pushes a value at the end of the active data.
  7292. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7293. * @param value defines the object to push in the array.
  7294. */
  7295. push(value: T): void;
  7296. /**
  7297. * Pushes a value at the end of the active data.
  7298. * If the data is already present, it won t be added again
  7299. * @param value defines the object to push in the array.
  7300. * @returns true if added false if it was already present
  7301. */
  7302. pushNoDuplicate(value: T): boolean;
  7303. /**
  7304. * Resets the active data to an empty array.
  7305. */
  7306. reset(): void;
  7307. /**
  7308. * Concats the active data with a given array.
  7309. * This ensures no dupplicate will be present in the result.
  7310. * @param array defines the data to concatenate with.
  7311. */
  7312. concatWithNoDuplicate(array: any): void;
  7313. }
  7314. }
  7315. declare module BABYLON {
  7316. /**
  7317. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7318. * separate meshes. This can be use to improve performances.
  7319. * @see http://doc.babylonjs.com/how_to/multi_materials
  7320. */
  7321. export class MultiMaterial extends Material {
  7322. private _subMaterials;
  7323. /**
  7324. * Gets or Sets the list of Materials used within the multi material.
  7325. * They need to be ordered according to the submeshes order in the associated mesh
  7326. */
  7327. subMaterials: Nullable<Material>[];
  7328. /**
  7329. * Function used to align with Node.getChildren()
  7330. * @returns the list of Materials used within the multi material
  7331. */
  7332. getChildren(): Nullable<Material>[];
  7333. /**
  7334. * Instantiates a new Multi Material
  7335. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7336. * separate meshes. This can be use to improve performances.
  7337. * @see http://doc.babylonjs.com/how_to/multi_materials
  7338. * @param name Define the name in the scene
  7339. * @param scene Define the scene the material belongs to
  7340. */
  7341. constructor(name: string, scene: Scene);
  7342. private _hookArray;
  7343. /**
  7344. * Get one of the submaterial by its index in the submaterials array
  7345. * @param index The index to look the sub material at
  7346. * @returns The Material if the index has been defined
  7347. */
  7348. getSubMaterial(index: number): Nullable<Material>;
  7349. /**
  7350. * Get the list of active textures for the whole sub materials list.
  7351. * @returns All the textures that will be used during the rendering
  7352. */
  7353. getActiveTextures(): BaseTexture[];
  7354. /**
  7355. * Gets the current class name of the material e.g. "MultiMaterial"
  7356. * Mainly use in serialization.
  7357. * @returns the class name
  7358. */
  7359. getClassName(): string;
  7360. /**
  7361. * Checks if the material is ready to render the requested sub mesh
  7362. * @param mesh Define the mesh the submesh belongs to
  7363. * @param subMesh Define the sub mesh to look readyness for
  7364. * @param useInstances Define whether or not the material is used with instances
  7365. * @returns true if ready, otherwise false
  7366. */
  7367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7368. /**
  7369. * Clones the current material and its related sub materials
  7370. * @param name Define the name of the newly cloned material
  7371. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7372. * @returns the cloned material
  7373. */
  7374. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7375. /**
  7376. * Serializes the materials into a JSON representation.
  7377. * @returns the JSON representation
  7378. */
  7379. serialize(): any;
  7380. /**
  7381. * Dispose the material and release its associated resources
  7382. * @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)
  7383. * @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)
  7384. * @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)
  7385. */
  7386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7387. /**
  7388. * Creates a MultiMaterial from parsed MultiMaterial data.
  7389. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7390. * @param scene defines the hosting scene
  7391. * @returns a new MultiMaterial
  7392. */
  7393. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7394. }
  7395. }
  7396. declare module BABYLON {
  7397. /**
  7398. * Class used to represent data loading progression
  7399. */
  7400. export class SceneLoaderFlags {
  7401. private static _ForceFullSceneLoadingForIncremental;
  7402. private static _ShowLoadingScreen;
  7403. private static _CleanBoneMatrixWeights;
  7404. private static _loggingLevel;
  7405. /**
  7406. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7407. */
  7408. static ForceFullSceneLoadingForIncremental: boolean;
  7409. /**
  7410. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7411. */
  7412. static ShowLoadingScreen: boolean;
  7413. /**
  7414. * Defines the current logging level (while loading the scene)
  7415. * @ignorenaming
  7416. */
  7417. static loggingLevel: number;
  7418. /**
  7419. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7420. */
  7421. static CleanBoneMatrixWeights: boolean;
  7422. }
  7423. }
  7424. declare module BABYLON {
  7425. /**
  7426. * 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.
  7427. * @see https://doc.babylonjs.com/how_to/transformnode
  7428. */
  7429. export class TransformNode extends Node {
  7430. /**
  7431. * Object will not rotate to face the camera
  7432. */
  7433. static BILLBOARDMODE_NONE: number;
  7434. /**
  7435. * Object will rotate to face the camera but only on the x axis
  7436. */
  7437. static BILLBOARDMODE_X: number;
  7438. /**
  7439. * Object will rotate to face the camera but only on the y axis
  7440. */
  7441. static BILLBOARDMODE_Y: number;
  7442. /**
  7443. * Object will rotate to face the camera but only on the z axis
  7444. */
  7445. static BILLBOARDMODE_Z: number;
  7446. /**
  7447. * Object will rotate to face the camera
  7448. */
  7449. static BILLBOARDMODE_ALL: number;
  7450. private _forward;
  7451. private _forwardInverted;
  7452. private _up;
  7453. private _right;
  7454. private _rightInverted;
  7455. private _position;
  7456. private _rotation;
  7457. private _rotationQuaternion;
  7458. protected _scaling: Vector3;
  7459. protected _isDirty: boolean;
  7460. private _transformToBoneReferal;
  7461. private _billboardMode;
  7462. /**
  7463. * Gets or sets the billboard mode. Default is 0.
  7464. *
  7465. * | Value | Type | Description |
  7466. * | --- | --- | --- |
  7467. * | 0 | BILLBOARDMODE_NONE | |
  7468. * | 1 | BILLBOARDMODE_X | |
  7469. * | 2 | BILLBOARDMODE_Y | |
  7470. * | 4 | BILLBOARDMODE_Z | |
  7471. * | 7 | BILLBOARDMODE_ALL | |
  7472. *
  7473. */
  7474. billboardMode: number;
  7475. private _preserveParentRotationForBillboard;
  7476. /**
  7477. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7478. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7479. */
  7480. preserveParentRotationForBillboard: boolean;
  7481. /**
  7482. * 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
  7483. */
  7484. scalingDeterminant: number;
  7485. private _infiniteDistance;
  7486. /**
  7487. * Gets or sets the distance of the object to max, often used by skybox
  7488. */
  7489. infiniteDistance: boolean;
  7490. /**
  7491. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7492. * By default the system will update normals to compensate
  7493. */
  7494. ignoreNonUniformScaling: boolean;
  7495. /**
  7496. * 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
  7497. */
  7498. reIntegrateRotationIntoRotationQuaternion: boolean;
  7499. /** @hidden */ poseMatrix: Nullable<Matrix>;
  7500. /** @hidden */ localMatrix: Matrix;
  7501. private _usePivotMatrix;
  7502. private _absolutePosition;
  7503. private _pivotMatrix;
  7504. private _pivotMatrixInverse;
  7505. protected _postMultiplyPivotMatrix: boolean;
  7506. protected _isWorldMatrixFrozen: boolean;
  7507. /** @hidden */ indexInSceneTransformNodesArray: number;
  7508. /**
  7509. * An event triggered after the world matrix is updated
  7510. */
  7511. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7512. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7513. /**
  7514. * Gets a string identifying the name of the class
  7515. * @returns "TransformNode" string
  7516. */
  7517. getClassName(): string;
  7518. /**
  7519. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7520. */
  7521. position: Vector3;
  7522. /**
  7523. * 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)).
  7524. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7525. */
  7526. rotation: Vector3;
  7527. /**
  7528. * 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)).
  7529. */
  7530. scaling: Vector3;
  7531. /**
  7532. * 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).
  7533. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7534. */
  7535. rotationQuaternion: Nullable<Quaternion>;
  7536. /**
  7537. * The forward direction of that transform in world space.
  7538. */
  7539. readonly forward: Vector3;
  7540. /**
  7541. * The up direction of that transform in world space.
  7542. */
  7543. readonly up: Vector3;
  7544. /**
  7545. * The right direction of that transform in world space.
  7546. */
  7547. readonly right: Vector3;
  7548. /**
  7549. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7550. * @param matrix the matrix to copy the pose from
  7551. * @returns this TransformNode.
  7552. */
  7553. updatePoseMatrix(matrix: Matrix): TransformNode;
  7554. /**
  7555. * Returns the mesh Pose matrix.
  7556. * @returns the pose matrix
  7557. */
  7558. getPoseMatrix(): Matrix;
  7559. /** @hidden */ isSynchronized(): boolean;
  7560. /** @hidden */ initCache(): void;
  7561. /**
  7562. * Flag the transform node as dirty (Forcing it to update everything)
  7563. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7564. * @returns this transform node
  7565. */
  7566. markAsDirty(property: string): TransformNode;
  7567. /**
  7568. * Returns the current mesh absolute position.
  7569. * Returns a Vector3.
  7570. */
  7571. readonly absolutePosition: Vector3;
  7572. /**
  7573. * Sets a new matrix to apply before all other transformation
  7574. * @param matrix defines the transform matrix
  7575. * @returns the current TransformNode
  7576. */
  7577. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7578. /**
  7579. * Sets a new pivot matrix to the current node
  7580. * @param matrix defines the new pivot matrix to use
  7581. * @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
  7582. * @returns the current TransformNode
  7583. */
  7584. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7585. /**
  7586. * Returns the mesh pivot matrix.
  7587. * Default : Identity.
  7588. * @returns the matrix
  7589. */
  7590. getPivotMatrix(): Matrix;
  7591. /**
  7592. * Prevents the World matrix to be computed any longer.
  7593. * @returns the TransformNode.
  7594. */
  7595. freezeWorldMatrix(): TransformNode;
  7596. /**
  7597. * Allows back the World matrix computation.
  7598. * @returns the TransformNode.
  7599. */
  7600. unfreezeWorldMatrix(): this;
  7601. /**
  7602. * True if the World matrix has been frozen.
  7603. */
  7604. readonly isWorldMatrixFrozen: boolean;
  7605. /**
  7606. * Retuns the mesh absolute position in the World.
  7607. * @returns a Vector3.
  7608. */
  7609. getAbsolutePosition(): Vector3;
  7610. /**
  7611. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7612. * @param absolutePosition the absolute position to set
  7613. * @returns the TransformNode.
  7614. */
  7615. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7616. /**
  7617. * Sets the mesh position in its local space.
  7618. * @param vector3 the position to set in localspace
  7619. * @returns the TransformNode.
  7620. */
  7621. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7622. /**
  7623. * Returns the mesh position in the local space from the current World matrix values.
  7624. * @returns a new Vector3.
  7625. */
  7626. getPositionExpressedInLocalSpace(): Vector3;
  7627. /**
  7628. * Translates the mesh along the passed Vector3 in its local space.
  7629. * @param vector3 the distance to translate in localspace
  7630. * @returns the TransformNode.
  7631. */
  7632. locallyTranslate(vector3: Vector3): TransformNode;
  7633. private static _lookAtVectorCache;
  7634. /**
  7635. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7636. * @param targetPoint the position (must be in same space as current mesh) to look at
  7637. * @param yawCor optional yaw (y-axis) correction in radians
  7638. * @param pitchCor optional pitch (x-axis) correction in radians
  7639. * @param rollCor optional roll (z-axis) correction in radians
  7640. * @param space the choosen space of the target
  7641. * @returns the TransformNode.
  7642. */
  7643. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7644. /**
  7645. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7646. * This Vector3 is expressed in the World space.
  7647. * @param localAxis axis to rotate
  7648. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7649. */
  7650. getDirection(localAxis: Vector3): Vector3;
  7651. /**
  7652. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7653. * localAxis is expressed in the mesh local space.
  7654. * result is computed in the Wordl space from the mesh World matrix.
  7655. * @param localAxis axis to rotate
  7656. * @param result the resulting transformnode
  7657. * @returns this TransformNode.
  7658. */
  7659. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7660. /**
  7661. * Sets this transform node rotation to the given local axis.
  7662. * @param localAxis the axis in local space
  7663. * @param yawCor optional yaw (y-axis) correction in radians
  7664. * @param pitchCor optional pitch (x-axis) correction in radians
  7665. * @param rollCor optional roll (z-axis) correction in radians
  7666. * @returns this TransformNode
  7667. */
  7668. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7669. /**
  7670. * Sets a new pivot point to the current node
  7671. * @param point defines the new pivot point to use
  7672. * @param space defines if the point is in world or local space (local by default)
  7673. * @returns the current TransformNode
  7674. */
  7675. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7676. /**
  7677. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7678. * @returns the pivot point
  7679. */
  7680. getPivotPoint(): Vector3;
  7681. /**
  7682. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7683. * @param result the vector3 to store the result
  7684. * @returns this TransformNode.
  7685. */
  7686. getPivotPointToRef(result: Vector3): TransformNode;
  7687. /**
  7688. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7689. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7690. */
  7691. getAbsolutePivotPoint(): Vector3;
  7692. /**
  7693. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7694. * @param result vector3 to store the result
  7695. * @returns this TransformNode.
  7696. */
  7697. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7698. /**
  7699. * Defines the passed node as the parent of the current node.
  7700. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7701. * @see https://doc.babylonjs.com/how_to/parenting
  7702. * @param node the node ot set as the parent
  7703. * @returns this TransformNode.
  7704. */
  7705. setParent(node: Nullable<Node>): TransformNode;
  7706. private _nonUniformScaling;
  7707. /**
  7708. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7709. */
  7710. readonly nonUniformScaling: boolean;
  7711. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7712. /**
  7713. * Attach the current TransformNode to another TransformNode associated with a bone
  7714. * @param bone Bone affecting the TransformNode
  7715. * @param affectedTransformNode TransformNode associated with the bone
  7716. * @returns this object
  7717. */
  7718. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7719. /**
  7720. * Detach the transform node if its associated with a bone
  7721. * @returns this object
  7722. */
  7723. detachFromBone(): TransformNode;
  7724. private static _rotationAxisCache;
  7725. /**
  7726. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7727. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7728. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7729. * The passed axis is also normalized.
  7730. * @param axis the axis to rotate around
  7731. * @param amount the amount to rotate in radians
  7732. * @param space Space to rotate in (Default: local)
  7733. * @returns the TransformNode.
  7734. */
  7735. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7736. /**
  7737. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7738. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7739. * The passed axis is also normalized. .
  7740. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7741. * @param point the point to rotate around
  7742. * @param axis the axis to rotate around
  7743. * @param amount the amount to rotate in radians
  7744. * @returns the TransformNode
  7745. */
  7746. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7747. /**
  7748. * Translates the mesh along the axis vector for the passed distance in the given space.
  7749. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7750. * @param axis the axis to translate in
  7751. * @param distance the distance to translate
  7752. * @param space Space to rotate in (Default: local)
  7753. * @returns the TransformNode.
  7754. */
  7755. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7756. /**
  7757. * Adds a rotation step to the mesh current rotation.
  7758. * x, y, z are Euler angles expressed in radians.
  7759. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7760. * This means this rotation is made in the mesh local space only.
  7761. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7762. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7763. * ```javascript
  7764. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7765. * ```
  7766. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7767. * 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.
  7768. * @param x Rotation to add
  7769. * @param y Rotation to add
  7770. * @param z Rotation to add
  7771. * @returns the TransformNode.
  7772. */
  7773. addRotation(x: number, y: number, z: number): TransformNode;
  7774. /**
  7775. * @hidden
  7776. */
  7777. protected _getEffectiveParent(): Nullable<Node>;
  7778. /**
  7779. * Computes the world matrix of the node
  7780. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7781. * @returns the world matrix
  7782. */
  7783. computeWorldMatrix(force?: boolean): Matrix;
  7784. protected _afterComputeWorldMatrix(): void;
  7785. /**
  7786. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7787. * @param func callback function to add
  7788. *
  7789. * @returns the TransformNode.
  7790. */
  7791. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7792. /**
  7793. * Removes a registered callback function.
  7794. * @param func callback function to remove
  7795. * @returns the TransformNode.
  7796. */
  7797. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7798. /**
  7799. * Gets the position of the current mesh in camera space
  7800. * @param camera defines the camera to use
  7801. * @returns a position
  7802. */
  7803. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7804. /**
  7805. * Returns the distance from the mesh to the active camera
  7806. * @param camera defines the camera to use
  7807. * @returns the distance
  7808. */
  7809. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7810. /**
  7811. * Clone the current transform node
  7812. * @param name Name of the new clone
  7813. * @param newParent New parent for the clone
  7814. * @param doNotCloneChildren Do not clone children hierarchy
  7815. * @returns the new transform node
  7816. */
  7817. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7818. /**
  7819. * Serializes the objects information.
  7820. * @param currentSerializationObject defines the object to serialize in
  7821. * @returns the serialized object
  7822. */
  7823. serialize(currentSerializationObject?: any): any;
  7824. /**
  7825. * Returns a new TransformNode object parsed from the source provided.
  7826. * @param parsedTransformNode is the source.
  7827. * @param scene the scne the object belongs to
  7828. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7829. * @returns a new TransformNode object parsed from the source provided.
  7830. */
  7831. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7832. /**
  7833. * Get all child-transformNodes of this node
  7834. * @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
  7835. * @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
  7836. * @returns an array of TransformNode
  7837. */
  7838. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7839. /**
  7840. * Releases resources associated with this transform node.
  7841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7843. */
  7844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7845. }
  7846. }
  7847. declare module BABYLON {
  7848. /**
  7849. * Class used to override all child animations of a given target
  7850. */
  7851. export class AnimationPropertiesOverride {
  7852. /**
  7853. * Gets or sets a value indicating if animation blending must be used
  7854. */
  7855. enableBlending: boolean;
  7856. /**
  7857. * Gets or sets the blending speed to use when enableBlending is true
  7858. */
  7859. blendingSpeed: number;
  7860. /**
  7861. * Gets or sets the default loop mode to use
  7862. */
  7863. loopMode: number;
  7864. }
  7865. }
  7866. declare module BABYLON {
  7867. /**
  7868. * Class used to store bone information
  7869. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7870. */
  7871. export class Bone extends Node {
  7872. /**
  7873. * defines the bone name
  7874. */
  7875. name: string;
  7876. private static _tmpVecs;
  7877. private static _tmpQuat;
  7878. private static _tmpMats;
  7879. /**
  7880. * Gets the list of child bones
  7881. */
  7882. children: Bone[];
  7883. /** Gets the animations associated with this bone */
  7884. animations: Animation[];
  7885. /**
  7886. * Gets or sets bone length
  7887. */
  7888. length: number;
  7889. /**
  7890. * @hidden Internal only
  7891. * Set this value to map this bone to a different index in the transform matrices
  7892. * Set this value to -1 to exclude the bone from the transform matrices
  7893. */ index: Nullable<number>;
  7894. private _skeleton;
  7895. private _localMatrix;
  7896. private _restPose;
  7897. private _baseMatrix;
  7898. private _absoluteTransform;
  7899. private _invertedAbsoluteTransform;
  7900. private _parent;
  7901. private _scalingDeterminant;
  7902. private _worldTransform;
  7903. private _localScaling;
  7904. private _localRotation;
  7905. private _localPosition;
  7906. private _needToDecompose;
  7907. private _needToCompose;
  7908. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7909. /** @hidden */ waitingTransformNodeId: Nullable<string>;
  7910. /** @hidden */
  7911. /** @hidden */ matrix: Matrix;
  7912. /**
  7913. * Create a new bone
  7914. * @param name defines the bone name
  7915. * @param skeleton defines the parent skeleton
  7916. * @param parentBone defines the parent (can be null if the bone is the root)
  7917. * @param localMatrix defines the local matrix
  7918. * @param restPose defines the rest pose matrix
  7919. * @param baseMatrix defines the base matrix
  7920. * @param index defines index of the bone in the hiearchy
  7921. */
  7922. constructor(
  7923. /**
  7924. * defines the bone name
  7925. */
  7926. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7927. /**
  7928. * Gets the current object class name.
  7929. * @return the class name
  7930. */
  7931. getClassName(): string;
  7932. /**
  7933. * Gets the parent skeleton
  7934. * @returns a skeleton
  7935. */
  7936. getSkeleton(): Skeleton;
  7937. /**
  7938. * Gets parent bone
  7939. * @returns a bone or null if the bone is the root of the bone hierarchy
  7940. */
  7941. getParent(): Nullable<Bone>;
  7942. /**
  7943. * Returns an array containing the root bones
  7944. * @returns an array containing the root bones
  7945. */
  7946. getChildren(): Array<Bone>;
  7947. /**
  7948. * Sets the parent bone
  7949. * @param parent defines the parent (can be null if the bone is the root)
  7950. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7951. */
  7952. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7953. /**
  7954. * Gets the local matrix
  7955. * @returns a matrix
  7956. */
  7957. getLocalMatrix(): Matrix;
  7958. /**
  7959. * Gets the base matrix (initial matrix which remains unchanged)
  7960. * @returns a matrix
  7961. */
  7962. getBaseMatrix(): Matrix;
  7963. /**
  7964. * Gets the rest pose matrix
  7965. * @returns a matrix
  7966. */
  7967. getRestPose(): Matrix;
  7968. /**
  7969. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7970. */
  7971. getWorldMatrix(): Matrix;
  7972. /**
  7973. * Sets the local matrix to rest pose matrix
  7974. */
  7975. returnToRest(): void;
  7976. /**
  7977. * Gets the inverse of the absolute transform matrix.
  7978. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7979. * @returns a matrix
  7980. */
  7981. getInvertedAbsoluteTransform(): Matrix;
  7982. /**
  7983. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7984. * @returns a matrix
  7985. */
  7986. getAbsoluteTransform(): Matrix;
  7987. /**
  7988. * Links with the given transform node.
  7989. * The local matrix of this bone is copied from the transform node every frame.
  7990. * @param transformNode defines the transform node to link to
  7991. */
  7992. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7993. /** Gets or sets current position (in local space) */
  7994. position: Vector3;
  7995. /** Gets or sets current rotation (in local space) */
  7996. rotation: Vector3;
  7997. /** Gets or sets current rotation quaternion (in local space) */
  7998. rotationQuaternion: Quaternion;
  7999. /** Gets or sets current scaling (in local space) */
  8000. scaling: Vector3;
  8001. /**
  8002. * Gets the animation properties override
  8003. */
  8004. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8005. private _decompose;
  8006. private _compose;
  8007. /**
  8008. * Update the base and local matrices
  8009. * @param matrix defines the new base or local matrix
  8010. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8011. * @param updateLocalMatrix defines if the local matrix should be updated
  8012. */
  8013. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8014. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8015. /**
  8016. * Flag the bone as dirty (Forcing it to update everything)
  8017. */
  8018. markAsDirty(): void;
  8019. private _markAsDirtyAndCompose;
  8020. private _markAsDirtyAndDecompose;
  8021. /**
  8022. * Translate the bone in local or world space
  8023. * @param vec The amount to translate the bone
  8024. * @param space The space that the translation is in
  8025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8026. */
  8027. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8028. /**
  8029. * Set the postion of the bone in local or world space
  8030. * @param position The position to set the bone
  8031. * @param space The space that the position is in
  8032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8033. */
  8034. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8035. /**
  8036. * Set the absolute position of the bone (world space)
  8037. * @param position The position to set the bone
  8038. * @param mesh The mesh that this bone is attached to
  8039. */
  8040. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8041. /**
  8042. * Scale the bone on the x, y and z axes (in local space)
  8043. * @param x The amount to scale the bone on the x axis
  8044. * @param y The amount to scale the bone on the y axis
  8045. * @param z The amount to scale the bone on the z axis
  8046. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8047. */
  8048. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8049. /**
  8050. * Set the bone scaling in local space
  8051. * @param scale defines the scaling vector
  8052. */
  8053. setScale(scale: Vector3): void;
  8054. /**
  8055. * Gets the current scaling in local space
  8056. * @returns the current scaling vector
  8057. */
  8058. getScale(): Vector3;
  8059. /**
  8060. * Gets the current scaling in local space and stores it in a target vector
  8061. * @param result defines the target vector
  8062. */
  8063. getScaleToRef(result: Vector3): void;
  8064. /**
  8065. * Set the yaw, pitch, and roll of the bone in local or world space
  8066. * @param yaw The rotation of the bone on the y axis
  8067. * @param pitch The rotation of the bone on the x axis
  8068. * @param roll The rotation of the bone on the z axis
  8069. * @param space The space that the axes of rotation are in
  8070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8071. */
  8072. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8073. /**
  8074. * Add a rotation to the bone on an axis in local or world space
  8075. * @param axis The axis to rotate the bone on
  8076. * @param amount The amount to rotate the bone
  8077. * @param space The space that the axis is in
  8078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8079. */
  8080. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8081. /**
  8082. * Set the rotation of the bone to a particular axis angle in local or world space
  8083. * @param axis The axis to rotate the bone on
  8084. * @param angle The angle that the bone should be rotated to
  8085. * @param space The space that the axis is in
  8086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8087. */
  8088. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8089. /**
  8090. * Set the euler rotation of the bone in local of world space
  8091. * @param rotation The euler rotation that the bone should be set to
  8092. * @param space The space that the rotation is in
  8093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8094. */
  8095. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8096. /**
  8097. * Set the quaternion rotation of the bone in local of world space
  8098. * @param quat The quaternion rotation that the bone should be set to
  8099. * @param space The space that the rotation is in
  8100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8101. */
  8102. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8103. /**
  8104. * Set the rotation matrix of the bone in local of world space
  8105. * @param rotMat The rotation matrix that the bone should be set to
  8106. * @param space The space that the rotation is in
  8107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8108. */
  8109. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8110. private _rotateWithMatrix;
  8111. private _getNegativeRotationToRef;
  8112. /**
  8113. * Get the position of the bone in local or world space
  8114. * @param space The space that the returned position is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. * @returns The position of the bone
  8117. */
  8118. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8119. /**
  8120. * Copy the position of the bone to a vector3 in local or world space
  8121. * @param space The space that the returned position is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. * @param result The vector3 to copy the position to
  8124. */
  8125. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8126. /**
  8127. * Get the absolute position of the bone (world space)
  8128. * @param mesh The mesh that this bone is attached to
  8129. * @returns The absolute position of the bone
  8130. */
  8131. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8132. /**
  8133. * Copy the absolute position of the bone (world space) to the result param
  8134. * @param mesh The mesh that this bone is attached to
  8135. * @param result The vector3 to copy the absolute position to
  8136. */
  8137. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8138. /**
  8139. * Compute the absolute transforms of this bone and its children
  8140. */
  8141. computeAbsoluteTransforms(): void;
  8142. /**
  8143. * Get the world direction from an axis that is in the local space of the bone
  8144. * @param localAxis The local direction that is used to compute the world direction
  8145. * @param mesh The mesh that this bone is attached to
  8146. * @returns The world direction
  8147. */
  8148. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8149. /**
  8150. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8151. * @param localAxis The local direction that is used to compute the world direction
  8152. * @param mesh The mesh that this bone is attached to
  8153. * @param result The vector3 that the world direction will be copied to
  8154. */
  8155. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8156. /**
  8157. * Get the euler rotation of the bone in local or world space
  8158. * @param space The space that the rotation should be in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @returns The euler rotation
  8161. */
  8162. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8163. /**
  8164. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8165. * @param space The space that the rotation should be in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. * @param result The vector3 that the rotation should be copied to
  8168. */
  8169. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8170. /**
  8171. * Get the quaternion rotation of the bone in either local or world space
  8172. * @param space The space that the rotation should be in
  8173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8174. * @returns The quaternion rotation
  8175. */
  8176. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8177. /**
  8178. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8179. * @param space The space that the rotation should be in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. * @param result The quaternion that the rotation should be copied to
  8182. */
  8183. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8184. /**
  8185. * Get the rotation matrix of the bone in local or world space
  8186. * @param space The space that the rotation should be in
  8187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8188. * @returns The rotation matrix
  8189. */
  8190. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8191. /**
  8192. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8193. * @param space The space that the rotation should be in
  8194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8195. * @param result The quaternion that the rotation should be copied to
  8196. */
  8197. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8198. /**
  8199. * Get the world position of a point that is in the local space of the bone
  8200. * @param position The local position
  8201. * @param mesh The mesh that this bone is attached to
  8202. * @returns The world position
  8203. */
  8204. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8205. /**
  8206. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8207. * @param position The local position
  8208. * @param mesh The mesh that this bone is attached to
  8209. * @param result The vector3 that the world position should be copied to
  8210. */
  8211. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8212. /**
  8213. * Get the local position of a point that is in world space
  8214. * @param position The world position
  8215. * @param mesh The mesh that this bone is attached to
  8216. * @returns The local position
  8217. */
  8218. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8219. /**
  8220. * Get the local position of a point that is in world space and copy it to the result param
  8221. * @param position The world position
  8222. * @param mesh The mesh that this bone is attached to
  8223. * @param result The vector3 that the local position should be copied to
  8224. */
  8225. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8226. }
  8227. }
  8228. declare module BABYLON {
  8229. /**
  8230. * Enum that determines the text-wrapping mode to use.
  8231. */
  8232. export enum InspectableType {
  8233. /**
  8234. * Checkbox for booleans
  8235. */
  8236. Checkbox = 0,
  8237. /**
  8238. * Sliders for numbers
  8239. */
  8240. Slider = 1,
  8241. /**
  8242. * Vector3
  8243. */
  8244. Vector3 = 2,
  8245. /**
  8246. * Quaternions
  8247. */
  8248. Quaternion = 3,
  8249. /**
  8250. * Color3
  8251. */
  8252. Color3 = 4
  8253. }
  8254. /**
  8255. * Interface used to define custom inspectable properties.
  8256. * This interface is used by the inspector to display custom property grids
  8257. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8258. */
  8259. export interface IInspectable {
  8260. /**
  8261. * Gets the label to display
  8262. */
  8263. label: string;
  8264. /**
  8265. * Gets the name of the property to edit
  8266. */
  8267. propertyName: string;
  8268. /**
  8269. * Gets the type of the editor to use
  8270. */
  8271. type: InspectableType;
  8272. /**
  8273. * Gets the minimum value of the property when using in "slider" mode
  8274. */
  8275. min?: number;
  8276. /**
  8277. * Gets the maximum value of the property when using in "slider" mode
  8278. */
  8279. max?: number;
  8280. /**
  8281. * Gets the setp to use when using in "slider" mode
  8282. */
  8283. step?: number;
  8284. }
  8285. }
  8286. declare module BABYLON {
  8287. /**
  8288. * This represents the required contract to create a new type of texture loader.
  8289. */
  8290. export interface IInternalTextureLoader {
  8291. /**
  8292. * Defines wether the loader supports cascade loading the different faces.
  8293. */
  8294. supportCascades: boolean;
  8295. /**
  8296. * This returns if the loader support the current file information.
  8297. * @param extension defines the file extension of the file being loaded
  8298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8299. * @param fallback defines the fallback internal texture if any
  8300. * @param isBase64 defines whether the texture is encoded as a base64
  8301. * @param isBuffer defines whether the texture data are stored as a buffer
  8302. * @returns true if the loader can load the specified file
  8303. */
  8304. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8305. /**
  8306. * Transform the url before loading if required.
  8307. * @param rootUrl the url of the texture
  8308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8309. * @returns the transformed texture
  8310. */
  8311. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8312. /**
  8313. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8314. * @param rootUrl the url of the texture
  8315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8316. * @returns the fallback texture
  8317. */
  8318. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8319. /**
  8320. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8321. * @param data contains the texture data
  8322. * @param texture defines the BabylonJS internal texture
  8323. * @param createPolynomials will be true if polynomials have been requested
  8324. * @param onLoad defines the callback to trigger once the texture is ready
  8325. * @param onError defines the callback to trigger in case of error
  8326. */
  8327. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8328. /**
  8329. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8330. * @param data contains the texture data
  8331. * @param texture defines the BabylonJS internal texture
  8332. * @param callback defines the method to call once ready to upload
  8333. */
  8334. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8335. }
  8336. }
  8337. declare module BABYLON {
  8338. interface Engine {
  8339. /**
  8340. * Creates a depth stencil cube texture.
  8341. * This is only available in WebGL 2.
  8342. * @param size The size of face edge in the cube texture.
  8343. * @param options The options defining the cube texture.
  8344. * @returns The cube texture
  8345. */ createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8346. /**
  8347. * Creates a cube texture
  8348. * @param rootUrl defines the url where the files to load is located
  8349. * @param scene defines the current scene
  8350. * @param files defines the list of files to load (1 per face)
  8351. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8352. * @param onLoad defines an optional callback raised when the texture is loaded
  8353. * @param onError defines an optional callback raised if there is an issue to load the texture
  8354. * @param format defines the format of the data
  8355. * @param forcedExtension defines the extension to use to pick the right loader
  8356. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8357. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8358. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8359. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8360. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8361. * @returns the cube texture as an InternalTexture
  8362. */
  8363. 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;
  8364. /**
  8365. * Creates a cube texture
  8366. * @param rootUrl defines the url where the files to load is located
  8367. * @param scene defines the current scene
  8368. * @param files defines the list of files to load (1 per face)
  8369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8370. * @param onLoad defines an optional callback raised when the texture is loaded
  8371. * @param onError defines an optional callback raised if there is an issue to load the texture
  8372. * @param format defines the format of the data
  8373. * @param forcedExtension defines the extension to use to pick the right loader
  8374. * @returns the cube texture as an InternalTexture
  8375. */
  8376. 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;
  8377. /**
  8378. * Creates a cube texture
  8379. * @param rootUrl defines the url where the files to load is located
  8380. * @param scene defines the current scene
  8381. * @param files defines the list of files to load (1 per face)
  8382. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8383. * @param onLoad defines an optional callback raised when the texture is loaded
  8384. * @param onError defines an optional callback raised if there is an issue to load the texture
  8385. * @param format defines the format of the data
  8386. * @param forcedExtension defines the extension to use to pick the right loader
  8387. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8388. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8389. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8390. * @returns the cube texture as an InternalTexture
  8391. */
  8392. 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;
  8393. /** @hidden */ partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8394. /** @hidden */ cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8395. /** @hidden */ cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8396. /** @hidden */ partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /**
  8401. * Class for creating a cube texture
  8402. */
  8403. export class CubeTexture extends BaseTexture {
  8404. private _delayedOnLoad;
  8405. /**
  8406. * The url of the texture
  8407. */
  8408. url: string;
  8409. /**
  8410. * Gets or sets the center of the bounding box associated with the cube texture.
  8411. * It must define where the camera used to render the texture was set
  8412. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8413. */
  8414. boundingBoxPosition: Vector3;
  8415. private _boundingBoxSize;
  8416. /**
  8417. * Gets or sets the size of the bounding box associated with the cube texture
  8418. * When defined, the cubemap will switch to local mode
  8419. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8420. * @example https://www.babylonjs-playground.com/#RNASML
  8421. */
  8422. /**
  8423. * Returns the bounding box size
  8424. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8425. */
  8426. boundingBoxSize: Vector3;
  8427. protected _rotationY: number;
  8428. /**
  8429. * Sets texture matrix rotation angle around Y axis in radians.
  8430. */
  8431. /**
  8432. * Gets texture matrix rotation angle around Y axis radians.
  8433. */
  8434. rotationY: number;
  8435. /**
  8436. * Are mip maps generated for this texture or not.
  8437. */
  8438. readonly noMipmap: boolean;
  8439. private _noMipmap;
  8440. private _files;
  8441. private _extensions;
  8442. private _textureMatrix;
  8443. private _format;
  8444. private _createPolynomials;
  8445. /** @hidden */ prefiltered: boolean;
  8446. /**
  8447. * Creates a cube texture from an array of image urls
  8448. * @param files defines an array of image urls
  8449. * @param scene defines the hosting scene
  8450. * @param noMipmap specifies if mip maps are not used
  8451. * @returns a cube texture
  8452. */
  8453. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8454. /**
  8455. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8456. * @param url defines the url of the prefiltered texture
  8457. * @param scene defines the scene the texture is attached to
  8458. * @param forcedExtension defines the extension of the file if different from the url
  8459. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8460. * @return the prefiltered texture
  8461. */
  8462. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8463. /**
  8464. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8465. * as prefiltered data.
  8466. * @param rootUrl defines the url of the texture or the root name of the six images
  8467. * @param scene defines the scene the texture is attached to
  8468. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8469. * @param noMipmap defines if mipmaps should be created or not
  8470. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8471. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8472. * @param onError defines a callback triggered in case of error during load
  8473. * @param format defines the internal format to use for the texture once loaded
  8474. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8475. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8476. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8477. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8478. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8479. * @return the cube texture
  8480. */
  8481. 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);
  8482. /**
  8483. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8484. */
  8485. readonly isPrefiltered: boolean;
  8486. /**
  8487. * Get the current class name of the texture useful for serialization or dynamic coding.
  8488. * @returns "CubeTexture"
  8489. */
  8490. getClassName(): string;
  8491. /**
  8492. * Update the url (and optional buffer) of this texture if url was null during construction.
  8493. * @param url the url of the texture
  8494. * @param forcedExtension defines the extension to use
  8495. * @param onLoad callback called when the texture is loaded (defaults to null)
  8496. */
  8497. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8498. /**
  8499. * Delays loading of the cube texture
  8500. * @param forcedExtension defines the extension to use
  8501. */
  8502. delayLoad(forcedExtension?: string): void;
  8503. /**
  8504. * Returns the reflection texture matrix
  8505. * @returns the reflection texture matrix
  8506. */
  8507. getReflectionTextureMatrix(): Matrix;
  8508. /**
  8509. * Sets the reflection texture matrix
  8510. * @param value Reflection texture matrix
  8511. */
  8512. setReflectionTextureMatrix(value: Matrix): void;
  8513. /**
  8514. * Parses text to create a cube texture
  8515. * @param parsedTexture define the serialized text to read from
  8516. * @param scene defines the hosting scene
  8517. * @param rootUrl defines the root url of the cube texture
  8518. * @returns a cube texture
  8519. */
  8520. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8521. /**
  8522. * Makes a clone, or deep copy, of the cube texture
  8523. * @returns a new cube texture
  8524. */
  8525. clone(): CubeTexture;
  8526. }
  8527. }
  8528. declare module BABYLON {
  8529. /** @hidden */
  8530. export var postprocessVertexShader: {
  8531. name: string;
  8532. shader: string;
  8533. };
  8534. }
  8535. declare module BABYLON {
  8536. /**
  8537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. */
  8541. export class TargetCamera extends Camera {
  8542. private static _RigCamTransformMatrix;
  8543. private static _TargetTransformMatrix;
  8544. private static _TargetFocalPoint;
  8545. /**
  8546. * Define the current direction the camera is moving to
  8547. */
  8548. cameraDirection: Vector3;
  8549. /**
  8550. * Define the current rotation the camera is rotating to
  8551. */
  8552. cameraRotation: Vector2;
  8553. /**
  8554. * When set, the up vector of the camera will be updated by the rotation of the camera
  8555. */
  8556. updateUpVectorFromRotation: boolean;
  8557. private _tmpQuaternion;
  8558. /**
  8559. * Define the current rotation of the camera
  8560. */
  8561. rotation: Vector3;
  8562. /**
  8563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8564. */
  8565. rotationQuaternion: Quaternion;
  8566. /**
  8567. * Define the current speed of the camera
  8568. */
  8569. speed: number;
  8570. /**
  8571. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8572. * around all axis.
  8573. */
  8574. noRotationConstraint: boolean;
  8575. /**
  8576. * Define the current target of the camera as an object or a position.
  8577. */
  8578. lockedTarget: any;
  8579. /** @hidden */ currentTarget: Vector3;
  8580. /** @hidden */ initialFocalDistance: number;
  8581. /** @hidden */ viewMatrix: Matrix;
  8582. /** @hidden */ camMatrix: Matrix;
  8583. /** @hidden */ cameraTransformMatrix: Matrix;
  8584. /** @hidden */ cameraRotationMatrix: Matrix;
  8585. /** @hidden */ referencePoint: Vector3;
  8586. /** @hidden */ transformedReferencePoint: Vector3;
  8587. protected _globalCurrentTarget: Vector3;
  8588. protected _globalCurrentUpVector: Vector3;
  8589. /** @hidden */ reset: () => void;
  8590. private _defaultUp;
  8591. /**
  8592. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8593. * This is the base of the follow, arc rotate cameras and Free camera
  8594. * @see http://doc.babylonjs.com/features/cameras
  8595. * @param name Defines the name of the camera in the scene
  8596. * @param position Defines the start position of the camera in the scene
  8597. * @param scene Defines the scene the camera belongs to
  8598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8599. */
  8600. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8601. /**
  8602. * Gets the position in front of the camera at a given distance.
  8603. * @param distance The distance from the camera we want the position to be
  8604. * @returns the position
  8605. */
  8606. getFrontPosition(distance: number): Vector3;
  8607. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8608. private _storedPosition;
  8609. private _storedRotation;
  8610. private _storedRotationQuaternion;
  8611. /**
  8612. * Store current camera state of the camera (fov, position, rotation, etc..)
  8613. * @returns the camera
  8614. */
  8615. storeState(): Camera;
  8616. /**
  8617. * Restored camera state. You must call storeState() first
  8618. * @returns whether it was successful or not
  8619. * @hidden
  8620. */ restoreStateValues(): boolean;
  8621. /** @hidden */ initCache(): void;
  8622. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8624. /** @hidden */ computeLocalCameraSpeed(): number;
  8625. /**
  8626. * Defines the target the camera should look at.
  8627. * This will automatically adapt alpha beta and radius to fit within the new target.
  8628. * @param target Defines the new target as a Vector or a mesh
  8629. */
  8630. setTarget(target: Vector3): void;
  8631. /**
  8632. * Return the current target position of the camera. This value is expressed in local space.
  8633. * @returns the target position
  8634. */
  8635. getTarget(): Vector3;
  8636. /** @hidden */ decideIfNeedsToMove(): boolean;
  8637. /** @hidden */ updatePosition(): void;
  8638. /** @hidden */ checkInputs(): void;
  8639. protected _updateCameraRotationMatrix(): void;
  8640. /**
  8641. * 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)
  8642. * @returns the current camera
  8643. */
  8644. private _rotateUpVectorWithCameraRotationMatrix;
  8645. private _cachedRotationZ;
  8646. private _cachedQuaternionRotationZ;
  8647. /** @hidden */ getViewMatrix(): Matrix;
  8648. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8649. /**
  8650. * @hidden
  8651. */
  8652. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8653. /**
  8654. * @hidden
  8655. */ updateRigCameras(): void;
  8656. private _getRigCamPositionAndTarget;
  8657. /**
  8658. * Gets the current object class name.
  8659. * @return the class name
  8660. */
  8661. getClassName(): string;
  8662. }
  8663. }
  8664. declare module BABYLON {
  8665. /**
  8666. * @ignore
  8667. * This is a list of all the different input types that are available in the application.
  8668. * Fo instance: ArcRotateCameraGamepadInput...
  8669. */
  8670. export var CameraInputTypes: {};
  8671. /**
  8672. * This is the contract to implement in order to create a new input class.
  8673. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8674. */
  8675. export interface ICameraInput<TCamera extends Camera> {
  8676. /**
  8677. * Defines the camera the input is attached to.
  8678. */
  8679. camera: Nullable<TCamera>;
  8680. /**
  8681. * Gets the class name of the current intput.
  8682. * @returns the class name
  8683. */
  8684. getClassName(): string;
  8685. /**
  8686. * Get the friendly name associated with the input class.
  8687. * @returns the input friendly name
  8688. */
  8689. getSimpleName(): string;
  8690. /**
  8691. * Attach the input controls to a specific dom element to get the input from.
  8692. * @param element Defines the element the controls should be listened from
  8693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8694. */
  8695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8696. /**
  8697. * Detach the current controls from the specified dom element.
  8698. * @param element Defines the element to stop listening the inputs from
  8699. */
  8700. detachControl(element: Nullable<HTMLElement>): void;
  8701. /**
  8702. * Update the current camera state depending on the inputs that have been used this frame.
  8703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8704. */
  8705. checkInputs?: () => void;
  8706. }
  8707. /**
  8708. * Represents a map of input types to input instance or input index to input instance.
  8709. */
  8710. export interface CameraInputsMap<TCamera extends Camera> {
  8711. /**
  8712. * Accessor to the input by input type.
  8713. */
  8714. [name: string]: ICameraInput<TCamera>;
  8715. /**
  8716. * Accessor to the input by input index.
  8717. */
  8718. [idx: number]: ICameraInput<TCamera>;
  8719. }
  8720. /**
  8721. * This represents the input manager used within a camera.
  8722. * It helps dealing with all the different kind of input attached to a camera.
  8723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8724. */
  8725. export class CameraInputsManager<TCamera extends Camera> {
  8726. /**
  8727. * Defines the list of inputs attahed to the camera.
  8728. */
  8729. attached: CameraInputsMap<TCamera>;
  8730. /**
  8731. * Defines the dom element the camera is collecting inputs from.
  8732. * This is null if the controls have not been attached.
  8733. */
  8734. attachedElement: Nullable<HTMLElement>;
  8735. /**
  8736. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8737. */
  8738. noPreventDefault: boolean;
  8739. /**
  8740. * Defined the camera the input manager belongs to.
  8741. */
  8742. camera: TCamera;
  8743. /**
  8744. * Update the current camera state depending on the inputs that have been used this frame.
  8745. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8746. */
  8747. checkInputs: () => void;
  8748. /**
  8749. * Instantiate a new Camera Input Manager.
  8750. * @param camera Defines the camera the input manager blongs to
  8751. */
  8752. constructor(camera: TCamera);
  8753. /**
  8754. * Add an input method to a camera
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. * @param input camera input method
  8757. */
  8758. add(input: ICameraInput<TCamera>): void;
  8759. /**
  8760. * Remove a specific input method from a camera
  8761. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8762. * @param inputToRemove camera input method
  8763. */
  8764. remove(inputToRemove: ICameraInput<TCamera>): void;
  8765. /**
  8766. * Remove a specific input type from a camera
  8767. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8768. * @param inputType the type of the input to remove
  8769. */
  8770. removeByType(inputType: string): void;
  8771. private _addCheckInputs;
  8772. /**
  8773. * Attach the input controls to the currently attached dom element to listen the events from.
  8774. * @param input Defines the input to attach
  8775. */
  8776. attachInput(input: ICameraInput<TCamera>): void;
  8777. /**
  8778. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8779. * @param element Defines the dom element to collect the events from
  8780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8781. */
  8782. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8783. /**
  8784. * Detach the current manager inputs controls from a specific dom element.
  8785. * @param element Defines the dom element to collect the events from
  8786. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8787. */
  8788. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8789. /**
  8790. * Rebuild the dynamic inputCheck function from the current list of
  8791. * defined inputs in the manager.
  8792. */
  8793. rebuildInputCheck(): void;
  8794. /**
  8795. * Remove all attached input methods from a camera
  8796. */
  8797. clear(): void;
  8798. /**
  8799. * Serialize the current input manager attached to a camera.
  8800. * This ensures than once parsed,
  8801. * the input associated to the camera will be identical to the current ones
  8802. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8803. */
  8804. serialize(serializedCamera: any): void;
  8805. /**
  8806. * Parses an input manager serialized JSON to restore the previous list of inputs
  8807. * and states associated to a camera.
  8808. * @param parsedCamera Defines the JSON to parse
  8809. */
  8810. parse(parsedCamera: any): void;
  8811. }
  8812. }
  8813. declare module BABYLON {
  8814. /**
  8815. * Gather the list of keyboard event types as constants.
  8816. */
  8817. export class KeyboardEventTypes {
  8818. /**
  8819. * The keydown event is fired when a key becomes active (pressed).
  8820. */
  8821. static readonly KEYDOWN: number;
  8822. /**
  8823. * The keyup event is fired when a key has been released.
  8824. */
  8825. static readonly KEYUP: number;
  8826. }
  8827. /**
  8828. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8829. */
  8830. export class KeyboardInfo {
  8831. /**
  8832. * Defines the type of event (KeyboardEventTypes)
  8833. */
  8834. type: number;
  8835. /**
  8836. * Defines the related dom event
  8837. */
  8838. event: KeyboardEvent;
  8839. /**
  8840. * Instantiates a new keyboard info.
  8841. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8842. * @param type Defines the type of event (KeyboardEventTypes)
  8843. * @param event Defines the related dom event
  8844. */
  8845. constructor(
  8846. /**
  8847. * Defines the type of event (KeyboardEventTypes)
  8848. */
  8849. type: number,
  8850. /**
  8851. * Defines the related dom event
  8852. */
  8853. event: KeyboardEvent);
  8854. }
  8855. /**
  8856. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8857. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8858. */
  8859. export class KeyboardInfoPre extends KeyboardInfo {
  8860. /**
  8861. * Defines the type of event (KeyboardEventTypes)
  8862. */
  8863. type: number;
  8864. /**
  8865. * Defines the related dom event
  8866. */
  8867. event: KeyboardEvent;
  8868. /**
  8869. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8870. */
  8871. skipOnPointerObservable: boolean;
  8872. /**
  8873. * Instantiates a new keyboard pre info.
  8874. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8875. * @param type Defines the type of event (KeyboardEventTypes)
  8876. * @param event Defines the related dom event
  8877. */
  8878. constructor(
  8879. /**
  8880. * Defines the type of event (KeyboardEventTypes)
  8881. */
  8882. type: number,
  8883. /**
  8884. * Defines the related dom event
  8885. */
  8886. event: KeyboardEvent);
  8887. }
  8888. }
  8889. declare module BABYLON {
  8890. /**
  8891. * Manage the keyboard inputs to control the movement of a free camera.
  8892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8893. */
  8894. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8895. /**
  8896. * Defines the camera the input is attached to.
  8897. */
  8898. camera: FreeCamera;
  8899. /**
  8900. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8901. */
  8902. keysUp: number[];
  8903. /**
  8904. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8905. */
  8906. keysDown: number[];
  8907. /**
  8908. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8909. */
  8910. keysLeft: number[];
  8911. /**
  8912. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8913. */
  8914. keysRight: number[];
  8915. private _keys;
  8916. private _onCanvasBlurObserver;
  8917. private _onKeyboardObserver;
  8918. private _engine;
  8919. private _scene;
  8920. /**
  8921. * Attach the input controls to a specific dom element to get the input from.
  8922. * @param element Defines the element the controls should be listened from
  8923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8924. */
  8925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8926. /**
  8927. * Detach the current controls from the specified dom element.
  8928. * @param element Defines the element to stop listening the inputs from
  8929. */
  8930. detachControl(element: Nullable<HTMLElement>): void;
  8931. /**
  8932. * Update the current camera state depending on the inputs that have been used this frame.
  8933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8934. */
  8935. checkInputs(): void;
  8936. /**
  8937. * Gets the class name of the current intput.
  8938. * @returns the class name
  8939. */
  8940. getClassName(): string;
  8941. /** @hidden */ onLostFocus(): void;
  8942. /**
  8943. * Get the friendly name associated with the input class.
  8944. * @returns the input friendly name
  8945. */
  8946. getSimpleName(): string;
  8947. }
  8948. }
  8949. declare module BABYLON {
  8950. /**
  8951. * Interface describing all the common properties and methods a shadow light needs to implement.
  8952. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8953. * as well as binding the different shadow properties to the effects.
  8954. */
  8955. export interface IShadowLight extends Light {
  8956. /**
  8957. * The light id in the scene (used in scene.findLighById for instance)
  8958. */
  8959. id: string;
  8960. /**
  8961. * The position the shdow will be casted from.
  8962. */
  8963. position: Vector3;
  8964. /**
  8965. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8966. */
  8967. direction: Vector3;
  8968. /**
  8969. * The transformed position. Position of the light in world space taking parenting in account.
  8970. */
  8971. transformedPosition: Vector3;
  8972. /**
  8973. * The transformed direction. Direction of the light in world space taking parenting in account.
  8974. */
  8975. transformedDirection: Vector3;
  8976. /**
  8977. * The friendly name of the light in the scene.
  8978. */
  8979. name: string;
  8980. /**
  8981. * Defines the shadow projection clipping minimum z value.
  8982. */
  8983. shadowMinZ: number;
  8984. /**
  8985. * Defines the shadow projection clipping maximum z value.
  8986. */
  8987. shadowMaxZ: number;
  8988. /**
  8989. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8990. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8991. */
  8992. computeTransformedInformation(): boolean;
  8993. /**
  8994. * Gets the scene the light belongs to.
  8995. * @returns The scene
  8996. */
  8997. getScene(): Scene;
  8998. /**
  8999. * Callback defining a custom Projection Matrix Builder.
  9000. * This can be used to override the default projection matrix computation.
  9001. */
  9002. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9003. /**
  9004. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9005. * @param matrix The materix to updated with the projection information
  9006. * @param viewMatrix The transform matrix of the light
  9007. * @param renderList The list of mesh to render in the map
  9008. * @returns The current light
  9009. */
  9010. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9011. /**
  9012. * Gets the current depth scale used in ESM.
  9013. * @returns The scale
  9014. */
  9015. getDepthScale(): number;
  9016. /**
  9017. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9018. * @returns true if a cube texture needs to be use
  9019. */
  9020. needCube(): boolean;
  9021. /**
  9022. * Detects if the projection matrix requires to be recomputed this frame.
  9023. * @returns true if it requires to be recomputed otherwise, false.
  9024. */
  9025. needProjectionMatrixCompute(): boolean;
  9026. /**
  9027. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9028. */
  9029. forceProjectionMatrixCompute(): void;
  9030. /**
  9031. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9032. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9033. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9034. */
  9035. getShadowDirection(faceIndex?: number): Vector3;
  9036. /**
  9037. * Gets the minZ used for shadow according to both the scene and the light.
  9038. * @param activeCamera The camera we are returning the min for
  9039. * @returns the depth min z
  9040. */
  9041. getDepthMinZ(activeCamera: Camera): number;
  9042. /**
  9043. * Gets the maxZ used for shadow according to both the scene and the light.
  9044. * @param activeCamera The camera we are returning the max for
  9045. * @returns the depth max z
  9046. */
  9047. getDepthMaxZ(activeCamera: Camera): number;
  9048. }
  9049. /**
  9050. * Base implementation IShadowLight
  9051. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9052. */
  9053. export abstract class ShadowLight extends Light implements IShadowLight {
  9054. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9055. protected _position: Vector3;
  9056. protected _setPosition(value: Vector3): void;
  9057. /**
  9058. * Sets the position the shadow will be casted from. Also use as the light position for both
  9059. * point and spot lights.
  9060. */
  9061. /**
  9062. * Sets the position the shadow will be casted from. Also use as the light position for both
  9063. * point and spot lights.
  9064. */
  9065. position: Vector3;
  9066. protected _direction: Vector3;
  9067. protected _setDirection(value: Vector3): void;
  9068. /**
  9069. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9070. * Also use as the light direction on spot and directional lights.
  9071. */
  9072. /**
  9073. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9074. * Also use as the light direction on spot and directional lights.
  9075. */
  9076. direction: Vector3;
  9077. private _shadowMinZ;
  9078. /**
  9079. * Gets the shadow projection clipping minimum z value.
  9080. */
  9081. /**
  9082. * Sets the shadow projection clipping minimum z value.
  9083. */
  9084. shadowMinZ: number;
  9085. private _shadowMaxZ;
  9086. /**
  9087. * Sets the shadow projection clipping maximum z value.
  9088. */
  9089. /**
  9090. * Gets the shadow projection clipping maximum z value.
  9091. */
  9092. shadowMaxZ: number;
  9093. /**
  9094. * Callback defining a custom Projection Matrix Builder.
  9095. * This can be used to override the default projection matrix computation.
  9096. */
  9097. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9098. /**
  9099. * The transformed position. Position of the light in world space taking parenting in account.
  9100. */
  9101. transformedPosition: Vector3;
  9102. /**
  9103. * The transformed direction. Direction of the light in world space taking parenting in account.
  9104. */
  9105. transformedDirection: Vector3;
  9106. private _needProjectionMatrixCompute;
  9107. /**
  9108. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9109. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9110. */
  9111. computeTransformedInformation(): boolean;
  9112. /**
  9113. * Return the depth scale used for the shadow map.
  9114. * @returns the depth scale.
  9115. */
  9116. getDepthScale(): number;
  9117. /**
  9118. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9119. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9120. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9121. */
  9122. getShadowDirection(faceIndex?: number): Vector3;
  9123. /**
  9124. * Returns the ShadowLight absolute position in the World.
  9125. * @returns the position vector in world space
  9126. */
  9127. getAbsolutePosition(): Vector3;
  9128. /**
  9129. * Sets the ShadowLight direction toward the passed target.
  9130. * @param target The point to target in local space
  9131. * @returns the updated ShadowLight direction
  9132. */
  9133. setDirectionToTarget(target: Vector3): Vector3;
  9134. /**
  9135. * Returns the light rotation in euler definition.
  9136. * @returns the x y z rotation in local space.
  9137. */
  9138. getRotation(): Vector3;
  9139. /**
  9140. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9141. * @returns true if a cube texture needs to be use
  9142. */
  9143. needCube(): boolean;
  9144. /**
  9145. * Detects if the projection matrix requires to be recomputed this frame.
  9146. * @returns true if it requires to be recomputed otherwise, false.
  9147. */
  9148. needProjectionMatrixCompute(): boolean;
  9149. /**
  9150. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9151. */
  9152. forceProjectionMatrixCompute(): void;
  9153. /** @hidden */ initCache(): void;
  9154. /** @hidden */ isSynchronized(): boolean;
  9155. /**
  9156. * Computes the world matrix of the node
  9157. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9158. * @returns the world matrix
  9159. */
  9160. computeWorldMatrix(force?: boolean): Matrix;
  9161. /**
  9162. * Gets the minZ used for shadow according to both the scene and the light.
  9163. * @param activeCamera The camera we are returning the min for
  9164. * @returns the depth min z
  9165. */
  9166. getDepthMinZ(activeCamera: Camera): number;
  9167. /**
  9168. * Gets the maxZ used for shadow according to both the scene and the light.
  9169. * @param activeCamera The camera we are returning the max for
  9170. * @returns the depth max z
  9171. */
  9172. getDepthMaxZ(activeCamera: Camera): number;
  9173. /**
  9174. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9175. * @param matrix The materix to updated with the projection information
  9176. * @param viewMatrix The transform matrix of the light
  9177. * @param renderList The list of mesh to render in the map
  9178. * @returns The current light
  9179. */
  9180. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9181. }
  9182. }
  9183. declare module BABYLON {
  9184. /**
  9185. * "Static Class" containing the most commonly used helper while dealing with material for
  9186. * rendering purpose.
  9187. *
  9188. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9189. *
  9190. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9191. */
  9192. export class MaterialHelper {
  9193. /**
  9194. * Bind the current view position to an effect.
  9195. * @param effect The effect to be bound
  9196. * @param scene The scene the eyes position is used from
  9197. */
  9198. static BindEyePosition(effect: Effect, scene: Scene): void;
  9199. /**
  9200. * Helps preparing the defines values about the UVs in used in the effect.
  9201. * UVs are shared as much as we can accross channels in the shaders.
  9202. * @param texture The texture we are preparing the UVs for
  9203. * @param defines The defines to update
  9204. * @param key The channel key "diffuse", "specular"... used in the shader
  9205. */
  9206. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9207. /**
  9208. * Binds a texture matrix value to its corrsponding uniform
  9209. * @param texture The texture to bind the matrix for
  9210. * @param uniformBuffer The uniform buffer receivin the data
  9211. * @param key The channel key "diffuse", "specular"... used in the shader
  9212. */
  9213. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9214. /**
  9215. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9216. * @param mesh defines the current mesh
  9217. * @param scene defines the current scene
  9218. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9219. * @param pointsCloud defines if point cloud rendering has to be turned on
  9220. * @param fogEnabled defines if fog has to be turned on
  9221. * @param alphaTest defines if alpha testing has to be turned on
  9222. * @param defines defines the current list of defines
  9223. */
  9224. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9225. /**
  9226. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9227. * @param scene defines the current scene
  9228. * @param engine defines the current engine
  9229. * @param defines specifies the list of active defines
  9230. * @param useInstances defines if instances have to be turned on
  9231. * @param useClipPlane defines if clip plane have to be turned on
  9232. */
  9233. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9234. /**
  9235. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9236. * @param mesh The mesh containing the geometry data we will draw
  9237. * @param defines The defines to update
  9238. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9239. * @param useBones Precise whether bones should be used or not (override mesh info)
  9240. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9241. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9242. * @returns false if defines are considered not dirty and have not been checked
  9243. */
  9244. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9245. /**
  9246. * Prepares the defines related to multiview
  9247. * @param scene The scene we are intending to draw
  9248. * @param defines The defines to update
  9249. */
  9250. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9251. /**
  9252. * Prepares the defines related to the light information passed in parameter
  9253. * @param scene The scene we are intending to draw
  9254. * @param mesh The mesh the effect is compiling for
  9255. * @param defines The defines to update
  9256. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9257. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9258. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9259. * @returns true if normals will be required for the rest of the effect
  9260. */
  9261. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9262. /**
  9263. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9264. * that won t be acctive due to defines being turned off.
  9265. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9266. * @param samplersList The samplers list
  9267. * @param defines The defines helping in the list generation
  9268. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9269. */
  9270. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9271. /**
  9272. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9273. * @param defines The defines to update while falling back
  9274. * @param fallbacks The authorized effect fallbacks
  9275. * @param maxSimultaneousLights The maximum number of lights allowed
  9276. * @param rank the current rank of the Effect
  9277. * @returns The newly affected rank
  9278. */
  9279. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9280. /**
  9281. * Prepares the list of attributes required for morph targets according to the effect defines.
  9282. * @param attribs The current list of supported attribs
  9283. * @param mesh The mesh to prepare the morph targets attributes for
  9284. * @param defines The current Defines of the effect
  9285. */
  9286. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9287. /**
  9288. * Prepares the list of attributes required for bones according to the effect defines.
  9289. * @param attribs The current list of supported attribs
  9290. * @param mesh The mesh to prepare the bones attributes for
  9291. * @param defines The current Defines of the effect
  9292. * @param fallbacks The current efffect fallback strategy
  9293. */
  9294. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9295. /**
  9296. * Prepares the list of attributes required for instances according to the effect defines.
  9297. * @param attribs The current list of supported attribs
  9298. * @param defines The current Defines of the effect
  9299. */
  9300. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9301. /**
  9302. * Binds the light shadow information to the effect for the given mesh.
  9303. * @param light The light containing the generator
  9304. * @param scene The scene the lights belongs to
  9305. * @param mesh The mesh we are binding the information to render
  9306. * @param lightIndex The light index in the effect used to render the mesh
  9307. * @param effect The effect we are binding the data to
  9308. */
  9309. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9310. /**
  9311. * Binds the light information to the effect.
  9312. * @param light The light containing the generator
  9313. * @param effect The effect we are binding the data to
  9314. * @param lightIndex The light index in the effect used to render
  9315. */
  9316. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9317. /**
  9318. * Binds the lights information from the scene to the effect for the given mesh.
  9319. * @param scene The scene the lights belongs to
  9320. * @param mesh The mesh we are binding the information to render
  9321. * @param effect The effect we are binding the data to
  9322. * @param defines The generated defines for the effect
  9323. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9324. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9325. */
  9326. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9327. private static _tempFogColor;
  9328. /**
  9329. * Binds the fog information from the scene to the effect for the given mesh.
  9330. * @param scene The scene the lights belongs to
  9331. * @param mesh The mesh we are binding the information to render
  9332. * @param effect The effect we are binding the data to
  9333. * @param linearSpace Defines if the fog effect is applied in linear space
  9334. */
  9335. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9336. /**
  9337. * Binds the bones information from the mesh to the effect.
  9338. * @param mesh The mesh we are binding the information to render
  9339. * @param effect The effect we are binding the data to
  9340. */
  9341. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9342. /**
  9343. * Binds the morph targets information from the mesh to the effect.
  9344. * @param abstractMesh The mesh we are binding the information to render
  9345. * @param effect The effect we are binding the data to
  9346. */
  9347. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9348. /**
  9349. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9350. * @param defines The generated defines used in the effect
  9351. * @param effect The effect we are binding the data to
  9352. * @param scene The scene we are willing to render with logarithmic scale for
  9353. */
  9354. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9355. /**
  9356. * Binds the clip plane information from the scene to the effect.
  9357. * @param scene The scene the clip plane information are extracted from
  9358. * @param effect The effect we are binding the data to
  9359. */
  9360. static BindClipPlane(effect: Effect, scene: Scene): void;
  9361. }
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var kernelBlurVaryingDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var kernelBlurFragment: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var kernelBlurFragment2: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var kernelBlurPixelShader: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var kernelBlurVertex: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var kernelBlurVertexShader: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /**
  9407. * The Blur Post Process which blurs an image based on a kernel and direction.
  9408. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9409. */
  9410. export class BlurPostProcess extends PostProcess {
  9411. /** The direction in which to blur the image. */
  9412. direction: Vector2;
  9413. private blockCompilation;
  9414. protected _kernel: number;
  9415. protected _idealKernel: number;
  9416. protected _packedFloat: boolean;
  9417. private _staticDefines;
  9418. /**
  9419. * Sets the length in pixels of the blur sample region
  9420. */
  9421. /**
  9422. * Gets the length in pixels of the blur sample region
  9423. */
  9424. kernel: number;
  9425. /**
  9426. * Sets wether or not the blur needs to unpack/repack floats
  9427. */
  9428. /**
  9429. * Gets wether or not the blur is unpacking/repacking floats
  9430. */
  9431. packedFloat: boolean;
  9432. /**
  9433. * Creates a new instance BlurPostProcess
  9434. * @param name The name of the effect.
  9435. * @param direction The direction in which to blur the image.
  9436. * @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.
  9437. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9438. * @param camera The camera to apply the render pass to.
  9439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9440. * @param engine The engine which the post process will be applied. (default: current engine)
  9441. * @param reusable If the post process can be reused on the same frame. (default: false)
  9442. * @param textureType Type of textures used when performing the post process. (default: 0)
  9443. * @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)
  9444. */
  9445. constructor(name: string,
  9446. /** The direction in which to blur the image. */
  9447. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9448. /**
  9449. * Updates the effect with the current post process compile time values and recompiles the shader.
  9450. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9451. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9452. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9453. * @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
  9454. * @param onCompiled Called when the shader has been compiled.
  9455. * @param onError Called if there is an error when compiling a shader.
  9456. */
  9457. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9458. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9459. /**
  9460. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9461. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9462. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9463. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9464. * The gaps between physical kernels are compensated for in the weighting of the samples
  9465. * @param idealKernel Ideal blur kernel.
  9466. * @return Nearest best kernel.
  9467. */
  9468. protected _nearestBestKernel(idealKernel: number): number;
  9469. /**
  9470. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9471. * @param x The point on the Gaussian distribution to sample.
  9472. * @return the value of the Gaussian function at x.
  9473. */
  9474. protected _gaussianWeight(x: number): number;
  9475. /**
  9476. * Generates a string that can be used as a floating point number in GLSL.
  9477. * @param x Value to print.
  9478. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9479. * @return GLSL float string.
  9480. */
  9481. protected _glslFloat(x: number, decimalFigures?: number): string;
  9482. }
  9483. }
  9484. declare module BABYLON {
  9485. /** @hidden */
  9486. export var shadowMapPixelShader: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module BABYLON {
  9492. /** @hidden */
  9493. export var bonesDeclaration: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module BABYLON {
  9499. /** @hidden */
  9500. export var morphTargetsVertexGlobalDeclaration: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module BABYLON {
  9506. /** @hidden */
  9507. export var morphTargetsVertexDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module BABYLON {
  9513. /** @hidden */
  9514. export var instancesDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module BABYLON {
  9520. /** @hidden */
  9521. export var helperFunctions: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module BABYLON {
  9527. /** @hidden */
  9528. export var morphTargetsVertex: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module BABYLON {
  9534. /** @hidden */
  9535. export var instancesVertex: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module BABYLON {
  9541. /** @hidden */
  9542. export var bonesVertex: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module BABYLON {
  9548. /** @hidden */
  9549. export var shadowMapVertexShader: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module BABYLON {
  9555. /** @hidden */
  9556. export var depthBoxBlurPixelShader: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module BABYLON {
  9562. /**
  9563. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9564. */
  9565. export interface ICustomShaderOptions {
  9566. /**
  9567. * Gets or sets the custom shader name to use
  9568. */
  9569. shaderName: string;
  9570. /**
  9571. * The list of attribute names used in the shader
  9572. */
  9573. attributes?: string[];
  9574. /**
  9575. * The list of unifrom names used in the shader
  9576. */
  9577. uniforms?: string[];
  9578. /**
  9579. * The list of sampler names used in the shader
  9580. */
  9581. samplers?: string[];
  9582. /**
  9583. * The list of defines used in the shader
  9584. */
  9585. defines?: string[];
  9586. }
  9587. /**
  9588. * Interface to implement to create a shadow generator compatible with BJS.
  9589. */
  9590. export interface IShadowGenerator {
  9591. /**
  9592. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9593. * @returns The render target texture if present otherwise, null
  9594. */
  9595. getShadowMap(): Nullable<RenderTargetTexture>;
  9596. /**
  9597. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9598. * @returns The render target texture if the shadow map is present otherwise, null
  9599. */
  9600. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9601. /**
  9602. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9603. * @param subMesh The submesh we want to render in the shadow map
  9604. * @param useInstances Defines wether will draw in the map using instances
  9605. * @returns true if ready otherwise, false
  9606. */
  9607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9608. /**
  9609. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9610. * @param defines Defines of the material we want to update
  9611. * @param lightIndex Index of the light in the enabled light list of the material
  9612. */
  9613. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9614. /**
  9615. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9616. * defined in the generator but impacting the effect).
  9617. * It implies the unifroms available on the materials are the standard BJS ones.
  9618. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9619. * @param effect The effect we are binfing the information for
  9620. */
  9621. bindShadowLight(lightIndex: string, effect: Effect): void;
  9622. /**
  9623. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9624. * (eq to shadow prjection matrix * light transform matrix)
  9625. * @returns The transform matrix used to create the shadow map
  9626. */
  9627. getTransformMatrix(): Matrix;
  9628. /**
  9629. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9630. * Cube and 2D textures for instance.
  9631. */
  9632. recreateShadowMap(): void;
  9633. /**
  9634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9635. * @param onCompiled Callback triggered at the and of the effects compilation
  9636. * @param options Sets of optional options forcing the compilation with different modes
  9637. */
  9638. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9639. useInstances: boolean;
  9640. }>): void;
  9641. /**
  9642. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9643. * @param options Sets of optional options forcing the compilation with different modes
  9644. * @returns A promise that resolves when the compilation completes
  9645. */
  9646. forceCompilationAsync(options?: Partial<{
  9647. useInstances: boolean;
  9648. }>): Promise<void>;
  9649. /**
  9650. * Serializes the shadow generator setup to a json object.
  9651. * @returns The serialized JSON object
  9652. */
  9653. serialize(): any;
  9654. /**
  9655. * Disposes the Shadow map and related Textures and effects.
  9656. */
  9657. dispose(): void;
  9658. }
  9659. /**
  9660. * Default implementation IShadowGenerator.
  9661. * This is the main object responsible of generating shadows in the framework.
  9662. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9663. */
  9664. export class ShadowGenerator implements IShadowGenerator {
  9665. /**
  9666. * Shadow generator mode None: no filtering applied.
  9667. */
  9668. static readonly FILTER_NONE: number;
  9669. /**
  9670. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9671. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9672. */
  9673. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9674. /**
  9675. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9676. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9677. */
  9678. static readonly FILTER_POISSONSAMPLING: number;
  9679. /**
  9680. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9681. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9682. */
  9683. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9684. /**
  9685. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9686. * edge artifacts on steep falloff.
  9687. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9688. */
  9689. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9690. /**
  9691. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9692. * edge artifacts on steep falloff.
  9693. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9694. */
  9695. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9696. /**
  9697. * Shadow generator mode PCF: Percentage Closer Filtering
  9698. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9699. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9700. */
  9701. static readonly FILTER_PCF: number;
  9702. /**
  9703. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9704. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9705. * Contact Hardening
  9706. */
  9707. static readonly FILTER_PCSS: number;
  9708. /**
  9709. * Reserved for PCF and PCSS
  9710. * Highest Quality.
  9711. *
  9712. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9713. *
  9714. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9715. */
  9716. static readonly QUALITY_HIGH: number;
  9717. /**
  9718. * Reserved for PCF and PCSS
  9719. * Good tradeoff for quality/perf cross devices
  9720. *
  9721. * Execute PCF on a 3*3 kernel.
  9722. *
  9723. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9724. */
  9725. static readonly QUALITY_MEDIUM: number;
  9726. /**
  9727. * Reserved for PCF and PCSS
  9728. * The lowest quality but the fastest.
  9729. *
  9730. * Execute PCF on a 1*1 kernel.
  9731. *
  9732. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9733. */
  9734. static readonly QUALITY_LOW: number;
  9735. /** Gets or sets the custom shader name to use */
  9736. customShaderOptions: ICustomShaderOptions;
  9737. /**
  9738. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9739. */
  9740. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9741. /**
  9742. * Observable triggered before a mesh is rendered in the shadow map.
  9743. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9744. */
  9745. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9746. private _bias;
  9747. /**
  9748. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9749. */
  9750. /**
  9751. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9752. */
  9753. bias: number;
  9754. private _normalBias;
  9755. /**
  9756. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9757. */
  9758. /**
  9759. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9760. */
  9761. normalBias: number;
  9762. private _blurBoxOffset;
  9763. /**
  9764. * Gets the blur box offset: offset applied during the blur pass.
  9765. * Only useful if useKernelBlur = false
  9766. */
  9767. /**
  9768. * Sets the blur box offset: offset applied during the blur pass.
  9769. * Only useful if useKernelBlur = false
  9770. */
  9771. blurBoxOffset: number;
  9772. private _blurScale;
  9773. /**
  9774. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9775. * 2 means half of the size.
  9776. */
  9777. /**
  9778. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9779. * 2 means half of the size.
  9780. */
  9781. blurScale: number;
  9782. private _blurKernel;
  9783. /**
  9784. * Gets the blur kernel: kernel size of the blur pass.
  9785. * Only useful if useKernelBlur = true
  9786. */
  9787. /**
  9788. * Sets the blur kernel: kernel size of the blur pass.
  9789. * Only useful if useKernelBlur = true
  9790. */
  9791. blurKernel: number;
  9792. private _useKernelBlur;
  9793. /**
  9794. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9795. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9796. */
  9797. /**
  9798. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9799. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9800. */
  9801. useKernelBlur: boolean;
  9802. private _depthScale;
  9803. /**
  9804. * Gets the depth scale used in ESM mode.
  9805. */
  9806. /**
  9807. * Sets the depth scale used in ESM mode.
  9808. * This can override the scale stored on the light.
  9809. */
  9810. depthScale: number;
  9811. private _filter;
  9812. /**
  9813. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9815. */
  9816. /**
  9817. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9818. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9819. */
  9820. filter: number;
  9821. /**
  9822. * Gets if the current filter is set to Poisson Sampling.
  9823. */
  9824. /**
  9825. * Sets the current filter to Poisson Sampling.
  9826. */
  9827. usePoissonSampling: boolean;
  9828. /**
  9829. * Gets if the current filter is set to ESM.
  9830. */
  9831. /**
  9832. * Sets the current filter is to ESM.
  9833. */
  9834. useExponentialShadowMap: boolean;
  9835. /**
  9836. * Gets if the current filter is set to filtered ESM.
  9837. */
  9838. /**
  9839. * Gets if the current filter is set to filtered ESM.
  9840. */
  9841. useBlurExponentialShadowMap: boolean;
  9842. /**
  9843. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9844. * exponential to prevent steep falloff artifacts).
  9845. */
  9846. /**
  9847. * Sets the current filter to "close ESM" (using the inverse of the
  9848. * exponential to prevent steep falloff artifacts).
  9849. */
  9850. useCloseExponentialShadowMap: boolean;
  9851. /**
  9852. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9853. * exponential to prevent steep falloff artifacts).
  9854. */
  9855. /**
  9856. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9857. * exponential to prevent steep falloff artifacts).
  9858. */
  9859. useBlurCloseExponentialShadowMap: boolean;
  9860. /**
  9861. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9862. */
  9863. /**
  9864. * Sets the current filter to "PCF" (percentage closer filtering).
  9865. */
  9866. usePercentageCloserFiltering: boolean;
  9867. private _filteringQuality;
  9868. /**
  9869. * Gets the PCF or PCSS Quality.
  9870. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9871. */
  9872. /**
  9873. * Sets the PCF or PCSS Quality.
  9874. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9875. */
  9876. filteringQuality: number;
  9877. /**
  9878. * Gets if the current filter is set to "PCSS" (contact hardening).
  9879. */
  9880. /**
  9881. * Sets the current filter to "PCSS" (contact hardening).
  9882. */
  9883. useContactHardeningShadow: boolean;
  9884. private _contactHardeningLightSizeUVRatio;
  9885. /**
  9886. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9887. * Using a ratio helps keeping shape stability independently of the map size.
  9888. *
  9889. * It does not account for the light projection as it was having too much
  9890. * instability during the light setup or during light position changes.
  9891. *
  9892. * Only valid if useContactHardeningShadow is true.
  9893. */
  9894. /**
  9895. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9896. * Using a ratio helps keeping shape stability independently of the map size.
  9897. *
  9898. * It does not account for the light projection as it was having too much
  9899. * instability during the light setup or during light position changes.
  9900. *
  9901. * Only valid if useContactHardeningShadow is true.
  9902. */
  9903. contactHardeningLightSizeUVRatio: number;
  9904. private _darkness;
  9905. /**
  9906. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9907. * 0 means strongest and 1 would means no shadow.
  9908. * @returns the darkness.
  9909. */
  9910. getDarkness(): number;
  9911. /**
  9912. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9913. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9914. * @returns the shadow generator allowing fluent coding.
  9915. */
  9916. setDarkness(darkness: number): ShadowGenerator;
  9917. private _transparencyShadow;
  9918. /**
  9919. * Sets the ability to have transparent shadow (boolean).
  9920. * @param transparent True if transparent else False
  9921. * @returns the shadow generator allowing fluent coding
  9922. */
  9923. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9924. private _shadowMap;
  9925. private _shadowMap2;
  9926. /**
  9927. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9928. * @returns The render target texture if present otherwise, null
  9929. */
  9930. getShadowMap(): Nullable<RenderTargetTexture>;
  9931. /**
  9932. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9933. * @returns The render target texture if the shadow map is present otherwise, null
  9934. */
  9935. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9936. /**
  9937. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9938. * @param mesh Mesh to add
  9939. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9940. * @returns the Shadow Generator itself
  9941. */
  9942. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9943. /**
  9944. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9945. * @param mesh Mesh to remove
  9946. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9947. * @returns the Shadow Generator itself
  9948. */
  9949. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9950. /**
  9951. * Controls the extent to which the shadows fade out at the edge of the frustum
  9952. * Used only by directionals and spots
  9953. */
  9954. frustumEdgeFalloff: number;
  9955. private _light;
  9956. /**
  9957. * Returns the associated light object.
  9958. * @returns the light generating the shadow
  9959. */
  9960. getLight(): IShadowLight;
  9961. /**
  9962. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9963. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9964. * It might on the other hand introduce peter panning.
  9965. */
  9966. forceBackFacesOnly: boolean;
  9967. private _scene;
  9968. private _lightDirection;
  9969. private _effect;
  9970. private _viewMatrix;
  9971. private _projectionMatrix;
  9972. private _transformMatrix;
  9973. private _cachedPosition;
  9974. private _cachedDirection;
  9975. private _cachedDefines;
  9976. private _currentRenderID;
  9977. private _boxBlurPostprocess;
  9978. private _kernelBlurXPostprocess;
  9979. private _kernelBlurYPostprocess;
  9980. private _blurPostProcesses;
  9981. private _mapSize;
  9982. private _currentFaceIndex;
  9983. private _currentFaceIndexCache;
  9984. private _textureType;
  9985. private _defaultTextureMatrix;
  9986. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9987. /**
  9988. * Creates a ShadowGenerator object.
  9989. * A ShadowGenerator is the required tool to use the shadows.
  9990. * Each light casting shadows needs to use its own ShadowGenerator.
  9991. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9992. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9993. * @param light The light object generating the shadows.
  9994. * @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.
  9995. */
  9996. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9997. private _initializeGenerator;
  9998. private _initializeShadowMap;
  9999. private _initializeBlurRTTAndPostProcesses;
  10000. private _renderForShadowMap;
  10001. private _renderSubMeshForShadowMap;
  10002. private _applyFilterValues;
  10003. /**
  10004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10005. * @param onCompiled Callback triggered at the and of the effects compilation
  10006. * @param options Sets of optional options forcing the compilation with different modes
  10007. */
  10008. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10009. useInstances: boolean;
  10010. }>): void;
  10011. /**
  10012. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10013. * @param options Sets of optional options forcing the compilation with different modes
  10014. * @returns A promise that resolves when the compilation completes
  10015. */
  10016. forceCompilationAsync(options?: Partial<{
  10017. useInstances: boolean;
  10018. }>): Promise<void>;
  10019. /**
  10020. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10021. * @param subMesh The submesh we want to render in the shadow map
  10022. * @param useInstances Defines wether will draw in the map using instances
  10023. * @returns true if ready otherwise, false
  10024. */
  10025. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10026. /**
  10027. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10028. * @param defines Defines of the material we want to update
  10029. * @param lightIndex Index of the light in the enabled light list of the material
  10030. */
  10031. prepareDefines(defines: any, lightIndex: number): void;
  10032. /**
  10033. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10034. * defined in the generator but impacting the effect).
  10035. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10036. * @param effect The effect we are binfing the information for
  10037. */
  10038. bindShadowLight(lightIndex: string, effect: Effect): void;
  10039. /**
  10040. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10041. * (eq to shadow prjection matrix * light transform matrix)
  10042. * @returns The transform matrix used to create the shadow map
  10043. */
  10044. getTransformMatrix(): Matrix;
  10045. /**
  10046. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10047. * Cube and 2D textures for instance.
  10048. */
  10049. recreateShadowMap(): void;
  10050. private _disposeBlurPostProcesses;
  10051. private _disposeRTTandPostProcesses;
  10052. /**
  10053. * Disposes the ShadowGenerator.
  10054. * Returns nothing.
  10055. */
  10056. dispose(): void;
  10057. /**
  10058. * Serializes the shadow generator setup to a json object.
  10059. * @returns The serialized JSON object
  10060. */
  10061. serialize(): any;
  10062. /**
  10063. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10064. * @param parsedShadowGenerator The JSON object to parse
  10065. * @param scene The scene to create the shadow map for
  10066. * @returns The parsed shadow generator
  10067. */
  10068. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10069. }
  10070. }
  10071. declare module BABYLON {
  10072. /**
  10073. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10074. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10075. * 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.
  10076. */
  10077. export abstract class Light extends Node {
  10078. /**
  10079. * Falloff Default: light is falling off following the material specification:
  10080. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10081. */
  10082. static readonly FALLOFF_DEFAULT: number;
  10083. /**
  10084. * Falloff Physical: light is falling off following the inverse squared distance law.
  10085. */
  10086. static readonly FALLOFF_PHYSICAL: number;
  10087. /**
  10088. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10089. * to enhance interoperability with other engines.
  10090. */
  10091. static readonly FALLOFF_GLTF: number;
  10092. /**
  10093. * Falloff Standard: light is falling off like in the standard material
  10094. * to enhance interoperability with other materials.
  10095. */
  10096. static readonly FALLOFF_STANDARD: number;
  10097. /**
  10098. * If every light affecting the material is in this lightmapMode,
  10099. * material.lightmapTexture adds or multiplies
  10100. * (depends on material.useLightmapAsShadowmap)
  10101. * after every other light calculations.
  10102. */
  10103. static readonly LIGHTMAP_DEFAULT: number;
  10104. /**
  10105. * material.lightmapTexture as only diffuse lighting from this light
  10106. * adds only specular lighting from this light
  10107. * adds dynamic shadows
  10108. */
  10109. static readonly LIGHTMAP_SPECULAR: number;
  10110. /**
  10111. * material.lightmapTexture as only lighting
  10112. * no light calculation from this light
  10113. * only adds dynamic shadows from this light
  10114. */
  10115. static readonly LIGHTMAP_SHADOWSONLY: number;
  10116. /**
  10117. * Each light type uses the default quantity according to its type:
  10118. * point/spot lights use luminous intensity
  10119. * directional lights use illuminance
  10120. */
  10121. static readonly INTENSITYMODE_AUTOMATIC: number;
  10122. /**
  10123. * lumen (lm)
  10124. */
  10125. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10126. /**
  10127. * candela (lm/sr)
  10128. */
  10129. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10130. /**
  10131. * lux (lm/m^2)
  10132. */
  10133. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10134. /**
  10135. * nit (cd/m^2)
  10136. */
  10137. static readonly INTENSITYMODE_LUMINANCE: number;
  10138. /**
  10139. * Light type const id of the point light.
  10140. */
  10141. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10142. /**
  10143. * Light type const id of the directional light.
  10144. */
  10145. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10146. /**
  10147. * Light type const id of the spot light.
  10148. */
  10149. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10150. /**
  10151. * Light type const id of the hemispheric light.
  10152. */
  10153. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10154. /**
  10155. * Diffuse gives the basic color to an object.
  10156. */
  10157. diffuse: Color3;
  10158. /**
  10159. * Specular produces a highlight color on an object.
  10160. * Note: This is note affecting PBR materials.
  10161. */
  10162. specular: Color3;
  10163. /**
  10164. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10165. * falling off base on range or angle.
  10166. * This can be set to any values in Light.FALLOFF_x.
  10167. *
  10168. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10169. * other types of materials.
  10170. */
  10171. falloffType: number;
  10172. /**
  10173. * Strength of the light.
  10174. * Note: By default it is define in the framework own unit.
  10175. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10176. */
  10177. intensity: number;
  10178. private _range;
  10179. protected _inverseSquaredRange: number;
  10180. /**
  10181. * Defines how far from the source the light is impacting in scene units.
  10182. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10183. */
  10184. /**
  10185. * Defines how far from the source the light is impacting in scene units.
  10186. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10187. */
  10188. range: number;
  10189. /**
  10190. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10191. * of light.
  10192. */
  10193. private _photometricScale;
  10194. private _intensityMode;
  10195. /**
  10196. * Gets the photometric scale used to interpret the intensity.
  10197. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10198. */
  10199. /**
  10200. * Sets the photometric scale used to interpret the intensity.
  10201. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10202. */
  10203. intensityMode: number;
  10204. private _radius;
  10205. /**
  10206. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10207. */
  10208. /**
  10209. * sets the light radius used by PBR Materials to simulate soft area lights.
  10210. */
  10211. radius: number;
  10212. private _renderPriority;
  10213. /**
  10214. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10215. * exceeding the number allowed of the materials.
  10216. */
  10217. renderPriority: number;
  10218. private _shadowEnabled;
  10219. /**
  10220. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10221. * the current shadow generator.
  10222. */
  10223. /**
  10224. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10225. * the current shadow generator.
  10226. */
  10227. shadowEnabled: boolean;
  10228. private _includedOnlyMeshes;
  10229. /**
  10230. * Gets the only meshes impacted by this light.
  10231. */
  10232. /**
  10233. * Sets the only meshes impacted by this light.
  10234. */
  10235. includedOnlyMeshes: AbstractMesh[];
  10236. private _excludedMeshes;
  10237. /**
  10238. * Gets the meshes not impacted by this light.
  10239. */
  10240. /**
  10241. * Sets the meshes not impacted by this light.
  10242. */
  10243. excludedMeshes: AbstractMesh[];
  10244. private _excludeWithLayerMask;
  10245. /**
  10246. * Gets the layer id use to find what meshes are not impacted by the light.
  10247. * Inactive if 0
  10248. */
  10249. /**
  10250. * Sets the layer id use to find what meshes are not impacted by the light.
  10251. * Inactive if 0
  10252. */
  10253. excludeWithLayerMask: number;
  10254. private _includeOnlyWithLayerMask;
  10255. /**
  10256. * Gets the layer id use to find what meshes are impacted by the light.
  10257. * Inactive if 0
  10258. */
  10259. /**
  10260. * Sets the layer id use to find what meshes are impacted by the light.
  10261. * Inactive if 0
  10262. */
  10263. includeOnlyWithLayerMask: number;
  10264. private _lightmapMode;
  10265. /**
  10266. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10267. */
  10268. /**
  10269. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10270. */
  10271. lightmapMode: number;
  10272. /**
  10273. * Shadow generator associted to the light.
  10274. * @hidden Internal use only.
  10275. */ shadowGenerator: Nullable<IShadowGenerator>;
  10276. /**
  10277. * @hidden Internal use only.
  10278. */ excludedMeshesIds: string[];
  10279. /**
  10280. * @hidden Internal use only.
  10281. */ includedOnlyMeshesIds: string[];
  10282. /**
  10283. * The current light unifom buffer.
  10284. * @hidden Internal use only.
  10285. */ uniformBuffer: UniformBuffer;
  10286. /**
  10287. * Creates a Light object in the scene.
  10288. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10289. * @param name The firendly name of the light
  10290. * @param scene The scene the light belongs too
  10291. */
  10292. constructor(name: string, scene: Scene);
  10293. protected abstract _buildUniformLayout(): void;
  10294. /**
  10295. * Sets the passed Effect "effect" with the Light information.
  10296. * @param effect The effect to update
  10297. * @param lightIndex The index of the light in the effect to update
  10298. * @returns The light
  10299. */
  10300. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10301. /**
  10302. * Returns the string "Light".
  10303. * @returns the class name
  10304. */
  10305. getClassName(): string;
  10306. /** @hidden */ protected readonly _isLight: boolean;
  10307. /**
  10308. * Converts the light information to a readable string for debug purpose.
  10309. * @param fullDetails Supports for multiple levels of logging within scene loading
  10310. * @returns the human readable light info
  10311. */
  10312. toString(fullDetails?: boolean): string;
  10313. /** @hidden */
  10314. protected _syncParentEnabledState(): void;
  10315. /**
  10316. * Set the enabled state of this node.
  10317. * @param value - the new enabled state
  10318. */
  10319. setEnabled(value: boolean): void;
  10320. /**
  10321. * Returns the Light associated shadow generator if any.
  10322. * @return the associated shadow generator.
  10323. */
  10324. getShadowGenerator(): Nullable<IShadowGenerator>;
  10325. /**
  10326. * Returns a Vector3, the absolute light position in the World.
  10327. * @returns the world space position of the light
  10328. */
  10329. getAbsolutePosition(): Vector3;
  10330. /**
  10331. * Specifies if the light will affect the passed mesh.
  10332. * @param mesh The mesh to test against the light
  10333. * @return true the mesh is affected otherwise, false.
  10334. */
  10335. canAffectMesh(mesh: AbstractMesh): boolean;
  10336. /**
  10337. * Sort function to order lights for rendering.
  10338. * @param a First Light object to compare to second.
  10339. * @param b Second Light object to compare first.
  10340. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10341. */
  10342. static CompareLightsPriority(a: Light, b: Light): number;
  10343. /**
  10344. * Releases resources associated with this node.
  10345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10347. */
  10348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10349. /**
  10350. * Returns the light type ID (integer).
  10351. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10352. */
  10353. getTypeID(): number;
  10354. /**
  10355. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10356. * @returns the scaled intensity in intensity mode unit
  10357. */
  10358. getScaledIntensity(): number;
  10359. /**
  10360. * Returns a new Light object, named "name", from the current one.
  10361. * @param name The name of the cloned light
  10362. * @returns the new created light
  10363. */
  10364. clone(name: string): Nullable<Light>;
  10365. /**
  10366. * Serializes the current light into a Serialization object.
  10367. * @returns the serialized object.
  10368. */
  10369. serialize(): any;
  10370. /**
  10371. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10372. * This new light is named "name" and added to the passed scene.
  10373. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10374. * @param name The friendly name of the light
  10375. * @param scene The scene the new light will belong to
  10376. * @returns the constructor function
  10377. */
  10378. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10379. /**
  10380. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10381. * @param parsedLight The JSON representation of the light
  10382. * @param scene The scene to create the parsed light in
  10383. * @returns the created light after parsing
  10384. */
  10385. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10386. private _hookArrayForExcluded;
  10387. private _hookArrayForIncludedOnly;
  10388. private _resyncMeshes;
  10389. /**
  10390. * Forces the meshes to update their light related information in their rendering used effects
  10391. * @hidden Internal Use Only
  10392. */ markMeshesAsLightDirty(): void;
  10393. /**
  10394. * Recomputes the cached photometric scale if needed.
  10395. */
  10396. private _computePhotometricScale;
  10397. /**
  10398. * Returns the Photometric Scale according to the light type and intensity mode.
  10399. */
  10400. private _getPhotometricScale;
  10401. /**
  10402. * Reorder the light in the scene according to their defined priority.
  10403. * @hidden Internal Use Only
  10404. */ reorderLightsInScene(): void;
  10405. /**
  10406. * Prepares the list of defines specific to the light type.
  10407. * @param defines the list of defines
  10408. * @param lightIndex defines the index of the light for the effect
  10409. */
  10410. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10411. }
  10412. }
  10413. declare module BABYLON {
  10414. /**
  10415. * Interface used to define Action
  10416. */
  10417. export interface IAction {
  10418. /**
  10419. * Trigger for the action
  10420. */
  10421. trigger: number;
  10422. /** Options of the trigger */
  10423. triggerOptions: any;
  10424. /**
  10425. * Gets the trigger parameters
  10426. * @returns the trigger parameters
  10427. */
  10428. getTriggerParameter(): any;
  10429. /**
  10430. * Internal only - executes current action event
  10431. * @hidden
  10432. */ executeCurrent(evt?: ActionEvent): void;
  10433. /**
  10434. * Serialize placeholder for child classes
  10435. * @param parent of child
  10436. * @returns the serialized object
  10437. */
  10438. serialize(parent: any): any;
  10439. /**
  10440. * Internal only
  10441. * @hidden
  10442. */ prepare(): void;
  10443. /**
  10444. * Internal only - manager for action
  10445. * @hidden
  10446. */ actionManager: AbstractActionManager;
  10447. }
  10448. /**
  10449. * The action to be carried out following a trigger
  10450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10451. */
  10452. export class Action implements IAction {
  10453. /** the trigger, with or without parameters, for the action */
  10454. triggerOptions: any;
  10455. /**
  10456. * Trigger for the action
  10457. */
  10458. trigger: number;
  10459. /**
  10460. * Internal only - manager for action
  10461. * @hidden
  10462. */ actionManager: ActionManager;
  10463. private _nextActiveAction;
  10464. private _child;
  10465. private _condition?;
  10466. private _triggerParameter;
  10467. /**
  10468. * An event triggered prior to action being executed.
  10469. */
  10470. onBeforeExecuteObservable: Observable<Action>;
  10471. /**
  10472. * Creates a new Action
  10473. * @param triggerOptions the trigger, with or without parameters, for the action
  10474. * @param condition an optional determinant of action
  10475. */
  10476. constructor(
  10477. /** the trigger, with or without parameters, for the action */
  10478. triggerOptions: any, condition?: Condition);
  10479. /**
  10480. * Internal only
  10481. * @hidden
  10482. */ prepare(): void;
  10483. /**
  10484. * Gets the trigger parameters
  10485. * @returns the trigger parameters
  10486. */
  10487. getTriggerParameter(): any;
  10488. /**
  10489. * Internal only - executes current action event
  10490. * @hidden
  10491. */ executeCurrent(evt?: ActionEvent): void;
  10492. /**
  10493. * Execute placeholder for child classes
  10494. * @param evt optional action event
  10495. */
  10496. execute(evt?: ActionEvent): void;
  10497. /**
  10498. * Skips to next active action
  10499. */
  10500. skipToNextActiveAction(): void;
  10501. /**
  10502. * Adds action to chain of actions, may be a DoNothingAction
  10503. * @param action defines the next action to execute
  10504. * @returns The action passed in
  10505. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10506. */
  10507. then(action: Action): Action;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */ getProperty(propertyPath: string): string;
  10512. /**
  10513. * Internal only
  10514. * @hidden
  10515. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10516. /**
  10517. * Serialize placeholder for child classes
  10518. * @param parent of child
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. /**
  10523. * Internal only called by serialize
  10524. * @hidden
  10525. */
  10526. protected _serialize(serializedAction: any, parent?: any): any;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */ private static _SerializeValueAsString: (value: any) => string;
  10531. /**
  10532. * Internal only
  10533. * @hidden
  10534. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10535. name: string;
  10536. targetType: string;
  10537. value: string;
  10538. };
  10539. }
  10540. }
  10541. declare module BABYLON {
  10542. /**
  10543. * A Condition applied to an Action
  10544. */
  10545. export class Condition {
  10546. /**
  10547. * Internal only - manager for action
  10548. * @hidden
  10549. */ actionManager: ActionManager;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */ evaluationId: number;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */ currentResult: boolean;
  10558. /**
  10559. * Creates a new Condition
  10560. * @param actionManager the manager of the action the condition is applied to
  10561. */
  10562. constructor(actionManager: ActionManager);
  10563. /**
  10564. * Check if the current condition is valid
  10565. * @returns a boolean
  10566. */
  10567. isValid(): boolean;
  10568. /**
  10569. * Internal only
  10570. * @hidden
  10571. */ getProperty(propertyPath: string): string;
  10572. /**
  10573. * Internal only
  10574. * @hidden
  10575. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10576. /**
  10577. * Serialize placeholder for child classes
  10578. * @returns the serialized object
  10579. */
  10580. serialize(): any;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. protected _serialize(serializedCondition: any): any;
  10586. }
  10587. /**
  10588. * Defines specific conditional operators as extensions of Condition
  10589. */
  10590. export class ValueCondition extends Condition {
  10591. /** path to specify the property of the target the conditional operator uses */
  10592. propertyPath: string;
  10593. /** the value compared by the conditional operator against the current value of the property */
  10594. value: any;
  10595. /** the conditional operator, default ValueCondition.IsEqual */
  10596. operator: number;
  10597. /**
  10598. * Internal only
  10599. * @hidden
  10600. */
  10601. private static _IsEqual;
  10602. /**
  10603. * Internal only
  10604. * @hidden
  10605. */
  10606. private static _IsDifferent;
  10607. /**
  10608. * Internal only
  10609. * @hidden
  10610. */
  10611. private static _IsGreater;
  10612. /**
  10613. * Internal only
  10614. * @hidden
  10615. */
  10616. private static _IsLesser;
  10617. /**
  10618. * returns the number for IsEqual
  10619. */
  10620. static readonly IsEqual: number;
  10621. /**
  10622. * Returns the number for IsDifferent
  10623. */
  10624. static readonly IsDifferent: number;
  10625. /**
  10626. * Returns the number for IsGreater
  10627. */
  10628. static readonly IsGreater: number;
  10629. /**
  10630. * Returns the number for IsLesser
  10631. */
  10632. static readonly IsLesser: number;
  10633. /**
  10634. * Internal only The action manager for the condition
  10635. * @hidden
  10636. */ actionManager: ActionManager;
  10637. /**
  10638. * Internal only
  10639. * @hidden
  10640. */
  10641. private _target;
  10642. /**
  10643. * Internal only
  10644. * @hidden
  10645. */
  10646. private _effectiveTarget;
  10647. /**
  10648. * Internal only
  10649. * @hidden
  10650. */
  10651. private _property;
  10652. /**
  10653. * Creates a new ValueCondition
  10654. * @param actionManager manager for the action the condition applies to
  10655. * @param target for the action
  10656. * @param propertyPath path to specify the property of the target the conditional operator uses
  10657. * @param value the value compared by the conditional operator against the current value of the property
  10658. * @param operator the conditional operator, default ValueCondition.IsEqual
  10659. */
  10660. constructor(actionManager: ActionManager, target: any,
  10661. /** path to specify the property of the target the conditional operator uses */
  10662. propertyPath: string,
  10663. /** the value compared by the conditional operator against the current value of the property */
  10664. value: any,
  10665. /** the conditional operator, default ValueCondition.IsEqual */
  10666. operator?: number);
  10667. /**
  10668. * Compares the given value with the property value for the specified conditional operator
  10669. * @returns the result of the comparison
  10670. */
  10671. isValid(): boolean;
  10672. /**
  10673. * Serialize the ValueCondition into a JSON compatible object
  10674. * @returns serialization object
  10675. */
  10676. serialize(): any;
  10677. /**
  10678. * Gets the name of the conditional operator for the ValueCondition
  10679. * @param operator the conditional operator
  10680. * @returns the name
  10681. */
  10682. static GetOperatorName(operator: number): string;
  10683. }
  10684. /**
  10685. * Defines a predicate condition as an extension of Condition
  10686. */
  10687. export class PredicateCondition extends Condition {
  10688. /** defines the predicate function used to validate the condition */
  10689. predicate: () => boolean;
  10690. /**
  10691. * Internal only - manager for action
  10692. * @hidden
  10693. */ actionManager: ActionManager;
  10694. /**
  10695. * Creates a new PredicateCondition
  10696. * @param actionManager manager for the action the condition applies to
  10697. * @param predicate defines the predicate function used to validate the condition
  10698. */
  10699. constructor(actionManager: ActionManager,
  10700. /** defines the predicate function used to validate the condition */
  10701. predicate: () => boolean);
  10702. /**
  10703. * @returns the validity of the predicate condition
  10704. */
  10705. isValid(): boolean;
  10706. }
  10707. /**
  10708. * Defines a state condition as an extension of Condition
  10709. */
  10710. export class StateCondition extends Condition {
  10711. /** Value to compare with target state */
  10712. value: string;
  10713. /**
  10714. * Internal only - manager for action
  10715. * @hidden
  10716. */ actionManager: ActionManager;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. private _target;
  10722. /**
  10723. * Creates a new StateCondition
  10724. * @param actionManager manager for the action the condition applies to
  10725. * @param target of the condition
  10726. * @param value to compare with target state
  10727. */
  10728. constructor(actionManager: ActionManager, target: any,
  10729. /** Value to compare with target state */
  10730. value: string);
  10731. /**
  10732. * Gets a boolean indicating if the current condition is met
  10733. * @returns the validity of the state
  10734. */
  10735. isValid(): boolean;
  10736. /**
  10737. * Serialize the StateCondition into a JSON compatible object
  10738. * @returns serialization object
  10739. */
  10740. serialize(): any;
  10741. }
  10742. }
  10743. declare module BABYLON {
  10744. /**
  10745. * This defines an action responsible to toggle a boolean once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class SwitchBooleanAction extends Action {
  10749. /**
  10750. * The path to the boolean property in the target object
  10751. */
  10752. propertyPath: string;
  10753. private _target;
  10754. private _effectiveTarget;
  10755. private _property;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the object containing the boolean
  10760. * @param propertyPath defines the path to the boolean property in the target object
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10764. /** @hidden */ prepare(): void;
  10765. /**
  10766. * Execute the action toggle the boolean value.
  10767. */
  10768. execute(): void;
  10769. /**
  10770. * Serializes the actions and its related information.
  10771. * @param parent defines the object to serialize in
  10772. * @returns the serialized object
  10773. */
  10774. serialize(parent: any): any;
  10775. }
  10776. /**
  10777. * This defines an action responsible to set a the state field of the target
  10778. * to a desired value once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class SetStateAction extends Action {
  10782. /**
  10783. * The value to store in the state field.
  10784. */
  10785. value: string;
  10786. private _target;
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param target defines the object containing the state property
  10791. * @param value defines the value to store in the state field
  10792. * @param condition defines the trigger related conditions
  10793. */
  10794. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10795. /**
  10796. * Execute the action and store the value on the target state property.
  10797. */
  10798. execute(): void;
  10799. /**
  10800. * Serializes the actions and its related information.
  10801. * @param parent defines the object to serialize in
  10802. * @returns the serialized object
  10803. */
  10804. serialize(parent: any): any;
  10805. }
  10806. /**
  10807. * This defines an action responsible to set a property of the target
  10808. * to a desired value once triggered.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class SetValueAction extends Action {
  10812. /**
  10813. * The path of the property to set in the target.
  10814. */
  10815. propertyPath: string;
  10816. /**
  10817. * The value to set in the property
  10818. */
  10819. value: any;
  10820. private _target;
  10821. private _effectiveTarget;
  10822. private _property;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the object containing the property
  10827. * @param propertyPath defines the path of the property to set in the target
  10828. * @param value defines the value to set in the property
  10829. * @param condition defines the trigger related conditions
  10830. */
  10831. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10832. /** @hidden */ prepare(): void;
  10833. /**
  10834. * Execute the action and set the targetted property to the desired value.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. /**
  10845. * This defines an action responsible to increment the target value
  10846. * to a desired value once triggered.
  10847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10848. */
  10849. export class IncrementValueAction extends Action {
  10850. /**
  10851. * The path of the property to increment in the target.
  10852. */
  10853. propertyPath: string;
  10854. /**
  10855. * The value we should increment the property by.
  10856. */
  10857. value: any;
  10858. private _target;
  10859. private _effectiveTarget;
  10860. private _property;
  10861. /**
  10862. * Instantiate the action
  10863. * @param triggerOptions defines the trigger options
  10864. * @param target defines the object containing the property
  10865. * @param propertyPath defines the path of the property to increment in the target
  10866. * @param value defines the value value we should increment the property by
  10867. * @param condition defines the trigger related conditions
  10868. */
  10869. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10870. /** @hidden */ prepare(): void;
  10871. /**
  10872. * Execute the action and increment the target of the value amount.
  10873. */
  10874. execute(): void;
  10875. /**
  10876. * Serializes the actions and its related information.
  10877. * @param parent defines the object to serialize in
  10878. * @returns the serialized object
  10879. */
  10880. serialize(parent: any): any;
  10881. }
  10882. /**
  10883. * This defines an action responsible to start an animation once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class PlayAnimationAction extends Action {
  10887. /**
  10888. * Where the animation should start (animation frame)
  10889. */
  10890. from: number;
  10891. /**
  10892. * Where the animation should stop (animation frame)
  10893. */
  10894. to: number;
  10895. /**
  10896. * Define if the animation should loop or stop after the first play.
  10897. */
  10898. loop?: boolean;
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the target animation or animation name
  10904. * @param from defines from where the animation should start (animation frame)
  10905. * @param end defines where the animation should stop (animation frame)
  10906. * @param loop defines if the animation should loop or stop after the first play
  10907. * @param condition defines the trigger related conditions
  10908. */
  10909. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10910. /** @hidden */ prepare(): void;
  10911. /**
  10912. * Execute the action and play the animation.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible to stop an animation once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class StopAnimationAction extends Action {
  10927. private _target;
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param target defines the target animation or animation name
  10932. * @param condition defines the trigger related conditions
  10933. */
  10934. constructor(triggerOptions: any, target: any, condition?: Condition);
  10935. /** @hidden */ prepare(): void;
  10936. /**
  10937. * Execute the action and stop the animation.
  10938. */
  10939. execute(): void;
  10940. /**
  10941. * Serializes the actions and its related information.
  10942. * @param parent defines the object to serialize in
  10943. * @returns the serialized object
  10944. */
  10945. serialize(parent: any): any;
  10946. }
  10947. /**
  10948. * This defines an action responsible that does nothing once triggered.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class DoNothingAction extends Action {
  10952. /**
  10953. * Instantiate the action
  10954. * @param triggerOptions defines the trigger options
  10955. * @param condition defines the trigger related conditions
  10956. */
  10957. constructor(triggerOptions?: any, condition?: Condition);
  10958. /**
  10959. * Execute the action and do nothing.
  10960. */
  10961. execute(): void;
  10962. /**
  10963. * Serializes the actions and its related information.
  10964. * @param parent defines the object to serialize in
  10965. * @returns the serialized object
  10966. */
  10967. serialize(parent: any): any;
  10968. }
  10969. /**
  10970. * This defines an action responsible to trigger several actions once triggered.
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10972. */
  10973. export class CombineAction extends Action {
  10974. /**
  10975. * The list of aggregated animations to run.
  10976. */
  10977. children: Action[];
  10978. /**
  10979. * Instantiate the action
  10980. * @param triggerOptions defines the trigger options
  10981. * @param children defines the list of aggregated animations to run
  10982. * @param condition defines the trigger related conditions
  10983. */
  10984. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10985. /** @hidden */ prepare(): void;
  10986. /**
  10987. * Execute the action and executes all the aggregated actions.
  10988. */
  10989. execute(evt: ActionEvent): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to run code (external event) once triggered.
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11000. */
  11001. export class ExecuteCodeAction extends Action {
  11002. /**
  11003. * The callback function to run.
  11004. */
  11005. func: (evt: ActionEvent) => void;
  11006. /**
  11007. * Instantiate the action
  11008. * @param triggerOptions defines the trigger options
  11009. * @param func defines the callback function to run
  11010. * @param condition defines the trigger related conditions
  11011. */
  11012. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11013. /**
  11014. * Execute the action and run the attached code.
  11015. */
  11016. execute(evt: ActionEvent): void;
  11017. }
  11018. /**
  11019. * This defines an action responsible to set the parent property of the target once triggered.
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11021. */
  11022. export class SetParentAction extends Action {
  11023. private _parent;
  11024. private _target;
  11025. /**
  11026. * Instantiate the action
  11027. * @param triggerOptions defines the trigger options
  11028. * @param target defines the target containing the parent property
  11029. * @param parent defines from where the animation should start (animation frame)
  11030. * @param condition defines the trigger related conditions
  11031. */
  11032. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11033. /** @hidden */ prepare(): void;
  11034. /**
  11035. * Execute the action and set the parent property.
  11036. */
  11037. execute(): void;
  11038. /**
  11039. * Serializes the actions and its related information.
  11040. * @param parent defines the object to serialize in
  11041. * @returns the serialized object
  11042. */
  11043. serialize(parent: any): any;
  11044. }
  11045. }
  11046. declare module BABYLON {
  11047. /**
  11048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11051. */
  11052. export class ActionManager extends AbstractActionManager {
  11053. /**
  11054. * Nothing
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly NothingTrigger: number;
  11058. /**
  11059. * On pick
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnPickTrigger: number;
  11063. /**
  11064. * On left pick
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnLeftPickTrigger: number;
  11068. /**
  11069. * On right pick
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnRightPickTrigger: number;
  11073. /**
  11074. * On center pick
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnCenterPickTrigger: number;
  11078. /**
  11079. * On pick down
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnPickDownTrigger: number;
  11083. /**
  11084. * On double pick
  11085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11086. */
  11087. static readonly OnDoublePickTrigger: number;
  11088. /**
  11089. * On pick up
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11091. */
  11092. static readonly OnPickUpTrigger: number;
  11093. /**
  11094. * On pick out.
  11095. * This trigger will only be raised if you also declared a OnPickDown
  11096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11097. */
  11098. static readonly OnPickOutTrigger: number;
  11099. /**
  11100. * On long press
  11101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11102. */
  11103. static readonly OnLongPressTrigger: number;
  11104. /**
  11105. * On pointer over
  11106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11107. */
  11108. static readonly OnPointerOverTrigger: number;
  11109. /**
  11110. * On pointer out
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11112. */
  11113. static readonly OnPointerOutTrigger: number;
  11114. /**
  11115. * On every frame
  11116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11117. */
  11118. static readonly OnEveryFrameTrigger: number;
  11119. /**
  11120. * On intersection enter
  11121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11122. */
  11123. static readonly OnIntersectionEnterTrigger: number;
  11124. /**
  11125. * On intersection exit
  11126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11127. */
  11128. static readonly OnIntersectionExitTrigger: number;
  11129. /**
  11130. * On key down
  11131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11132. */
  11133. static readonly OnKeyDownTrigger: number;
  11134. /**
  11135. * On key up
  11136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11137. */
  11138. static readonly OnKeyUpTrigger: number;
  11139. private _scene;
  11140. /**
  11141. * Creates a new action manager
  11142. * @param scene defines the hosting scene
  11143. */
  11144. constructor(scene: Scene);
  11145. /**
  11146. * Releases all associated resources
  11147. */
  11148. dispose(): void;
  11149. /**
  11150. * Gets hosting scene
  11151. * @returns the hosting scene
  11152. */
  11153. getScene(): Scene;
  11154. /**
  11155. * Does this action manager handles actions of any of the given triggers
  11156. * @param triggers defines the triggers to be tested
  11157. * @return a boolean indicating whether one (or more) of the triggers is handled
  11158. */
  11159. hasSpecificTriggers(triggers: number[]): boolean;
  11160. /**
  11161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11162. * speed.
  11163. * @param triggerA defines the trigger to be tested
  11164. * @param triggerB defines the trigger to be tested
  11165. * @return a boolean indicating whether one (or more) of the triggers is handled
  11166. */
  11167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11168. /**
  11169. * Does this action manager handles actions of a given trigger
  11170. * @param trigger defines the trigger to be tested
  11171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11172. * @return whether the trigger is handled
  11173. */
  11174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11175. /**
  11176. * Does this action manager has pointer triggers
  11177. */
  11178. readonly hasPointerTriggers: boolean;
  11179. /**
  11180. * Does this action manager has pick triggers
  11181. */
  11182. readonly hasPickTriggers: boolean;
  11183. /**
  11184. * Registers an action to this action manager
  11185. * @param action defines the action to be registered
  11186. * @return the action amended (prepared) after registration
  11187. */
  11188. registerAction(action: IAction): Nullable<IAction>;
  11189. /**
  11190. * Unregisters an action to this action manager
  11191. * @param action defines the action to be unregistered
  11192. * @return a boolean indicating whether the action has been unregistered
  11193. */
  11194. unregisterAction(action: IAction): Boolean;
  11195. /**
  11196. * Process a specific trigger
  11197. * @param trigger defines the trigger to process
  11198. * @param evt defines the event details to be processed
  11199. */
  11200. processTrigger(trigger: number, evt?: IActionEvent): void;
  11201. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11202. /** @hidden */ getProperty(propertyPath: string): string;
  11203. /**
  11204. * Serialize this manager to a JSON object
  11205. * @param name defines the property name to store this manager
  11206. * @returns a JSON representation of this manager
  11207. */
  11208. serialize(name: string): any;
  11209. /**
  11210. * Creates a new ActionManager from a JSON data
  11211. * @param parsedActions defines the JSON data to read from
  11212. * @param object defines the hosting mesh
  11213. * @param scene defines the hosting scene
  11214. */
  11215. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11216. /**
  11217. * Get a trigger name by index
  11218. * @param trigger defines the trigger index
  11219. * @returns a trigger name
  11220. */
  11221. static GetTriggerName(trigger: number): string;
  11222. }
  11223. }
  11224. declare module BABYLON {
  11225. /**
  11226. * Class representing a ray with position and direction
  11227. */
  11228. export class Ray {
  11229. /** origin point */
  11230. origin: Vector3;
  11231. /** direction */
  11232. direction: Vector3;
  11233. /** length of the ray */
  11234. length: number;
  11235. private static readonly TmpVector3;
  11236. private _tmpRay;
  11237. /**
  11238. * Creates a new ray
  11239. * @param origin origin point
  11240. * @param direction direction
  11241. * @param length length of the ray
  11242. */
  11243. constructor(
  11244. /** origin point */
  11245. origin: Vector3,
  11246. /** direction */
  11247. direction: Vector3,
  11248. /** length of the ray */
  11249. length?: number);
  11250. /**
  11251. * Checks if the ray intersects a box
  11252. * @param minimum bound of the box
  11253. * @param maximum bound of the box
  11254. * @param intersectionTreshold extra extend to be added to the box in all direction
  11255. * @returns if the box was hit
  11256. */
  11257. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11258. /**
  11259. * Checks if the ray intersects a box
  11260. * @param box the bounding box to check
  11261. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11262. * @returns if the box was hit
  11263. */
  11264. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11265. /**
  11266. * If the ray hits a sphere
  11267. * @param sphere the bounding sphere to check
  11268. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11269. * @returns true if it hits the sphere
  11270. */
  11271. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11272. /**
  11273. * If the ray hits a triange
  11274. * @param vertex0 triangle vertex
  11275. * @param vertex1 triangle vertex
  11276. * @param vertex2 triangle vertex
  11277. * @returns intersection information if hit
  11278. */
  11279. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11280. /**
  11281. * Checks if ray intersects a plane
  11282. * @param plane the plane to check
  11283. * @returns the distance away it was hit
  11284. */
  11285. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11286. /**
  11287. * Checks if ray intersects a mesh
  11288. * @param mesh the mesh to check
  11289. * @param fastCheck if only the bounding box should checked
  11290. * @returns picking info of the intersecton
  11291. */
  11292. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11293. /**
  11294. * Checks if ray intersects a mesh
  11295. * @param meshes the meshes to check
  11296. * @param fastCheck if only the bounding box should checked
  11297. * @param results array to store result in
  11298. * @returns Array of picking infos
  11299. */
  11300. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11301. private _comparePickingInfo;
  11302. private static smallnum;
  11303. private static rayl;
  11304. /**
  11305. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11306. * @param sega the first point of the segment to test the intersection against
  11307. * @param segb the second point of the segment to test the intersection against
  11308. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11309. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11310. */
  11311. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11312. /**
  11313. * Update the ray from viewport position
  11314. * @param x position
  11315. * @param y y position
  11316. * @param viewportWidth viewport width
  11317. * @param viewportHeight viewport height
  11318. * @param world world matrix
  11319. * @param view view matrix
  11320. * @param projection projection matrix
  11321. * @returns this ray updated
  11322. */
  11323. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11324. /**
  11325. * Creates a ray with origin and direction of 0,0,0
  11326. * @returns the new ray
  11327. */
  11328. static Zero(): Ray;
  11329. /**
  11330. * Creates a new ray from screen space and viewport
  11331. * @param x position
  11332. * @param y y position
  11333. * @param viewportWidth viewport width
  11334. * @param viewportHeight viewport height
  11335. * @param world world matrix
  11336. * @param view view matrix
  11337. * @param projection projection matrix
  11338. * @returns new ray
  11339. */
  11340. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11341. /**
  11342. * 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
  11343. * transformed to the given world matrix.
  11344. * @param origin The origin point
  11345. * @param end The end point
  11346. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11347. * @returns the new ray
  11348. */
  11349. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11350. /**
  11351. * Transforms a ray by a matrix
  11352. * @param ray ray to transform
  11353. * @param matrix matrix to apply
  11354. * @returns the resulting new ray
  11355. */
  11356. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11357. /**
  11358. * Transforms a ray by a matrix
  11359. * @param ray ray to transform
  11360. * @param matrix matrix to apply
  11361. * @param result ray to store result in
  11362. */
  11363. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11364. /**
  11365. * Unproject a ray from screen space to object space
  11366. * @param sourceX defines the screen space x coordinate to use
  11367. * @param sourceY defines the screen space y coordinate to use
  11368. * @param viewportWidth defines the current width of the viewport
  11369. * @param viewportHeight defines the current height of the viewport
  11370. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11371. * @param view defines the view matrix to use
  11372. * @param projection defines the projection matrix to use
  11373. */
  11374. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11375. }
  11376. /**
  11377. * Type used to define predicate used to select faces when a mesh intersection is detected
  11378. */
  11379. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11380. interface Scene {
  11381. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11382. /** @hidden */ cachedRayForTransform: Ray;
  11383. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11384. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11385. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11386. }
  11387. }
  11388. declare module BABYLON {
  11389. /**
  11390. * Groups all the scene component constants in one place to ease maintenance.
  11391. * @hidden
  11392. */
  11393. export class SceneComponentConstants {
  11394. static readonly NAME_EFFECTLAYER: string;
  11395. static readonly NAME_LAYER: string;
  11396. static readonly NAME_LENSFLARESYSTEM: string;
  11397. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11398. static readonly NAME_PARTICLESYSTEM: string;
  11399. static readonly NAME_GAMEPAD: string;
  11400. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11401. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11402. static readonly NAME_DEPTHRENDERER: string;
  11403. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11404. static readonly NAME_SPRITE: string;
  11405. static readonly NAME_OUTLINERENDERER: string;
  11406. static readonly NAME_PROCEDURALTEXTURE: string;
  11407. static readonly NAME_SHADOWGENERATOR: string;
  11408. static readonly NAME_OCTREE: string;
  11409. static readonly NAME_PHYSICSENGINE: string;
  11410. static readonly NAME_AUDIO: string;
  11411. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11412. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11413. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11414. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11416. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11417. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11418. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11419. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11420. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11421. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11422. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11423. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11424. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11425. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11426. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11427. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11428. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11429. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11430. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11431. static readonly STEP_AFTERRENDER_AUDIO: number;
  11432. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11433. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11436. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11437. static readonly STEP_POINTERMOVE_SPRITE: number;
  11438. static readonly STEP_POINTERDOWN_SPRITE: number;
  11439. static readonly STEP_POINTERUP_SPRITE: number;
  11440. }
  11441. /**
  11442. * This represents a scene component.
  11443. *
  11444. * This is used to decouple the dependency the scene is having on the different workloads like
  11445. * layers, post processes...
  11446. */
  11447. export interface ISceneComponent {
  11448. /**
  11449. * The name of the component. Each component must have a unique name.
  11450. */
  11451. name: string;
  11452. /**
  11453. * The scene the component belongs to.
  11454. */
  11455. scene: Scene;
  11456. /**
  11457. * Register the component to one instance of a scene.
  11458. */
  11459. register(): void;
  11460. /**
  11461. * Rebuilds the elements related to this component in case of
  11462. * context lost for instance.
  11463. */
  11464. rebuild(): void;
  11465. /**
  11466. * Disposes the component and the associated ressources.
  11467. */
  11468. dispose(): void;
  11469. }
  11470. /**
  11471. * This represents a SERIALIZABLE scene component.
  11472. *
  11473. * This extends Scene Component to add Serialization methods on top.
  11474. */
  11475. export interface ISceneSerializableComponent extends ISceneComponent {
  11476. /**
  11477. * Adds all the element from the container to the scene
  11478. * @param container the container holding the elements
  11479. */
  11480. addFromContainer(container: AbstractScene): void;
  11481. /**
  11482. * Removes all the elements in the container from the scene
  11483. * @param container contains the elements to remove
  11484. * @param dispose if the removed element should be disposed (default: false)
  11485. */
  11486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11487. /**
  11488. * Serializes the component data to the specified json object
  11489. * @param serializationObject The object to serialize to
  11490. */
  11491. serialize(serializationObject: any): void;
  11492. }
  11493. /**
  11494. * Strong typing of a Mesh related stage step action
  11495. */
  11496. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11497. /**
  11498. * Strong typing of a Evaluate Sub Mesh related stage step action
  11499. */
  11500. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11501. /**
  11502. * Strong typing of a Active Mesh related stage step action
  11503. */
  11504. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11505. /**
  11506. * Strong typing of a Camera related stage step action
  11507. */
  11508. export type CameraStageAction = (camera: Camera) => void;
  11509. /**
  11510. * Strong typing of a Camera Frame buffer related stage step action
  11511. */
  11512. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11513. /**
  11514. * Strong typing of a Render Target related stage step action
  11515. */
  11516. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11517. /**
  11518. * Strong typing of a RenderingGroup related stage step action
  11519. */
  11520. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11521. /**
  11522. * Strong typing of a Mesh Render related stage step action
  11523. */
  11524. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11525. /**
  11526. * Strong typing of a simple stage step action
  11527. */
  11528. export type SimpleStageAction = () => void;
  11529. /**
  11530. * Strong typing of a render target action.
  11531. */
  11532. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11533. /**
  11534. * Strong typing of a pointer move action.
  11535. */
  11536. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11537. /**
  11538. * Strong typing of a pointer up/down action.
  11539. */
  11540. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11541. /**
  11542. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11543. * @hidden
  11544. */
  11545. export class Stage<T extends Function> extends Array<{
  11546. index: number;
  11547. component: ISceneComponent;
  11548. action: T;
  11549. }> {
  11550. /**
  11551. * Hide ctor from the rest of the world.
  11552. * @param items The items to add.
  11553. */
  11554. private constructor();
  11555. /**
  11556. * Creates a new Stage.
  11557. * @returns A new instance of a Stage
  11558. */
  11559. static Create<T extends Function>(): Stage<T>;
  11560. /**
  11561. * Registers a step in an ordered way in the targeted stage.
  11562. * @param index Defines the position to register the step in
  11563. * @param component Defines the component attached to the step
  11564. * @param action Defines the action to launch during the step
  11565. */
  11566. registerStep(index: number, component: ISceneComponent, action: T): void;
  11567. /**
  11568. * Clears all the steps from the stage.
  11569. */
  11570. clear(): void;
  11571. }
  11572. }
  11573. declare module BABYLON {
  11574. interface Scene {
  11575. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11576. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11577. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11578. /**
  11579. * All of the sprite managers added to this scene
  11580. * @see http://doc.babylonjs.com/babylon101/sprites
  11581. */
  11582. spriteManagers: Array<ISpriteManager>;
  11583. /**
  11584. * An event triggered when sprites rendering is about to start
  11585. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11586. */
  11587. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11588. /**
  11589. * An event triggered when sprites rendering is done
  11590. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11591. */
  11592. onAfterSpritesRenderingObservable: Observable<Scene>;
  11593. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11594. /** Launch a ray to try to pick a sprite in the scene
  11595. * @param x position on screen
  11596. * @param y position on screen
  11597. * @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
  11598. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11599. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11600. * @returns a PickingInfo
  11601. */
  11602. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11603. /** Use the given ray to pick a sprite in the scene
  11604. * @param ray The ray (in world space) to use to pick meshes
  11605. * @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
  11606. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11607. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11608. * @returns a PickingInfo
  11609. */
  11610. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11611. /**
  11612. * Force the sprite under the pointer
  11613. * @param sprite defines the sprite to use
  11614. */
  11615. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11616. /**
  11617. * Gets the sprite under the pointer
  11618. * @returns a Sprite or null if no sprite is under the pointer
  11619. */
  11620. getPointerOverSprite(): Nullable<Sprite>;
  11621. }
  11622. /**
  11623. * Defines the sprite scene component responsible to manage sprites
  11624. * in a given scene.
  11625. */
  11626. export class SpriteSceneComponent implements ISceneComponent {
  11627. /**
  11628. * The component name helpfull to identify the component in the list of scene components.
  11629. */
  11630. readonly name: string;
  11631. /**
  11632. * The scene the component belongs to.
  11633. */
  11634. scene: Scene;
  11635. /** @hidden */
  11636. private _spritePredicate;
  11637. /**
  11638. * Creates a new instance of the component for the given scene
  11639. * @param scene Defines the scene to register the component in
  11640. */
  11641. constructor(scene: Scene);
  11642. /**
  11643. * Registers the component in a given scene
  11644. */
  11645. register(): void;
  11646. /**
  11647. * Rebuilds the elements related to this component in case of
  11648. * context lost for instance.
  11649. */
  11650. rebuild(): void;
  11651. /**
  11652. * Disposes the component and the associated ressources.
  11653. */
  11654. dispose(): void;
  11655. private _pickSpriteButKeepRay;
  11656. private _pointerMove;
  11657. private _pointerDown;
  11658. private _pointerUp;
  11659. }
  11660. }
  11661. declare module BABYLON {
  11662. /** @hidden */
  11663. export var fogFragmentDeclaration: {
  11664. name: string;
  11665. shader: string;
  11666. };
  11667. }
  11668. declare module BABYLON {
  11669. /** @hidden */
  11670. export var fogFragment: {
  11671. name: string;
  11672. shader: string;
  11673. };
  11674. }
  11675. declare module BABYLON {
  11676. /** @hidden */
  11677. export var spritesPixelShader: {
  11678. name: string;
  11679. shader: string;
  11680. };
  11681. }
  11682. declare module BABYLON {
  11683. /** @hidden */
  11684. export var fogVertexDeclaration: {
  11685. name: string;
  11686. shader: string;
  11687. };
  11688. }
  11689. declare module BABYLON {
  11690. /** @hidden */
  11691. export var spritesVertexShader: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module BABYLON {
  11697. /**
  11698. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11699. */
  11700. export interface ISpriteManager extends IDisposable {
  11701. /**
  11702. * Restricts the camera to viewing objects with the same layerMask.
  11703. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11704. */
  11705. layerMask: number;
  11706. /**
  11707. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11708. */
  11709. isPickable: boolean;
  11710. /**
  11711. * Specifies the rendering group id for this mesh (0 by default)
  11712. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11713. */
  11714. renderingGroupId: number;
  11715. /**
  11716. * Defines the list of sprites managed by the manager.
  11717. */
  11718. sprites: Array<Sprite>;
  11719. /**
  11720. * Tests the intersection of a sprite with a specific ray.
  11721. * @param ray The ray we are sending to test the collision
  11722. * @param camera The camera space we are sending rays in
  11723. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11724. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11725. * @returns picking info or null.
  11726. */
  11727. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11728. /**
  11729. * Renders the list of sprites on screen.
  11730. */
  11731. render(): void;
  11732. }
  11733. /**
  11734. * Class used to manage multiple sprites on the same spritesheet
  11735. * @see http://doc.babylonjs.com/babylon101/sprites
  11736. */
  11737. export class SpriteManager implements ISpriteManager {
  11738. /** defines the manager's name */
  11739. name: string;
  11740. /** Gets the list of sprites */
  11741. sprites: Sprite[];
  11742. /** Gets or sets the rendering group id (0 by default) */
  11743. renderingGroupId: number;
  11744. /** Gets or sets camera layer mask */
  11745. layerMask: number;
  11746. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11747. fogEnabled: boolean;
  11748. /** Gets or sets a boolean indicating if the sprites are pickable */
  11749. isPickable: boolean;
  11750. /** Defines the default width of a cell in the spritesheet */
  11751. cellWidth: number;
  11752. /** Defines the default height of a cell in the spritesheet */
  11753. cellHeight: number;
  11754. /**
  11755. * An event triggered when the manager is disposed.
  11756. */
  11757. onDisposeObservable: Observable<SpriteManager>;
  11758. private _onDisposeObserver;
  11759. /**
  11760. * Callback called when the manager is disposed
  11761. */
  11762. onDispose: () => void;
  11763. private _capacity;
  11764. private _spriteTexture;
  11765. private _epsilon;
  11766. private _scene;
  11767. private _vertexData;
  11768. private _buffer;
  11769. private _vertexBuffers;
  11770. private _indexBuffer;
  11771. private _effectBase;
  11772. private _effectFog;
  11773. /**
  11774. * Gets or sets the spritesheet texture
  11775. */
  11776. texture: Texture;
  11777. /**
  11778. * Creates a new sprite manager
  11779. * @param name defines the manager's name
  11780. * @param imgUrl defines the sprite sheet url
  11781. * @param capacity defines the maximum allowed number of sprites
  11782. * @param cellSize defines the size of a sprite cell
  11783. * @param scene defines the hosting scene
  11784. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11785. * @param samplingMode defines the smapling mode to use with spritesheet
  11786. */
  11787. constructor(
  11788. /** defines the manager's name */
  11789. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11790. private _appendSpriteVertex;
  11791. /**
  11792. * Intersects the sprites with a ray
  11793. * @param ray defines the ray to intersect with
  11794. * @param camera defines the current active camera
  11795. * @param predicate defines a predicate used to select candidate sprites
  11796. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11797. * @returns null if no hit or a PickingInfo
  11798. */
  11799. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11800. /**
  11801. * Render all child sprites
  11802. */
  11803. render(): void;
  11804. /**
  11805. * Release associated resources
  11806. */
  11807. dispose(): void;
  11808. }
  11809. }
  11810. declare module BABYLON {
  11811. /**
  11812. * Class used to represent a sprite
  11813. * @see http://doc.babylonjs.com/babylon101/sprites
  11814. */
  11815. export class Sprite {
  11816. /** defines the name */
  11817. name: string;
  11818. /** Gets or sets the current world position */
  11819. position: Vector3;
  11820. /** Gets or sets the main color */
  11821. color: Color4;
  11822. /** Gets or sets the width */
  11823. width: number;
  11824. /** Gets or sets the height */
  11825. height: number;
  11826. /** Gets or sets rotation angle */
  11827. angle: number;
  11828. /** Gets or sets the cell index in the sprite sheet */
  11829. cellIndex: number;
  11830. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11831. invertU: number;
  11832. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11833. invertV: number;
  11834. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11835. disposeWhenFinishedAnimating: boolean;
  11836. /** Gets the list of attached animations */
  11837. animations: Animation[];
  11838. /** Gets or sets a boolean indicating if the sprite can be picked */
  11839. isPickable: boolean;
  11840. /**
  11841. * Gets or sets the associated action manager
  11842. */
  11843. actionManager: Nullable<ActionManager>;
  11844. private _animationStarted;
  11845. private _loopAnimation;
  11846. private _fromIndex;
  11847. private _toIndex;
  11848. private _delay;
  11849. private _direction;
  11850. private _manager;
  11851. private _time;
  11852. private _onAnimationEnd;
  11853. /**
  11854. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11855. */
  11856. isVisible: boolean;
  11857. /**
  11858. * Gets or sets the sprite size
  11859. */
  11860. size: number;
  11861. /**
  11862. * Creates a new Sprite
  11863. * @param name defines the name
  11864. * @param manager defines the manager
  11865. */
  11866. constructor(
  11867. /** defines the name */
  11868. name: string, manager: ISpriteManager);
  11869. /**
  11870. * Starts an animation
  11871. * @param from defines the initial key
  11872. * @param to defines the end key
  11873. * @param loop defines if the animation must loop
  11874. * @param delay defines the start delay (in ms)
  11875. * @param onAnimationEnd defines a callback to call when animation ends
  11876. */
  11877. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11878. /** Stops current animation (if any) */
  11879. stopAnimation(): void;
  11880. /** @hidden */ animate(deltaTime: number): void;
  11881. /** Release associated resources */
  11882. dispose(): void;
  11883. }
  11884. }
  11885. declare module BABYLON {
  11886. /**
  11887. * Information about the result of picking within a scene
  11888. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11889. */
  11890. export class PickingInfo {
  11891. /** @hidden */ pickingUnavailable: boolean;
  11892. /**
  11893. * If the pick collided with an object
  11894. */
  11895. hit: boolean;
  11896. /**
  11897. * Distance away where the pick collided
  11898. */
  11899. distance: number;
  11900. /**
  11901. * The location of pick collision
  11902. */
  11903. pickedPoint: Nullable<Vector3>;
  11904. /**
  11905. * The mesh corresponding the the pick collision
  11906. */
  11907. pickedMesh: Nullable<AbstractMesh>;
  11908. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11909. bu: number;
  11910. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11911. bv: number;
  11912. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11913. faceId: number;
  11914. /** Id of the the submesh that was picked */
  11915. subMeshId: number;
  11916. /** If a sprite was picked, this will be the sprite the pick collided with */
  11917. pickedSprite: Nullable<Sprite>;
  11918. /**
  11919. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11920. */
  11921. originMesh: Nullable<AbstractMesh>;
  11922. /**
  11923. * The ray that was used to perform the picking.
  11924. */
  11925. ray: Nullable<Ray>;
  11926. /**
  11927. * Gets the normal correspodning to the face the pick collided with
  11928. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11929. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11930. * @returns The normal correspodning to the face the pick collided with
  11931. */
  11932. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11933. /**
  11934. * Gets the texture coordinates of where the pick occured
  11935. * @returns the vector containing the coordnates of the texture
  11936. */
  11937. getTextureCoordinates(): Nullable<Vector2>;
  11938. }
  11939. }
  11940. declare module BABYLON {
  11941. /**
  11942. * Gather the list of pointer event types as constants.
  11943. */
  11944. export class PointerEventTypes {
  11945. /**
  11946. * 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.
  11947. */
  11948. static readonly POINTERDOWN: number;
  11949. /**
  11950. * The pointerup event is fired when a pointer is no longer active.
  11951. */
  11952. static readonly POINTERUP: number;
  11953. /**
  11954. * The pointermove event is fired when a pointer changes coordinates.
  11955. */
  11956. static readonly POINTERMOVE: number;
  11957. /**
  11958. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11959. */
  11960. static readonly POINTERWHEEL: number;
  11961. /**
  11962. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11963. */
  11964. static readonly POINTERPICK: number;
  11965. /**
  11966. * The pointertap event is fired when a the object has been touched and released without drag.
  11967. */
  11968. static readonly POINTERTAP: number;
  11969. /**
  11970. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11971. */
  11972. static readonly POINTERDOUBLETAP: number;
  11973. }
  11974. /**
  11975. * Base class of pointer info types.
  11976. */
  11977. export class PointerInfoBase {
  11978. /**
  11979. * Defines the type of event (PointerEventTypes)
  11980. */
  11981. type: number;
  11982. /**
  11983. * Defines the related dom event
  11984. */
  11985. event: PointerEvent | MouseWheelEvent;
  11986. /**
  11987. * Instantiates the base class of pointers info.
  11988. * @param type Defines the type of event (PointerEventTypes)
  11989. * @param event Defines the related dom event
  11990. */
  11991. constructor(
  11992. /**
  11993. * Defines the type of event (PointerEventTypes)
  11994. */
  11995. type: number,
  11996. /**
  11997. * Defines the related dom event
  11998. */
  11999. event: PointerEvent | MouseWheelEvent);
  12000. }
  12001. /**
  12002. * This class is used to store pointer related info for the onPrePointerObservable event.
  12003. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12004. */
  12005. export class PointerInfoPre extends PointerInfoBase {
  12006. /**
  12007. * Ray from a pointer if availible (eg. 6dof controller)
  12008. */
  12009. ray: Nullable<Ray>;
  12010. /**
  12011. * Defines the local position of the pointer on the canvas.
  12012. */
  12013. localPosition: Vector2;
  12014. /**
  12015. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12016. */
  12017. skipOnPointerObservable: boolean;
  12018. /**
  12019. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12020. * @param type Defines the type of event (PointerEventTypes)
  12021. * @param event Defines the related dom event
  12022. * @param localX Defines the local x coordinates of the pointer when the event occured
  12023. * @param localY Defines the local y coordinates of the pointer when the event occured
  12024. */
  12025. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12026. }
  12027. /**
  12028. * This type contains all the data related to a pointer event in Babylon.js.
  12029. * 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.
  12030. */
  12031. export class PointerInfo extends PointerInfoBase {
  12032. /**
  12033. * Defines the picking info associated to the info (if any)\
  12034. */
  12035. pickInfo: Nullable<PickingInfo>;
  12036. /**
  12037. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12038. * @param type Defines the type of event (PointerEventTypes)
  12039. * @param event Defines the related dom event
  12040. * @param pickInfo Defines the picking info associated to the info (if any)\
  12041. */
  12042. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12043. /**
  12044. * Defines the picking info associated to the info (if any)\
  12045. */
  12046. pickInfo: Nullable<PickingInfo>);
  12047. }
  12048. /**
  12049. * Data relating to a touch event on the screen.
  12050. */
  12051. export interface PointerTouch {
  12052. /**
  12053. * X coordinate of touch.
  12054. */
  12055. x: number;
  12056. /**
  12057. * Y coordinate of touch.
  12058. */
  12059. y: number;
  12060. /**
  12061. * Id of touch. Unique for each finger.
  12062. */
  12063. pointerId: number;
  12064. /**
  12065. * Event type passed from DOM.
  12066. */
  12067. type: any;
  12068. }
  12069. }
  12070. declare module BABYLON {
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */ allowCameraRotation: boolean;
  12107. /**
  12108. * Manage the mouse inputs to control the movement of a free camera.
  12109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12110. * @param touchEnabled Defines if touch is enabled or not
  12111. */
  12112. constructor(
  12113. /**
  12114. * Define if touch is enabled in the mouse input
  12115. */
  12116. touchEnabled?: boolean);
  12117. /**
  12118. * Attach the input controls to a specific dom element to get the input from.
  12119. * @param element Defines the element the controls should be listened from
  12120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12121. */
  12122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12123. /**
  12124. * Called on JS contextmenu event.
  12125. * Override this method to provide functionality.
  12126. */
  12127. protected onContextMenu(evt: PointerEvent): void;
  12128. /**
  12129. * Detach the current controls from the specified dom element.
  12130. * @param element Defines the element to stop listening the inputs from
  12131. */
  12132. detachControl(element: Nullable<HTMLElement>): void;
  12133. /**
  12134. * Gets the class name of the current intput.
  12135. * @returns the class name
  12136. */
  12137. getClassName(): string;
  12138. /**
  12139. * Get the friendly name associated with the input class.
  12140. * @returns the input friendly name
  12141. */
  12142. getSimpleName(): string;
  12143. }
  12144. }
  12145. declare module BABYLON {
  12146. /**
  12147. * Manage the touch inputs to control the movement of a free camera.
  12148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12149. */
  12150. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12151. /**
  12152. * Defines the camera the input is attached to.
  12153. */
  12154. camera: FreeCamera;
  12155. /**
  12156. * Defines the touch sensibility for rotation.
  12157. * The higher the faster.
  12158. */
  12159. touchAngularSensibility: number;
  12160. /**
  12161. * Defines the touch sensibility for move.
  12162. * The higher the faster.
  12163. */
  12164. touchMoveSensibility: number;
  12165. private _offsetX;
  12166. private _offsetY;
  12167. private _pointerPressed;
  12168. private _pointerInput;
  12169. private _observer;
  12170. private _onLostFocus;
  12171. /**
  12172. * Attach the input controls to a specific dom element to get the input from.
  12173. * @param element Defines the element the controls should be listened from
  12174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12175. */
  12176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12177. /**
  12178. * Detach the current controls from the specified dom element.
  12179. * @param element Defines the element to stop listening the inputs from
  12180. */
  12181. detachControl(element: Nullable<HTMLElement>): void;
  12182. /**
  12183. * Update the current camera state depending on the inputs that have been used this frame.
  12184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12185. */
  12186. checkInputs(): void;
  12187. /**
  12188. * Gets the class name of the current intput.
  12189. * @returns the class name
  12190. */
  12191. getClassName(): string;
  12192. /**
  12193. * Get the friendly name associated with the input class.
  12194. * @returns the input friendly name
  12195. */
  12196. getSimpleName(): string;
  12197. }
  12198. }
  12199. declare module BABYLON {
  12200. /**
  12201. * Default Inputs manager for the FreeCamera.
  12202. * It groups all the default supported inputs for ease of use.
  12203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12204. */
  12205. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12206. /**
  12207. * @hidden
  12208. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12209. /**
  12210. * Instantiates a new FreeCameraInputsManager.
  12211. * @param camera Defines the camera the inputs belong to
  12212. */
  12213. constructor(camera: FreeCamera);
  12214. /**
  12215. * Add keyboard input support to the input manager.
  12216. * @returns the current input manager
  12217. */
  12218. addKeyboard(): FreeCameraInputsManager;
  12219. /**
  12220. * Add mouse input support to the input manager.
  12221. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12222. * @returns the current input manager
  12223. */
  12224. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12225. /**
  12226. * Removes the mouse input support from the manager
  12227. * @returns the current input manager
  12228. */
  12229. removeMouse(): FreeCameraInputsManager;
  12230. /**
  12231. * Add touch input support to the input manager.
  12232. * @returns the current input manager
  12233. */
  12234. addTouch(): FreeCameraInputsManager;
  12235. /**
  12236. * Remove all attached input methods from a camera
  12237. */
  12238. clear(): void;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. /**
  12243. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12244. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12246. */
  12247. export class FreeCamera extends TargetCamera {
  12248. /**
  12249. * Define the collision ellipsoid of the camera.
  12250. * This is helpful to simulate a camera body like the player body around the camera
  12251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12252. */
  12253. ellipsoid: Vector3;
  12254. /**
  12255. * Define an offset for the position of the ellipsoid around the camera.
  12256. * This can be helpful to determine the center of the body near the gravity center of the body
  12257. * instead of its head.
  12258. */
  12259. ellipsoidOffset: Vector3;
  12260. /**
  12261. * Enable or disable collisions of the camera with the rest of the scene objects.
  12262. */
  12263. checkCollisions: boolean;
  12264. /**
  12265. * Enable or disable gravity on the camera.
  12266. */
  12267. applyGravity: boolean;
  12268. /**
  12269. * Define the input manager associated to the camera.
  12270. */
  12271. inputs: FreeCameraInputsManager;
  12272. /**
  12273. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12274. * Higher values reduce sensitivity.
  12275. */
  12276. /**
  12277. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12278. * Higher values reduce sensitivity.
  12279. */
  12280. angularSensibility: number;
  12281. /**
  12282. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12283. */
  12284. keysUp: number[];
  12285. /**
  12286. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12287. */
  12288. keysDown: number[];
  12289. /**
  12290. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12291. */
  12292. keysLeft: number[];
  12293. /**
  12294. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12295. */
  12296. keysRight: number[];
  12297. /**
  12298. * Event raised when the camera collide with a mesh in the scene.
  12299. */
  12300. onCollide: (collidedMesh: AbstractMesh) => void;
  12301. private _collider;
  12302. private _needMoveForGravity;
  12303. private _oldPosition;
  12304. private _diffPosition;
  12305. private _newPosition;
  12306. /** @hidden */ localDirection: Vector3;
  12307. /** @hidden */ transformedDirection: Vector3;
  12308. /**
  12309. * Instantiates a Free Camera.
  12310. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12311. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12312. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12313. * @param name Define the name of the camera in the scene
  12314. * @param position Define the start position of the camera in the scene
  12315. * @param scene Define the scene the camera belongs to
  12316. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12317. */
  12318. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12319. /**
  12320. * Attached controls to the current camera.
  12321. * @param element Defines the element the controls should be listened from
  12322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12323. */
  12324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12325. /**
  12326. * Detach the current controls from the camera.
  12327. * The camera will stop reacting to inputs.
  12328. * @param element Defines the element to stop listening the inputs from
  12329. */
  12330. detachControl(element: HTMLElement): void;
  12331. private _collisionMask;
  12332. /**
  12333. * Define a collision mask to limit the list of object the camera can collide with
  12334. */
  12335. collisionMask: number;
  12336. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12337. private _onCollisionPositionChange;
  12338. /** @hidden */ checkInputs(): void;
  12339. /** @hidden */ decideIfNeedsToMove(): boolean;
  12340. /** @hidden */ updatePosition(): void;
  12341. /**
  12342. * Destroy the camera and release the current resources hold by it.
  12343. */
  12344. dispose(): void;
  12345. /**
  12346. * Gets the current object class name.
  12347. * @return the class name
  12348. */
  12349. getClassName(): string;
  12350. }
  12351. }
  12352. declare module BABYLON {
  12353. /**
  12354. * Represents a gamepad control stick position
  12355. */
  12356. export class StickValues {
  12357. /**
  12358. * The x component of the control stick
  12359. */
  12360. x: number;
  12361. /**
  12362. * The y component of the control stick
  12363. */
  12364. y: number;
  12365. /**
  12366. * Initializes the gamepad x and y control stick values
  12367. * @param x The x component of the gamepad control stick value
  12368. * @param y The y component of the gamepad control stick value
  12369. */
  12370. constructor(
  12371. /**
  12372. * The x component of the control stick
  12373. */
  12374. x: number,
  12375. /**
  12376. * The y component of the control stick
  12377. */
  12378. y: number);
  12379. }
  12380. /**
  12381. * An interface which manages callbacks for gamepad button changes
  12382. */
  12383. export interface GamepadButtonChanges {
  12384. /**
  12385. * Called when a gamepad has been changed
  12386. */
  12387. changed: boolean;
  12388. /**
  12389. * Called when a gamepad press event has been triggered
  12390. */
  12391. pressChanged: boolean;
  12392. /**
  12393. * Called when a touch event has been triggered
  12394. */
  12395. touchChanged: boolean;
  12396. /**
  12397. * Called when a value has changed
  12398. */
  12399. valueChanged: boolean;
  12400. }
  12401. /**
  12402. * Represents a gamepad
  12403. */
  12404. export class Gamepad {
  12405. /**
  12406. * The id of the gamepad
  12407. */
  12408. id: string;
  12409. /**
  12410. * The index of the gamepad
  12411. */
  12412. index: number;
  12413. /**
  12414. * The browser gamepad
  12415. */
  12416. browserGamepad: any;
  12417. /**
  12418. * Specifies what type of gamepad this represents
  12419. */
  12420. type: number;
  12421. private _leftStick;
  12422. private _rightStick;
  12423. /** @hidden */ isConnected: boolean;
  12424. private _leftStickAxisX;
  12425. private _leftStickAxisY;
  12426. private _rightStickAxisX;
  12427. private _rightStickAxisY;
  12428. /**
  12429. * Triggered when the left control stick has been changed
  12430. */
  12431. private _onleftstickchanged;
  12432. /**
  12433. * Triggered when the right control stick has been changed
  12434. */
  12435. private _onrightstickchanged;
  12436. /**
  12437. * Represents a gamepad controller
  12438. */
  12439. static GAMEPAD: number;
  12440. /**
  12441. * Represents a generic controller
  12442. */
  12443. static GENERIC: number;
  12444. /**
  12445. * Represents an XBox controller
  12446. */
  12447. static XBOX: number;
  12448. /**
  12449. * Represents a pose-enabled controller
  12450. */
  12451. static POSE_ENABLED: number;
  12452. /**
  12453. * Specifies whether the left control stick should be Y-inverted
  12454. */
  12455. protected _invertLeftStickY: boolean;
  12456. /**
  12457. * Specifies if the gamepad has been connected
  12458. */
  12459. readonly isConnected: boolean;
  12460. /**
  12461. * Initializes the gamepad
  12462. * @param id The id of the gamepad
  12463. * @param index The index of the gamepad
  12464. * @param browserGamepad The browser gamepad
  12465. * @param leftStickX The x component of the left joystick
  12466. * @param leftStickY The y component of the left joystick
  12467. * @param rightStickX The x component of the right joystick
  12468. * @param rightStickY The y component of the right joystick
  12469. */
  12470. constructor(
  12471. /**
  12472. * The id of the gamepad
  12473. */
  12474. id: string,
  12475. /**
  12476. * The index of the gamepad
  12477. */
  12478. index: number,
  12479. /**
  12480. * The browser gamepad
  12481. */
  12482. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12483. /**
  12484. * Callback triggered when the left joystick has changed
  12485. * @param callback
  12486. */
  12487. onleftstickchanged(callback: (values: StickValues) => void): void;
  12488. /**
  12489. * Callback triggered when the right joystick has changed
  12490. * @param callback
  12491. */
  12492. onrightstickchanged(callback: (values: StickValues) => void): void;
  12493. /**
  12494. * Gets the left joystick
  12495. */
  12496. /**
  12497. * Sets the left joystick values
  12498. */
  12499. leftStick: StickValues;
  12500. /**
  12501. * Gets the right joystick
  12502. */
  12503. /**
  12504. * Sets the right joystick value
  12505. */
  12506. rightStick: StickValues;
  12507. /**
  12508. * Updates the gamepad joystick positions
  12509. */
  12510. update(): void;
  12511. /**
  12512. * Disposes the gamepad
  12513. */
  12514. dispose(): void;
  12515. }
  12516. /**
  12517. * Represents a generic gamepad
  12518. */
  12519. export class GenericPad extends Gamepad {
  12520. private _buttons;
  12521. private _onbuttondown;
  12522. private _onbuttonup;
  12523. /**
  12524. * Observable triggered when a button has been pressed
  12525. */
  12526. onButtonDownObservable: Observable<number>;
  12527. /**
  12528. * Observable triggered when a button has been released
  12529. */
  12530. onButtonUpObservable: Observable<number>;
  12531. /**
  12532. * Callback triggered when a button has been pressed
  12533. * @param callback Called when a button has been pressed
  12534. */
  12535. onbuttondown(callback: (buttonPressed: number) => void): void;
  12536. /**
  12537. * Callback triggered when a button has been released
  12538. * @param callback Called when a button has been released
  12539. */
  12540. onbuttonup(callback: (buttonReleased: number) => void): void;
  12541. /**
  12542. * Initializes the generic gamepad
  12543. * @param id The id of the generic gamepad
  12544. * @param index The index of the generic gamepad
  12545. * @param browserGamepad The browser gamepad
  12546. */
  12547. constructor(id: string, index: number, browserGamepad: any);
  12548. private _setButtonValue;
  12549. /**
  12550. * Updates the generic gamepad
  12551. */
  12552. update(): void;
  12553. /**
  12554. * Disposes the generic gamepad
  12555. */
  12556. dispose(): void;
  12557. }
  12558. }
  12559. declare module BABYLON {
  12560. /**
  12561. * Defines the types of pose enabled controllers that are supported
  12562. */
  12563. export enum PoseEnabledControllerType {
  12564. /**
  12565. * HTC Vive
  12566. */
  12567. VIVE = 0,
  12568. /**
  12569. * Oculus Rift
  12570. */
  12571. OCULUS = 1,
  12572. /**
  12573. * Windows mixed reality
  12574. */
  12575. WINDOWS = 2,
  12576. /**
  12577. * Samsung gear VR
  12578. */
  12579. GEAR_VR = 3,
  12580. /**
  12581. * Google Daydream
  12582. */
  12583. DAYDREAM = 4,
  12584. /**
  12585. * Generic
  12586. */
  12587. GENERIC = 5
  12588. }
  12589. /**
  12590. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12591. */
  12592. export interface MutableGamepadButton {
  12593. /**
  12594. * Value of the button/trigger
  12595. */
  12596. value: number;
  12597. /**
  12598. * If the button/trigger is currently touched
  12599. */
  12600. touched: boolean;
  12601. /**
  12602. * If the button/trigger is currently pressed
  12603. */
  12604. pressed: boolean;
  12605. }
  12606. /**
  12607. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12608. * @hidden
  12609. */
  12610. export interface ExtendedGamepadButton extends GamepadButton {
  12611. /**
  12612. * If the button/trigger is currently pressed
  12613. */
  12614. readonly pressed: boolean;
  12615. /**
  12616. * If the button/trigger is currently touched
  12617. */
  12618. readonly touched: boolean;
  12619. /**
  12620. * Value of the button/trigger
  12621. */
  12622. readonly value: number;
  12623. }
  12624. /** @hidden */
  12625. export interface _GamePadFactory {
  12626. /**
  12627. * Returns wether or not the current gamepad can be created for this type of controller.
  12628. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12629. * @returns true if it can be created, otherwise false
  12630. */
  12631. canCreate(gamepadInfo: any): boolean;
  12632. /**
  12633. * Creates a new instance of the Gamepad.
  12634. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12635. * @returns the new gamepad instance
  12636. */
  12637. create(gamepadInfo: any): Gamepad;
  12638. }
  12639. /**
  12640. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12641. */
  12642. export class PoseEnabledControllerHelper {
  12643. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12644. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12645. /**
  12646. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12647. * @param vrGamepad the gamepad to initialized
  12648. * @returns a vr controller of the type the gamepad identified as
  12649. */
  12650. static InitiateController(vrGamepad: any): Gamepad;
  12651. }
  12652. /**
  12653. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12654. */
  12655. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12656. private _deviceRoomPosition;
  12657. private _deviceRoomRotationQuaternion;
  12658. /**
  12659. * The device position in babylon space
  12660. */
  12661. devicePosition: Vector3;
  12662. /**
  12663. * The device rotation in babylon space
  12664. */
  12665. deviceRotationQuaternion: Quaternion;
  12666. /**
  12667. * The scale factor of the device in babylon space
  12668. */
  12669. deviceScaleFactor: number;
  12670. /**
  12671. * (Likely devicePosition should be used instead) The device position in its room space
  12672. */
  12673. position: Vector3;
  12674. /**
  12675. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12676. */
  12677. rotationQuaternion: Quaternion;
  12678. /**
  12679. * The type of controller (Eg. Windows mixed reality)
  12680. */
  12681. controllerType: PoseEnabledControllerType;
  12682. protected _calculatedPosition: Vector3;
  12683. private _calculatedRotation;
  12684. /**
  12685. * The raw pose from the device
  12686. */
  12687. rawPose: DevicePose;
  12688. private _trackPosition;
  12689. private _maxRotationDistFromHeadset;
  12690. private _draggedRoomRotation;
  12691. /**
  12692. * @hidden
  12693. */ disableTrackPosition(fixedPosition: Vector3): void;
  12694. /**
  12695. * Internal, the mesh attached to the controller
  12696. * @hidden
  12697. */ mesh: Nullable<AbstractMesh>;
  12698. private _poseControlledCamera;
  12699. private _leftHandSystemQuaternion;
  12700. /**
  12701. * Internal, matrix used to convert room space to babylon space
  12702. * @hidden
  12703. */ deviceToWorld: Matrix;
  12704. /**
  12705. * Node to be used when casting a ray from the controller
  12706. * @hidden
  12707. */ pointingPoseNode: Nullable<TransformNode>;
  12708. /**
  12709. * Name of the child mesh that can be used to cast a ray from the controller
  12710. */
  12711. static readonly POINTING_POSE: string;
  12712. /**
  12713. * Creates a new PoseEnabledController from a gamepad
  12714. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12715. */
  12716. constructor(browserGamepad: any);
  12717. private _workingMatrix;
  12718. /**
  12719. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12720. */
  12721. update(): void;
  12722. /**
  12723. * Updates only the pose device and mesh without doing any button event checking
  12724. */
  12725. protected _updatePoseAndMesh(): void;
  12726. /**
  12727. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12728. * @param poseData raw pose fromthe device
  12729. */
  12730. updateFromDevice(poseData: DevicePose): void;
  12731. /**
  12732. * @hidden
  12733. */ meshAttachedObservable: Observable<AbstractMesh>;
  12734. /**
  12735. * Attaches a mesh to the controller
  12736. * @param mesh the mesh to be attached
  12737. */
  12738. attachToMesh(mesh: AbstractMesh): void;
  12739. /**
  12740. * Attaches the controllers mesh to a camera
  12741. * @param camera the camera the mesh should be attached to
  12742. */
  12743. attachToPoseControlledCamera(camera: TargetCamera): void;
  12744. /**
  12745. * Disposes of the controller
  12746. */
  12747. dispose(): void;
  12748. /**
  12749. * The mesh that is attached to the controller
  12750. */
  12751. readonly mesh: Nullable<AbstractMesh>;
  12752. /**
  12753. * Gets the ray of the controller in the direction the controller is pointing
  12754. * @param length the length the resulting ray should be
  12755. * @returns a ray in the direction the controller is pointing
  12756. */
  12757. getForwardRay(length?: number): Ray;
  12758. }
  12759. }
  12760. declare module BABYLON {
  12761. /**
  12762. * Defines the WebVRController object that represents controllers tracked in 3D space
  12763. */
  12764. export abstract class WebVRController extends PoseEnabledController {
  12765. /**
  12766. * Internal, the default controller model for the controller
  12767. */
  12768. protected _defaultModel: AbstractMesh;
  12769. /**
  12770. * Fired when the trigger state has changed
  12771. */
  12772. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12773. /**
  12774. * Fired when the main button state has changed
  12775. */
  12776. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12777. /**
  12778. * Fired when the secondary button state has changed
  12779. */
  12780. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12781. /**
  12782. * Fired when the pad state has changed
  12783. */
  12784. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12785. /**
  12786. * Fired when controllers stick values have changed
  12787. */
  12788. onPadValuesChangedObservable: Observable<StickValues>;
  12789. /**
  12790. * Array of button availible on the controller
  12791. */
  12792. protected _buttons: Array<MutableGamepadButton>;
  12793. private _onButtonStateChange;
  12794. /**
  12795. * Fired when a controller button's state has changed
  12796. * @param callback the callback containing the button that was modified
  12797. */
  12798. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12799. /**
  12800. * X and Y axis corrisponding to the controllers joystick
  12801. */
  12802. pad: StickValues;
  12803. /**
  12804. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12805. */
  12806. hand: string;
  12807. /**
  12808. * The default controller model for the controller
  12809. */
  12810. readonly defaultModel: AbstractMesh;
  12811. /**
  12812. * Creates a new WebVRController from a gamepad
  12813. * @param vrGamepad the gamepad that the WebVRController should be created from
  12814. */
  12815. constructor(vrGamepad: any);
  12816. /**
  12817. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12818. */
  12819. update(): void;
  12820. /**
  12821. * Function to be called when a button is modified
  12822. */
  12823. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12824. /**
  12825. * Loads a mesh and attaches it to the controller
  12826. * @param scene the scene the mesh should be added to
  12827. * @param meshLoaded callback for when the mesh has been loaded
  12828. */
  12829. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12830. private _setButtonValue;
  12831. private _changes;
  12832. private _checkChanges;
  12833. /**
  12834. * Disposes of th webVRCOntroller
  12835. */
  12836. dispose(): void;
  12837. }
  12838. }
  12839. declare module BABYLON {
  12840. /**
  12841. * The HemisphericLight simulates the ambient environment light,
  12842. * so the passed direction is the light reflection direction, not the incoming direction.
  12843. */
  12844. export class HemisphericLight extends Light {
  12845. /**
  12846. * The groundColor is the light in the opposite direction to the one specified during creation.
  12847. * 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.
  12848. */
  12849. groundColor: Color3;
  12850. /**
  12851. * The light reflection direction, not the incoming direction.
  12852. */
  12853. direction: Vector3;
  12854. /**
  12855. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12856. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12857. * The HemisphericLight can't cast shadows.
  12858. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12859. * @param name The friendly name of the light
  12860. * @param direction The direction of the light reflection
  12861. * @param scene The scene the light belongs to
  12862. */
  12863. constructor(name: string, direction: Vector3, scene: Scene);
  12864. protected _buildUniformLayout(): void;
  12865. /**
  12866. * Returns the string "HemisphericLight".
  12867. * @return The class name
  12868. */
  12869. getClassName(): string;
  12870. /**
  12871. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12872. * Returns the updated direction.
  12873. * @param target The target the direction should point to
  12874. * @return The computed direction
  12875. */
  12876. setDirectionToTarget(target: Vector3): Vector3;
  12877. /**
  12878. * Returns the shadow generator associated to the light.
  12879. * @returns Always null for hemispheric lights because it does not support shadows.
  12880. */
  12881. getShadowGenerator(): Nullable<IShadowGenerator>;
  12882. /**
  12883. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12884. * @param effect The effect to update
  12885. * @param lightIndex The index of the light in the effect to update
  12886. * @returns The hemispheric light
  12887. */
  12888. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12889. /**
  12890. * Computes the world matrix of the node
  12891. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12892. * @param useWasUpdatedFlag defines a reserved property
  12893. * @returns the world matrix
  12894. */
  12895. computeWorldMatrix(): Matrix;
  12896. /**
  12897. * Returns the integer 3.
  12898. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12899. */
  12900. getTypeID(): number;
  12901. /**
  12902. * Prepares the list of defines specific to the light type.
  12903. * @param defines the list of defines
  12904. * @param lightIndex defines the index of the light for the effect
  12905. */
  12906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12907. }
  12908. }
  12909. declare module BABYLON {
  12910. /** @hidden */
  12911. export var vrMultiviewToSingleviewPixelShader: {
  12912. name: string;
  12913. shader: string;
  12914. };
  12915. }
  12916. declare module BABYLON {
  12917. /**
  12918. * Renders to multiple views with a single draw call
  12919. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12920. */
  12921. export class MultiviewRenderTarget extends RenderTargetTexture {
  12922. /**
  12923. * Creates a multiview render target
  12924. * @param scene scene used with the render target
  12925. * @param size the size of the render target (used for each view)
  12926. */
  12927. constructor(scene: Scene, size?: number | {
  12928. width: number;
  12929. height: number;
  12930. } | {
  12931. ratio: number;
  12932. });
  12933. /**
  12934. * @hidden
  12935. * @param faceIndex the face index, if its a cube texture
  12936. */ bindFrameBuffer(faceIndex?: number): void;
  12937. /**
  12938. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12939. * @returns the view count
  12940. */
  12941. getViewCount(): number;
  12942. }
  12943. }
  12944. declare module BABYLON {
  12945. interface Engine {
  12946. /**
  12947. * Creates a new multiview render target
  12948. * @param width defines the width of the texture
  12949. * @param height defines the height of the texture
  12950. * @returns the created multiview texture
  12951. */
  12952. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12953. /**
  12954. * Binds a multiview framebuffer to be drawn to
  12955. * @param multiviewTexture texture to bind
  12956. */
  12957. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12958. }
  12959. interface Camera {
  12960. /**
  12961. * @hidden
  12962. * 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)
  12963. */ useMultiviewToSingleView: boolean;
  12964. /**
  12965. * @hidden
  12966. * 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)
  12967. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12968. /**
  12969. * @hidden
  12970. * ensures the multiview texture of the camera exists and has the specified width/height
  12971. * @param width height to set on the multiview texture
  12972. * @param height width to set on the multiview texture
  12973. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12974. }
  12975. interface Scene {
  12976. /** @hidden */ transformMatrixR: Matrix;
  12977. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12978. /** @hidden */ createMultiviewUbo(): void;
  12979. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12980. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12981. }
  12982. }
  12983. declare module BABYLON {
  12984. /**
  12985. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12986. * This will not be used for webXR as it supports displaying texture arrays directly
  12987. */
  12988. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12989. /**
  12990. * Initializes a VRMultiviewToSingleview
  12991. * @param name name of the post process
  12992. * @param camera camera to be applied to
  12993. * @param scaleFactor scaling factor to the size of the output texture
  12994. */
  12995. constructor(name: string, camera: Camera, scaleFactor: number);
  12996. }
  12997. }
  12998. declare module BABYLON {
  12999. /**
  13000. * Defines the interface used by display changed events
  13001. */
  13002. interface IDisplayChangedEventArgs {
  13003. /** Gets the vrDisplay object (if any) */
  13004. vrDisplay: Nullable<any>;
  13005. /** Gets a boolean indicating if webVR is supported */
  13006. vrSupported: boolean;
  13007. }
  13008. interface Engine {
  13009. /** @hidden */ vrDisplay: any;
  13010. /** @hidden */ vrSupported: boolean;
  13011. /** @hidden */ oldSize: Size;
  13012. /** @hidden */ oldHardwareScaleFactor: number;
  13013. /** @hidden */ vrExclusivePointerMode: boolean;
  13014. /** @hidden */ webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13015. /** @hidden */ onVRDisplayPointerRestricted: () => void;
  13016. /** @hidden */ onVRDisplayPointerUnrestricted: () => void;
  13017. /** @hidden */ onVrDisplayConnect: Nullable<(display: any) => void>;
  13018. /** @hidden */ onVrDisplayDisconnect: Nullable<() => void>;
  13019. /** @hidden */ onVrDisplayPresentChange: Nullable<() => void>;
  13020. /**
  13021. * Observable signaled when VR display mode changes
  13022. */
  13023. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13024. /**
  13025. * Observable signaled when VR request present is complete
  13026. */
  13027. onVRRequestPresentComplete: Observable<boolean>;
  13028. /**
  13029. * Observable signaled when VR request present starts
  13030. */
  13031. onVRRequestPresentStart: Observable<Engine>;
  13032. /**
  13033. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13034. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13035. */
  13036. isInVRExclusivePointerMode: boolean;
  13037. /**
  13038. * Gets a boolean indicating if a webVR device was detected
  13039. * @returns true if a webVR device was detected
  13040. */
  13041. isVRDevicePresent(): boolean;
  13042. /**
  13043. * Gets the current webVR device
  13044. * @returns the current webVR device (or null)
  13045. */
  13046. getVRDevice(): any;
  13047. /**
  13048. * Initializes a webVR display and starts listening to display change events
  13049. * The onVRDisplayChangedObservable will be notified upon these changes
  13050. * @returns A promise containing a VRDisplay and if vr is supported
  13051. */
  13052. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13053. /** @hidden */ getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13054. /**
  13055. * Call this function to switch to webVR mode
  13056. * Will do nothing if webVR is not supported or if there is no webVR device
  13057. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13058. */
  13059. enableVR(): void;
  13060. /** @hidden */ onVRFullScreenTriggered(): void;
  13061. }
  13062. }
  13063. declare module BABYLON {
  13064. /**
  13065. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13066. * IMPORTANT!! The data is right-hand data.
  13067. * @export
  13068. * @interface DevicePose
  13069. */
  13070. export interface DevicePose {
  13071. /**
  13072. * The position of the device, values in array are [x,y,z].
  13073. */
  13074. readonly position: Nullable<Float32Array>;
  13075. /**
  13076. * The linearVelocity of the device, values in array are [x,y,z].
  13077. */
  13078. readonly linearVelocity: Nullable<Float32Array>;
  13079. /**
  13080. * The linearAcceleration of the device, values in array are [x,y,z].
  13081. */
  13082. readonly linearAcceleration: Nullable<Float32Array>;
  13083. /**
  13084. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13085. */
  13086. readonly orientation: Nullable<Float32Array>;
  13087. /**
  13088. * The angularVelocity of the device, values in array are [x,y,z].
  13089. */
  13090. readonly angularVelocity: Nullable<Float32Array>;
  13091. /**
  13092. * The angularAcceleration of the device, values in array are [x,y,z].
  13093. */
  13094. readonly angularAcceleration: Nullable<Float32Array>;
  13095. }
  13096. /**
  13097. * Interface representing a pose controlled object in Babylon.
  13098. * A pose controlled object has both regular pose values as well as pose values
  13099. * from an external device such as a VR head mounted display
  13100. */
  13101. export interface PoseControlled {
  13102. /**
  13103. * The position of the object in babylon space.
  13104. */
  13105. position: Vector3;
  13106. /**
  13107. * The rotation quaternion of the object in babylon space.
  13108. */
  13109. rotationQuaternion: Quaternion;
  13110. /**
  13111. * The position of the device in babylon space.
  13112. */
  13113. devicePosition?: Vector3;
  13114. /**
  13115. * The rotation quaternion of the device in babylon space.
  13116. */
  13117. deviceRotationQuaternion: Quaternion;
  13118. /**
  13119. * The raw pose coming from the device.
  13120. */
  13121. rawPose: Nullable<DevicePose>;
  13122. /**
  13123. * The scale of the device to be used when translating from device space to babylon space.
  13124. */
  13125. deviceScaleFactor: number;
  13126. /**
  13127. * Updates the poseControlled values based on the input device pose.
  13128. * @param poseData the pose data to update the object with
  13129. */
  13130. updateFromDevice(poseData: DevicePose): void;
  13131. }
  13132. /**
  13133. * Set of options to customize the webVRCamera
  13134. */
  13135. export interface WebVROptions {
  13136. /**
  13137. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13138. */
  13139. trackPosition?: boolean;
  13140. /**
  13141. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13142. */
  13143. positionScale?: number;
  13144. /**
  13145. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13146. */
  13147. displayName?: string;
  13148. /**
  13149. * Should the native controller meshes be initialized. (default: true)
  13150. */
  13151. controllerMeshes?: boolean;
  13152. /**
  13153. * Creating a default HemiLight only on controllers. (default: true)
  13154. */
  13155. defaultLightingOnControllers?: boolean;
  13156. /**
  13157. * If you don't want to use the default VR button of the helper. (default: false)
  13158. */
  13159. useCustomVRButton?: boolean;
  13160. /**
  13161. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13162. */
  13163. customVRButton?: HTMLButtonElement;
  13164. /**
  13165. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13166. */
  13167. rayLength?: number;
  13168. /**
  13169. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13170. */
  13171. defaultHeight?: number;
  13172. /**
  13173. * If multiview should be used if availible (default: false)
  13174. */
  13175. useMultiview?: boolean;
  13176. }
  13177. /**
  13178. * This represents a WebVR camera.
  13179. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13180. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13181. */
  13182. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13183. private webVROptions;
  13184. /**
  13185. * @hidden
  13186. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13187. */ vrDevice: any;
  13188. /**
  13189. * The rawPose of the vrDevice.
  13190. */
  13191. rawPose: Nullable<DevicePose>;
  13192. private _onVREnabled;
  13193. private _specsVersion;
  13194. private _attached;
  13195. private _frameData;
  13196. protected _descendants: Array<Node>;
  13197. private _deviceRoomPosition;
  13198. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  13199. private _standingMatrix;
  13200. /**
  13201. * Represents device position in babylon space.
  13202. */
  13203. devicePosition: Vector3;
  13204. /**
  13205. * Represents device rotation in babylon space.
  13206. */
  13207. deviceRotationQuaternion: Quaternion;
  13208. /**
  13209. * The scale of the device to be used when translating from device space to babylon space.
  13210. */
  13211. deviceScaleFactor: number;
  13212. private _deviceToWorld;
  13213. private _worldToDevice;
  13214. /**
  13215. * References to the webVR controllers for the vrDevice.
  13216. */
  13217. controllers: Array<WebVRController>;
  13218. /**
  13219. * Emits an event when a controller is attached.
  13220. */
  13221. onControllersAttachedObservable: Observable<WebVRController[]>;
  13222. /**
  13223. * Emits an event when a controller's mesh has been loaded;
  13224. */
  13225. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13226. /**
  13227. * Emits an event when the HMD's pose has been updated.
  13228. */
  13229. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13230. private _poseSet;
  13231. /**
  13232. * If the rig cameras be used as parent instead of this camera.
  13233. */
  13234. rigParenting: boolean;
  13235. private _lightOnControllers;
  13236. private _defaultHeight?;
  13237. /**
  13238. * Instantiates a WebVRFreeCamera.
  13239. * @param name The name of the WebVRFreeCamera
  13240. * @param position The starting anchor position for the camera
  13241. * @param scene The scene the camera belongs to
  13242. * @param webVROptions a set of customizable options for the webVRCamera
  13243. */
  13244. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13245. /**
  13246. * Gets the device distance from the ground in meters.
  13247. * @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.
  13248. */
  13249. deviceDistanceToRoomGround(): number;
  13250. /**
  13251. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13252. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13253. */
  13254. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13255. /**
  13256. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13257. * @returns A promise with a boolean set to if the standing matrix is supported.
  13258. */
  13259. useStandingMatrixAsync(): Promise<boolean>;
  13260. /**
  13261. * Disposes the camera
  13262. */
  13263. dispose(): void;
  13264. /**
  13265. * Gets a vrController by name.
  13266. * @param name The name of the controller to retreive
  13267. * @returns the controller matching the name specified or null if not found
  13268. */
  13269. getControllerByName(name: string): Nullable<WebVRController>;
  13270. private _leftController;
  13271. /**
  13272. * The controller corrisponding to the users left hand.
  13273. */
  13274. readonly leftController: Nullable<WebVRController>;
  13275. private _rightController;
  13276. /**
  13277. * The controller corrisponding to the users right hand.
  13278. */
  13279. readonly rightController: Nullable<WebVRController>;
  13280. /**
  13281. * Casts a ray forward from the vrCamera's gaze.
  13282. * @param length Length of the ray (default: 100)
  13283. * @returns the ray corrisponding to the gaze
  13284. */
  13285. getForwardRay(length?: number): Ray;
  13286. /**
  13287. * @hidden
  13288. * Updates the camera based on device's frame data
  13289. */ checkInputs(): void;
  13290. /**
  13291. * Updates the poseControlled values based on the input device pose.
  13292. * @param poseData Pose coming from the device
  13293. */
  13294. updateFromDevice(poseData: DevicePose): void;
  13295. private _htmlElementAttached;
  13296. private _detachIfAttached;
  13297. /**
  13298. * WebVR's attach control will start broadcasting frames to the device.
  13299. * Note that in certain browsers (chrome for example) this function must be called
  13300. * within a user-interaction callback. Example:
  13301. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13302. *
  13303. * @param element html element to attach the vrDevice to
  13304. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13305. */
  13306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13307. /**
  13308. * Detaches the camera from the html element and disables VR
  13309. *
  13310. * @param element html element to detach from
  13311. */
  13312. detachControl(element: HTMLElement): void;
  13313. /**
  13314. * @returns the name of this class
  13315. */
  13316. getClassName(): string;
  13317. /**
  13318. * Calls resetPose on the vrDisplay
  13319. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13320. */
  13321. resetToCurrentRotation(): void;
  13322. /**
  13323. * @hidden
  13324. * Updates the rig cameras (left and right eye)
  13325. */ updateRigCameras(): void;
  13326. private _workingVector;
  13327. private _oneVector;
  13328. private _workingMatrix;
  13329. private updateCacheCalled;
  13330. private _correctPositionIfNotTrackPosition;
  13331. /**
  13332. * @hidden
  13333. * Updates the cached values of the camera
  13334. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13335. */ updateCache(ignoreParentClass?: boolean): void;
  13336. /**
  13337. * @hidden
  13338. * Get current device position in babylon world
  13339. */ computeDevicePosition(): void;
  13340. /**
  13341. * Updates the current device position and rotation in the babylon world
  13342. */
  13343. update(): void;
  13344. /**
  13345. * @hidden
  13346. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13347. * @returns an identity matrix
  13348. */ getViewMatrix(): Matrix;
  13349. private _tmpMatrix;
  13350. /**
  13351. * This function is called by the two RIG cameras.
  13352. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13353. * @hidden
  13354. */ getWebVRViewMatrix(): Matrix;
  13355. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13356. private _onGamepadConnectedObserver;
  13357. private _onGamepadDisconnectedObserver;
  13358. private _updateCacheWhenTrackingDisabledObserver;
  13359. /**
  13360. * Initializes the controllers and their meshes
  13361. */
  13362. initControllers(): void;
  13363. }
  13364. }
  13365. declare module BABYLON {
  13366. /**
  13367. * Size options for a post process
  13368. */
  13369. export type PostProcessOptions = {
  13370. width: number;
  13371. height: number;
  13372. };
  13373. /**
  13374. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13375. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13376. */
  13377. export class PostProcess {
  13378. /** Name of the PostProcess. */
  13379. name: string;
  13380. /**
  13381. * Gets or sets the unique id of the post process
  13382. */
  13383. uniqueId: number;
  13384. /**
  13385. * Width of the texture to apply the post process on
  13386. */
  13387. width: number;
  13388. /**
  13389. * Height of the texture to apply the post process on
  13390. */
  13391. height: number;
  13392. /**
  13393. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13394. * @hidden
  13395. */ outputTexture: Nullable<InternalTexture>;
  13396. /**
  13397. * Sampling mode used by the shader
  13398. * See https://doc.babylonjs.com/classes/3.1/texture
  13399. */
  13400. renderTargetSamplingMode: number;
  13401. /**
  13402. * Clear color to use when screen clearing
  13403. */
  13404. clearColor: Color4;
  13405. /**
  13406. * If the buffer needs to be cleared before applying the post process. (default: true)
  13407. * Should be set to false if shader will overwrite all previous pixels.
  13408. */
  13409. autoClear: boolean;
  13410. /**
  13411. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13412. */
  13413. alphaMode: number;
  13414. /**
  13415. * Sets the setAlphaBlendConstants of the babylon engine
  13416. */
  13417. alphaConstants: Color4;
  13418. /**
  13419. * Animations to be used for the post processing
  13420. */
  13421. animations: Animation[];
  13422. /**
  13423. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13424. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13425. */
  13426. enablePixelPerfectMode: boolean;
  13427. /**
  13428. * Force the postprocess to be applied without taking in account viewport
  13429. */
  13430. forceFullscreenViewport: boolean;
  13431. /**
  13432. * List of inspectable custom properties (used by the Inspector)
  13433. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13434. */
  13435. inspectableCustomProperties: IInspectable[];
  13436. /**
  13437. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13438. *
  13439. * | Value | Type | Description |
  13440. * | ----- | ----------------------------------- | ----------- |
  13441. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13442. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13443. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13444. *
  13445. */
  13446. scaleMode: number;
  13447. /**
  13448. * Force textures to be a power of two (default: false)
  13449. */
  13450. alwaysForcePOT: boolean;
  13451. private _samples;
  13452. /**
  13453. * Number of sample textures (default: 1)
  13454. */
  13455. samples: number;
  13456. /**
  13457. * Modify the scale of the post process to be the same as the viewport (default: false)
  13458. */
  13459. adaptScaleToCurrentViewport: boolean;
  13460. private _camera;
  13461. private _scene;
  13462. private _engine;
  13463. private _options;
  13464. private _reusable;
  13465. private _textureType;
  13466. /**
  13467. * Smart array of input and output textures for the post process.
  13468. * @hidden
  13469. */ textures: SmartArray<InternalTexture>;
  13470. /**
  13471. * The index in _textures that corresponds to the output texture.
  13472. * @hidden
  13473. */ currentRenderTextureInd: number;
  13474. private _effect;
  13475. private _samplers;
  13476. private _fragmentUrl;
  13477. private _vertexUrl;
  13478. private _parameters;
  13479. private _scaleRatio;
  13480. protected _indexParameters: any;
  13481. private _shareOutputWithPostProcess;
  13482. private _texelSize;
  13483. private _forcedOutputTexture;
  13484. /**
  13485. * Returns the fragment url or shader name used in the post process.
  13486. * @returns the fragment url or name in the shader store.
  13487. */
  13488. getEffectName(): string;
  13489. /**
  13490. * An event triggered when the postprocess is activated.
  13491. */
  13492. onActivateObservable: Observable<Camera>;
  13493. private _onActivateObserver;
  13494. /**
  13495. * A function that is added to the onActivateObservable
  13496. */
  13497. onActivate: Nullable<(camera: Camera) => void>;
  13498. /**
  13499. * An event triggered when the postprocess changes its size.
  13500. */
  13501. onSizeChangedObservable: Observable<PostProcess>;
  13502. private _onSizeChangedObserver;
  13503. /**
  13504. * A function that is added to the onSizeChangedObservable
  13505. */
  13506. onSizeChanged: (postProcess: PostProcess) => void;
  13507. /**
  13508. * An event triggered when the postprocess applies its effect.
  13509. */
  13510. onApplyObservable: Observable<Effect>;
  13511. private _onApplyObserver;
  13512. /**
  13513. * A function that is added to the onApplyObservable
  13514. */
  13515. onApply: (effect: Effect) => void;
  13516. /**
  13517. * An event triggered before rendering the postprocess
  13518. */
  13519. onBeforeRenderObservable: Observable<Effect>;
  13520. private _onBeforeRenderObserver;
  13521. /**
  13522. * A function that is added to the onBeforeRenderObservable
  13523. */
  13524. onBeforeRender: (effect: Effect) => void;
  13525. /**
  13526. * An event triggered after rendering the postprocess
  13527. */
  13528. onAfterRenderObservable: Observable<Effect>;
  13529. private _onAfterRenderObserver;
  13530. /**
  13531. * A function that is added to the onAfterRenderObservable
  13532. */
  13533. onAfterRender: (efect: Effect) => void;
  13534. /**
  13535. * 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
  13536. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13537. */
  13538. inputTexture: InternalTexture;
  13539. /**
  13540. * Gets the camera which post process is applied to.
  13541. * @returns The camera the post process is applied to.
  13542. */
  13543. getCamera(): Camera;
  13544. /**
  13545. * Gets the texel size of the postprocess.
  13546. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13547. */
  13548. readonly texelSize: Vector2;
  13549. /**
  13550. * Creates a new instance PostProcess
  13551. * @param name The name of the PostProcess.
  13552. * @param fragmentUrl The url of the fragment shader to be used.
  13553. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13554. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13555. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13556. * @param camera The camera to apply the render pass to.
  13557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13558. * @param engine The engine which the post process will be applied. (default: current engine)
  13559. * @param reusable If the post process can be reused on the same frame. (default: false)
  13560. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13561. * @param textureType Type of textures used when performing the post process. (default: 0)
  13562. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13563. * @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
  13564. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13565. */
  13566. constructor(
  13567. /** Name of the PostProcess. */
  13568. 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);
  13569. /**
  13570. * Gets a string idenfifying the name of the class
  13571. * @returns "PostProcess" string
  13572. */
  13573. getClassName(): string;
  13574. /**
  13575. * Gets the engine which this post process belongs to.
  13576. * @returns The engine the post process was enabled with.
  13577. */
  13578. getEngine(): Engine;
  13579. /**
  13580. * The effect that is created when initializing the post process.
  13581. * @returns The created effect corrisponding the the postprocess.
  13582. */
  13583. getEffect(): Effect;
  13584. /**
  13585. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13586. * @param postProcess The post process to share the output with.
  13587. * @returns This post process.
  13588. */
  13589. shareOutputWith(postProcess: PostProcess): PostProcess;
  13590. /**
  13591. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13592. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13593. */
  13594. useOwnOutput(): void;
  13595. /**
  13596. * Updates the effect with the current post process compile time values and recompiles the shader.
  13597. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13598. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13599. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13600. * @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
  13601. * @param onCompiled Called when the shader has been compiled.
  13602. * @param onError Called if there is an error when compiling a shader.
  13603. */
  13604. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13605. /**
  13606. * The post process is reusable if it can be used multiple times within one frame.
  13607. * @returns If the post process is reusable
  13608. */
  13609. isReusable(): boolean;
  13610. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13611. markTextureDirty(): void;
  13612. /**
  13613. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13614. * 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.
  13615. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13616. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13617. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13618. * @returns The target texture that was bound to be written to.
  13619. */
  13620. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13621. /**
  13622. * If the post process is supported.
  13623. */
  13624. readonly isSupported: boolean;
  13625. /**
  13626. * The aspect ratio of the output texture.
  13627. */
  13628. readonly aspectRatio: number;
  13629. /**
  13630. * Get a value indicating if the post-process is ready to be used
  13631. * @returns true if the post-process is ready (shader is compiled)
  13632. */
  13633. isReady(): boolean;
  13634. /**
  13635. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13636. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13637. */
  13638. apply(): Nullable<Effect>;
  13639. private _disposeTextures;
  13640. /**
  13641. * Disposes the post process.
  13642. * @param camera The camera to dispose the post process on.
  13643. */
  13644. dispose(camera?: Camera): void;
  13645. }
  13646. }
  13647. declare module BABYLON {
  13648. /**
  13649. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13650. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13651. */
  13652. export class PostProcessManager {
  13653. private _scene;
  13654. private _indexBuffer;
  13655. private _vertexBuffers;
  13656. /**
  13657. * Creates a new instance PostProcess
  13658. * @param scene The scene that the post process is associated with.
  13659. */
  13660. constructor(scene: Scene);
  13661. private _prepareBuffers;
  13662. private _buildIndexBuffer;
  13663. /**
  13664. * Rebuilds the vertex buffers of the manager.
  13665. * @hidden
  13666. */ rebuild(): void;
  13667. /**
  13668. * Prepares a frame to be run through a post process.
  13669. * @param sourceTexture The input texture to the post procesess. (default: null)
  13670. * @param postProcesses An array of post processes to be run. (default: null)
  13671. * @returns True if the post processes were able to be run.
  13672. * @hidden
  13673. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13674. /**
  13675. * Manually render a set of post processes to a texture.
  13676. * @param postProcesses An array of post processes to be run.
  13677. * @param targetTexture The target texture to render to.
  13678. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13679. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13680. * @param lodLevel defines which lod of the texture to render to
  13681. */
  13682. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13683. /**
  13684. * Finalize the result of the output of the postprocesses.
  13685. * @param doNotPresent If true the result will not be displayed to the screen.
  13686. * @param targetTexture The target texture to render to.
  13687. * @param faceIndex The index of the face to bind the target texture to.
  13688. * @param postProcesses The array of post processes to render.
  13689. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13690. * @hidden
  13691. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13692. /**
  13693. * Disposes of the post process manager.
  13694. */
  13695. dispose(): void;
  13696. }
  13697. }
  13698. declare module BABYLON {
  13699. interface AbstractScene {
  13700. /**
  13701. * The list of layers (background and foreground) of the scene
  13702. */
  13703. layers: Array<Layer>;
  13704. }
  13705. /**
  13706. * Defines the layer scene component responsible to manage any layers
  13707. * in a given scene.
  13708. */
  13709. export class LayerSceneComponent implements ISceneComponent {
  13710. /**
  13711. * The component name helpfull to identify the component in the list of scene components.
  13712. */
  13713. readonly name: string;
  13714. /**
  13715. * The scene the component belongs to.
  13716. */
  13717. scene: Scene;
  13718. private _engine;
  13719. /**
  13720. * Creates a new instance of the component for the given scene
  13721. * @param scene Defines the scene to register the component in
  13722. */
  13723. constructor(scene: Scene);
  13724. /**
  13725. * Registers the component in a given scene
  13726. */
  13727. register(): void;
  13728. /**
  13729. * Rebuilds the elements related to this component in case of
  13730. * context lost for instance.
  13731. */
  13732. rebuild(): void;
  13733. /**
  13734. * Disposes the component and the associated ressources.
  13735. */
  13736. dispose(): void;
  13737. private _draw;
  13738. private _drawCameraPredicate;
  13739. private _drawCameraBackground;
  13740. private _drawCameraForeground;
  13741. private _drawRenderTargetPredicate;
  13742. private _drawRenderTargetBackground;
  13743. private _drawRenderTargetForeground;
  13744. }
  13745. }
  13746. declare module BABYLON {
  13747. /** @hidden */
  13748. export var layerPixelShader: {
  13749. name: string;
  13750. shader: string;
  13751. };
  13752. }
  13753. declare module BABYLON {
  13754. /** @hidden */
  13755. export var layerVertexShader: {
  13756. name: string;
  13757. shader: string;
  13758. };
  13759. }
  13760. declare module BABYLON {
  13761. /**
  13762. * This represents a full screen 2d layer.
  13763. * This can be useful to display a picture in the background of your scene for instance.
  13764. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13765. */
  13766. export class Layer {
  13767. /**
  13768. * Define the name of the layer.
  13769. */
  13770. name: string;
  13771. /**
  13772. * Define the texture the layer should display.
  13773. */
  13774. texture: Nullable<Texture>;
  13775. /**
  13776. * Is the layer in background or foreground.
  13777. */
  13778. isBackground: boolean;
  13779. /**
  13780. * Define the color of the layer (instead of texture).
  13781. */
  13782. color: Color4;
  13783. /**
  13784. * Define the scale of the layer in order to zoom in out of the texture.
  13785. */
  13786. scale: Vector2;
  13787. /**
  13788. * Define an offset for the layer in order to shift the texture.
  13789. */
  13790. offset: Vector2;
  13791. /**
  13792. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13793. */
  13794. alphaBlendingMode: number;
  13795. /**
  13796. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13797. * Alpha test will not mix with the background color in case of transparency.
  13798. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13799. */
  13800. alphaTest: boolean;
  13801. /**
  13802. * Define a mask to restrict the layer to only some of the scene cameras.
  13803. */
  13804. layerMask: number;
  13805. /**
  13806. * Define the list of render target the layer is visible into.
  13807. */
  13808. renderTargetTextures: RenderTargetTexture[];
  13809. /**
  13810. * Define if the layer is only used in renderTarget or if it also
  13811. * renders in the main frame buffer of the canvas.
  13812. */
  13813. renderOnlyInRenderTargetTextures: boolean;
  13814. private _scene;
  13815. private _vertexBuffers;
  13816. private _indexBuffer;
  13817. private _effect;
  13818. private _alphaTestEffect;
  13819. /**
  13820. * An event triggered when the layer is disposed.
  13821. */
  13822. onDisposeObservable: Observable<Layer>;
  13823. private _onDisposeObserver;
  13824. /**
  13825. * Back compatibility with callback before the onDisposeObservable existed.
  13826. * The set callback will be triggered when the layer has been disposed.
  13827. */
  13828. onDispose: () => void;
  13829. /**
  13830. * An event triggered before rendering the scene
  13831. */
  13832. onBeforeRenderObservable: Observable<Layer>;
  13833. private _onBeforeRenderObserver;
  13834. /**
  13835. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13836. * The set callback will be triggered just before rendering the layer.
  13837. */
  13838. onBeforeRender: () => void;
  13839. /**
  13840. * An event triggered after rendering the scene
  13841. */
  13842. onAfterRenderObservable: Observable<Layer>;
  13843. private _onAfterRenderObserver;
  13844. /**
  13845. * Back compatibility with callback before the onAfterRenderObservable existed.
  13846. * The set callback will be triggered just after rendering the layer.
  13847. */
  13848. onAfterRender: () => void;
  13849. /**
  13850. * Instantiates a new layer.
  13851. * This represents a full screen 2d layer.
  13852. * This can be useful to display a picture in the background of your scene for instance.
  13853. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13854. * @param name Define the name of the layer in the scene
  13855. * @param imgUrl Define the url of the texture to display in the layer
  13856. * @param scene Define the scene the layer belongs to
  13857. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13858. * @param color Defines a color for the layer
  13859. */
  13860. constructor(
  13861. /**
  13862. * Define the name of the layer.
  13863. */
  13864. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13865. private _createIndexBuffer;
  13866. /** @hidden */ rebuild(): void;
  13867. /**
  13868. * Renders the layer in the scene.
  13869. */
  13870. render(): void;
  13871. /**
  13872. * Disposes and releases the associated ressources.
  13873. */
  13874. dispose(): void;
  13875. }
  13876. }
  13877. declare module BABYLON {
  13878. interface AbstractScene {
  13879. /**
  13880. * The list of procedural textures added to the scene
  13881. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13882. */
  13883. proceduralTextures: Array<ProceduralTexture>;
  13884. }
  13885. /**
  13886. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13887. * in a given scene.
  13888. */
  13889. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13890. /**
  13891. * The component name helpfull to identify the component in the list of scene components.
  13892. */
  13893. readonly name: string;
  13894. /**
  13895. * The scene the component belongs to.
  13896. */
  13897. scene: Scene;
  13898. /**
  13899. * Creates a new instance of the component for the given scene
  13900. * @param scene Defines the scene to register the component in
  13901. */
  13902. constructor(scene: Scene);
  13903. /**
  13904. * Registers the component in a given scene
  13905. */
  13906. register(): void;
  13907. /**
  13908. * Rebuilds the elements related to this component in case of
  13909. * context lost for instance.
  13910. */
  13911. rebuild(): void;
  13912. /**
  13913. * Disposes the component and the associated ressources.
  13914. */
  13915. dispose(): void;
  13916. private _beforeClear;
  13917. }
  13918. }
  13919. declare module BABYLON {
  13920. interface Engine {
  13921. /**
  13922. * Creates a new render target cube texture
  13923. * @param size defines the size of the texture
  13924. * @param options defines the options used to create the texture
  13925. * @returns a new render target cube texture stored in an InternalTexture
  13926. */
  13927. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13928. }
  13929. }
  13930. declare module BABYLON {
  13931. /** @hidden */
  13932. export var proceduralVertexShader: {
  13933. name: string;
  13934. shader: string;
  13935. };
  13936. }
  13937. declare module BABYLON {
  13938. /**
  13939. * 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.
  13940. * This is the base class of any Procedural texture and contains most of the shareable code.
  13941. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13942. */
  13943. export class ProceduralTexture extends Texture {
  13944. isCube: boolean;
  13945. /**
  13946. * Define if the texture is enabled or not (disabled texture will not render)
  13947. */
  13948. isEnabled: boolean;
  13949. /**
  13950. * Define if the texture must be cleared before rendering (default is true)
  13951. */
  13952. autoClear: boolean;
  13953. /**
  13954. * Callback called when the texture is generated
  13955. */
  13956. onGenerated: () => void;
  13957. /**
  13958. * Event raised when the texture is generated
  13959. */
  13960. onGeneratedObservable: Observable<ProceduralTexture>;
  13961. /** @hidden */ generateMipMaps: boolean;
  13962. /** @hidden **/ effect: Effect;
  13963. /** @hidden */ textures: {
  13964. [key: string]: Texture;
  13965. };
  13966. private _size;
  13967. private _currentRefreshId;
  13968. private _refreshRate;
  13969. private _vertexBuffers;
  13970. private _indexBuffer;
  13971. private _uniforms;
  13972. private _samplers;
  13973. private _fragment;
  13974. private _floats;
  13975. private _ints;
  13976. private _floatsArrays;
  13977. private _colors3;
  13978. private _colors4;
  13979. private _vectors2;
  13980. private _vectors3;
  13981. private _matrices;
  13982. private _fallbackTexture;
  13983. private _fallbackTextureUsed;
  13984. private _engine;
  13985. private _cachedDefines;
  13986. private _contentUpdateId;
  13987. private _contentData;
  13988. /**
  13989. * Instantiates a new procedural texture.
  13990. * 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.
  13991. * This is the base class of any Procedural texture and contains most of the shareable code.
  13992. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13993. * @param name Define the name of the texture
  13994. * @param size Define the size of the texture to create
  13995. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13996. * @param scene Define the scene the texture belongs to
  13997. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13998. * @param generateMipMaps Define if the texture should creates mip maps or not
  13999. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14000. */
  14001. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14002. /**
  14003. * The effect that is created when initializing the post process.
  14004. * @returns The created effect corrisponding the the postprocess.
  14005. */
  14006. getEffect(): Effect;
  14007. /**
  14008. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14009. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14010. */
  14011. getContent(): Nullable<ArrayBufferView>;
  14012. private _createIndexBuffer;
  14013. /** @hidden */ rebuild(): void;
  14014. /**
  14015. * Resets the texture in order to recreate its associated resources.
  14016. * This can be called in case of context loss
  14017. */
  14018. reset(): void;
  14019. protected _getDefines(): string;
  14020. /**
  14021. * Is the texture ready to be used ? (rendered at least once)
  14022. * @returns true if ready, otherwise, false.
  14023. */
  14024. isReady(): boolean;
  14025. /**
  14026. * Resets the refresh counter of the texture and start bak from scratch.
  14027. * Could be useful to regenerate the texture if it is setup to render only once.
  14028. */
  14029. resetRefreshCounter(): void;
  14030. /**
  14031. * Set the fragment shader to use in order to render the texture.
  14032. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14033. */
  14034. setFragment(fragment: any): void;
  14035. /**
  14036. * Define the refresh rate of the texture or the rendering frequency.
  14037. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14038. */
  14039. refreshRate: number;
  14040. /** @hidden */ shouldRender(): boolean;
  14041. /**
  14042. * Get the size the texture is rendering at.
  14043. * @returns the size (texture is always squared)
  14044. */
  14045. getRenderSize(): number;
  14046. /**
  14047. * Resize the texture to new value.
  14048. * @param size Define the new size the texture should have
  14049. * @param generateMipMaps Define whether the new texture should create mip maps
  14050. */
  14051. resize(size: number, generateMipMaps: boolean): void;
  14052. private _checkUniform;
  14053. /**
  14054. * Set a texture in the shader program used to render.
  14055. * @param name Define the name of the uniform samplers as defined in the shader
  14056. * @param texture Define the texture to bind to this sampler
  14057. * @return the texture itself allowing "fluent" like uniform updates
  14058. */
  14059. setTexture(name: string, texture: Texture): ProceduralTexture;
  14060. /**
  14061. * Set a float in the shader.
  14062. * @param name Define the name of the uniform as defined in the shader
  14063. * @param value Define the value to give to the uniform
  14064. * @return the texture itself allowing "fluent" like uniform updates
  14065. */
  14066. setFloat(name: string, value: number): ProceduralTexture;
  14067. /**
  14068. * Set a int in the shader.
  14069. * @param name Define the name of the uniform as defined in the shader
  14070. * @param value Define the value to give to the uniform
  14071. * @return the texture itself allowing "fluent" like uniform updates
  14072. */
  14073. setInt(name: string, value: number): ProceduralTexture;
  14074. /**
  14075. * Set an array of floats in the shader.
  14076. * @param name Define the name of the uniform as defined in the shader
  14077. * @param value Define the value to give to the uniform
  14078. * @return the texture itself allowing "fluent" like uniform updates
  14079. */
  14080. setFloats(name: string, value: number[]): ProceduralTexture;
  14081. /**
  14082. * Set a vec3 in the shader from a Color3.
  14083. * @param name Define the name of the uniform as defined in the shader
  14084. * @param value Define the value to give to the uniform
  14085. * @return the texture itself allowing "fluent" like uniform updates
  14086. */
  14087. setColor3(name: string, value: Color3): ProceduralTexture;
  14088. /**
  14089. * Set a vec4 in the shader from a Color4.
  14090. * @param name Define the name of the uniform as defined in the shader
  14091. * @param value Define the value to give to the uniform
  14092. * @return the texture itself allowing "fluent" like uniform updates
  14093. */
  14094. setColor4(name: string, value: Color4): ProceduralTexture;
  14095. /**
  14096. * Set a vec2 in the shader from a Vector2.
  14097. * @param name Define the name of the uniform as defined in the shader
  14098. * @param value Define the value to give to the uniform
  14099. * @return the texture itself allowing "fluent" like uniform updates
  14100. */
  14101. setVector2(name: string, value: Vector2): ProceduralTexture;
  14102. /**
  14103. * Set a vec3 in the shader from a Vector3.
  14104. * @param name Define the name of the uniform as defined in the shader
  14105. * @param value Define the value to give to the uniform
  14106. * @return the texture itself allowing "fluent" like uniform updates
  14107. */
  14108. setVector3(name: string, value: Vector3): ProceduralTexture;
  14109. /**
  14110. * Set a mat4 in the shader from a MAtrix.
  14111. * @param name Define the name of the uniform as defined in the shader
  14112. * @param value Define the value to give to the uniform
  14113. * @return the texture itself allowing "fluent" like uniform updates
  14114. */
  14115. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14116. /**
  14117. * Render the texture to its associated render target.
  14118. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14119. */
  14120. render(useCameraPostProcess?: boolean): void;
  14121. /**
  14122. * Clone the texture.
  14123. * @returns the cloned texture
  14124. */
  14125. clone(): ProceduralTexture;
  14126. /**
  14127. * Dispose the texture and release its asoociated resources.
  14128. */
  14129. dispose(): void;
  14130. }
  14131. }
  14132. declare module BABYLON {
  14133. /**
  14134. * This represents the base class for particle system in Babylon.
  14135. * 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.
  14136. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14137. * @example https://doc.babylonjs.com/babylon101/particles
  14138. */
  14139. export class BaseParticleSystem {
  14140. /**
  14141. * Source color is added to the destination color without alpha affecting the result
  14142. */
  14143. static BLENDMODE_ONEONE: number;
  14144. /**
  14145. * Blend current color and particle color using particle’s alpha
  14146. */
  14147. static BLENDMODE_STANDARD: number;
  14148. /**
  14149. * Add current color and particle color multiplied by particle’s alpha
  14150. */
  14151. static BLENDMODE_ADD: number;
  14152. /**
  14153. * Multiply current color with particle color
  14154. */
  14155. static BLENDMODE_MULTIPLY: number;
  14156. /**
  14157. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14158. */
  14159. static BLENDMODE_MULTIPLYADD: number;
  14160. /**
  14161. * List of animations used by the particle system.
  14162. */
  14163. animations: Animation[];
  14164. /**
  14165. * The id of the Particle system.
  14166. */
  14167. id: string;
  14168. /**
  14169. * The friendly name of the Particle system.
  14170. */
  14171. name: string;
  14172. /**
  14173. * The rendering group used by the Particle system to chose when to render.
  14174. */
  14175. renderingGroupId: number;
  14176. /**
  14177. * The emitter represents the Mesh or position we are attaching the particle system to.
  14178. */
  14179. emitter: Nullable<AbstractMesh | Vector3>;
  14180. /**
  14181. * The maximum number of particles to emit per frame
  14182. */
  14183. emitRate: number;
  14184. /**
  14185. * If you want to launch only a few particles at once, that can be done, as well.
  14186. */
  14187. manualEmitCount: number;
  14188. /**
  14189. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14190. */
  14191. updateSpeed: number;
  14192. /**
  14193. * The amount of time the particle system is running (depends of the overall update speed).
  14194. */
  14195. targetStopDuration: number;
  14196. /**
  14197. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14198. */
  14199. disposeOnStop: boolean;
  14200. /**
  14201. * Minimum power of emitting particles.
  14202. */
  14203. minEmitPower: number;
  14204. /**
  14205. * Maximum power of emitting particles.
  14206. */
  14207. maxEmitPower: number;
  14208. /**
  14209. * Minimum life time of emitting particles.
  14210. */
  14211. minLifeTime: number;
  14212. /**
  14213. * Maximum life time of emitting particles.
  14214. */
  14215. maxLifeTime: number;
  14216. /**
  14217. * Minimum Size of emitting particles.
  14218. */
  14219. minSize: number;
  14220. /**
  14221. * Maximum Size of emitting particles.
  14222. */
  14223. maxSize: number;
  14224. /**
  14225. * Minimum scale of emitting particles on X axis.
  14226. */
  14227. minScaleX: number;
  14228. /**
  14229. * Maximum scale of emitting particles on X axis.
  14230. */
  14231. maxScaleX: number;
  14232. /**
  14233. * Minimum scale of emitting particles on Y axis.
  14234. */
  14235. minScaleY: number;
  14236. /**
  14237. * Maximum scale of emitting particles on Y axis.
  14238. */
  14239. maxScaleY: number;
  14240. /**
  14241. * Gets or sets the minimal initial rotation in radians.
  14242. */
  14243. minInitialRotation: number;
  14244. /**
  14245. * Gets or sets the maximal initial rotation in radians.
  14246. */
  14247. maxInitialRotation: number;
  14248. /**
  14249. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14250. */
  14251. minAngularSpeed: number;
  14252. /**
  14253. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14254. */
  14255. maxAngularSpeed: number;
  14256. /**
  14257. * The texture used to render each particle. (this can be a spritesheet)
  14258. */
  14259. particleTexture: Nullable<Texture>;
  14260. /**
  14261. * The layer mask we are rendering the particles through.
  14262. */
  14263. layerMask: number;
  14264. /**
  14265. * This can help using your own shader to render the particle system.
  14266. * The according effect will be created
  14267. */
  14268. customShader: any;
  14269. /**
  14270. * By default particle system starts as soon as they are created. This prevents the
  14271. * automatic start to happen and let you decide when to start emitting particles.
  14272. */
  14273. preventAutoStart: boolean;
  14274. private _noiseTexture;
  14275. /**
  14276. * Gets or sets a texture used to add random noise to particle positions
  14277. */
  14278. noiseTexture: Nullable<ProceduralTexture>;
  14279. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14280. noiseStrength: Vector3;
  14281. /**
  14282. * Callback triggered when the particle animation is ending.
  14283. */
  14284. onAnimationEnd: Nullable<() => void>;
  14285. /**
  14286. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14287. */
  14288. blendMode: number;
  14289. /**
  14290. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14291. * to override the particles.
  14292. */
  14293. forceDepthWrite: boolean;
  14294. /** 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 */
  14295. preWarmCycles: number;
  14296. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14297. preWarmStepOffset: number;
  14298. /**
  14299. * 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)
  14300. */
  14301. spriteCellChangeSpeed: number;
  14302. /**
  14303. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14304. */
  14305. startSpriteCellID: number;
  14306. /**
  14307. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14308. */
  14309. endSpriteCellID: number;
  14310. /**
  14311. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14312. */
  14313. spriteCellWidth: number;
  14314. /**
  14315. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14316. */
  14317. spriteCellHeight: number;
  14318. /**
  14319. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14320. */
  14321. spriteRandomStartCell: boolean;
  14322. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14323. translationPivot: Vector2;
  14324. /** @hidden */
  14325. protected _isAnimationSheetEnabled: boolean;
  14326. /**
  14327. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14328. */
  14329. beginAnimationOnStart: boolean;
  14330. /**
  14331. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14332. */
  14333. beginAnimationFrom: number;
  14334. /**
  14335. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14336. */
  14337. beginAnimationTo: number;
  14338. /**
  14339. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14340. */
  14341. beginAnimationLoop: boolean;
  14342. /**
  14343. * Gets or sets a world offset applied to all particles
  14344. */
  14345. worldOffset: Vector3;
  14346. /**
  14347. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14348. */
  14349. isAnimationSheetEnabled: boolean;
  14350. /**
  14351. * Get hosting scene
  14352. * @returns the scene
  14353. */
  14354. getScene(): Scene;
  14355. /**
  14356. * You can use gravity if you want to give an orientation to your particles.
  14357. */
  14358. gravity: Vector3;
  14359. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14360. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14361. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14362. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14363. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14364. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14365. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14366. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14367. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14368. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14369. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14370. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14371. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14372. /**
  14373. * Defines the delay in milliseconds before starting the system (0 by default)
  14374. */
  14375. startDelay: number;
  14376. /**
  14377. * Gets the current list of drag gradients.
  14378. * You must use addDragGradient and removeDragGradient to udpate this list
  14379. * @returns the list of drag gradients
  14380. */
  14381. getDragGradients(): Nullable<Array<FactorGradient>>;
  14382. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14383. limitVelocityDamping: number;
  14384. /**
  14385. * Gets the current list of limit velocity gradients.
  14386. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14387. * @returns the list of limit velocity gradients
  14388. */
  14389. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14390. /**
  14391. * Gets the current list of color gradients.
  14392. * You must use addColorGradient and removeColorGradient to udpate this list
  14393. * @returns the list of color gradients
  14394. */
  14395. getColorGradients(): Nullable<Array<ColorGradient>>;
  14396. /**
  14397. * Gets the current list of size gradients.
  14398. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14399. * @returns the list of size gradients
  14400. */
  14401. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14402. /**
  14403. * Gets the current list of color remap gradients.
  14404. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14405. * @returns the list of color remap gradients
  14406. */
  14407. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14408. /**
  14409. * Gets the current list of alpha remap gradients.
  14410. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14411. * @returns the list of alpha remap gradients
  14412. */
  14413. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14414. /**
  14415. * Gets the current list of life time gradients.
  14416. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14417. * @returns the list of life time gradients
  14418. */
  14419. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14420. /**
  14421. * Gets the current list of angular speed gradients.
  14422. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14423. * @returns the list of angular speed gradients
  14424. */
  14425. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14426. /**
  14427. * Gets the current list of velocity gradients.
  14428. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14429. * @returns the list of velocity gradients
  14430. */
  14431. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14432. /**
  14433. * Gets the current list of start size gradients.
  14434. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14435. * @returns the list of start size gradients
  14436. */
  14437. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14438. /**
  14439. * Gets the current list of emit rate gradients.
  14440. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14441. * @returns the list of emit rate gradients
  14442. */
  14443. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14444. /**
  14445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14446. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14447. */
  14448. direction1: Vector3;
  14449. /**
  14450. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14451. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14452. */
  14453. direction2: Vector3;
  14454. /**
  14455. * 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.
  14456. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14457. */
  14458. minEmitBox: Vector3;
  14459. /**
  14460. * 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.
  14461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14462. */
  14463. maxEmitBox: Vector3;
  14464. /**
  14465. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14466. */
  14467. color1: Color4;
  14468. /**
  14469. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14470. */
  14471. color2: Color4;
  14472. /**
  14473. * Color the particle will have at the end of its lifetime
  14474. */
  14475. colorDead: Color4;
  14476. /**
  14477. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14478. */
  14479. textureMask: Color4;
  14480. /**
  14481. * The particle emitter type defines the emitter used by the particle system.
  14482. * It can be for example box, sphere, or cone...
  14483. */
  14484. particleEmitterType: IParticleEmitterType;
  14485. /** @hidden */ isSubEmitter: boolean;
  14486. /**
  14487. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14488. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14489. */
  14490. billboardMode: number;
  14491. protected _isBillboardBased: boolean;
  14492. /**
  14493. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14494. */
  14495. isBillboardBased: boolean;
  14496. /**
  14497. * The scene the particle system belongs to.
  14498. */
  14499. protected _scene: Scene;
  14500. /**
  14501. * Local cache of defines for image processing.
  14502. */
  14503. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14504. /**
  14505. * Default configuration related to image processing available in the standard Material.
  14506. */
  14507. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14508. /**
  14509. * Gets the image processing configuration used either in this material.
  14510. */
  14511. /**
  14512. * Sets the Default image processing configuration used either in the this material.
  14513. *
  14514. * If sets to null, the scene one is in use.
  14515. */
  14516. imageProcessingConfiguration: ImageProcessingConfiguration;
  14517. /**
  14518. * Attaches a new image processing configuration to the Standard Material.
  14519. * @param configuration
  14520. */
  14521. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14522. /** @hidden */
  14523. protected _reset(): void;
  14524. /** @hidden */
  14525. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14526. /**
  14527. * Instantiates a particle system.
  14528. * 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.
  14529. * @param name The name of the particle system
  14530. */
  14531. constructor(name: string);
  14532. /**
  14533. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @returns the emitter
  14537. */
  14538. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14539. /**
  14540. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14541. * @param radius The radius of the hemisphere to emit from
  14542. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14543. * @returns the emitter
  14544. */
  14545. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14546. /**
  14547. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14548. * @param radius The radius of the sphere to emit from
  14549. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14550. * @returns the emitter
  14551. */
  14552. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14553. /**
  14554. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14555. * @param radius The radius of the sphere to emit from
  14556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @returns the emitter
  14559. */
  14560. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14561. /**
  14562. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14563. * @param radius The radius of the emission cylinder
  14564. * @param height The height of the emission cylinder
  14565. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14566. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14567. * @returns the emitter
  14568. */
  14569. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14570. /**
  14571. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14572. * @param radius The radius of the cylinder to emit from
  14573. * @param height The height of the emission cylinder
  14574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @returns the emitter
  14578. */
  14579. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14580. /**
  14581. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14582. * @param radius The radius of the cone to emit from
  14583. * @param angle The base angle of the cone
  14584. * @returns the emitter
  14585. */
  14586. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14587. /**
  14588. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14592. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @returns the emitter
  14594. */
  14595. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14596. }
  14597. }
  14598. declare module BABYLON {
  14599. /**
  14600. * Type of sub emitter
  14601. */
  14602. export enum SubEmitterType {
  14603. /**
  14604. * Attached to the particle over it's lifetime
  14605. */
  14606. ATTACHED = 0,
  14607. /**
  14608. * Created when the particle dies
  14609. */
  14610. END = 1
  14611. }
  14612. /**
  14613. * Sub emitter class used to emit particles from an existing particle
  14614. */
  14615. export class SubEmitter {
  14616. /**
  14617. * the particle system to be used by the sub emitter
  14618. */
  14619. particleSystem: ParticleSystem;
  14620. /**
  14621. * Type of the submitter (Default: END)
  14622. */
  14623. type: SubEmitterType;
  14624. /**
  14625. * 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)
  14626. * Note: This only is supported when using an emitter of type Mesh
  14627. */
  14628. inheritDirection: boolean;
  14629. /**
  14630. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14631. */
  14632. inheritedVelocityAmount: number;
  14633. /**
  14634. * Creates a sub emitter
  14635. * @param particleSystem the particle system to be used by the sub emitter
  14636. */
  14637. constructor(
  14638. /**
  14639. * the particle system to be used by the sub emitter
  14640. */
  14641. particleSystem: ParticleSystem);
  14642. /**
  14643. * Clones the sub emitter
  14644. * @returns the cloned sub emitter
  14645. */
  14646. clone(): SubEmitter;
  14647. /**
  14648. * Serialize current object to a JSON object
  14649. * @returns the serialized object
  14650. */
  14651. serialize(): any;
  14652. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14653. /**
  14654. * Creates a new SubEmitter from a serialized JSON version
  14655. * @param serializationObject defines the JSON object to read from
  14656. * @param scene defines the hosting scene
  14657. * @param rootUrl defines the rootUrl for data loading
  14658. * @returns a new SubEmitter
  14659. */
  14660. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14661. /** Release associated resources */
  14662. dispose(): void;
  14663. }
  14664. }
  14665. declare module BABYLON {
  14666. /** @hidden */
  14667. export var clipPlaneFragmentDeclaration: {
  14668. name: string;
  14669. shader: string;
  14670. };
  14671. }
  14672. declare module BABYLON {
  14673. /** @hidden */
  14674. export var imageProcessingDeclaration: {
  14675. name: string;
  14676. shader: string;
  14677. };
  14678. }
  14679. declare module BABYLON {
  14680. /** @hidden */
  14681. export var imageProcessingFunctions: {
  14682. name: string;
  14683. shader: string;
  14684. };
  14685. }
  14686. declare module BABYLON {
  14687. /** @hidden */
  14688. export var clipPlaneFragment: {
  14689. name: string;
  14690. shader: string;
  14691. };
  14692. }
  14693. declare module BABYLON {
  14694. /** @hidden */
  14695. export var particlesPixelShader: {
  14696. name: string;
  14697. shader: string;
  14698. };
  14699. }
  14700. declare module BABYLON {
  14701. /** @hidden */
  14702. export var clipPlaneVertexDeclaration: {
  14703. name: string;
  14704. shader: string;
  14705. };
  14706. }
  14707. declare module BABYLON {
  14708. /** @hidden */
  14709. export var clipPlaneVertex: {
  14710. name: string;
  14711. shader: string;
  14712. };
  14713. }
  14714. declare module BABYLON {
  14715. /** @hidden */
  14716. export var particlesVertexShader: {
  14717. name: string;
  14718. shader: string;
  14719. };
  14720. }
  14721. declare module BABYLON {
  14722. /**
  14723. * This represents a particle system in Babylon.
  14724. * 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.
  14725. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14726. * @example https://doc.babylonjs.com/babylon101/particles
  14727. */
  14728. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14729. /**
  14730. * Billboard mode will only apply to Y axis
  14731. */
  14732. static readonly BILLBOARDMODE_Y: number;
  14733. /**
  14734. * Billboard mode will apply to all axes
  14735. */
  14736. static readonly BILLBOARDMODE_ALL: number;
  14737. /**
  14738. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14739. */
  14740. static readonly BILLBOARDMODE_STRETCHED: number;
  14741. /**
  14742. * This function can be defined to provide custom update for active particles.
  14743. * This function will be called instead of regular update (age, position, color, etc.).
  14744. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14745. */
  14746. updateFunction: (particles: Particle[]) => void;
  14747. private _emitterWorldMatrix;
  14748. /**
  14749. * This function can be defined to specify initial direction for every new particle.
  14750. * It by default use the emitterType defined function
  14751. */
  14752. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14753. /**
  14754. * This function can be defined to specify initial position for every new particle.
  14755. * It by default use the emitterType defined function
  14756. */
  14757. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14758. /**
  14759. * @hidden
  14760. */ inheritedVelocityOffset: Vector3;
  14761. /**
  14762. * An event triggered when the system is disposed
  14763. */
  14764. onDisposeObservable: Observable<ParticleSystem>;
  14765. private _onDisposeObserver;
  14766. /**
  14767. * Sets a callback that will be triggered when the system is disposed
  14768. */
  14769. onDispose: () => void;
  14770. private _particles;
  14771. private _epsilon;
  14772. private _capacity;
  14773. private _stockParticles;
  14774. private _newPartsExcess;
  14775. private _vertexData;
  14776. private _vertexBuffer;
  14777. private _vertexBuffers;
  14778. private _spriteBuffer;
  14779. private _indexBuffer;
  14780. private _effect;
  14781. private _customEffect;
  14782. private _cachedDefines;
  14783. private _scaledColorStep;
  14784. private _colorDiff;
  14785. private _scaledDirection;
  14786. private _scaledGravity;
  14787. private _currentRenderId;
  14788. private _alive;
  14789. private _useInstancing;
  14790. private _started;
  14791. private _stopped;
  14792. private _actualFrame;
  14793. private _scaledUpdateSpeed;
  14794. private _vertexBufferSize;
  14795. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14796. /** @hidden */ currentEmitRate1: number;
  14797. /** @hidden */ currentEmitRate2: number;
  14798. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14799. /** @hidden */ currentStartSize1: number;
  14800. /** @hidden */ currentStartSize2: number;
  14801. private readonly _rawTextureWidth;
  14802. private _rampGradientsTexture;
  14803. private _useRampGradients;
  14804. /** Gets or sets a boolean indicating that ramp gradients must be used
  14805. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14806. */
  14807. useRampGradients: boolean;
  14808. /**
  14809. * 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.
  14810. * 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: [])
  14811. */
  14812. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14813. private _subEmitters;
  14814. /**
  14815. * @hidden
  14816. * If the particle systems emitter should be disposed when the particle system is disposed
  14817. */ disposeEmitterOnDispose: boolean;
  14818. /**
  14819. * The current active Sub-systems, this property is used by the root particle system only.
  14820. */
  14821. activeSubSystems: Array<ParticleSystem>;
  14822. private _rootParticleSystem;
  14823. /**
  14824. * Gets the current list of active particles
  14825. */
  14826. readonly particles: Particle[];
  14827. /**
  14828. * Returns the string "ParticleSystem"
  14829. * @returns a string containing the class name
  14830. */
  14831. getClassName(): string;
  14832. /**
  14833. * Instantiates a particle system.
  14834. * 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.
  14835. * @param name The name of the particle system
  14836. * @param capacity The max number of particles alive at the same time
  14837. * @param scene The scene the particle system belongs to
  14838. * @param customEffect a custom effect used to change the way particles are rendered by default
  14839. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14840. * @param epsilon Offset used to render the particles
  14841. */
  14842. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14843. private _addFactorGradient;
  14844. private _removeFactorGradient;
  14845. /**
  14846. * Adds a new life time gradient
  14847. * @param gradient defines the gradient to use (between 0 and 1)
  14848. * @param factor defines the life time factor to affect to the specified gradient
  14849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14850. * @returns the current particle system
  14851. */
  14852. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14853. /**
  14854. * Remove a specific life time gradient
  14855. * @param gradient defines the gradient to remove
  14856. * @returns the current particle system
  14857. */
  14858. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14859. /**
  14860. * Adds a new size gradient
  14861. * @param gradient defines the gradient to use (between 0 and 1)
  14862. * @param factor defines the size factor to affect to the specified gradient
  14863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14864. * @returns the current particle system
  14865. */
  14866. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14867. /**
  14868. * Remove a specific size gradient
  14869. * @param gradient defines the gradient to remove
  14870. * @returns the current particle system
  14871. */
  14872. removeSizeGradient(gradient: number): IParticleSystem;
  14873. /**
  14874. * Adds a new color remap gradient
  14875. * @param gradient defines the gradient to use (between 0 and 1)
  14876. * @param min defines the color remap minimal range
  14877. * @param max defines the color remap maximal range
  14878. * @returns the current particle system
  14879. */
  14880. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14881. /**
  14882. * Remove a specific color remap gradient
  14883. * @param gradient defines the gradient to remove
  14884. * @returns the current particle system
  14885. */
  14886. removeColorRemapGradient(gradient: number): IParticleSystem;
  14887. /**
  14888. * Adds a new alpha remap gradient
  14889. * @param gradient defines the gradient to use (between 0 and 1)
  14890. * @param min defines the alpha remap minimal range
  14891. * @param max defines the alpha remap maximal range
  14892. * @returns the current particle system
  14893. */
  14894. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14895. /**
  14896. * Remove a specific alpha remap gradient
  14897. * @param gradient defines the gradient to remove
  14898. * @returns the current particle system
  14899. */
  14900. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14901. /**
  14902. * Adds a new angular speed gradient
  14903. * @param gradient defines the gradient to use (between 0 and 1)
  14904. * @param factor defines the angular speed to affect to the specified gradient
  14905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14906. * @returns the current particle system
  14907. */
  14908. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14909. /**
  14910. * Remove a specific angular speed gradient
  14911. * @param gradient defines the gradient to remove
  14912. * @returns the current particle system
  14913. */
  14914. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14915. /**
  14916. * Adds a new velocity gradient
  14917. * @param gradient defines the gradient to use (between 0 and 1)
  14918. * @param factor defines the velocity to affect to the specified gradient
  14919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14920. * @returns the current particle system
  14921. */
  14922. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14923. /**
  14924. * Remove a specific velocity gradient
  14925. * @param gradient defines the gradient to remove
  14926. * @returns the current particle system
  14927. */
  14928. removeVelocityGradient(gradient: number): IParticleSystem;
  14929. /**
  14930. * Adds a new limit velocity gradient
  14931. * @param gradient defines the gradient to use (between 0 and 1)
  14932. * @param factor defines the limit velocity value to affect to the specified gradient
  14933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14934. * @returns the current particle system
  14935. */
  14936. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14937. /**
  14938. * Remove a specific limit velocity gradient
  14939. * @param gradient defines the gradient to remove
  14940. * @returns the current particle system
  14941. */
  14942. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14943. /**
  14944. * Adds a new drag gradient
  14945. * @param gradient defines the gradient to use (between 0 and 1)
  14946. * @param factor defines the drag value to affect to the specified gradient
  14947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14948. * @returns the current particle system
  14949. */
  14950. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14951. /**
  14952. * Remove a specific drag gradient
  14953. * @param gradient defines the gradient to remove
  14954. * @returns the current particle system
  14955. */
  14956. removeDragGradient(gradient: number): IParticleSystem;
  14957. /**
  14958. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14959. * @param gradient defines the gradient to use (between 0 and 1)
  14960. * @param factor defines the emit rate value to affect to the specified gradient
  14961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14962. * @returns the current particle system
  14963. */
  14964. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14965. /**
  14966. * Remove a specific emit rate gradient
  14967. * @param gradient defines the gradient to remove
  14968. * @returns the current particle system
  14969. */
  14970. removeEmitRateGradient(gradient: number): IParticleSystem;
  14971. /**
  14972. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14973. * @param gradient defines the gradient to use (between 0 and 1)
  14974. * @param factor defines the start size value to affect to the specified gradient
  14975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14976. * @returns the current particle system
  14977. */
  14978. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14979. /**
  14980. * Remove a specific start size gradient
  14981. * @param gradient defines the gradient to remove
  14982. * @returns the current particle system
  14983. */
  14984. removeStartSizeGradient(gradient: number): IParticleSystem;
  14985. private _createRampGradientTexture;
  14986. /**
  14987. * Gets the current list of ramp gradients.
  14988. * You must use addRampGradient and removeRampGradient to udpate this list
  14989. * @returns the list of ramp gradients
  14990. */
  14991. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14992. /**
  14993. * Adds a new ramp gradient used to remap particle colors
  14994. * @param gradient defines the gradient to use (between 0 and 1)
  14995. * @param color defines the color to affect to the specified gradient
  14996. * @returns the current particle system
  14997. */
  14998. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14999. /**
  15000. * Remove a specific ramp gradient
  15001. * @param gradient defines the gradient to remove
  15002. * @returns the current particle system
  15003. */
  15004. removeRampGradient(gradient: number): ParticleSystem;
  15005. /**
  15006. * Adds a new color gradient
  15007. * @param gradient defines the gradient to use (between 0 and 1)
  15008. * @param color1 defines the color to affect to the specified gradient
  15009. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15010. * @returns this particle system
  15011. */
  15012. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15013. /**
  15014. * Remove a specific color gradient
  15015. * @param gradient defines the gradient to remove
  15016. * @returns this particle system
  15017. */
  15018. removeColorGradient(gradient: number): IParticleSystem;
  15019. private _fetchR;
  15020. protected _reset(): void;
  15021. private _resetEffect;
  15022. private _createVertexBuffers;
  15023. private _createIndexBuffer;
  15024. /**
  15025. * Gets the maximum number of particles active at the same time.
  15026. * @returns The max number of active particles.
  15027. */
  15028. getCapacity(): number;
  15029. /**
  15030. * Gets whether there are still active particles in the system.
  15031. * @returns True if it is alive, otherwise false.
  15032. */
  15033. isAlive(): boolean;
  15034. /**
  15035. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15036. * @returns True if it has been started, otherwise false.
  15037. */
  15038. isStarted(): boolean;
  15039. private _prepareSubEmitterInternalArray;
  15040. /**
  15041. * Starts the particle system and begins to emit
  15042. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15043. */
  15044. start(delay?: number): void;
  15045. /**
  15046. * Stops the particle system.
  15047. * @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.
  15048. */
  15049. stop(stopSubEmitters?: boolean): void;
  15050. /**
  15051. * Remove all active particles
  15052. */
  15053. reset(): void;
  15054. /**
  15055. * @hidden (for internal use only)
  15056. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15057. /**
  15058. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15059. * Its lifetime will start back at 0.
  15060. */
  15061. recycleParticle: (particle: Particle) => void;
  15062. private _stopSubEmitters;
  15063. private _createParticle;
  15064. private _removeFromRoot;
  15065. private _emitFromParticle;
  15066. private _update;
  15067. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15068. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15069. /** @hidden */
  15070. private _getEffect;
  15071. /**
  15072. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15073. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15074. */
  15075. animate(preWarmOnly?: boolean): void;
  15076. private _appendParticleVertices;
  15077. /**
  15078. * Rebuilds the particle system.
  15079. */
  15080. rebuild(): void;
  15081. /**
  15082. * Is this system ready to be used/rendered
  15083. * @return true if the system is ready
  15084. */
  15085. isReady(): boolean;
  15086. private _render;
  15087. /**
  15088. * Renders the particle system in its current state.
  15089. * @returns the current number of particles
  15090. */
  15091. render(): number;
  15092. /**
  15093. * Disposes the particle system and free the associated resources
  15094. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15095. */
  15096. dispose(disposeTexture?: boolean): void;
  15097. /**
  15098. * Clones the particle system.
  15099. * @param name The name of the cloned object
  15100. * @param newEmitter The new emitter to use
  15101. * @returns the cloned particle system
  15102. */
  15103. clone(name: string, newEmitter: any): ParticleSystem;
  15104. /**
  15105. * Serializes the particle system to a JSON object.
  15106. * @returns the JSON object
  15107. */
  15108. serialize(): any;
  15109. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15110. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15111. /**
  15112. * Parses a JSON object to create a particle system.
  15113. * @param parsedParticleSystem The JSON object to parse
  15114. * @param scene The scene to create the particle system in
  15115. * @param rootUrl The root url to use to load external dependencies like texture
  15116. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15117. * @returns the Parsed particle system
  15118. */
  15119. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15120. }
  15121. }
  15122. declare module BABYLON {
  15123. /**
  15124. * A particle represents one of the element emitted by a particle system.
  15125. * This is mainly define by its coordinates, direction, velocity and age.
  15126. */
  15127. export class Particle {
  15128. /**
  15129. * The particle system the particle belongs to.
  15130. */
  15131. particleSystem: ParticleSystem;
  15132. private static _Count;
  15133. /**
  15134. * Unique ID of the particle
  15135. */
  15136. id: number;
  15137. /**
  15138. * The world position of the particle in the scene.
  15139. */
  15140. position: Vector3;
  15141. /**
  15142. * The world direction of the particle in the scene.
  15143. */
  15144. direction: Vector3;
  15145. /**
  15146. * The color of the particle.
  15147. */
  15148. color: Color4;
  15149. /**
  15150. * The color change of the particle per step.
  15151. */
  15152. colorStep: Color4;
  15153. /**
  15154. * Defines how long will the life of the particle be.
  15155. */
  15156. lifeTime: number;
  15157. /**
  15158. * The current age of the particle.
  15159. */
  15160. age: number;
  15161. /**
  15162. * The current size of the particle.
  15163. */
  15164. size: number;
  15165. /**
  15166. * The current scale of the particle.
  15167. */
  15168. scale: Vector2;
  15169. /**
  15170. * The current angle of the particle.
  15171. */
  15172. angle: number;
  15173. /**
  15174. * Defines how fast is the angle changing.
  15175. */
  15176. angularSpeed: number;
  15177. /**
  15178. * Defines the cell index used by the particle to be rendered from a sprite.
  15179. */
  15180. cellIndex: number;
  15181. /**
  15182. * The information required to support color remapping
  15183. */
  15184. remapData: Vector4;
  15185. /** @hidden */ randomCellOffset?: number;
  15186. /** @hidden */ initialDirection: Nullable<Vector3>;
  15187. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15188. /** @hidden */ initialStartSpriteCellID: number;
  15189. /** @hidden */ initialEndSpriteCellID: number;
  15190. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15191. /** @hidden */ currentColor1: Color4;
  15192. /** @hidden */ currentColor2: Color4;
  15193. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15194. /** @hidden */ currentSize1: number;
  15195. /** @hidden */ currentSize2: number;
  15196. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15197. /** @hidden */ currentAngularSpeed1: number;
  15198. /** @hidden */ currentAngularSpeed2: number;
  15199. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15200. /** @hidden */ currentVelocity1: number;
  15201. /** @hidden */ currentVelocity2: number;
  15202. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15203. /** @hidden */ currentLimitVelocity1: number;
  15204. /** @hidden */ currentLimitVelocity2: number;
  15205. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15206. /** @hidden */ currentDrag1: number;
  15207. /** @hidden */ currentDrag2: number;
  15208. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15209. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15210. /**
  15211. * Creates a new instance Particle
  15212. * @param particleSystem the particle system the particle belongs to
  15213. */
  15214. constructor(
  15215. /**
  15216. * The particle system the particle belongs to.
  15217. */
  15218. particleSystem: ParticleSystem);
  15219. private updateCellInfoFromSystem;
  15220. /**
  15221. * Defines how the sprite cell index is updated for the particle
  15222. */
  15223. updateCellIndex(): void;
  15224. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15225. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15226. /** @hidden */ reset(): void;
  15227. /**
  15228. * Copy the properties of particle to another one.
  15229. * @param other the particle to copy the information to.
  15230. */
  15231. copyTo(other: Particle): void;
  15232. }
  15233. }
  15234. declare module BABYLON {
  15235. /**
  15236. * Particle emitter represents a volume emitting particles.
  15237. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15238. */
  15239. export interface IParticleEmitterType {
  15240. /**
  15241. * Called by the particle System when the direction is computed for the created particle.
  15242. * @param worldMatrix is the world matrix of the particle system
  15243. * @param directionToUpdate is the direction vector to update with the result
  15244. * @param particle is the particle we are computed the direction for
  15245. */
  15246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15247. /**
  15248. * Called by the particle System when the position is computed for the created particle.
  15249. * @param worldMatrix is the world matrix of the particle system
  15250. * @param positionToUpdate is the position vector to update with the result
  15251. * @param particle is the particle we are computed the position for
  15252. */
  15253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15254. /**
  15255. * Clones the current emitter and returns a copy of it
  15256. * @returns the new emitter
  15257. */
  15258. clone(): IParticleEmitterType;
  15259. /**
  15260. * Called by the GPUParticleSystem to setup the update shader
  15261. * @param effect defines the update shader
  15262. */
  15263. applyToShader(effect: Effect): void;
  15264. /**
  15265. * Returns a string to use to update the GPU particles update shader
  15266. * @returns the effect defines string
  15267. */
  15268. getEffectDefines(): string;
  15269. /**
  15270. * Returns a string representing the class name
  15271. * @returns a string containing the class name
  15272. */
  15273. getClassName(): string;
  15274. /**
  15275. * Serializes the particle system to a JSON object.
  15276. * @returns the JSON object
  15277. */
  15278. serialize(): any;
  15279. /**
  15280. * Parse properties from a JSON object
  15281. * @param serializationObject defines the JSON object
  15282. */
  15283. parse(serializationObject: any): void;
  15284. }
  15285. }
  15286. declare module BABYLON {
  15287. /**
  15288. * Particle emitter emitting particles from the inside of a box.
  15289. * It emits the particles randomly between 2 given directions.
  15290. */
  15291. export class BoxParticleEmitter implements IParticleEmitterType {
  15292. /**
  15293. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15294. */
  15295. direction1: Vector3;
  15296. /**
  15297. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15298. */
  15299. direction2: Vector3;
  15300. /**
  15301. * 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.
  15302. */
  15303. minEmitBox: Vector3;
  15304. /**
  15305. * 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.
  15306. */
  15307. maxEmitBox: Vector3;
  15308. /**
  15309. * Creates a new instance BoxParticleEmitter
  15310. */
  15311. constructor();
  15312. /**
  15313. * Called by the particle System when the direction is computed for the created particle.
  15314. * @param worldMatrix is the world matrix of the particle system
  15315. * @param directionToUpdate is the direction vector to update with the result
  15316. * @param particle is the particle we are computed the direction for
  15317. */
  15318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15319. /**
  15320. * Called by the particle System when the position is computed for the created particle.
  15321. * @param worldMatrix is the world matrix of the particle system
  15322. * @param positionToUpdate is the position vector to update with the result
  15323. * @param particle is the particle we are computed the position for
  15324. */
  15325. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15326. /**
  15327. * Clones the current emitter and returns a copy of it
  15328. * @returns the new emitter
  15329. */
  15330. clone(): BoxParticleEmitter;
  15331. /**
  15332. * Called by the GPUParticleSystem to setup the update shader
  15333. * @param effect defines the update shader
  15334. */
  15335. applyToShader(effect: Effect): void;
  15336. /**
  15337. * Returns a string to use to update the GPU particles update shader
  15338. * @returns a string containng the defines string
  15339. */
  15340. getEffectDefines(): string;
  15341. /**
  15342. * Returns the string "BoxParticleEmitter"
  15343. * @returns a string containing the class name
  15344. */
  15345. getClassName(): string;
  15346. /**
  15347. * Serializes the particle system to a JSON object.
  15348. * @returns the JSON object
  15349. */
  15350. serialize(): any;
  15351. /**
  15352. * Parse properties from a JSON object
  15353. * @param serializationObject defines the JSON object
  15354. */
  15355. parse(serializationObject: any): void;
  15356. }
  15357. }
  15358. declare module BABYLON {
  15359. /**
  15360. * Particle emitter emitting particles from the inside of a cone.
  15361. * It emits the particles alongside the cone volume from the base to the particle.
  15362. * The emission direction might be randomized.
  15363. */
  15364. export class ConeParticleEmitter implements IParticleEmitterType {
  15365. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15366. directionRandomizer: number;
  15367. private _radius;
  15368. private _angle;
  15369. private _height;
  15370. /**
  15371. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15372. */
  15373. radiusRange: number;
  15374. /**
  15375. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15376. */
  15377. heightRange: number;
  15378. /**
  15379. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15380. */
  15381. emitFromSpawnPointOnly: boolean;
  15382. /**
  15383. * Gets or sets the radius of the emission cone
  15384. */
  15385. radius: number;
  15386. /**
  15387. * Gets or sets the angle of the emission cone
  15388. */
  15389. angle: number;
  15390. private _buildHeight;
  15391. /**
  15392. * Creates a new instance ConeParticleEmitter
  15393. * @param radius the radius of the emission cone (1 by default)
  15394. * @param angle the cone base angle (PI by default)
  15395. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15396. */
  15397. constructor(radius?: number, angle?: number,
  15398. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15399. directionRandomizer?: number);
  15400. /**
  15401. * Called by the particle System when the direction is computed for the created particle.
  15402. * @param worldMatrix is the world matrix of the particle system
  15403. * @param directionToUpdate is the direction vector to update with the result
  15404. * @param particle is the particle we are computed the direction for
  15405. */
  15406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15407. /**
  15408. * Called by the particle System when the position is computed for the created particle.
  15409. * @param worldMatrix is the world matrix of the particle system
  15410. * @param positionToUpdate is the position vector to update with the result
  15411. * @param particle is the particle we are computed the position for
  15412. */
  15413. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15414. /**
  15415. * Clones the current emitter and returns a copy of it
  15416. * @returns the new emitter
  15417. */
  15418. clone(): ConeParticleEmitter;
  15419. /**
  15420. * Called by the GPUParticleSystem to setup the update shader
  15421. * @param effect defines the update shader
  15422. */
  15423. applyToShader(effect: Effect): void;
  15424. /**
  15425. * Returns a string to use to update the GPU particles update shader
  15426. * @returns a string containng the defines string
  15427. */
  15428. getEffectDefines(): string;
  15429. /**
  15430. * Returns the string "ConeParticleEmitter"
  15431. * @returns a string containing the class name
  15432. */
  15433. getClassName(): string;
  15434. /**
  15435. * Serializes the particle system to a JSON object.
  15436. * @returns the JSON object
  15437. */
  15438. serialize(): any;
  15439. /**
  15440. * Parse properties from a JSON object
  15441. * @param serializationObject defines the JSON object
  15442. */
  15443. parse(serializationObject: any): void;
  15444. }
  15445. }
  15446. declare module BABYLON {
  15447. /**
  15448. * Particle emitter emitting particles from the inside of a cylinder.
  15449. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15450. */
  15451. export class CylinderParticleEmitter implements IParticleEmitterType {
  15452. /**
  15453. * The radius of the emission cylinder.
  15454. */
  15455. radius: number;
  15456. /**
  15457. * The height of the emission cylinder.
  15458. */
  15459. height: number;
  15460. /**
  15461. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15462. */
  15463. radiusRange: number;
  15464. /**
  15465. * How much to randomize the particle direction [0-1].
  15466. */
  15467. directionRandomizer: number;
  15468. /**
  15469. * Creates a new instance CylinderParticleEmitter
  15470. * @param radius the radius of the emission cylinder (1 by default)
  15471. * @param height the height of the emission cylinder (1 by default)
  15472. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15473. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15474. */
  15475. constructor(
  15476. /**
  15477. * The radius of the emission cylinder.
  15478. */
  15479. radius?: number,
  15480. /**
  15481. * The height of the emission cylinder.
  15482. */
  15483. height?: number,
  15484. /**
  15485. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15486. */
  15487. radiusRange?: number,
  15488. /**
  15489. * How much to randomize the particle direction [0-1].
  15490. */
  15491. directionRandomizer?: number);
  15492. /**
  15493. * Called by the particle System when the direction is computed for the created particle.
  15494. * @param worldMatrix is the world matrix of the particle system
  15495. * @param directionToUpdate is the direction vector to update with the result
  15496. * @param particle is the particle we are computed the direction for
  15497. */
  15498. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15499. /**
  15500. * Called by the particle System when the position is computed for the created particle.
  15501. * @param worldMatrix is the world matrix of the particle system
  15502. * @param positionToUpdate is the position vector to update with the result
  15503. * @param particle is the particle we are computed the position for
  15504. */
  15505. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15506. /**
  15507. * Clones the current emitter and returns a copy of it
  15508. * @returns the new emitter
  15509. */
  15510. clone(): CylinderParticleEmitter;
  15511. /**
  15512. * Called by the GPUParticleSystem to setup the update shader
  15513. * @param effect defines the update shader
  15514. */
  15515. applyToShader(effect: Effect): void;
  15516. /**
  15517. * Returns a string to use to update the GPU particles update shader
  15518. * @returns a string containng the defines string
  15519. */
  15520. getEffectDefines(): string;
  15521. /**
  15522. * Returns the string "CylinderParticleEmitter"
  15523. * @returns a string containing the class name
  15524. */
  15525. getClassName(): string;
  15526. /**
  15527. * Serializes the particle system to a JSON object.
  15528. * @returns the JSON object
  15529. */
  15530. serialize(): any;
  15531. /**
  15532. * Parse properties from a JSON object
  15533. * @param serializationObject defines the JSON object
  15534. */
  15535. parse(serializationObject: any): void;
  15536. }
  15537. /**
  15538. * Particle emitter emitting particles from the inside of a cylinder.
  15539. * It emits the particles randomly between two vectors.
  15540. */
  15541. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15542. /**
  15543. * The min limit of the emission direction.
  15544. */
  15545. direction1: Vector3;
  15546. /**
  15547. * The max limit of the emission direction.
  15548. */
  15549. direction2: Vector3;
  15550. /**
  15551. * Creates a new instance CylinderDirectedParticleEmitter
  15552. * @param radius the radius of the emission cylinder (1 by default)
  15553. * @param height the height of the emission cylinder (1 by default)
  15554. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15555. * @param direction1 the min limit of the emission direction (up vector by default)
  15556. * @param direction2 the max limit of the emission direction (up vector by default)
  15557. */
  15558. constructor(radius?: number, height?: number, radiusRange?: number,
  15559. /**
  15560. * The min limit of the emission direction.
  15561. */
  15562. direction1?: Vector3,
  15563. /**
  15564. * The max limit of the emission direction.
  15565. */
  15566. direction2?: Vector3);
  15567. /**
  15568. * Called by the particle System when the direction is computed for the created particle.
  15569. * @param worldMatrix is the world matrix of the particle system
  15570. * @param directionToUpdate is the direction vector to update with the result
  15571. * @param particle is the particle we are computed the direction for
  15572. */
  15573. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15574. /**
  15575. * Clones the current emitter and returns a copy of it
  15576. * @returns the new emitter
  15577. */
  15578. clone(): CylinderDirectedParticleEmitter;
  15579. /**
  15580. * Called by the GPUParticleSystem to setup the update shader
  15581. * @param effect defines the update shader
  15582. */
  15583. applyToShader(effect: Effect): void;
  15584. /**
  15585. * Returns a string to use to update the GPU particles update shader
  15586. * @returns a string containng the defines string
  15587. */
  15588. getEffectDefines(): string;
  15589. /**
  15590. * Returns the string "CylinderDirectedParticleEmitter"
  15591. * @returns a string containing the class name
  15592. */
  15593. getClassName(): string;
  15594. /**
  15595. * Serializes the particle system to a JSON object.
  15596. * @returns the JSON object
  15597. */
  15598. serialize(): any;
  15599. /**
  15600. * Parse properties from a JSON object
  15601. * @param serializationObject defines the JSON object
  15602. */
  15603. parse(serializationObject: any): void;
  15604. }
  15605. }
  15606. declare module BABYLON {
  15607. /**
  15608. * Particle emitter emitting particles from the inside of a hemisphere.
  15609. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15610. */
  15611. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15612. /**
  15613. * The radius of the emission hemisphere.
  15614. */
  15615. radius: number;
  15616. /**
  15617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15618. */
  15619. radiusRange: number;
  15620. /**
  15621. * How much to randomize the particle direction [0-1].
  15622. */
  15623. directionRandomizer: number;
  15624. /**
  15625. * Creates a new instance HemisphericParticleEmitter
  15626. * @param radius the radius of the emission hemisphere (1 by default)
  15627. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15628. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15629. */
  15630. constructor(
  15631. /**
  15632. * The radius of the emission hemisphere.
  15633. */
  15634. radius?: number,
  15635. /**
  15636. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15637. */
  15638. radiusRange?: number,
  15639. /**
  15640. * How much to randomize the particle direction [0-1].
  15641. */
  15642. directionRandomizer?: number);
  15643. /**
  15644. * Called by the particle System when the direction is computed for the created particle.
  15645. * @param worldMatrix is the world matrix of the particle system
  15646. * @param directionToUpdate is the direction vector to update with the result
  15647. * @param particle is the particle we are computed the direction for
  15648. */
  15649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15650. /**
  15651. * Called by the particle System when the position is computed for the created particle.
  15652. * @param worldMatrix is the world matrix of the particle system
  15653. * @param positionToUpdate is the position vector to update with the result
  15654. * @param particle is the particle we are computed the position for
  15655. */
  15656. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15657. /**
  15658. * Clones the current emitter and returns a copy of it
  15659. * @returns the new emitter
  15660. */
  15661. clone(): HemisphericParticleEmitter;
  15662. /**
  15663. * Called by the GPUParticleSystem to setup the update shader
  15664. * @param effect defines the update shader
  15665. */
  15666. applyToShader(effect: Effect): void;
  15667. /**
  15668. * Returns a string to use to update the GPU particles update shader
  15669. * @returns a string containng the defines string
  15670. */
  15671. getEffectDefines(): string;
  15672. /**
  15673. * Returns the string "HemisphericParticleEmitter"
  15674. * @returns a string containing the class name
  15675. */
  15676. getClassName(): string;
  15677. /**
  15678. * Serializes the particle system to a JSON object.
  15679. * @returns the JSON object
  15680. */
  15681. serialize(): any;
  15682. /**
  15683. * Parse properties from a JSON object
  15684. * @param serializationObject defines the JSON object
  15685. */
  15686. parse(serializationObject: any): void;
  15687. }
  15688. }
  15689. declare module BABYLON {
  15690. /**
  15691. * Particle emitter emitting particles from a point.
  15692. * It emits the particles randomly between 2 given directions.
  15693. */
  15694. export class PointParticleEmitter implements IParticleEmitterType {
  15695. /**
  15696. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15697. */
  15698. direction1: Vector3;
  15699. /**
  15700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15701. */
  15702. direction2: Vector3;
  15703. /**
  15704. * Creates a new instance PointParticleEmitter
  15705. */
  15706. constructor();
  15707. /**
  15708. * Called by the particle System when the direction is computed for the created particle.
  15709. * @param worldMatrix is the world matrix of the particle system
  15710. * @param directionToUpdate is the direction vector to update with the result
  15711. * @param particle is the particle we are computed the direction for
  15712. */
  15713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15714. /**
  15715. * Called by the particle System when the position is computed for the created particle.
  15716. * @param worldMatrix is the world matrix of the particle system
  15717. * @param positionToUpdate is the position vector to update with the result
  15718. * @param particle is the particle we are computed the position for
  15719. */
  15720. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15721. /**
  15722. * Clones the current emitter and returns a copy of it
  15723. * @returns the new emitter
  15724. */
  15725. clone(): PointParticleEmitter;
  15726. /**
  15727. * Called by the GPUParticleSystem to setup the update shader
  15728. * @param effect defines the update shader
  15729. */
  15730. applyToShader(effect: Effect): void;
  15731. /**
  15732. * Returns a string to use to update the GPU particles update shader
  15733. * @returns a string containng the defines string
  15734. */
  15735. getEffectDefines(): string;
  15736. /**
  15737. * Returns the string "PointParticleEmitter"
  15738. * @returns a string containing the class name
  15739. */
  15740. getClassName(): string;
  15741. /**
  15742. * Serializes the particle system to a JSON object.
  15743. * @returns the JSON object
  15744. */
  15745. serialize(): any;
  15746. /**
  15747. * Parse properties from a JSON object
  15748. * @param serializationObject defines the JSON object
  15749. */
  15750. parse(serializationObject: any): void;
  15751. }
  15752. }
  15753. declare module BABYLON {
  15754. /**
  15755. * Particle emitter emitting particles from the inside of a sphere.
  15756. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15757. */
  15758. export class SphereParticleEmitter implements IParticleEmitterType {
  15759. /**
  15760. * The radius of the emission sphere.
  15761. */
  15762. radius: number;
  15763. /**
  15764. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15765. */
  15766. radiusRange: number;
  15767. /**
  15768. * How much to randomize the particle direction [0-1].
  15769. */
  15770. directionRandomizer: number;
  15771. /**
  15772. * Creates a new instance SphereParticleEmitter
  15773. * @param radius the radius of the emission sphere (1 by default)
  15774. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15775. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15776. */
  15777. constructor(
  15778. /**
  15779. * The radius of the emission sphere.
  15780. */
  15781. radius?: number,
  15782. /**
  15783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15784. */
  15785. radiusRange?: number,
  15786. /**
  15787. * How much to randomize the particle direction [0-1].
  15788. */
  15789. directionRandomizer?: number);
  15790. /**
  15791. * Called by the particle System when the direction is computed for the created particle.
  15792. * @param worldMatrix is the world matrix of the particle system
  15793. * @param directionToUpdate is the direction vector to update with the result
  15794. * @param particle is the particle we are computed the direction for
  15795. */
  15796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15797. /**
  15798. * Called by the particle System when the position is computed for the created particle.
  15799. * @param worldMatrix is the world matrix of the particle system
  15800. * @param positionToUpdate is the position vector to update with the result
  15801. * @param particle is the particle we are computed the position for
  15802. */
  15803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15804. /**
  15805. * Clones the current emitter and returns a copy of it
  15806. * @returns the new emitter
  15807. */
  15808. clone(): SphereParticleEmitter;
  15809. /**
  15810. * Called by the GPUParticleSystem to setup the update shader
  15811. * @param effect defines the update shader
  15812. */
  15813. applyToShader(effect: Effect): void;
  15814. /**
  15815. * Returns a string to use to update the GPU particles update shader
  15816. * @returns a string containng the defines string
  15817. */
  15818. getEffectDefines(): string;
  15819. /**
  15820. * Returns the string "SphereParticleEmitter"
  15821. * @returns a string containing the class name
  15822. */
  15823. getClassName(): string;
  15824. /**
  15825. * Serializes the particle system to a JSON object.
  15826. * @returns the JSON object
  15827. */
  15828. serialize(): any;
  15829. /**
  15830. * Parse properties from a JSON object
  15831. * @param serializationObject defines the JSON object
  15832. */
  15833. parse(serializationObject: any): void;
  15834. }
  15835. /**
  15836. * Particle emitter emitting particles from the inside of a sphere.
  15837. * It emits the particles randomly between two vectors.
  15838. */
  15839. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15840. /**
  15841. * The min limit of the emission direction.
  15842. */
  15843. direction1: Vector3;
  15844. /**
  15845. * The max limit of the emission direction.
  15846. */
  15847. direction2: Vector3;
  15848. /**
  15849. * Creates a new instance SphereDirectedParticleEmitter
  15850. * @param radius the radius of the emission sphere (1 by default)
  15851. * @param direction1 the min limit of the emission direction (up vector by default)
  15852. * @param direction2 the max limit of the emission direction (up vector by default)
  15853. */
  15854. constructor(radius?: number,
  15855. /**
  15856. * The min limit of the emission direction.
  15857. */
  15858. direction1?: Vector3,
  15859. /**
  15860. * The max limit of the emission direction.
  15861. */
  15862. direction2?: Vector3);
  15863. /**
  15864. * Called by the particle System when the direction is computed for the created particle.
  15865. * @param worldMatrix is the world matrix of the particle system
  15866. * @param directionToUpdate is the direction vector to update with the result
  15867. * @param particle is the particle we are computed the direction for
  15868. */
  15869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15870. /**
  15871. * Clones the current emitter and returns a copy of it
  15872. * @returns the new emitter
  15873. */
  15874. clone(): SphereDirectedParticleEmitter;
  15875. /**
  15876. * Called by the GPUParticleSystem to setup the update shader
  15877. * @param effect defines the update shader
  15878. */
  15879. applyToShader(effect: Effect): void;
  15880. /**
  15881. * Returns a string to use to update the GPU particles update shader
  15882. * @returns a string containng the defines string
  15883. */
  15884. getEffectDefines(): string;
  15885. /**
  15886. * Returns the string "SphereDirectedParticleEmitter"
  15887. * @returns a string containing the class name
  15888. */
  15889. getClassName(): string;
  15890. /**
  15891. * Serializes the particle system to a JSON object.
  15892. * @returns the JSON object
  15893. */
  15894. serialize(): any;
  15895. /**
  15896. * Parse properties from a JSON object
  15897. * @param serializationObject defines the JSON object
  15898. */
  15899. parse(serializationObject: any): void;
  15900. }
  15901. }
  15902. declare module BABYLON {
  15903. /**
  15904. * Interface representing a particle system in Babylon.js.
  15905. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15906. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15907. */
  15908. export interface IParticleSystem {
  15909. /**
  15910. * List of animations used by the particle system.
  15911. */
  15912. animations: Animation[];
  15913. /**
  15914. * The id of the Particle system.
  15915. */
  15916. id: string;
  15917. /**
  15918. * The name of the Particle system.
  15919. */
  15920. name: string;
  15921. /**
  15922. * The emitter represents the Mesh or position we are attaching the particle system to.
  15923. */
  15924. emitter: Nullable<AbstractMesh | Vector3>;
  15925. /**
  15926. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15927. */
  15928. isBillboardBased: boolean;
  15929. /**
  15930. * The rendering group used by the Particle system to chose when to render.
  15931. */
  15932. renderingGroupId: number;
  15933. /**
  15934. * The layer mask we are rendering the particles through.
  15935. */
  15936. layerMask: number;
  15937. /**
  15938. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15939. */
  15940. updateSpeed: number;
  15941. /**
  15942. * The amount of time the particle system is running (depends of the overall update speed).
  15943. */
  15944. targetStopDuration: number;
  15945. /**
  15946. * The texture used to render each particle. (this can be a spritesheet)
  15947. */
  15948. particleTexture: Nullable<Texture>;
  15949. /**
  15950. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15951. */
  15952. blendMode: number;
  15953. /**
  15954. * Minimum life time of emitting particles.
  15955. */
  15956. minLifeTime: number;
  15957. /**
  15958. * Maximum life time of emitting particles.
  15959. */
  15960. maxLifeTime: number;
  15961. /**
  15962. * Minimum Size of emitting particles.
  15963. */
  15964. minSize: number;
  15965. /**
  15966. * Maximum Size of emitting particles.
  15967. */
  15968. maxSize: number;
  15969. /**
  15970. * Minimum scale of emitting particles on X axis.
  15971. */
  15972. minScaleX: number;
  15973. /**
  15974. * Maximum scale of emitting particles on X axis.
  15975. */
  15976. maxScaleX: number;
  15977. /**
  15978. * Minimum scale of emitting particles on Y axis.
  15979. */
  15980. minScaleY: number;
  15981. /**
  15982. * Maximum scale of emitting particles on Y axis.
  15983. */
  15984. maxScaleY: number;
  15985. /**
  15986. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15987. */
  15988. color1: Color4;
  15989. /**
  15990. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15991. */
  15992. color2: Color4;
  15993. /**
  15994. * Color the particle will have at the end of its lifetime.
  15995. */
  15996. colorDead: Color4;
  15997. /**
  15998. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15999. */
  16000. emitRate: number;
  16001. /**
  16002. * You can use gravity if you want to give an orientation to your particles.
  16003. */
  16004. gravity: Vector3;
  16005. /**
  16006. * Minimum power of emitting particles.
  16007. */
  16008. minEmitPower: number;
  16009. /**
  16010. * Maximum power of emitting particles.
  16011. */
  16012. maxEmitPower: number;
  16013. /**
  16014. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16015. */
  16016. minAngularSpeed: number;
  16017. /**
  16018. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16019. */
  16020. maxAngularSpeed: number;
  16021. /**
  16022. * Gets or sets the minimal initial rotation in radians.
  16023. */
  16024. minInitialRotation: number;
  16025. /**
  16026. * Gets or sets the maximal initial rotation in radians.
  16027. */
  16028. maxInitialRotation: number;
  16029. /**
  16030. * The particle emitter type defines the emitter used by the particle system.
  16031. * It can be for example box, sphere, or cone...
  16032. */
  16033. particleEmitterType: Nullable<IParticleEmitterType>;
  16034. /**
  16035. * Defines the delay in milliseconds before starting the system (0 by default)
  16036. */
  16037. startDelay: number;
  16038. /**
  16039. * 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
  16040. */
  16041. preWarmCycles: number;
  16042. /**
  16043. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16044. */
  16045. preWarmStepOffset: number;
  16046. /**
  16047. * 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)
  16048. */
  16049. spriteCellChangeSpeed: number;
  16050. /**
  16051. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16052. */
  16053. startSpriteCellID: number;
  16054. /**
  16055. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16056. */
  16057. endSpriteCellID: number;
  16058. /**
  16059. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16060. */
  16061. spriteCellWidth: number;
  16062. /**
  16063. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16064. */
  16065. spriteCellHeight: number;
  16066. /**
  16067. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16068. */
  16069. spriteRandomStartCell: boolean;
  16070. /**
  16071. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16072. */
  16073. isAnimationSheetEnabled: boolean;
  16074. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16075. translationPivot: Vector2;
  16076. /**
  16077. * Gets or sets a texture used to add random noise to particle positions
  16078. */
  16079. noiseTexture: Nullable<BaseTexture>;
  16080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16081. noiseStrength: Vector3;
  16082. /**
  16083. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16084. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16085. */
  16086. billboardMode: number;
  16087. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16088. limitVelocityDamping: number;
  16089. /**
  16090. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16091. */
  16092. beginAnimationOnStart: boolean;
  16093. /**
  16094. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16095. */
  16096. beginAnimationFrom: number;
  16097. /**
  16098. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16099. */
  16100. beginAnimationTo: number;
  16101. /**
  16102. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16103. */
  16104. beginAnimationLoop: boolean;
  16105. /**
  16106. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16107. */
  16108. disposeOnStop: boolean;
  16109. /**
  16110. * Gets the maximum number of particles active at the same time.
  16111. * @returns The max number of active particles.
  16112. */
  16113. getCapacity(): number;
  16114. /**
  16115. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16116. * @returns True if it has been started, otherwise false.
  16117. */
  16118. isStarted(): boolean;
  16119. /**
  16120. * Animates the particle system for this frame.
  16121. */
  16122. animate(): void;
  16123. /**
  16124. * Renders the particle system in its current state.
  16125. * @returns the current number of particles
  16126. */
  16127. render(): number;
  16128. /**
  16129. * Dispose the particle system and frees its associated resources.
  16130. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16131. */
  16132. dispose(disposeTexture?: boolean): void;
  16133. /**
  16134. * Clones the particle system.
  16135. * @param name The name of the cloned object
  16136. * @param newEmitter The new emitter to use
  16137. * @returns the cloned particle system
  16138. */
  16139. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16140. /**
  16141. * Serializes the particle system to a JSON object.
  16142. * @returns the JSON object
  16143. */
  16144. serialize(): any;
  16145. /**
  16146. * Rebuild the particle system
  16147. */
  16148. rebuild(): void;
  16149. /**
  16150. * Starts the particle system and begins to emit
  16151. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16152. */
  16153. start(delay?: number): void;
  16154. /**
  16155. * Stops the particle system.
  16156. */
  16157. stop(): void;
  16158. /**
  16159. * Remove all active particles
  16160. */
  16161. reset(): void;
  16162. /**
  16163. * Is this system ready to be used/rendered
  16164. * @return true if the system is ready
  16165. */
  16166. isReady(): boolean;
  16167. /**
  16168. * Adds a new color gradient
  16169. * @param gradient defines the gradient to use (between 0 and 1)
  16170. * @param color1 defines the color to affect to the specified gradient
  16171. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16172. * @returns the current particle system
  16173. */
  16174. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16175. /**
  16176. * Remove a specific color gradient
  16177. * @param gradient defines the gradient to remove
  16178. * @returns the current particle system
  16179. */
  16180. removeColorGradient(gradient: number): IParticleSystem;
  16181. /**
  16182. * Adds a new size gradient
  16183. * @param gradient defines the gradient to use (between 0 and 1)
  16184. * @param factor defines the size factor to affect to the specified gradient
  16185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16186. * @returns the current particle system
  16187. */
  16188. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16189. /**
  16190. * Remove a specific size gradient
  16191. * @param gradient defines the gradient to remove
  16192. * @returns the current particle system
  16193. */
  16194. removeSizeGradient(gradient: number): IParticleSystem;
  16195. /**
  16196. * Gets the current list of color gradients.
  16197. * You must use addColorGradient and removeColorGradient to udpate this list
  16198. * @returns the list of color gradients
  16199. */
  16200. getColorGradients(): Nullable<Array<ColorGradient>>;
  16201. /**
  16202. * Gets the current list of size gradients.
  16203. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16204. * @returns the list of size gradients
  16205. */
  16206. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16207. /**
  16208. * Gets the current list of angular speed gradients.
  16209. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16210. * @returns the list of angular speed gradients
  16211. */
  16212. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16213. /**
  16214. * Adds a new angular speed gradient
  16215. * @param gradient defines the gradient to use (between 0 and 1)
  16216. * @param factor defines the angular speed to affect to the specified gradient
  16217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16218. * @returns the current particle system
  16219. */
  16220. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16221. /**
  16222. * Remove a specific angular speed gradient
  16223. * @param gradient defines the gradient to remove
  16224. * @returns the current particle system
  16225. */
  16226. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16227. /**
  16228. * Gets the current list of velocity gradients.
  16229. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16230. * @returns the list of velocity gradients
  16231. */
  16232. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16233. /**
  16234. * Adds a new velocity gradient
  16235. * @param gradient defines the gradient to use (between 0 and 1)
  16236. * @param factor defines the velocity to affect to the specified gradient
  16237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16238. * @returns the current particle system
  16239. */
  16240. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16241. /**
  16242. * Remove a specific velocity gradient
  16243. * @param gradient defines the gradient to remove
  16244. * @returns the current particle system
  16245. */
  16246. removeVelocityGradient(gradient: number): IParticleSystem;
  16247. /**
  16248. * Gets the current list of limit velocity gradients.
  16249. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16250. * @returns the list of limit velocity gradients
  16251. */
  16252. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16253. /**
  16254. * Adds a new limit velocity gradient
  16255. * @param gradient defines the gradient to use (between 0 and 1)
  16256. * @param factor defines the limit velocity to affect to the specified gradient
  16257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16258. * @returns the current particle system
  16259. */
  16260. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16261. /**
  16262. * Remove a specific limit velocity gradient
  16263. * @param gradient defines the gradient to remove
  16264. * @returns the current particle system
  16265. */
  16266. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16267. /**
  16268. * Adds a new drag gradient
  16269. * @param gradient defines the gradient to use (between 0 and 1)
  16270. * @param factor defines the drag to affect to the specified gradient
  16271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16272. * @returns the current particle system
  16273. */
  16274. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16275. /**
  16276. * Remove a specific drag gradient
  16277. * @param gradient defines the gradient to remove
  16278. * @returns the current particle system
  16279. */
  16280. removeDragGradient(gradient: number): IParticleSystem;
  16281. /**
  16282. * Gets the current list of drag gradients.
  16283. * You must use addDragGradient and removeDragGradient to udpate this list
  16284. * @returns the list of drag gradients
  16285. */
  16286. getDragGradients(): Nullable<Array<FactorGradient>>;
  16287. /**
  16288. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16289. * @param gradient defines the gradient to use (between 0 and 1)
  16290. * @param factor defines the emit rate to affect to the specified gradient
  16291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16292. * @returns the current particle system
  16293. */
  16294. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16295. /**
  16296. * Remove a specific emit rate gradient
  16297. * @param gradient defines the gradient to remove
  16298. * @returns the current particle system
  16299. */
  16300. removeEmitRateGradient(gradient: number): IParticleSystem;
  16301. /**
  16302. * Gets the current list of emit rate gradients.
  16303. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16304. * @returns the list of emit rate gradients
  16305. */
  16306. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16307. /**
  16308. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16309. * @param gradient defines the gradient to use (between 0 and 1)
  16310. * @param factor defines the start size to affect to the specified gradient
  16311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16312. * @returns the current particle system
  16313. */
  16314. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16315. /**
  16316. * Remove a specific start size gradient
  16317. * @param gradient defines the gradient to remove
  16318. * @returns the current particle system
  16319. */
  16320. removeStartSizeGradient(gradient: number): IParticleSystem;
  16321. /**
  16322. * Gets the current list of start size gradients.
  16323. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16324. * @returns the list of start size gradients
  16325. */
  16326. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16327. /**
  16328. * Adds a new life time gradient
  16329. * @param gradient defines the gradient to use (between 0 and 1)
  16330. * @param factor defines the life time factor to affect to the specified gradient
  16331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16332. * @returns the current particle system
  16333. */
  16334. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16335. /**
  16336. * Remove a specific life time gradient
  16337. * @param gradient defines the gradient to remove
  16338. * @returns the current particle system
  16339. */
  16340. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16341. /**
  16342. * Gets the current list of life time gradients.
  16343. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16344. * @returns the list of life time gradients
  16345. */
  16346. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16347. /**
  16348. * Gets the current list of color gradients.
  16349. * You must use addColorGradient and removeColorGradient to udpate this list
  16350. * @returns the list of color gradients
  16351. */
  16352. getColorGradients(): Nullable<Array<ColorGradient>>;
  16353. /**
  16354. * Adds a new ramp gradient used to remap particle colors
  16355. * @param gradient defines the gradient to use (between 0 and 1)
  16356. * @param color defines the color to affect to the specified gradient
  16357. * @returns the current particle system
  16358. */
  16359. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16360. /**
  16361. * Gets the current list of ramp gradients.
  16362. * You must use addRampGradient and removeRampGradient to udpate this list
  16363. * @returns the list of ramp gradients
  16364. */
  16365. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16366. /** Gets or sets a boolean indicating that ramp gradients must be used
  16367. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16368. */
  16369. useRampGradients: boolean;
  16370. /**
  16371. * Adds a new color remap gradient
  16372. * @param gradient defines the gradient to use (between 0 and 1)
  16373. * @param min defines the color remap minimal range
  16374. * @param max defines the color remap maximal range
  16375. * @returns the current particle system
  16376. */
  16377. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16378. /**
  16379. * Gets the current list of color remap gradients.
  16380. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16381. * @returns the list of color remap gradients
  16382. */
  16383. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16384. /**
  16385. * Adds a new alpha remap gradient
  16386. * @param gradient defines the gradient to use (between 0 and 1)
  16387. * @param min defines the alpha remap minimal range
  16388. * @param max defines the alpha remap maximal range
  16389. * @returns the current particle system
  16390. */
  16391. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16392. /**
  16393. * Gets the current list of alpha remap gradients.
  16394. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16395. * @returns the list of alpha remap gradients
  16396. */
  16397. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16398. /**
  16399. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16400. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16401. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16402. * @returns the emitter
  16403. */
  16404. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16405. /**
  16406. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16407. * @param radius The radius of the hemisphere to emit from
  16408. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16409. * @returns the emitter
  16410. */
  16411. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16412. /**
  16413. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16414. * @param radius The radius of the sphere to emit from
  16415. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16416. * @returns the emitter
  16417. */
  16418. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16419. /**
  16420. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16421. * @param radius The radius of the sphere to emit from
  16422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16424. * @returns the emitter
  16425. */
  16426. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16427. /**
  16428. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16429. * @param radius The radius of the emission cylinder
  16430. * @param height The height of the emission cylinder
  16431. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16432. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16433. * @returns the emitter
  16434. */
  16435. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16436. /**
  16437. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16438. * @param radius The radius of the cylinder to emit from
  16439. * @param height The height of the emission cylinder
  16440. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16443. * @returns the emitter
  16444. */
  16445. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16446. /**
  16447. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16448. * @param radius The radius of the cone to emit from
  16449. * @param angle The base angle of the cone
  16450. * @returns the emitter
  16451. */
  16452. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16453. /**
  16454. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16455. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16456. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16457. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16458. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16459. * @returns the emitter
  16460. */
  16461. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16462. /**
  16463. * Get hosting scene
  16464. * @returns the scene
  16465. */
  16466. getScene(): Scene;
  16467. }
  16468. }
  16469. declare module BABYLON {
  16470. /**
  16471. * Creates an instance based on a source mesh.
  16472. */
  16473. export class InstancedMesh extends AbstractMesh {
  16474. private _sourceMesh;
  16475. private _currentLOD;
  16476. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16477. constructor(name: string, source: Mesh);
  16478. /**
  16479. * Returns the string "InstancedMesh".
  16480. */
  16481. getClassName(): string;
  16482. /** Gets the list of lights affecting that mesh */
  16483. readonly lightSources: Light[]; resyncLightSources(): void; resyncLighSource(light: Light): void; removeLightSource(light: Light): void;
  16484. /**
  16485. * If the source mesh receives shadows
  16486. */
  16487. readonly receiveShadows: boolean;
  16488. /**
  16489. * The material of the source mesh
  16490. */
  16491. readonly material: Nullable<Material>;
  16492. /**
  16493. * Visibility of the source mesh
  16494. */
  16495. readonly visibility: number;
  16496. /**
  16497. * Skeleton of the source mesh
  16498. */
  16499. readonly skeleton: Nullable<Skeleton>;
  16500. /**
  16501. * Rendering ground id of the source mesh
  16502. */
  16503. renderingGroupId: number;
  16504. /**
  16505. * Returns the total number of vertices (integer).
  16506. */
  16507. getTotalVertices(): number;
  16508. /**
  16509. * Returns a positive integer : the total number of indices in this mesh geometry.
  16510. * @returns the numner of indices or zero if the mesh has no geometry.
  16511. */
  16512. getTotalIndices(): number;
  16513. /**
  16514. * The source mesh of the instance
  16515. */
  16516. readonly sourceMesh: Mesh;
  16517. /**
  16518. * Is this node ready to be used/rendered
  16519. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16520. * @return {boolean} is it ready
  16521. */
  16522. isReady(completeCheck?: boolean): boolean;
  16523. /**
  16524. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16525. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16526. * @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.
  16527. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16528. */
  16529. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16530. /**
  16531. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16532. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16533. * The `data` are either a numeric array either a Float32Array.
  16534. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16535. * 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).
  16536. * Note that a new underlying VertexBuffer object is created each call.
  16537. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16538. *
  16539. * Possible `kind` values :
  16540. * - VertexBuffer.PositionKind
  16541. * - VertexBuffer.UVKind
  16542. * - VertexBuffer.UV2Kind
  16543. * - VertexBuffer.UV3Kind
  16544. * - VertexBuffer.UV4Kind
  16545. * - VertexBuffer.UV5Kind
  16546. * - VertexBuffer.UV6Kind
  16547. * - VertexBuffer.ColorKind
  16548. * - VertexBuffer.MatricesIndicesKind
  16549. * - VertexBuffer.MatricesIndicesExtraKind
  16550. * - VertexBuffer.MatricesWeightsKind
  16551. * - VertexBuffer.MatricesWeightsExtraKind
  16552. *
  16553. * Returns the Mesh.
  16554. */
  16555. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16556. /**
  16557. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16558. * If the mesh has no geometry, it is simply returned as it is.
  16559. * The `data` are either a numeric array either a Float32Array.
  16560. * No new underlying VertexBuffer object is created.
  16561. * 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.
  16562. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16563. *
  16564. * Possible `kind` values :
  16565. * - VertexBuffer.PositionKind
  16566. * - VertexBuffer.UVKind
  16567. * - VertexBuffer.UV2Kind
  16568. * - VertexBuffer.UV3Kind
  16569. * - VertexBuffer.UV4Kind
  16570. * - VertexBuffer.UV5Kind
  16571. * - VertexBuffer.UV6Kind
  16572. * - VertexBuffer.ColorKind
  16573. * - VertexBuffer.MatricesIndicesKind
  16574. * - VertexBuffer.MatricesIndicesExtraKind
  16575. * - VertexBuffer.MatricesWeightsKind
  16576. * - VertexBuffer.MatricesWeightsExtraKind
  16577. *
  16578. * Returns the Mesh.
  16579. */
  16580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16581. /**
  16582. * Sets the mesh indices.
  16583. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16584. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16585. * This method creates a new index buffer each call.
  16586. * Returns the Mesh.
  16587. */
  16588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16589. /**
  16590. * Boolean : True if the mesh owns the requested kind of data.
  16591. */
  16592. isVerticesDataPresent(kind: string): boolean;
  16593. /**
  16594. * Returns an array of indices (IndicesArray).
  16595. */
  16596. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16597. /**
  16598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16599. * This means the mesh underlying bounding box and sphere are recomputed.
  16600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16601. * @returns the current mesh
  16602. */
  16603. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16604. /** @hidden */ preActivate(): InstancedMesh;
  16605. /** @hidden */ activate(renderId: number): boolean;
  16606. /** @hidden */ postActivate(): void;
  16607. getWorldMatrix(): Matrix;
  16608. readonly isAnInstance: boolean;
  16609. /**
  16610. * Returns the current associated LOD AbstractMesh.
  16611. */
  16612. getLOD(camera: Camera): AbstractMesh;
  16613. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16614. /** @hidden */ generatePointsArray(): boolean;
  16615. /**
  16616. * Creates a new InstancedMesh from the current mesh.
  16617. * - name (string) : the cloned mesh name
  16618. * - newParent (optional Node) : the optional Node to parent the clone to.
  16619. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16620. *
  16621. * Returns the clone.
  16622. */
  16623. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16624. /**
  16625. * Disposes the InstancedMesh.
  16626. * Returns nothing.
  16627. */
  16628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16629. }
  16630. }
  16631. declare module BABYLON {
  16632. /**
  16633. * Defines the options associated with the creation of a shader material.
  16634. */
  16635. export interface IShaderMaterialOptions {
  16636. /**
  16637. * Does the material work in alpha blend mode
  16638. */
  16639. needAlphaBlending: boolean;
  16640. /**
  16641. * Does the material work in alpha test mode
  16642. */
  16643. needAlphaTesting: boolean;
  16644. /**
  16645. * The list of attribute names used in the shader
  16646. */
  16647. attributes: string[];
  16648. /**
  16649. * The list of unifrom names used in the shader
  16650. */
  16651. uniforms: string[];
  16652. /**
  16653. * The list of UBO names used in the shader
  16654. */
  16655. uniformBuffers: string[];
  16656. /**
  16657. * The list of sampler names used in the shader
  16658. */
  16659. samplers: string[];
  16660. /**
  16661. * The list of defines used in the shader
  16662. */
  16663. defines: string[];
  16664. }
  16665. /**
  16666. * 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.
  16667. *
  16668. * This returned material effects how the mesh will look based on the code in the shaders.
  16669. *
  16670. * @see http://doc.babylonjs.com/how_to/shader_material
  16671. */
  16672. export class ShaderMaterial extends Material {
  16673. private _shaderPath;
  16674. private _options;
  16675. private _textures;
  16676. private _textureArrays;
  16677. private _floats;
  16678. private _ints;
  16679. private _floatsArrays;
  16680. private _colors3;
  16681. private _colors3Arrays;
  16682. private _colors4;
  16683. private _vectors2;
  16684. private _vectors3;
  16685. private _vectors4;
  16686. private _matrices;
  16687. private _matrices3x3;
  16688. private _matrices2x2;
  16689. private _vectors2Arrays;
  16690. private _vectors3Arrays;
  16691. private _cachedWorldViewMatrix;
  16692. private _renderId;
  16693. /**
  16694. * Instantiate a new shader material.
  16695. * 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.
  16696. * This returned material effects how the mesh will look based on the code in the shaders.
  16697. * @see http://doc.babylonjs.com/how_to/shader_material
  16698. * @param name Define the name of the material in the scene
  16699. * @param scene Define the scene the material belongs to
  16700. * @param shaderPath Defines the route to the shader code in one of three ways:
  16701. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16702. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16703. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16704. * @param options Define the options used to create the shader
  16705. */
  16706. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16707. /**
  16708. * Gets the options used to compile the shader.
  16709. * They can be modified to trigger a new compilation
  16710. */
  16711. readonly options: IShaderMaterialOptions;
  16712. /**
  16713. * Gets the current class name of the material e.g. "ShaderMaterial"
  16714. * Mainly use in serialization.
  16715. * @returns the class name
  16716. */
  16717. getClassName(): string;
  16718. /**
  16719. * Specifies if the material will require alpha blending
  16720. * @returns a boolean specifying if alpha blending is needed
  16721. */
  16722. needAlphaBlending(): boolean;
  16723. /**
  16724. * Specifies if this material should be rendered in alpha test mode
  16725. * @returns a boolean specifying if an alpha test is needed.
  16726. */
  16727. needAlphaTesting(): boolean;
  16728. private _checkUniform;
  16729. /**
  16730. * Set a texture in the shader.
  16731. * @param name Define the name of the uniform samplers as defined in the shader
  16732. * @param texture Define the texture to bind to this sampler
  16733. * @return the material itself allowing "fluent" like uniform updates
  16734. */
  16735. setTexture(name: string, texture: Texture): ShaderMaterial;
  16736. /**
  16737. * Set a texture array in the shader.
  16738. * @param name Define the name of the uniform sampler array as defined in the shader
  16739. * @param textures Define the list of textures to bind to this sampler
  16740. * @return the material itself allowing "fluent" like uniform updates
  16741. */
  16742. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16743. /**
  16744. * Set a float in the shader.
  16745. * @param name Define the name of the uniform as defined in the shader
  16746. * @param value Define the value to give to the uniform
  16747. * @return the material itself allowing "fluent" like uniform updates
  16748. */
  16749. setFloat(name: string, value: number): ShaderMaterial;
  16750. /**
  16751. * Set a int in the shader.
  16752. * @param name Define the name of the uniform as defined in the shader
  16753. * @param value Define the value to give to the uniform
  16754. * @return the material itself allowing "fluent" like uniform updates
  16755. */
  16756. setInt(name: string, value: number): ShaderMaterial;
  16757. /**
  16758. * Set an array of floats in the shader.
  16759. * @param name Define the name of the uniform as defined in the shader
  16760. * @param value Define the value to give to the uniform
  16761. * @return the material itself allowing "fluent" like uniform updates
  16762. */
  16763. setFloats(name: string, value: number[]): ShaderMaterial;
  16764. /**
  16765. * Set a vec3 in the shader from a Color3.
  16766. * @param name Define the name of the uniform as defined in the shader
  16767. * @param value Define the value to give to the uniform
  16768. * @return the material itself allowing "fluent" like uniform updates
  16769. */
  16770. setColor3(name: string, value: Color3): ShaderMaterial;
  16771. /**
  16772. * Set a vec3 array in the shader from a Color3 array.
  16773. * @param name Define the name of the uniform as defined in the shader
  16774. * @param value Define the value to give to the uniform
  16775. * @return the material itself allowing "fluent" like uniform updates
  16776. */
  16777. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16778. /**
  16779. * Set a vec4 in the shader from a Color4.
  16780. * @param name Define the name of the uniform as defined in the shader
  16781. * @param value Define the value to give to the uniform
  16782. * @return the material itself allowing "fluent" like uniform updates
  16783. */
  16784. setColor4(name: string, value: Color4): ShaderMaterial;
  16785. /**
  16786. * Set a vec2 in the shader from a Vector2.
  16787. * @param name Define the name of the uniform as defined in the shader
  16788. * @param value Define the value to give to the uniform
  16789. * @return the material itself allowing "fluent" like uniform updates
  16790. */
  16791. setVector2(name: string, value: Vector2): ShaderMaterial;
  16792. /**
  16793. * Set a vec3 in the shader from a Vector3.
  16794. * @param name Define the name of the uniform as defined in the shader
  16795. * @param value Define the value to give to the uniform
  16796. * @return the material itself allowing "fluent" like uniform updates
  16797. */
  16798. setVector3(name: string, value: Vector3): ShaderMaterial;
  16799. /**
  16800. * Set a vec4 in the shader from a Vector4.
  16801. * @param name Define the name of the uniform as defined in the shader
  16802. * @param value Define the value to give to the uniform
  16803. * @return the material itself allowing "fluent" like uniform updates
  16804. */
  16805. setVector4(name: string, value: Vector4): ShaderMaterial;
  16806. /**
  16807. * Set a mat4 in the shader from a Matrix.
  16808. * @param name Define the name of the uniform as defined in the shader
  16809. * @param value Define the value to give to the uniform
  16810. * @return the material itself allowing "fluent" like uniform updates
  16811. */
  16812. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16813. /**
  16814. * Set a mat3 in the shader from a Float32Array.
  16815. * @param name Define the name of the uniform as defined in the shader
  16816. * @param value Define the value to give to the uniform
  16817. * @return the material itself allowing "fluent" like uniform updates
  16818. */
  16819. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16820. /**
  16821. * Set a mat2 in the shader from a Float32Array.
  16822. * @param name Define the name of the uniform as defined in the shader
  16823. * @param value Define the value to give to the uniform
  16824. * @return the material itself allowing "fluent" like uniform updates
  16825. */
  16826. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16827. /**
  16828. * Set a vec2 array in the shader from a number array.
  16829. * @param name Define the name of the uniform as defined in the shader
  16830. * @param value Define the value to give to the uniform
  16831. * @return the material itself allowing "fluent" like uniform updates
  16832. */
  16833. setArray2(name: string, value: number[]): ShaderMaterial;
  16834. /**
  16835. * Set a vec3 array in the shader from a number array.
  16836. * @param name Define the name of the uniform as defined in the shader
  16837. * @param value Define the value to give to the uniform
  16838. * @return the material itself allowing "fluent" like uniform updates
  16839. */
  16840. setArray3(name: string, value: number[]): ShaderMaterial;
  16841. private _checkCache;
  16842. /**
  16843. * Specifies that the submesh is ready to be used
  16844. * @param mesh defines the mesh to check
  16845. * @param subMesh defines which submesh to check
  16846. * @param useInstances specifies that instances should be used
  16847. * @returns a boolean indicating that the submesh is ready or not
  16848. */
  16849. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16850. /**
  16851. * Checks if the material is ready to render the requested mesh
  16852. * @param mesh Define the mesh to render
  16853. * @param useInstances Define whether or not the material is used with instances
  16854. * @returns true if ready, otherwise false
  16855. */
  16856. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16857. /**
  16858. * Binds the world matrix to the material
  16859. * @param world defines the world transformation matrix
  16860. */
  16861. bindOnlyWorldMatrix(world: Matrix): void;
  16862. /**
  16863. * Binds the material to the mesh
  16864. * @param world defines the world transformation matrix
  16865. * @param mesh defines the mesh to bind the material to
  16866. */
  16867. bind(world: Matrix, mesh?: Mesh): void;
  16868. /**
  16869. * Gets the active textures from the material
  16870. * @returns an array of textures
  16871. */
  16872. getActiveTextures(): BaseTexture[];
  16873. /**
  16874. * Specifies if the material uses a texture
  16875. * @param texture defines the texture to check against the material
  16876. * @returns a boolean specifying if the material uses the texture
  16877. */
  16878. hasTexture(texture: BaseTexture): boolean;
  16879. /**
  16880. * Makes a duplicate of the material, and gives it a new name
  16881. * @param name defines the new name for the duplicated material
  16882. * @returns the cloned material
  16883. */
  16884. clone(name: string): ShaderMaterial;
  16885. /**
  16886. * Disposes the material
  16887. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16888. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16889. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16890. */
  16891. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16892. /**
  16893. * Serializes this material in a JSON representation
  16894. * @returns the serialized material object
  16895. */
  16896. serialize(): any;
  16897. /**
  16898. * Creates a shader material from parsed shader material data
  16899. * @param source defines the JSON represnetation of the material
  16900. * @param scene defines the hosting scene
  16901. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16902. * @returns a new material
  16903. */
  16904. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16905. }
  16906. }
  16907. declare module BABYLON {
  16908. /** @hidden */
  16909. export var colorPixelShader: {
  16910. name: string;
  16911. shader: string;
  16912. };
  16913. }
  16914. declare module BABYLON {
  16915. /** @hidden */
  16916. export var colorVertexShader: {
  16917. name: string;
  16918. shader: string;
  16919. };
  16920. }
  16921. declare module BABYLON {
  16922. /**
  16923. * Line mesh
  16924. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16925. */
  16926. export class LinesMesh extends Mesh {
  16927. /**
  16928. * If vertex color should be applied to the mesh
  16929. */
  16930. useVertexColor?: boolean | undefined;
  16931. /**
  16932. * If vertex alpha should be applied to the mesh
  16933. */
  16934. useVertexAlpha?: boolean | undefined;
  16935. /**
  16936. * Color of the line (Default: White)
  16937. */
  16938. color: Color3;
  16939. /**
  16940. * Alpha of the line (Default: 1)
  16941. */
  16942. alpha: number;
  16943. /**
  16944. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16945. * This margin is expressed in world space coordinates, so its value may vary.
  16946. * Default value is 0.1
  16947. */
  16948. intersectionThreshold: number;
  16949. private _colorShader;
  16950. /**
  16951. * Creates a new LinesMesh
  16952. * @param name defines the name
  16953. * @param scene defines the hosting scene
  16954. * @param parent defines the parent mesh if any
  16955. * @param source defines the optional source LinesMesh used to clone data from
  16956. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16957. * When false, achieved by calling a clone(), also passing False.
  16958. * This will make creation of children, recursive.
  16959. * @param useVertexColor defines if this LinesMesh supports vertex color
  16960. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16961. */
  16962. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16963. /**
  16964. * If vertex color should be applied to the mesh
  16965. */
  16966. useVertexColor?: boolean | undefined,
  16967. /**
  16968. * If vertex alpha should be applied to the mesh
  16969. */
  16970. useVertexAlpha?: boolean | undefined);
  16971. private _addClipPlaneDefine;
  16972. private _removeClipPlaneDefine;
  16973. isReady(): boolean;
  16974. /**
  16975. * Returns the string "LineMesh"
  16976. */
  16977. getClassName(): string;
  16978. /**
  16979. * @hidden
  16980. */
  16981. /**
  16982. * @hidden
  16983. */
  16984. material: Material;
  16985. /**
  16986. * @hidden
  16987. */
  16988. readonly checkCollisions: boolean;
  16989. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16990. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16991. /**
  16992. * Disposes of the line mesh
  16993. * @param doNotRecurse If children should be disposed
  16994. */
  16995. dispose(doNotRecurse?: boolean): void;
  16996. /**
  16997. * Returns a new LineMesh object cloned from the current one.
  16998. */
  16999. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17000. /**
  17001. * Creates a new InstancedLinesMesh object from the mesh model.
  17002. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17003. * @param name defines the name of the new instance
  17004. * @returns a new InstancedLinesMesh
  17005. */
  17006. createInstance(name: string): InstancedLinesMesh;
  17007. }
  17008. /**
  17009. * Creates an instance based on a source LinesMesh
  17010. */
  17011. export class InstancedLinesMesh extends InstancedMesh {
  17012. /**
  17013. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17014. * This margin is expressed in world space coordinates, so its value may vary.
  17015. * Initilized with the intersectionThreshold value of the source LinesMesh
  17016. */
  17017. intersectionThreshold: number;
  17018. constructor(name: string, source: LinesMesh);
  17019. /**
  17020. * Returns the string "InstancedLinesMesh".
  17021. */
  17022. getClassName(): string;
  17023. }
  17024. }
  17025. declare module BABYLON {
  17026. /** @hidden */
  17027. export var linePixelShader: {
  17028. name: string;
  17029. shader: string;
  17030. };
  17031. }
  17032. declare module BABYLON {
  17033. /** @hidden */
  17034. export var lineVertexShader: {
  17035. name: string;
  17036. shader: string;
  17037. };
  17038. }
  17039. declare module BABYLON {
  17040. interface AbstractMesh {
  17041. /**
  17042. * Disables the mesh edge rendering mode
  17043. * @returns the currentAbstractMesh
  17044. */
  17045. disableEdgesRendering(): AbstractMesh;
  17046. /**
  17047. * Enables the edge rendering mode on the mesh.
  17048. * This mode makes the mesh edges visible
  17049. * @param epsilon defines the maximal distance between two angles to detect a face
  17050. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17051. * @returns the currentAbstractMesh
  17052. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17053. */
  17054. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17055. /**
  17056. * Gets the edgesRenderer associated with the mesh
  17057. */
  17058. edgesRenderer: Nullable<EdgesRenderer>;
  17059. }
  17060. interface LinesMesh {
  17061. /**
  17062. * Enables the edge rendering mode on the mesh.
  17063. * This mode makes the mesh edges visible
  17064. * @param epsilon defines the maximal distance between two angles to detect a face
  17065. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17066. * @returns the currentAbstractMesh
  17067. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17068. */
  17069. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17070. }
  17071. interface InstancedLinesMesh {
  17072. /**
  17073. * Enables the edge rendering mode on the mesh.
  17074. * This mode makes the mesh edges visible
  17075. * @param epsilon defines the maximal distance between two angles to detect a face
  17076. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17077. * @returns the current InstancedLinesMesh
  17078. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17079. */
  17080. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17081. }
  17082. /**
  17083. * Defines the minimum contract an Edges renderer should follow.
  17084. */
  17085. export interface IEdgesRenderer extends IDisposable {
  17086. /**
  17087. * Gets or sets a boolean indicating if the edgesRenderer is active
  17088. */
  17089. isEnabled: boolean;
  17090. /**
  17091. * Renders the edges of the attached mesh,
  17092. */
  17093. render(): void;
  17094. /**
  17095. * Checks wether or not the edges renderer is ready to render.
  17096. * @return true if ready, otherwise false.
  17097. */
  17098. isReady(): boolean;
  17099. }
  17100. /**
  17101. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17102. */
  17103. export class EdgesRenderer implements IEdgesRenderer {
  17104. /**
  17105. * Define the size of the edges with an orthographic camera
  17106. */
  17107. edgesWidthScalerForOrthographic: number;
  17108. /**
  17109. * Define the size of the edges with a perspective camera
  17110. */
  17111. edgesWidthScalerForPerspective: number;
  17112. protected _source: AbstractMesh;
  17113. protected _linesPositions: number[];
  17114. protected _linesNormals: number[];
  17115. protected _linesIndices: number[];
  17116. protected _epsilon: number;
  17117. protected _indicesCount: number;
  17118. protected _lineShader: ShaderMaterial;
  17119. protected _ib: DataBuffer;
  17120. protected _buffers: {
  17121. [key: string]: Nullable<VertexBuffer>;
  17122. };
  17123. protected _checkVerticesInsteadOfIndices: boolean;
  17124. private _meshRebuildObserver;
  17125. private _meshDisposeObserver;
  17126. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17127. isEnabled: boolean;
  17128. /**
  17129. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17130. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17131. * @param source Mesh used to create edges
  17132. * @param epsilon sum of angles in adjacency to check for edge
  17133. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17134. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17135. */
  17136. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17137. protected _prepareRessources(): void;
  17138. /** @hidden */ rebuild(): void;
  17139. /**
  17140. * Releases the required resources for the edges renderer
  17141. */
  17142. dispose(): void;
  17143. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17144. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17145. /**
  17146. * Checks if the pair of p0 and p1 is en edge
  17147. * @param faceIndex
  17148. * @param edge
  17149. * @param faceNormals
  17150. * @param p0
  17151. * @param p1
  17152. * @private
  17153. */
  17154. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17155. /**
  17156. * push line into the position, normal and index buffer
  17157. * @protected
  17158. */
  17159. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17160. /**
  17161. * Generates lines edges from adjacencjes
  17162. * @private
  17163. */ generateEdgesLines(): void;
  17164. /**
  17165. * Checks wether or not the edges renderer is ready to render.
  17166. * @return true if ready, otherwise false.
  17167. */
  17168. isReady(): boolean;
  17169. /**
  17170. * Renders the edges of the attached mesh,
  17171. */
  17172. render(): void;
  17173. }
  17174. /**
  17175. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17176. */
  17177. export class LineEdgesRenderer extends EdgesRenderer {
  17178. /**
  17179. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17180. * @param source LineMesh used to generate edges
  17181. * @param epsilon not important (specified angle for edge detection)
  17182. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17183. */
  17184. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17185. /**
  17186. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17187. */ generateEdgesLines(): void;
  17188. }
  17189. }
  17190. declare module BABYLON {
  17191. /**
  17192. * This represents the object necessary to create a rendering group.
  17193. * This is exclusively used and created by the rendering manager.
  17194. * To modify the behavior, you use the available helpers in your scene or meshes.
  17195. * @hidden
  17196. */
  17197. export class RenderingGroup {
  17198. index: number;
  17199. private _scene;
  17200. private _opaqueSubMeshes;
  17201. private _transparentSubMeshes;
  17202. private _alphaTestSubMeshes;
  17203. private _depthOnlySubMeshes;
  17204. private _particleSystems;
  17205. private _spriteManagers;
  17206. private _opaqueSortCompareFn;
  17207. private _alphaTestSortCompareFn;
  17208. private _transparentSortCompareFn;
  17209. private _renderOpaque;
  17210. private _renderAlphaTest;
  17211. private _renderTransparent;
  17212. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  17213. onBeforeTransparentRendering: () => void;
  17214. /**
  17215. * Set the opaque sort comparison function.
  17216. * If null the sub meshes will be render in the order they were created
  17217. */
  17218. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17219. /**
  17220. * Set the alpha test sort comparison function.
  17221. * If null the sub meshes will be render in the order they were created
  17222. */
  17223. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17224. /**
  17225. * Set the transparent sort comparison function.
  17226. * If null the sub meshes will be render in the order they were created
  17227. */
  17228. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17229. /**
  17230. * Creates a new rendering group.
  17231. * @param index The rendering group index
  17232. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17233. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17234. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17235. */
  17236. 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>);
  17237. /**
  17238. * Render all the sub meshes contained in the group.
  17239. * @param customRenderFunction Used to override the default render behaviour of the group.
  17240. * @returns true if rendered some submeshes.
  17241. */
  17242. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17243. /**
  17244. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17245. * @param subMeshes The submeshes to render
  17246. */
  17247. private renderOpaqueSorted;
  17248. /**
  17249. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17250. * @param subMeshes The submeshes to render
  17251. */
  17252. private renderAlphaTestSorted;
  17253. /**
  17254. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17255. * @param subMeshes The submeshes to render
  17256. */
  17257. private renderTransparentSorted;
  17258. /**
  17259. * Renders the submeshes in a specified order.
  17260. * @param subMeshes The submeshes to sort before render
  17261. * @param sortCompareFn The comparison function use to sort
  17262. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17263. * @param transparent Specifies to activate blending if true
  17264. */
  17265. private static renderSorted;
  17266. /**
  17267. * Renders the submeshes in the order they were dispatched (no sort applied).
  17268. * @param subMeshes The submeshes to render
  17269. */
  17270. private static renderUnsorted;
  17271. /**
  17272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17273. * are rendered back to front if in the same alpha index.
  17274. *
  17275. * @param a The first submesh
  17276. * @param b The second submesh
  17277. * @returns The result of the comparison
  17278. */
  17279. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17280. /**
  17281. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17282. * are rendered back to front.
  17283. *
  17284. * @param a The first submesh
  17285. * @param b The second submesh
  17286. * @returns The result of the comparison
  17287. */
  17288. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17289. /**
  17290. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17291. * are rendered front to back (prevent overdraw).
  17292. *
  17293. * @param a The first submesh
  17294. * @param b The second submesh
  17295. * @returns The result of the comparison
  17296. */
  17297. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17298. /**
  17299. * Resets the different lists of submeshes to prepare a new frame.
  17300. */
  17301. prepare(): void;
  17302. dispose(): void;
  17303. /**
  17304. * Inserts the submesh in its correct queue depending on its material.
  17305. * @param subMesh The submesh to dispatch
  17306. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17307. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17308. */
  17309. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17310. dispatchSprites(spriteManager: ISpriteManager): void;
  17311. dispatchParticles(particleSystem: IParticleSystem): void;
  17312. private _renderParticles;
  17313. private _renderSprites;
  17314. }
  17315. }
  17316. declare module BABYLON {
  17317. /**
  17318. * Interface describing the different options available in the rendering manager
  17319. * regarding Auto Clear between groups.
  17320. */
  17321. export interface IRenderingManagerAutoClearSetup {
  17322. /**
  17323. * Defines whether or not autoclear is enable.
  17324. */
  17325. autoClear: boolean;
  17326. /**
  17327. * Defines whether or not to autoclear the depth buffer.
  17328. */
  17329. depth: boolean;
  17330. /**
  17331. * Defines whether or not to autoclear the stencil buffer.
  17332. */
  17333. stencil: boolean;
  17334. }
  17335. /**
  17336. * This class is used by the onRenderingGroupObservable
  17337. */
  17338. export class RenderingGroupInfo {
  17339. /**
  17340. * The Scene that being rendered
  17341. */
  17342. scene: Scene;
  17343. /**
  17344. * The camera currently used for the rendering pass
  17345. */
  17346. camera: Nullable<Camera>;
  17347. /**
  17348. * The ID of the renderingGroup being processed
  17349. */
  17350. renderingGroupId: number;
  17351. }
  17352. /**
  17353. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17354. * It is enable to manage the different groups as well as the different necessary sort functions.
  17355. * This should not be used directly aside of the few static configurations
  17356. */
  17357. export class RenderingManager {
  17358. /**
  17359. * The max id used for rendering groups (not included)
  17360. */
  17361. static MAX_RENDERINGGROUPS: number;
  17362. /**
  17363. * The min id used for rendering groups (included)
  17364. */
  17365. static MIN_RENDERINGGROUPS: number;
  17366. /**
  17367. * Used to globally prevent autoclearing scenes.
  17368. */
  17369. static AUTOCLEAR: boolean;
  17370. /**
  17371. * @hidden
  17372. */ useSceneAutoClearSetup: boolean;
  17373. private _scene;
  17374. private _renderingGroups;
  17375. private _depthStencilBufferAlreadyCleaned;
  17376. private _autoClearDepthStencil;
  17377. private _customOpaqueSortCompareFn;
  17378. private _customAlphaTestSortCompareFn;
  17379. private _customTransparentSortCompareFn;
  17380. private _renderingGroupInfo;
  17381. /**
  17382. * Instantiates a new rendering group for a particular scene
  17383. * @param scene Defines the scene the groups belongs to
  17384. */
  17385. constructor(scene: Scene);
  17386. private _clearDepthStencilBuffer;
  17387. /**
  17388. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17389. * @hidden
  17390. */
  17391. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17392. /**
  17393. * Resets the different information of the group to prepare a new frame
  17394. * @hidden
  17395. */
  17396. reset(): void;
  17397. /**
  17398. * Dispose and release the group and its associated resources.
  17399. * @hidden
  17400. */
  17401. dispose(): void;
  17402. /**
  17403. * Clear the info related to rendering groups preventing retention points during dispose.
  17404. */
  17405. freeRenderingGroups(): void;
  17406. private _prepareRenderingGroup;
  17407. /**
  17408. * Add a sprite manager to the rendering manager in order to render it this frame.
  17409. * @param spriteManager Define the sprite manager to render
  17410. */
  17411. dispatchSprites(spriteManager: ISpriteManager): void;
  17412. /**
  17413. * Add a particle system to the rendering manager in order to render it this frame.
  17414. * @param particleSystem Define the particle system to render
  17415. */
  17416. dispatchParticles(particleSystem: IParticleSystem): void;
  17417. /**
  17418. * Add a submesh to the manager in order to render it this frame
  17419. * @param subMesh The submesh to dispatch
  17420. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17421. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17422. */
  17423. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17424. /**
  17425. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17426. * This allowed control for front to back rendering or reversly depending of the special needs.
  17427. *
  17428. * @param renderingGroupId The rendering group id corresponding to its index
  17429. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17430. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17431. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17432. */
  17433. 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;
  17434. /**
  17435. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17436. *
  17437. * @param renderingGroupId The rendering group id corresponding to its index
  17438. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17439. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17440. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17441. */
  17442. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17443. /**
  17444. * Gets the current auto clear configuration for one rendering group of the rendering
  17445. * manager.
  17446. * @param index the rendering group index to get the information for
  17447. * @returns The auto clear setup for the requested rendering group
  17448. */
  17449. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17450. }
  17451. }
  17452. declare module BABYLON {
  17453. /**
  17454. * This Helps creating a texture that will be created from a camera in your scene.
  17455. * It is basically a dynamic texture that could be used to create special effects for instance.
  17456. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17457. */
  17458. export class RenderTargetTexture extends Texture {
  17459. isCube: boolean;
  17460. /**
  17461. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17462. */
  17463. static readonly REFRESHRATE_RENDER_ONCE: number;
  17464. /**
  17465. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17466. */
  17467. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17468. /**
  17469. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17470. * the central point of your effect and can save a lot of performances.
  17471. */
  17472. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17473. /**
  17474. * Use this predicate to dynamically define the list of mesh you want to render.
  17475. * If set, the renderList property will be overwritten.
  17476. */
  17477. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17478. private _renderList;
  17479. /**
  17480. * Use this list to define the list of mesh you want to render.
  17481. */
  17482. renderList: Nullable<Array<AbstractMesh>>;
  17483. private _hookArray;
  17484. /**
  17485. * Define if particles should be rendered in your texture.
  17486. */
  17487. renderParticles: boolean;
  17488. /**
  17489. * Define if sprites should be rendered in your texture.
  17490. */
  17491. renderSprites: boolean;
  17492. /**
  17493. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17494. */
  17495. coordinatesMode: number;
  17496. /**
  17497. * Define the camera used to render the texture.
  17498. */
  17499. activeCamera: Nullable<Camera>;
  17500. /**
  17501. * Override the render function of the texture with your own one.
  17502. */
  17503. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17504. /**
  17505. * Define if camera post processes should be use while rendering the texture.
  17506. */
  17507. useCameraPostProcesses: boolean;
  17508. /**
  17509. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17510. */
  17511. ignoreCameraViewport: boolean;
  17512. private _postProcessManager;
  17513. private _postProcesses;
  17514. private _resizeObserver;
  17515. /**
  17516. * An event triggered when the texture is unbind.
  17517. */
  17518. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17519. /**
  17520. * An event triggered when the texture is unbind.
  17521. */
  17522. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17523. private _onAfterUnbindObserver;
  17524. /**
  17525. * Set a after unbind callback in the texture.
  17526. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17527. */
  17528. onAfterUnbind: () => void;
  17529. /**
  17530. * An event triggered before rendering the texture
  17531. */
  17532. onBeforeRenderObservable: Observable<number>;
  17533. private _onBeforeRenderObserver;
  17534. /**
  17535. * Set a before render callback in the texture.
  17536. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17537. */
  17538. onBeforeRender: (faceIndex: number) => void;
  17539. /**
  17540. * An event triggered after rendering the texture
  17541. */
  17542. onAfterRenderObservable: Observable<number>;
  17543. private _onAfterRenderObserver;
  17544. /**
  17545. * Set a after render callback in the texture.
  17546. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17547. */
  17548. onAfterRender: (faceIndex: number) => void;
  17549. /**
  17550. * An event triggered after the texture clear
  17551. */
  17552. onClearObservable: Observable<Engine>;
  17553. private _onClearObserver;
  17554. /**
  17555. * Set a clear callback in the texture.
  17556. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17557. */
  17558. onClear: (Engine: Engine) => void;
  17559. /**
  17560. * Define the clear color of the Render Target if it should be different from the scene.
  17561. */
  17562. clearColor: Color4;
  17563. protected _size: number | {
  17564. width: number;
  17565. height: number;
  17566. };
  17567. protected _initialSizeParameter: number | {
  17568. width: number;
  17569. height: number;
  17570. } | {
  17571. ratio: number;
  17572. };
  17573. protected _sizeRatio: Nullable<number>;
  17574. /** @hidden */ generateMipMaps: boolean;
  17575. protected _renderingManager: RenderingManager;
  17576. /** @hidden */ waitingRenderList: string[];
  17577. protected _doNotChangeAspectRatio: boolean;
  17578. protected _currentRefreshId: number;
  17579. protected _refreshRate: number;
  17580. protected _textureMatrix: Matrix;
  17581. protected _samples: number;
  17582. protected _renderTargetOptions: RenderTargetCreationOptions;
  17583. /**
  17584. * Gets render target creation options that were used.
  17585. */
  17586. readonly renderTargetOptions: RenderTargetCreationOptions;
  17587. protected _engine: Engine;
  17588. protected _onRatioRescale(): void;
  17589. /**
  17590. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17591. * It must define where the camera used to render the texture is set
  17592. */
  17593. boundingBoxPosition: Vector3;
  17594. private _boundingBoxSize;
  17595. /**
  17596. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17597. * When defined, the cubemap will switch to local mode
  17598. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17599. * @example https://www.babylonjs-playground.com/#RNASML
  17600. */
  17601. boundingBoxSize: Vector3;
  17602. /**
  17603. * In case the RTT has been created with a depth texture, get the associated
  17604. * depth texture.
  17605. * Otherwise, return null.
  17606. */
  17607. depthStencilTexture: Nullable<InternalTexture>;
  17608. /**
  17609. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17610. * or used a shadow, depth texture...
  17611. * @param name The friendly name of the texture
  17612. * @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)
  17613. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17614. * @param generateMipMaps True if mip maps need to be generated after render.
  17615. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17616. * @param type The type of the buffer in the RTT (int, half float, float...)
  17617. * @param isCube True if a cube texture needs to be created
  17618. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17619. * @param generateDepthBuffer True to generate a depth buffer
  17620. * @param generateStencilBuffer True to generate a stencil buffer
  17621. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17622. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17623. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17624. */
  17625. constructor(name: string, size: number | {
  17626. width: number;
  17627. height: number;
  17628. } | {
  17629. ratio: number;
  17630. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17631. /**
  17632. * Creates a depth stencil texture.
  17633. * This is only available in WebGL 2 or with the depth texture extension available.
  17634. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17635. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17636. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17637. */
  17638. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17639. private _processSizeParameter;
  17640. /**
  17641. * Define the number of samples to use in case of MSAA.
  17642. * It defaults to one meaning no MSAA has been enabled.
  17643. */
  17644. samples: number;
  17645. /**
  17646. * Resets the refresh counter of the texture and start bak from scratch.
  17647. * Could be useful to regenerate the texture if it is setup to render only once.
  17648. */
  17649. resetRefreshCounter(): void;
  17650. /**
  17651. * Define the refresh rate of the texture or the rendering frequency.
  17652. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17653. */
  17654. refreshRate: number;
  17655. /**
  17656. * Adds a post process to the render target rendering passes.
  17657. * @param postProcess define the post process to add
  17658. */
  17659. addPostProcess(postProcess: PostProcess): void;
  17660. /**
  17661. * Clear all the post processes attached to the render target
  17662. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17663. */
  17664. clearPostProcesses(dispose?: boolean): void;
  17665. /**
  17666. * Remove one of the post process from the list of attached post processes to the texture
  17667. * @param postProcess define the post process to remove from the list
  17668. */
  17669. removePostProcess(postProcess: PostProcess): void;
  17670. /** @hidden */ shouldRender(): boolean;
  17671. /**
  17672. * Gets the actual render size of the texture.
  17673. * @returns the width of the render size
  17674. */
  17675. getRenderSize(): number;
  17676. /**
  17677. * Gets the actual render width of the texture.
  17678. * @returns the width of the render size
  17679. */
  17680. getRenderWidth(): number;
  17681. /**
  17682. * Gets the actual render height of the texture.
  17683. * @returns the height of the render size
  17684. */
  17685. getRenderHeight(): number;
  17686. /**
  17687. * Get if the texture can be rescaled or not.
  17688. */
  17689. readonly canRescale: boolean;
  17690. /**
  17691. * Resize the texture using a ratio.
  17692. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17693. */
  17694. scale(ratio: number): void;
  17695. /**
  17696. * Get the texture reflection matrix used to rotate/transform the reflection.
  17697. * @returns the reflection matrix
  17698. */
  17699. getReflectionTextureMatrix(): Matrix;
  17700. /**
  17701. * Resize the texture to a new desired size.
  17702. * Be carrefull as it will recreate all the data in the new texture.
  17703. * @param size Define the new size. It can be:
  17704. * - a number for squared texture,
  17705. * - an object containing { width: number, height: number }
  17706. * - or an object containing a ratio { ratio: number }
  17707. */
  17708. resize(size: number | {
  17709. width: number;
  17710. height: number;
  17711. } | {
  17712. ratio: number;
  17713. }): void;
  17714. /**
  17715. * Renders all the objects from the render list into the texture.
  17716. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17717. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17718. */
  17719. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17720. private _bestReflectionRenderTargetDimension;
  17721. /**
  17722. * @hidden
  17723. * @param faceIndex face index to bind to if this is a cubetexture
  17724. */ bindFrameBuffer(faceIndex?: number): void;
  17725. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17726. private renderToTarget;
  17727. /**
  17728. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17729. * This allowed control for front to back rendering or reversly depending of the special needs.
  17730. *
  17731. * @param renderingGroupId The rendering group id corresponding to its index
  17732. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17733. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17734. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17735. */
  17736. 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;
  17737. /**
  17738. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17739. *
  17740. * @param renderingGroupId The rendering group id corresponding to its index
  17741. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17742. */
  17743. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17744. /**
  17745. * Clones the texture.
  17746. * @returns the cloned texture
  17747. */
  17748. clone(): RenderTargetTexture;
  17749. /**
  17750. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17751. * @returns The JSON representation of the texture
  17752. */
  17753. serialize(): any;
  17754. /**
  17755. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17756. */
  17757. disposeFramebufferObjects(): void;
  17758. /**
  17759. * Dispose the texture and release its associated resources.
  17760. */
  17761. dispose(): void;
  17762. /** @hidden */ rebuild(): void;
  17763. /**
  17764. * Clear the info related to rendering groups preventing retention point in material dispose.
  17765. */
  17766. freeRenderingGroups(): void;
  17767. /**
  17768. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17769. * @returns the view count
  17770. */
  17771. getViewCount(): number;
  17772. }
  17773. }
  17774. declare module BABYLON {
  17775. /**
  17776. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17777. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17778. * You can then easily use it as a reflectionTexture on a flat surface.
  17779. * In case the surface is not a plane, please consider relying on reflection probes.
  17780. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17781. */
  17782. export class MirrorTexture extends RenderTargetTexture {
  17783. private scene;
  17784. /**
  17785. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17786. * 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.
  17787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17788. */
  17789. mirrorPlane: Plane;
  17790. /**
  17791. * Define the blur ratio used to blur the reflection if needed.
  17792. */
  17793. blurRatio: number;
  17794. /**
  17795. * Define the adaptive blur kernel used to blur the reflection if needed.
  17796. * This will autocompute the closest best match for the `blurKernel`
  17797. */
  17798. adaptiveBlurKernel: number;
  17799. /**
  17800. * Define the blur kernel used to blur the reflection if needed.
  17801. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17802. */
  17803. blurKernel: number;
  17804. /**
  17805. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17806. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17807. */
  17808. blurKernelX: number;
  17809. /**
  17810. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17811. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17812. */
  17813. blurKernelY: number;
  17814. private _autoComputeBlurKernel;
  17815. protected _onRatioRescale(): void;
  17816. private _updateGammaSpace;
  17817. private _imageProcessingConfigChangeObserver;
  17818. private _transformMatrix;
  17819. private _mirrorMatrix;
  17820. private _savedViewMatrix;
  17821. private _blurX;
  17822. private _blurY;
  17823. private _adaptiveBlurKernel;
  17824. private _blurKernelX;
  17825. private _blurKernelY;
  17826. private _blurRatio;
  17827. /**
  17828. * Instantiates a Mirror Texture.
  17829. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17830. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17831. * You can then easily use it as a reflectionTexture on a flat surface.
  17832. * In case the surface is not a plane, please consider relying on reflection probes.
  17833. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17834. * @param name
  17835. * @param size
  17836. * @param scene
  17837. * @param generateMipMaps
  17838. * @param type
  17839. * @param samplingMode
  17840. * @param generateDepthBuffer
  17841. */
  17842. constructor(name: string, size: number | {
  17843. width: number;
  17844. height: number;
  17845. } | {
  17846. ratio: number;
  17847. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17848. private _preparePostProcesses;
  17849. /**
  17850. * Clone the mirror texture.
  17851. * @returns the cloned texture
  17852. */
  17853. clone(): MirrorTexture;
  17854. /**
  17855. * Serialize the texture to a JSON representation you could use in Parse later on
  17856. * @returns the serialized JSON representation
  17857. */
  17858. serialize(): any;
  17859. /**
  17860. * Dispose the texture and release its associated resources.
  17861. */
  17862. dispose(): void;
  17863. }
  17864. }
  17865. declare module BABYLON {
  17866. /**
  17867. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17868. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17869. */
  17870. export class Texture extends BaseTexture {
  17871. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17872. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17873. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17874. /** nearest is mag = nearest and min = nearest and mip = linear */
  17875. static readonly NEAREST_SAMPLINGMODE: number;
  17876. /** nearest is mag = nearest and min = nearest and mip = linear */
  17877. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17879. static readonly BILINEAR_SAMPLINGMODE: number;
  17880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17881. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17882. /** Trilinear is mag = linear and min = linear and mip = linear */
  17883. static readonly TRILINEAR_SAMPLINGMODE: number;
  17884. /** Trilinear is mag = linear and min = linear and mip = linear */
  17885. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17886. /** mag = nearest and min = nearest and mip = nearest */
  17887. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17888. /** mag = nearest and min = linear and mip = nearest */
  17889. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17890. /** mag = nearest and min = linear and mip = linear */
  17891. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17892. /** mag = nearest and min = linear and mip = none */
  17893. static readonly NEAREST_LINEAR: number;
  17894. /** mag = nearest and min = nearest and mip = none */
  17895. static readonly NEAREST_NEAREST: number;
  17896. /** mag = linear and min = nearest and mip = nearest */
  17897. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17898. /** mag = linear and min = nearest and mip = linear */
  17899. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17900. /** mag = linear and min = linear and mip = none */
  17901. static readonly LINEAR_LINEAR: number;
  17902. /** mag = linear and min = nearest and mip = none */
  17903. static readonly LINEAR_NEAREST: number;
  17904. /** Explicit coordinates mode */
  17905. static readonly EXPLICIT_MODE: number;
  17906. /** Spherical coordinates mode */
  17907. static readonly SPHERICAL_MODE: number;
  17908. /** Planar coordinates mode */
  17909. static readonly PLANAR_MODE: number;
  17910. /** Cubic coordinates mode */
  17911. static readonly CUBIC_MODE: number;
  17912. /** Projection coordinates mode */
  17913. static readonly PROJECTION_MODE: number;
  17914. /** Inverse Cubic coordinates mode */
  17915. static readonly SKYBOX_MODE: number;
  17916. /** Inverse Cubic coordinates mode */
  17917. static readonly INVCUBIC_MODE: number;
  17918. /** Equirectangular coordinates mode */
  17919. static readonly EQUIRECTANGULAR_MODE: number;
  17920. /** Equirectangular Fixed coordinates mode */
  17921. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17922. /** Equirectangular Fixed Mirrored coordinates mode */
  17923. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17924. /** Texture is not repeating outside of 0..1 UVs */
  17925. static readonly CLAMP_ADDRESSMODE: number;
  17926. /** Texture is repeating outside of 0..1 UVs */
  17927. static readonly WRAP_ADDRESSMODE: number;
  17928. /** Texture is repeating and mirrored */
  17929. static readonly MIRROR_ADDRESSMODE: number;
  17930. /**
  17931. * 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
  17932. */
  17933. static UseSerializedUrlIfAny: boolean;
  17934. /**
  17935. * Define the url of the texture.
  17936. */
  17937. url: Nullable<string>;
  17938. /**
  17939. * Define an offset on the texture to offset the u coordinates of the UVs
  17940. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17941. */
  17942. uOffset: number;
  17943. /**
  17944. * Define an offset on the texture to offset the v coordinates of the UVs
  17945. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17946. */
  17947. vOffset: number;
  17948. /**
  17949. * Define an offset on the texture to scale the u coordinates of the UVs
  17950. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17951. */
  17952. uScale: number;
  17953. /**
  17954. * Define an offset on the texture to scale the v coordinates of the UVs
  17955. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17956. */
  17957. vScale: number;
  17958. /**
  17959. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17960. * @see http://doc.babylonjs.com/how_to/more_materials
  17961. */
  17962. uAng: number;
  17963. /**
  17964. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17965. * @see http://doc.babylonjs.com/how_to/more_materials
  17966. */
  17967. vAng: number;
  17968. /**
  17969. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17970. * @see http://doc.babylonjs.com/how_to/more_materials
  17971. */
  17972. wAng: number;
  17973. /**
  17974. * Defines the center of rotation (U)
  17975. */
  17976. uRotationCenter: number;
  17977. /**
  17978. * Defines the center of rotation (V)
  17979. */
  17980. vRotationCenter: number;
  17981. /**
  17982. * Defines the center of rotation (W)
  17983. */
  17984. wRotationCenter: number;
  17985. /**
  17986. * Are mip maps generated for this texture or not.
  17987. */
  17988. readonly noMipmap: boolean;
  17989. /**
  17990. * List of inspectable custom properties (used by the Inspector)
  17991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17992. */
  17993. inspectableCustomProperties: Nullable<IInspectable[]>;
  17994. private _noMipmap;
  17995. /** @hidden */ invertY: boolean;
  17996. private _rowGenerationMatrix;
  17997. private _cachedTextureMatrix;
  17998. private _projectionModeMatrix;
  17999. private _t0;
  18000. private _t1;
  18001. private _t2;
  18002. private _cachedUOffset;
  18003. private _cachedVOffset;
  18004. private _cachedUScale;
  18005. private _cachedVScale;
  18006. private _cachedUAng;
  18007. private _cachedVAng;
  18008. private _cachedWAng;
  18009. private _cachedProjectionMatrixId;
  18010. private _cachedCoordinatesMode;
  18011. /** @hidden */
  18012. protected _initialSamplingMode: number;
  18013. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18014. private _deleteBuffer;
  18015. protected _format: Nullable<number>;
  18016. private _delayedOnLoad;
  18017. private _delayedOnError;
  18018. /**
  18019. * Observable triggered once the texture has been loaded.
  18020. */
  18021. onLoadObservable: Observable<Texture>;
  18022. protected _isBlocking: boolean;
  18023. /**
  18024. * Is the texture preventing material to render while loading.
  18025. * If false, a default texture will be used instead of the loading one during the preparation step.
  18026. */
  18027. isBlocking: boolean;
  18028. /**
  18029. * Get the current sampling mode associated with the texture.
  18030. */
  18031. readonly samplingMode: number;
  18032. /**
  18033. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18034. */
  18035. readonly invertY: boolean;
  18036. /**
  18037. * Instantiates a new texture.
  18038. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18039. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18040. * @param url define the url of the picture to load as a texture
  18041. * @param scene define the scene the texture will belong to
  18042. * @param noMipmap define if the texture will require mip maps or not
  18043. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18044. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18045. * @param onLoad define a callback triggered when the texture has been loaded
  18046. * @param onError define a callback triggered when an error occurred during the loading session
  18047. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18048. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18049. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18050. */
  18051. 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);
  18052. /**
  18053. * Update the url (and optional buffer) of this texture if url was null during construction.
  18054. * @param url the url of the texture
  18055. * @param buffer the buffer of the texture (defaults to null)
  18056. * @param onLoad callback called when the texture is loaded (defaults to null)
  18057. */
  18058. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18059. /**
  18060. * Finish the loading sequence of a texture flagged as delayed load.
  18061. * @hidden
  18062. */
  18063. delayLoad(): void;
  18064. private _prepareRowForTextureGeneration;
  18065. /**
  18066. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18067. * @returns the transform matrix of the texture.
  18068. */
  18069. getTextureMatrix(): Matrix;
  18070. /**
  18071. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18072. * @returns The reflection texture transform
  18073. */
  18074. getReflectionTextureMatrix(): Matrix;
  18075. /**
  18076. * Clones the texture.
  18077. * @returns the cloned texture
  18078. */
  18079. clone(): Texture;
  18080. /**
  18081. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18082. * @returns The JSON representation of the texture
  18083. */
  18084. serialize(): any;
  18085. /**
  18086. * Get the current class name of the texture useful for serialization or dynamic coding.
  18087. * @returns "Texture"
  18088. */
  18089. getClassName(): string;
  18090. /**
  18091. * Dispose the texture and release its associated resources.
  18092. */
  18093. dispose(): void;
  18094. /**
  18095. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18096. * @param parsedTexture Define the JSON representation of the texture
  18097. * @param scene Define the scene the parsed texture should be instantiated in
  18098. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18099. * @returns The parsed texture if successful
  18100. */
  18101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18102. /**
  18103. * Creates a texture from its base 64 representation.
  18104. * @param data Define the base64 payload without the data: prefix
  18105. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18106. * @param scene Define the scene the texture should belong to
  18107. * @param noMipmap Forces the texture to not create mip map information if true
  18108. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18109. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18110. * @param onLoad define a callback triggered when the texture has been loaded
  18111. * @param onError define a callback triggered when an error occurred during the loading session
  18112. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18113. * @returns the created texture
  18114. */
  18115. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18116. /**
  18117. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18118. * @param data Define the base64 payload without the data: prefix
  18119. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18120. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18121. * @param scene Define the scene the texture should belong to
  18122. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18123. * @param noMipmap Forces the texture to not create mip map information if true
  18124. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18125. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18126. * @param onLoad define a callback triggered when the texture has been loaded
  18127. * @param onError define a callback triggered when an error occurred during the loading session
  18128. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18129. * @returns the created texture
  18130. */
  18131. 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;
  18132. }
  18133. }
  18134. declare module BABYLON {
  18135. interface Engine {
  18136. /**
  18137. * Creates a raw texture
  18138. * @param data defines the data to store in the texture
  18139. * @param width defines the width of the texture
  18140. * @param height defines the height of the texture
  18141. * @param format defines the format of the data
  18142. * @param generateMipMaps defines if the engine should generate the mip levels
  18143. * @param invertY defines if data must be stored with Y axis inverted
  18144. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18145. * @param compression defines the compression used (null by default)
  18146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18147. * @returns the raw texture inside an InternalTexture
  18148. */
  18149. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18150. /**
  18151. * Update a raw texture
  18152. * @param texture defines the texture to update
  18153. * @param data defines the data to store in the texture
  18154. * @param format defines the format of the data
  18155. * @param invertY defines if data must be stored with Y axis inverted
  18156. */
  18157. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18158. /**
  18159. * Update a raw texture
  18160. * @param texture defines the texture to update
  18161. * @param data defines the data to store in the texture
  18162. * @param format defines the format of the data
  18163. * @param invertY defines if data must be stored with Y axis inverted
  18164. * @param compression defines the compression used (null by default)
  18165. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18166. */
  18167. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18168. /**
  18169. * Creates a new raw cube texture
  18170. * @param data defines the array of data to use to create each face
  18171. * @param size defines the size of the textures
  18172. * @param format defines the format of the data
  18173. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18174. * @param generateMipMaps defines if the engine should generate the mip levels
  18175. * @param invertY defines if data must be stored with Y axis inverted
  18176. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18177. * @param compression defines the compression used (null by default)
  18178. * @returns the cube texture as an InternalTexture
  18179. */
  18180. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18181. /**
  18182. * Update a raw cube texture
  18183. * @param texture defines the texture to udpdate
  18184. * @param data defines the data to store
  18185. * @param format defines the data format
  18186. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18187. * @param invertY defines if data must be stored with Y axis inverted
  18188. */
  18189. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18190. /**
  18191. * Update a raw cube texture
  18192. * @param texture defines the texture to udpdate
  18193. * @param data defines the data to store
  18194. * @param format defines the data format
  18195. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18196. * @param invertY defines if data must be stored with Y axis inverted
  18197. * @param compression defines the compression used (null by default)
  18198. */
  18199. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18200. /**
  18201. * Update a raw cube texture
  18202. * @param texture defines the texture to udpdate
  18203. * @param data defines the data to store
  18204. * @param format defines the data format
  18205. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18206. * @param invertY defines if data must be stored with Y axis inverted
  18207. * @param compression defines the compression used (null by default)
  18208. * @param level defines which level of the texture to update
  18209. */
  18210. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18211. /**
  18212. * Creates a new raw cube texture from a specified url
  18213. * @param url defines the url where the data is located
  18214. * @param scene defines the current scene
  18215. * @param size defines the size of the textures
  18216. * @param format defines the format of the data
  18217. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18218. * @param noMipmap defines if the engine should avoid generating the mip levels
  18219. * @param callback defines a callback used to extract texture data from loaded data
  18220. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18221. * @param onLoad defines a callback called when texture is loaded
  18222. * @param onError defines a callback called if there is an error
  18223. * @returns the cube texture as an InternalTexture
  18224. */
  18225. 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;
  18226. /**
  18227. * Creates a new raw cube texture from a specified url
  18228. * @param url defines the url where the data is located
  18229. * @param scene defines the current scene
  18230. * @param size defines the size of the textures
  18231. * @param format defines the format of the data
  18232. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18233. * @param noMipmap defines if the engine should avoid generating the mip levels
  18234. * @param callback defines a callback used to extract texture data from loaded data
  18235. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18236. * @param onLoad defines a callback called when texture is loaded
  18237. * @param onError defines a callback called if there is an error
  18238. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18239. * @param invertY defines if data must be stored with Y axis inverted
  18240. * @returns the cube texture as an InternalTexture
  18241. */
  18242. 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;
  18243. /**
  18244. * Creates a new raw 3D texture
  18245. * @param data defines the data used to create the texture
  18246. * @param width defines the width of the texture
  18247. * @param height defines the height of the texture
  18248. * @param depth defines the depth of the texture
  18249. * @param format defines the format of the texture
  18250. * @param generateMipMaps defines if the engine must generate mip levels
  18251. * @param invertY defines if data must be stored with Y axis inverted
  18252. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18253. * @param compression defines the compressed used (can be null)
  18254. * @param textureType defines the compressed used (can be null)
  18255. * @returns a new raw 3D texture (stored in an InternalTexture)
  18256. */
  18257. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18258. /**
  18259. * Update a raw 3D texture
  18260. * @param texture defines the texture to update
  18261. * @param data defines the data to store
  18262. * @param format defines the data format
  18263. * @param invertY defines if data must be stored with Y axis inverted
  18264. */
  18265. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18266. /**
  18267. * Update a raw 3D texture
  18268. * @param texture defines the texture to update
  18269. * @param data defines the data to store
  18270. * @param format defines the data format
  18271. * @param invertY defines if data must be stored with Y axis inverted
  18272. * @param compression defines the used compression (can be null)
  18273. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18274. */
  18275. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18276. }
  18277. }
  18278. declare module BABYLON {
  18279. /**
  18280. * Raw texture can help creating a texture directly from an array of data.
  18281. * This can be super useful if you either get the data from an uncompressed source or
  18282. * if you wish to create your texture pixel by pixel.
  18283. */
  18284. export class RawTexture extends Texture {
  18285. /**
  18286. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18287. */
  18288. format: number;
  18289. private _engine;
  18290. /**
  18291. * Instantiates a new RawTexture.
  18292. * Raw texture can help creating a texture directly from an array of data.
  18293. * This can be super useful if you either get the data from an uncompressed source or
  18294. * if you wish to create your texture pixel by pixel.
  18295. * @param data define the array of data to use to create the texture
  18296. * @param width define the width of the texture
  18297. * @param height define the height of the texture
  18298. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18299. * @param scene define the scene the texture belongs to
  18300. * @param generateMipMaps define whether mip maps should be generated or not
  18301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18303. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18304. */
  18305. constructor(data: ArrayBufferView, width: number, height: number,
  18306. /**
  18307. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18308. */
  18309. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18310. /**
  18311. * Updates the texture underlying data.
  18312. * @param data Define the new data of the texture
  18313. */
  18314. update(data: ArrayBufferView): void;
  18315. /**
  18316. * Creates a luminance texture from some data.
  18317. * @param data Define the texture data
  18318. * @param width Define the width of the texture
  18319. * @param height Define the height of the texture
  18320. * @param scene Define the scene the texture belongs to
  18321. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18322. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18323. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18324. * @returns the luminance texture
  18325. */
  18326. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18327. /**
  18328. * Creates a luminance alpha texture from some data.
  18329. * @param data Define the texture data
  18330. * @param width Define the width of the texture
  18331. * @param height Define the height of the texture
  18332. * @param scene Define the scene the texture belongs to
  18333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18336. * @returns the luminance alpha texture
  18337. */
  18338. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18339. /**
  18340. * Creates an alpha texture from some data.
  18341. * @param data Define the texture data
  18342. * @param width Define the width of the texture
  18343. * @param height Define the height of the texture
  18344. * @param scene Define the scene the texture belongs to
  18345. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18348. * @returns the alpha texture
  18349. */
  18350. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18351. /**
  18352. * Creates a RGB texture from some data.
  18353. * @param data Define the texture data
  18354. * @param width Define the width of the texture
  18355. * @param height Define the height of the texture
  18356. * @param scene Define the scene the texture belongs to
  18357. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18360. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18361. * @returns the RGB alpha texture
  18362. */
  18363. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18364. /**
  18365. * Creates a RGBA texture from some data.
  18366. * @param data Define the texture data
  18367. * @param width Define the width of the texture
  18368. * @param height Define the height of the texture
  18369. * @param scene Define the scene the texture belongs to
  18370. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18371. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18372. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18373. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18374. * @returns the RGBA texture
  18375. */
  18376. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18377. /**
  18378. * Creates a R texture from some data.
  18379. * @param data Define the texture data
  18380. * @param width Define the width of the texture
  18381. * @param height Define the height of the texture
  18382. * @param scene Define the scene the texture belongs to
  18383. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18384. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18385. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18386. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18387. * @returns the R texture
  18388. */
  18389. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18390. }
  18391. }
  18392. declare module BABYLON {
  18393. /**
  18394. * Defines a runtime animation
  18395. */
  18396. export class RuntimeAnimation {
  18397. private _events;
  18398. /**
  18399. * The current frame of the runtime animation
  18400. */
  18401. private _currentFrame;
  18402. /**
  18403. * The animation used by the runtime animation
  18404. */
  18405. private _animation;
  18406. /**
  18407. * The target of the runtime animation
  18408. */
  18409. private _target;
  18410. /**
  18411. * The initiating animatable
  18412. */
  18413. private _host;
  18414. /**
  18415. * The original value of the runtime animation
  18416. */
  18417. private _originalValue;
  18418. /**
  18419. * The original blend value of the runtime animation
  18420. */
  18421. private _originalBlendValue;
  18422. /**
  18423. * The offsets cache of the runtime animation
  18424. */
  18425. private _offsetsCache;
  18426. /**
  18427. * The high limits cache of the runtime animation
  18428. */
  18429. private _highLimitsCache;
  18430. /**
  18431. * Specifies if the runtime animation has been stopped
  18432. */
  18433. private _stopped;
  18434. /**
  18435. * The blending factor of the runtime animation
  18436. */
  18437. private _blendingFactor;
  18438. /**
  18439. * The BabylonJS scene
  18440. */
  18441. private _scene;
  18442. /**
  18443. * The current value of the runtime animation
  18444. */
  18445. private _currentValue;
  18446. /** @hidden */ animationState: _IAnimationState;
  18447. /**
  18448. * The active target of the runtime animation
  18449. */
  18450. private _activeTargets;
  18451. private _currentActiveTarget;
  18452. private _directTarget;
  18453. /**
  18454. * The target path of the runtime animation
  18455. */
  18456. private _targetPath;
  18457. /**
  18458. * The weight of the runtime animation
  18459. */
  18460. private _weight;
  18461. /**
  18462. * The ratio offset of the runtime animation
  18463. */
  18464. private _ratioOffset;
  18465. /**
  18466. * The previous delay of the runtime animation
  18467. */
  18468. private _previousDelay;
  18469. /**
  18470. * The previous ratio of the runtime animation
  18471. */
  18472. private _previousRatio;
  18473. private _enableBlending;
  18474. private _keys;
  18475. private _minFrame;
  18476. private _maxFrame;
  18477. private _minValue;
  18478. private _maxValue;
  18479. private _targetIsArray;
  18480. /**
  18481. * Gets the current frame of the runtime animation
  18482. */
  18483. readonly currentFrame: number;
  18484. /**
  18485. * Gets the weight of the runtime animation
  18486. */
  18487. readonly weight: number;
  18488. /**
  18489. * Gets the current value of the runtime animation
  18490. */
  18491. readonly currentValue: any;
  18492. /**
  18493. * Gets the target path of the runtime animation
  18494. */
  18495. readonly targetPath: string;
  18496. /**
  18497. * Gets the actual target of the runtime animation
  18498. */
  18499. readonly target: any;
  18500. /** @hidden */ onLoop: () => void;
  18501. /**
  18502. * Create a new RuntimeAnimation object
  18503. * @param target defines the target of the animation
  18504. * @param animation defines the source animation object
  18505. * @param scene defines the hosting scene
  18506. * @param host defines the initiating Animatable
  18507. */
  18508. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18509. private _preparePath;
  18510. /**
  18511. * Gets the animation from the runtime animation
  18512. */
  18513. readonly animation: Animation;
  18514. /**
  18515. * Resets the runtime animation to the beginning
  18516. * @param restoreOriginal defines whether to restore the target property to the original value
  18517. */
  18518. reset(restoreOriginal?: boolean): void;
  18519. /**
  18520. * Specifies if the runtime animation is stopped
  18521. * @returns Boolean specifying if the runtime animation is stopped
  18522. */
  18523. isStopped(): boolean;
  18524. /**
  18525. * Disposes of the runtime animation
  18526. */
  18527. dispose(): void;
  18528. /**
  18529. * Apply the interpolated value to the target
  18530. * @param currentValue defines the value computed by the animation
  18531. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18532. */
  18533. setValue(currentValue: any, weight: number): void;
  18534. private _getOriginalValues;
  18535. private _setValue;
  18536. /**
  18537. * Gets the loop pmode of the runtime animation
  18538. * @returns Loop Mode
  18539. */
  18540. private _getCorrectLoopMode;
  18541. /**
  18542. * Move the current animation to a given frame
  18543. * @param frame defines the frame to move to
  18544. */
  18545. goToFrame(frame: number): void;
  18546. /**
  18547. * @hidden Internal use only
  18548. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18549. /**
  18550. * Execute the current animation
  18551. * @param delay defines the delay to add to the current frame
  18552. * @param from defines the lower bound of the animation range
  18553. * @param to defines the upper bound of the animation range
  18554. * @param loop defines if the current animation must loop
  18555. * @param speedRatio defines the current speed ratio
  18556. * @param weight defines the weight of the animation (default is -1 so no weight)
  18557. * @param onLoop optional callback called when animation loops
  18558. * @returns a boolean indicating if the animation is running
  18559. */
  18560. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18561. }
  18562. }
  18563. declare module BABYLON {
  18564. /**
  18565. * Class used to store an actual running animation
  18566. */
  18567. export class Animatable {
  18568. /** defines the target object */
  18569. target: any;
  18570. /** defines the starting frame number (default is 0) */
  18571. fromFrame: number;
  18572. /** defines the ending frame number (default is 100) */
  18573. toFrame: number;
  18574. /** defines if the animation must loop (default is false) */
  18575. loopAnimation: boolean;
  18576. /** defines a callback to call when animation ends if it is not looping */
  18577. onAnimationEnd?: (() => void) | null | undefined;
  18578. /** defines a callback to call when animation loops */
  18579. onAnimationLoop?: (() => void) | null | undefined;
  18580. private _localDelayOffset;
  18581. private _pausedDelay;
  18582. private _runtimeAnimations;
  18583. private _paused;
  18584. private _scene;
  18585. private _speedRatio;
  18586. private _weight;
  18587. private _syncRoot;
  18588. /**
  18589. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18590. * This will only apply for non looping animation (default is true)
  18591. */
  18592. disposeOnEnd: boolean;
  18593. /**
  18594. * Gets a boolean indicating if the animation has started
  18595. */
  18596. animationStarted: boolean;
  18597. /**
  18598. * Observer raised when the animation ends
  18599. */
  18600. onAnimationEndObservable: Observable<Animatable>;
  18601. /**
  18602. * Observer raised when the animation loops
  18603. */
  18604. onAnimationLoopObservable: Observable<Animatable>;
  18605. /**
  18606. * Gets the root Animatable used to synchronize and normalize animations
  18607. */
  18608. readonly syncRoot: Nullable<Animatable>;
  18609. /**
  18610. * Gets the current frame of the first RuntimeAnimation
  18611. * Used to synchronize Animatables
  18612. */
  18613. readonly masterFrame: number;
  18614. /**
  18615. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18616. */
  18617. weight: number;
  18618. /**
  18619. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18620. */
  18621. speedRatio: number;
  18622. /**
  18623. * Creates a new Animatable
  18624. * @param scene defines the hosting scene
  18625. * @param target defines the target object
  18626. * @param fromFrame defines the starting frame number (default is 0)
  18627. * @param toFrame defines the ending frame number (default is 100)
  18628. * @param loopAnimation defines if the animation must loop (default is false)
  18629. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18630. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18631. * @param animations defines a group of animation to add to the new Animatable
  18632. * @param onAnimationLoop defines a callback to call when animation loops
  18633. */
  18634. constructor(scene: Scene,
  18635. /** defines the target object */
  18636. target: any,
  18637. /** defines the starting frame number (default is 0) */
  18638. fromFrame?: number,
  18639. /** defines the ending frame number (default is 100) */
  18640. toFrame?: number,
  18641. /** defines if the animation must loop (default is false) */
  18642. loopAnimation?: boolean, speedRatio?: number,
  18643. /** defines a callback to call when animation ends if it is not looping */
  18644. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18645. /** defines a callback to call when animation loops */
  18646. onAnimationLoop?: (() => void) | null | undefined);
  18647. /**
  18648. * Synchronize and normalize current Animatable with a source Animatable
  18649. * This is useful when using animation weights and when animations are not of the same length
  18650. * @param root defines the root Animatable to synchronize with
  18651. * @returns the current Animatable
  18652. */
  18653. syncWith(root: Animatable): Animatable;
  18654. /**
  18655. * Gets the list of runtime animations
  18656. * @returns an array of RuntimeAnimation
  18657. */
  18658. getAnimations(): RuntimeAnimation[];
  18659. /**
  18660. * Adds more animations to the current animatable
  18661. * @param target defines the target of the animations
  18662. * @param animations defines the new animations to add
  18663. */
  18664. appendAnimations(target: any, animations: Animation[]): void;
  18665. /**
  18666. * Gets the source animation for a specific property
  18667. * @param property defines the propertyu to look for
  18668. * @returns null or the source animation for the given property
  18669. */
  18670. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18671. /**
  18672. * Gets the runtime animation for a specific property
  18673. * @param property defines the propertyu to look for
  18674. * @returns null or the runtime animation for the given property
  18675. */
  18676. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18677. /**
  18678. * Resets the animatable to its original state
  18679. */
  18680. reset(): void;
  18681. /**
  18682. * Allows the animatable to blend with current running animations
  18683. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18684. * @param blendingSpeed defines the blending speed to use
  18685. */
  18686. enableBlending(blendingSpeed: number): void;
  18687. /**
  18688. * Disable animation blending
  18689. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18690. */
  18691. disableBlending(): void;
  18692. /**
  18693. * Jump directly to a given frame
  18694. * @param frame defines the frame to jump to
  18695. */
  18696. goToFrame(frame: number): void;
  18697. /**
  18698. * Pause the animation
  18699. */
  18700. pause(): void;
  18701. /**
  18702. * Restart the animation
  18703. */
  18704. restart(): void;
  18705. private _raiseOnAnimationEnd;
  18706. /**
  18707. * Stop and delete the current animation
  18708. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18709. * @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)
  18710. */
  18711. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18712. /**
  18713. * Wait asynchronously for the animation to end
  18714. * @returns a promise which will be fullfilled when the animation ends
  18715. */
  18716. waitAsync(): Promise<Animatable>;
  18717. /** @hidden */ animate(delay: number): boolean;
  18718. }
  18719. interface Scene {
  18720. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18721. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18722. totalWeight: number;
  18723. animations: RuntimeAnimation[];
  18724. originalValue: Matrix;
  18725. }): any;
  18726. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18727. totalWeight: number;
  18728. animations: RuntimeAnimation[];
  18729. originalValue: Quaternion;
  18730. }, refQuaternion: Quaternion): Quaternion;
  18731. /** @hidden */ processLateAnimationBindings(): void;
  18732. /**
  18733. * Will start the animation sequence of a given target
  18734. * @param target defines the target
  18735. * @param from defines from which frame should animation start
  18736. * @param to defines until which frame should animation run.
  18737. * @param weight defines the weight to apply to the animation (1.0 by default)
  18738. * @param loop defines if the animation loops
  18739. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18740. * @param onAnimationEnd defines the function to be executed when the animation ends
  18741. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18742. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18743. * @param onAnimationLoop defines the callback to call when an animation loops
  18744. * @returns the animatable object created for this animation
  18745. */
  18746. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18747. /**
  18748. * Will start the animation sequence of a given target
  18749. * @param target defines the target
  18750. * @param from defines from which frame should animation start
  18751. * @param to defines until which frame should animation run.
  18752. * @param loop defines if the animation loops
  18753. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18754. * @param onAnimationEnd defines the function to be executed when the animation ends
  18755. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18756. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18757. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18758. * @param onAnimationLoop defines the callback to call when an animation loops
  18759. * @returns the animatable object created for this animation
  18760. */
  18761. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18762. /**
  18763. * Will start the animation sequence of a given target and its hierarchy
  18764. * @param target defines the target
  18765. * @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.
  18766. * @param from defines from which frame should animation start
  18767. * @param to defines until which frame should animation run.
  18768. * @param loop defines if the animation loops
  18769. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18770. * @param onAnimationEnd defines the function to be executed when the animation ends
  18771. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18772. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18773. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18774. * @param onAnimationLoop defines the callback to call when an animation loops
  18775. * @returns the list of created animatables
  18776. */
  18777. 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[];
  18778. /**
  18779. * Begin a new animation on a given node
  18780. * @param target defines the target where the animation will take place
  18781. * @param animations defines the list of animations to start
  18782. * @param from defines the initial value
  18783. * @param to defines the final value
  18784. * @param loop defines if you want animation to loop (off by default)
  18785. * @param speedRatio defines the speed ratio to apply to all animations
  18786. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18787. * @param onAnimationLoop defines the callback to call when an animation loops
  18788. * @returns the list of created animatables
  18789. */
  18790. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18791. /**
  18792. * Begin a new animation on a given node and its hierarchy
  18793. * @param target defines the root node where the animation will take place
  18794. * @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.
  18795. * @param animations defines the list of animations to start
  18796. * @param from defines the initial value
  18797. * @param to defines the final value
  18798. * @param loop defines if you want animation to loop (off by default)
  18799. * @param speedRatio defines the speed ratio to apply to all animations
  18800. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18801. * @param onAnimationLoop defines the callback to call when an animation loops
  18802. * @returns the list of animatables created for all nodes
  18803. */
  18804. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18805. /**
  18806. * Gets the animatable associated with a specific target
  18807. * @param target defines the target of the animatable
  18808. * @returns the required animatable if found
  18809. */
  18810. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18811. /**
  18812. * Gets all animatables associated with a given target
  18813. * @param target defines the target to look animatables for
  18814. * @returns an array of Animatables
  18815. */
  18816. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18817. /**
  18818. * Stops and removes all animations that have been applied to the scene
  18819. */
  18820. stopAllAnimations(): void;
  18821. }
  18822. interface Bone {
  18823. /**
  18824. * Copy an animation range from another bone
  18825. * @param source defines the source bone
  18826. * @param rangeName defines the range name to copy
  18827. * @param frameOffset defines the frame offset
  18828. * @param rescaleAsRequired defines if rescaling must be applied if required
  18829. * @param skelDimensionsRatio defines the scaling ratio
  18830. * @returns true if operation was successful
  18831. */
  18832. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18833. }
  18834. }
  18835. declare module BABYLON {
  18836. /**
  18837. * Class used to handle skinning animations
  18838. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18839. */
  18840. export class Skeleton implements IAnimatable {
  18841. /** defines the skeleton name */
  18842. name: string;
  18843. /** defines the skeleton Id */
  18844. id: string;
  18845. /**
  18846. * Defines the list of child bones
  18847. */
  18848. bones: Bone[];
  18849. /**
  18850. * Defines an estimate of the dimension of the skeleton at rest
  18851. */
  18852. dimensionsAtRest: Vector3;
  18853. /**
  18854. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18855. */
  18856. needInitialSkinMatrix: boolean;
  18857. /**
  18858. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18859. */
  18860. overrideMesh: Nullable<AbstractMesh>;
  18861. /**
  18862. * Gets the list of animations attached to this skeleton
  18863. */
  18864. animations: Array<Animation>;
  18865. private _scene;
  18866. private _isDirty;
  18867. private _transformMatrices;
  18868. private _transformMatrixTexture;
  18869. private _meshesWithPoseMatrix;
  18870. private _animatables;
  18871. private _identity;
  18872. private _synchronizedWithMesh;
  18873. private _ranges;
  18874. private _lastAbsoluteTransformsUpdateId;
  18875. private _canUseTextureForBones;
  18876. private _uniqueId;
  18877. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18878. /** @hidden */ hasWaitingData: Nullable<boolean>;
  18879. /**
  18880. * Specifies if the skeleton should be serialized
  18881. */
  18882. doNotSerialize: boolean;
  18883. private _useTextureToStoreBoneMatrices;
  18884. /**
  18885. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18886. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18887. */
  18888. useTextureToStoreBoneMatrices: boolean;
  18889. private _animationPropertiesOverride;
  18890. /**
  18891. * Gets or sets the animation properties override
  18892. */
  18893. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18894. /**
  18895. * List of inspectable custom properties (used by the Inspector)
  18896. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18897. */
  18898. inspectableCustomProperties: IInspectable[];
  18899. /**
  18900. * An observable triggered before computing the skeleton's matrices
  18901. */
  18902. onBeforeComputeObservable: Observable<Skeleton>;
  18903. /**
  18904. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18905. */
  18906. readonly isUsingTextureForMatrices: boolean;
  18907. /**
  18908. * Gets the unique ID of this skeleton
  18909. */
  18910. readonly uniqueId: number;
  18911. /**
  18912. * Creates a new skeleton
  18913. * @param name defines the skeleton name
  18914. * @param id defines the skeleton Id
  18915. * @param scene defines the hosting scene
  18916. */
  18917. constructor(
  18918. /** defines the skeleton name */
  18919. name: string,
  18920. /** defines the skeleton Id */
  18921. id: string, scene: Scene);
  18922. /**
  18923. * Gets the current object class name.
  18924. * @return the class name
  18925. */
  18926. getClassName(): string;
  18927. /**
  18928. * Returns an array containing the root bones
  18929. * @returns an array containing the root bones
  18930. */
  18931. getChildren(): Array<Bone>;
  18932. /**
  18933. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18934. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18935. * @returns a Float32Array containing matrices data
  18936. */
  18937. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18938. /**
  18939. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18940. * @returns a raw texture containing the data
  18941. */
  18942. getTransformMatrixTexture(): Nullable<RawTexture>;
  18943. /**
  18944. * Gets the current hosting scene
  18945. * @returns a scene object
  18946. */
  18947. getScene(): Scene;
  18948. /**
  18949. * Gets a string representing the current skeleton data
  18950. * @param fullDetails defines a boolean indicating if we want a verbose version
  18951. * @returns a string representing the current skeleton data
  18952. */
  18953. toString(fullDetails?: boolean): string;
  18954. /**
  18955. * Get bone's index searching by name
  18956. * @param name defines bone's name to search for
  18957. * @return the indice of the bone. Returns -1 if not found
  18958. */
  18959. getBoneIndexByName(name: string): number;
  18960. /**
  18961. * Creater a new animation range
  18962. * @param name defines the name of the range
  18963. * @param from defines the start key
  18964. * @param to defines the end key
  18965. */
  18966. createAnimationRange(name: string, from: number, to: number): void;
  18967. /**
  18968. * Delete a specific animation range
  18969. * @param name defines the name of the range
  18970. * @param deleteFrames defines if frames must be removed as well
  18971. */
  18972. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18973. /**
  18974. * Gets a specific animation range
  18975. * @param name defines the name of the range to look for
  18976. * @returns the requested animation range or null if not found
  18977. */
  18978. getAnimationRange(name: string): Nullable<AnimationRange>;
  18979. /**
  18980. * Gets the list of all animation ranges defined on this skeleton
  18981. * @returns an array
  18982. */
  18983. getAnimationRanges(): Nullable<AnimationRange>[];
  18984. /**
  18985. * Copy animation range from a source skeleton.
  18986. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18987. * @param source defines the source skeleton
  18988. * @param name defines the name of the range to copy
  18989. * @param rescaleAsRequired defines if rescaling must be applied if required
  18990. * @returns true if operation was successful
  18991. */
  18992. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18993. /**
  18994. * Forces the skeleton to go to rest pose
  18995. */
  18996. returnToRest(): void;
  18997. private _getHighestAnimationFrame;
  18998. /**
  18999. * Begin a specific animation range
  19000. * @param name defines the name of the range to start
  19001. * @param loop defines if looping must be turned on (false by default)
  19002. * @param speedRatio defines the speed ratio to apply (1 by default)
  19003. * @param onAnimationEnd defines a callback which will be called when animation will end
  19004. * @returns a new animatable
  19005. */
  19006. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19007. /** @hidden */ markAsDirty(): void;
  19008. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19009. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19010. private _computeTransformMatrices;
  19011. /**
  19012. * Build all resources required to render a skeleton
  19013. */
  19014. prepare(): void;
  19015. /**
  19016. * Gets the list of animatables currently running for this skeleton
  19017. * @returns an array of animatables
  19018. */
  19019. getAnimatables(): IAnimatable[];
  19020. /**
  19021. * Clone the current skeleton
  19022. * @param name defines the name of the new skeleton
  19023. * @param id defines the id of the new skeleton
  19024. * @returns the new skeleton
  19025. */
  19026. clone(name: string, id: string): Skeleton;
  19027. /**
  19028. * Enable animation blending for this skeleton
  19029. * @param blendingSpeed defines the blending speed to apply
  19030. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19031. */
  19032. enableBlending(blendingSpeed?: number): void;
  19033. /**
  19034. * Releases all resources associated with the current skeleton
  19035. */
  19036. dispose(): void;
  19037. /**
  19038. * Serialize the skeleton in a JSON object
  19039. * @returns a JSON object
  19040. */
  19041. serialize(): any;
  19042. /**
  19043. * Creates a new skeleton from serialized data
  19044. * @param parsedSkeleton defines the serialized data
  19045. * @param scene defines the hosting scene
  19046. * @returns a new skeleton
  19047. */
  19048. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19049. /**
  19050. * Compute all node absolute transforms
  19051. * @param forceUpdate defines if computation must be done even if cache is up to date
  19052. */
  19053. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19054. /**
  19055. * Gets the root pose matrix
  19056. * @returns a matrix
  19057. */
  19058. getPoseMatrix(): Nullable<Matrix>;
  19059. /**
  19060. * Sorts bones per internal index
  19061. */
  19062. sortBones(): void;
  19063. private _sortBones;
  19064. }
  19065. }
  19066. declare module BABYLON {
  19067. /**
  19068. * Defines a target to use with MorphTargetManager
  19069. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19070. */
  19071. export class MorphTarget implements IAnimatable {
  19072. /** defines the name of the target */
  19073. name: string;
  19074. /**
  19075. * Gets or sets the list of animations
  19076. */
  19077. animations: Animation[];
  19078. private _scene;
  19079. private _positions;
  19080. private _normals;
  19081. private _tangents;
  19082. private _influence;
  19083. /**
  19084. * Observable raised when the influence changes
  19085. */
  19086. onInfluenceChanged: Observable<boolean>;
  19087. /** @hidden */ onDataLayoutChanged: Observable<void>;
  19088. /**
  19089. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19090. */
  19091. influence: number;
  19092. /**
  19093. * Gets or sets the id of the morph Target
  19094. */
  19095. id: string;
  19096. private _animationPropertiesOverride;
  19097. /**
  19098. * Gets or sets the animation properties override
  19099. */
  19100. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19101. /**
  19102. * Creates a new MorphTarget
  19103. * @param name defines the name of the target
  19104. * @param influence defines the influence to use
  19105. * @param scene defines the scene the morphtarget belongs to
  19106. */
  19107. constructor(
  19108. /** defines the name of the target */
  19109. name: string, influence?: number, scene?: Nullable<Scene>);
  19110. /**
  19111. * Gets a boolean defining if the target contains position data
  19112. */
  19113. readonly hasPositions: boolean;
  19114. /**
  19115. * Gets a boolean defining if the target contains normal data
  19116. */
  19117. readonly hasNormals: boolean;
  19118. /**
  19119. * Gets a boolean defining if the target contains tangent data
  19120. */
  19121. readonly hasTangents: boolean;
  19122. /**
  19123. * Affects position data to this target
  19124. * @param data defines the position data to use
  19125. */
  19126. setPositions(data: Nullable<FloatArray>): void;
  19127. /**
  19128. * Gets the position data stored in this target
  19129. * @returns a FloatArray containing the position data (or null if not present)
  19130. */
  19131. getPositions(): Nullable<FloatArray>;
  19132. /**
  19133. * Affects normal data to this target
  19134. * @param data defines the normal data to use
  19135. */
  19136. setNormals(data: Nullable<FloatArray>): void;
  19137. /**
  19138. * Gets the normal data stored in this target
  19139. * @returns a FloatArray containing the normal data (or null if not present)
  19140. */
  19141. getNormals(): Nullable<FloatArray>;
  19142. /**
  19143. * Affects tangent data to this target
  19144. * @param data defines the tangent data to use
  19145. */
  19146. setTangents(data: Nullable<FloatArray>): void;
  19147. /**
  19148. * Gets the tangent data stored in this target
  19149. * @returns a FloatArray containing the tangent data (or null if not present)
  19150. */
  19151. getTangents(): Nullable<FloatArray>;
  19152. /**
  19153. * Serializes the current target into a Serialization object
  19154. * @returns the serialized object
  19155. */
  19156. serialize(): any;
  19157. /**
  19158. * Returns the string "MorphTarget"
  19159. * @returns "MorphTarget"
  19160. */
  19161. getClassName(): string;
  19162. /**
  19163. * Creates a new target from serialized data
  19164. * @param serializationObject defines the serialized data to use
  19165. * @returns a new MorphTarget
  19166. */
  19167. static Parse(serializationObject: any): MorphTarget;
  19168. /**
  19169. * Creates a MorphTarget from mesh data
  19170. * @param mesh defines the source mesh
  19171. * @param name defines the name to use for the new target
  19172. * @param influence defines the influence to attach to the target
  19173. * @returns a new MorphTarget
  19174. */
  19175. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19176. }
  19177. }
  19178. declare module BABYLON {
  19179. /**
  19180. * This class is used to deform meshes using morphing between different targets
  19181. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19182. */
  19183. export class MorphTargetManager {
  19184. private _targets;
  19185. private _targetInfluenceChangedObservers;
  19186. private _targetDataLayoutChangedObservers;
  19187. private _activeTargets;
  19188. private _scene;
  19189. private _influences;
  19190. private _supportsNormals;
  19191. private _supportsTangents;
  19192. private _vertexCount;
  19193. private _uniqueId;
  19194. private _tempInfluences;
  19195. /**
  19196. * Creates a new MorphTargetManager
  19197. * @param scene defines the current scene
  19198. */
  19199. constructor(scene?: Nullable<Scene>);
  19200. /**
  19201. * Gets the unique ID of this manager
  19202. */
  19203. readonly uniqueId: number;
  19204. /**
  19205. * Gets the number of vertices handled by this manager
  19206. */
  19207. readonly vertexCount: number;
  19208. /**
  19209. * Gets a boolean indicating if this manager supports morphing of normals
  19210. */
  19211. readonly supportsNormals: boolean;
  19212. /**
  19213. * Gets a boolean indicating if this manager supports morphing of tangents
  19214. */
  19215. readonly supportsTangents: boolean;
  19216. /**
  19217. * Gets the number of targets stored in this manager
  19218. */
  19219. readonly numTargets: number;
  19220. /**
  19221. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19222. */
  19223. readonly numInfluencers: number;
  19224. /**
  19225. * Gets the list of influences (one per target)
  19226. */
  19227. readonly influences: Float32Array;
  19228. /**
  19229. * Gets the active target at specified index. An active target is a target with an influence > 0
  19230. * @param index defines the index to check
  19231. * @returns the requested target
  19232. */
  19233. getActiveTarget(index: number): MorphTarget;
  19234. /**
  19235. * Gets the target at specified index
  19236. * @param index defines the index to check
  19237. * @returns the requested target
  19238. */
  19239. getTarget(index: number): MorphTarget;
  19240. /**
  19241. * Add a new target to this manager
  19242. * @param target defines the target to add
  19243. */
  19244. addTarget(target: MorphTarget): void;
  19245. /**
  19246. * Removes a target from the manager
  19247. * @param target defines the target to remove
  19248. */
  19249. removeTarget(target: MorphTarget): void;
  19250. /**
  19251. * Serializes the current manager into a Serialization object
  19252. * @returns the serialized object
  19253. */
  19254. serialize(): any;
  19255. private _syncActiveTargets;
  19256. /**
  19257. * Syncrhonize the targets with all the meshes using this morph target manager
  19258. */
  19259. synchronize(): void;
  19260. /**
  19261. * Creates a new MorphTargetManager from serialized data
  19262. * @param serializationObject defines the serialized data
  19263. * @param scene defines the hosting scene
  19264. * @returns the new MorphTargetManager
  19265. */
  19266. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19267. }
  19268. }
  19269. declare module BABYLON {
  19270. /**
  19271. * Class used to represent a specific level of detail of a mesh
  19272. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19273. */
  19274. export class MeshLODLevel {
  19275. /** Defines the distance where this level should star being displayed */
  19276. distance: number;
  19277. /** Defines the mesh to use to render this level */
  19278. mesh: Nullable<Mesh>;
  19279. /**
  19280. * Creates a new LOD level
  19281. * @param distance defines the distance where this level should star being displayed
  19282. * @param mesh defines the mesh to use to render this level
  19283. */
  19284. constructor(
  19285. /** Defines the distance where this level should star being displayed */
  19286. distance: number,
  19287. /** Defines the mesh to use to render this level */
  19288. mesh: Nullable<Mesh>);
  19289. }
  19290. }
  19291. declare module BABYLON {
  19292. /**
  19293. * Mesh representing the gorund
  19294. */
  19295. export class GroundMesh extends Mesh {
  19296. /** If octree should be generated */
  19297. generateOctree: boolean;
  19298. private _heightQuads;
  19299. /** @hidden */ subdivisionsX: number;
  19300. /** @hidden */ subdivisionsY: number;
  19301. /** @hidden */ width: number;
  19302. /** @hidden */ height: number;
  19303. /** @hidden */ minX: number;
  19304. /** @hidden */ maxX: number;
  19305. /** @hidden */ minZ: number;
  19306. /** @hidden */ maxZ: number;
  19307. constructor(name: string, scene: Scene);
  19308. /**
  19309. * "GroundMesh"
  19310. * @returns "GroundMesh"
  19311. */
  19312. getClassName(): string;
  19313. /**
  19314. * The minimum of x and y subdivisions
  19315. */
  19316. readonly subdivisions: number;
  19317. /**
  19318. * X subdivisions
  19319. */
  19320. readonly subdivisionsX: number;
  19321. /**
  19322. * Y subdivisions
  19323. */
  19324. readonly subdivisionsY: number;
  19325. /**
  19326. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19327. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19328. * @param chunksCount the number of subdivisions for x and y
  19329. * @param octreeBlocksSize (Default: 32)
  19330. */
  19331. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19332. /**
  19333. * Returns a height (y) value in the Worl system :
  19334. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19335. * @param x x coordinate
  19336. * @param z z coordinate
  19337. * @returns the ground y position if (x, z) are outside the ground surface.
  19338. */
  19339. getHeightAtCoordinates(x: number, z: number): number;
  19340. /**
  19341. * Returns a normalized vector (Vector3) orthogonal to the ground
  19342. * at the ground coordinates (x, z) expressed in the World system.
  19343. * @param x x coordinate
  19344. * @param z z coordinate
  19345. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19346. */
  19347. getNormalAtCoordinates(x: number, z: number): Vector3;
  19348. /**
  19349. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19350. * at the ground coordinates (x, z) expressed in the World system.
  19351. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19352. * @param x x coordinate
  19353. * @param z z coordinate
  19354. * @param ref vector to store the result
  19355. * @returns the GroundMesh.
  19356. */
  19357. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19358. /**
  19359. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19360. * if the ground has been updated.
  19361. * This can be used in the render loop.
  19362. * @returns the GroundMesh.
  19363. */
  19364. updateCoordinateHeights(): GroundMesh;
  19365. private _getFacetAt;
  19366. private _initHeightQuads;
  19367. private _computeHeightQuads;
  19368. /**
  19369. * Serializes this ground mesh
  19370. * @param serializationObject object to write serialization to
  19371. */
  19372. serialize(serializationObject: any): void;
  19373. /**
  19374. * Parses a serialized ground mesh
  19375. * @param parsedMesh the serialized mesh
  19376. * @param scene the scene to create the ground mesh in
  19377. * @returns the created ground mesh
  19378. */
  19379. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19380. }
  19381. }
  19382. declare module BABYLON {
  19383. /**
  19384. * Interface for Physics-Joint data
  19385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19386. */
  19387. export interface PhysicsJointData {
  19388. /**
  19389. * The main pivot of the joint
  19390. */
  19391. mainPivot?: Vector3;
  19392. /**
  19393. * The connected pivot of the joint
  19394. */
  19395. connectedPivot?: Vector3;
  19396. /**
  19397. * The main axis of the joint
  19398. */
  19399. mainAxis?: Vector3;
  19400. /**
  19401. * The connected axis of the joint
  19402. */
  19403. connectedAxis?: Vector3;
  19404. /**
  19405. * The collision of the joint
  19406. */
  19407. collision?: boolean;
  19408. /**
  19409. * Native Oimo/Cannon/Energy data
  19410. */
  19411. nativeParams?: any;
  19412. }
  19413. /**
  19414. * This is a holder class for the physics joint created by the physics plugin
  19415. * It holds a set of functions to control the underlying joint
  19416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19417. */
  19418. export class PhysicsJoint {
  19419. /**
  19420. * The type of the physics joint
  19421. */
  19422. type: number;
  19423. /**
  19424. * The data for the physics joint
  19425. */
  19426. jointData: PhysicsJointData;
  19427. private _physicsJoint;
  19428. protected _physicsPlugin: IPhysicsEnginePlugin;
  19429. /**
  19430. * Initializes the physics joint
  19431. * @param type The type of the physics joint
  19432. * @param jointData The data for the physics joint
  19433. */
  19434. constructor(
  19435. /**
  19436. * The type of the physics joint
  19437. */
  19438. type: number,
  19439. /**
  19440. * The data for the physics joint
  19441. */
  19442. jointData: PhysicsJointData);
  19443. /**
  19444. * Gets the physics joint
  19445. */
  19446. /**
  19447. * Sets the physics joint
  19448. */
  19449. physicsJoint: any;
  19450. /**
  19451. * Sets the physics plugin
  19452. */
  19453. physicsPlugin: IPhysicsEnginePlugin;
  19454. /**
  19455. * Execute a function that is physics-plugin specific.
  19456. * @param {Function} func the function that will be executed.
  19457. * It accepts two parameters: the physics world and the physics joint
  19458. */
  19459. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19460. /**
  19461. * Distance-Joint type
  19462. */
  19463. static DistanceJoint: number;
  19464. /**
  19465. * Hinge-Joint type
  19466. */
  19467. static HingeJoint: number;
  19468. /**
  19469. * Ball-and-Socket joint type
  19470. */
  19471. static BallAndSocketJoint: number;
  19472. /**
  19473. * Wheel-Joint type
  19474. */
  19475. static WheelJoint: number;
  19476. /**
  19477. * Slider-Joint type
  19478. */
  19479. static SliderJoint: number;
  19480. /**
  19481. * Prismatic-Joint type
  19482. */
  19483. static PrismaticJoint: number;
  19484. /**
  19485. * Universal-Joint type
  19486. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19487. */
  19488. static UniversalJoint: number;
  19489. /**
  19490. * Hinge-Joint 2 type
  19491. */
  19492. static Hinge2Joint: number;
  19493. /**
  19494. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19495. */
  19496. static PointToPointJoint: number;
  19497. /**
  19498. * Spring-Joint type
  19499. */
  19500. static SpringJoint: number;
  19501. /**
  19502. * Lock-Joint type
  19503. */
  19504. static LockJoint: number;
  19505. }
  19506. /**
  19507. * A class representing a physics distance joint
  19508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19509. */
  19510. export class DistanceJoint extends PhysicsJoint {
  19511. /**
  19512. *
  19513. * @param jointData The data for the Distance-Joint
  19514. */
  19515. constructor(jointData: DistanceJointData);
  19516. /**
  19517. * Update the predefined distance.
  19518. * @param maxDistance The maximum preferred distance
  19519. * @param minDistance The minimum preferred distance
  19520. */
  19521. updateDistance(maxDistance: number, minDistance?: number): void;
  19522. }
  19523. /**
  19524. * Represents a Motor-Enabled Joint
  19525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19526. */
  19527. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19528. /**
  19529. * Initializes the Motor-Enabled Joint
  19530. * @param type The type of the joint
  19531. * @param jointData The physica joint data for the joint
  19532. */
  19533. constructor(type: number, jointData: PhysicsJointData);
  19534. /**
  19535. * Set the motor values.
  19536. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19537. * @param force the force to apply
  19538. * @param maxForce max force for this motor.
  19539. */
  19540. setMotor(force?: number, maxForce?: number): void;
  19541. /**
  19542. * Set the motor's limits.
  19543. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19544. * @param upperLimit The upper limit of the motor
  19545. * @param lowerLimit The lower limit of the motor
  19546. */
  19547. setLimit(upperLimit: number, lowerLimit?: number): void;
  19548. }
  19549. /**
  19550. * This class represents a single physics Hinge-Joint
  19551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19552. */
  19553. export class HingeJoint extends MotorEnabledJoint {
  19554. /**
  19555. * Initializes the Hinge-Joint
  19556. * @param jointData The joint data for the Hinge-Joint
  19557. */
  19558. constructor(jointData: PhysicsJointData);
  19559. /**
  19560. * Set the motor values.
  19561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19562. * @param {number} force the force to apply
  19563. * @param {number} maxForce max force for this motor.
  19564. */
  19565. setMotor(force?: number, maxForce?: number): void;
  19566. /**
  19567. * Set the motor's limits.
  19568. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19569. * @param upperLimit The upper limit of the motor
  19570. * @param lowerLimit The lower limit of the motor
  19571. */
  19572. setLimit(upperLimit: number, lowerLimit?: number): void;
  19573. }
  19574. /**
  19575. * This class represents a dual hinge physics joint (same as wheel joint)
  19576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19577. */
  19578. export class Hinge2Joint extends MotorEnabledJoint {
  19579. /**
  19580. * Initializes the Hinge2-Joint
  19581. * @param jointData The joint data for the Hinge2-Joint
  19582. */
  19583. constructor(jointData: PhysicsJointData);
  19584. /**
  19585. * Set the motor values.
  19586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19587. * @param {number} targetSpeed the speed the motor is to reach
  19588. * @param {number} maxForce max force for this motor.
  19589. * @param {motorIndex} the motor's index, 0 or 1.
  19590. */
  19591. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19592. /**
  19593. * Set the motor limits.
  19594. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19595. * @param {number} upperLimit the upper limit
  19596. * @param {number} lowerLimit lower limit
  19597. * @param {motorIndex} the motor's index, 0 or 1.
  19598. */
  19599. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19600. }
  19601. /**
  19602. * Interface for a motor enabled joint
  19603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19604. */
  19605. export interface IMotorEnabledJoint {
  19606. /**
  19607. * Physics joint
  19608. */
  19609. physicsJoint: any;
  19610. /**
  19611. * Sets the motor of the motor-enabled joint
  19612. * @param force The force of the motor
  19613. * @param maxForce The maximum force of the motor
  19614. * @param motorIndex The index of the motor
  19615. */
  19616. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19617. /**
  19618. * Sets the limit of the motor
  19619. * @param upperLimit The upper limit of the motor
  19620. * @param lowerLimit The lower limit of the motor
  19621. * @param motorIndex The index of the motor
  19622. */
  19623. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19624. }
  19625. /**
  19626. * Joint data for a Distance-Joint
  19627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19628. */
  19629. export interface DistanceJointData extends PhysicsJointData {
  19630. /**
  19631. * Max distance the 2 joint objects can be apart
  19632. */
  19633. maxDistance: number;
  19634. }
  19635. /**
  19636. * Joint data from a spring joint
  19637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19638. */
  19639. export interface SpringJointData extends PhysicsJointData {
  19640. /**
  19641. * Length of the spring
  19642. */
  19643. length: number;
  19644. /**
  19645. * Stiffness of the spring
  19646. */
  19647. stiffness: number;
  19648. /**
  19649. * Damping of the spring
  19650. */
  19651. damping: number;
  19652. /** this callback will be called when applying the force to the impostors. */
  19653. forceApplicationCallback: () => void;
  19654. }
  19655. }
  19656. declare module BABYLON {
  19657. /**
  19658. * Holds the data for the raycast result
  19659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19660. */
  19661. export class PhysicsRaycastResult {
  19662. private _hasHit;
  19663. private _hitDistance;
  19664. private _hitNormalWorld;
  19665. private _hitPointWorld;
  19666. private _rayFromWorld;
  19667. private _rayToWorld;
  19668. /**
  19669. * Gets if there was a hit
  19670. */
  19671. readonly hasHit: boolean;
  19672. /**
  19673. * Gets the distance from the hit
  19674. */
  19675. readonly hitDistance: number;
  19676. /**
  19677. * Gets the hit normal/direction in the world
  19678. */
  19679. readonly hitNormalWorld: Vector3;
  19680. /**
  19681. * Gets the hit point in the world
  19682. */
  19683. readonly hitPointWorld: Vector3;
  19684. /**
  19685. * Gets the ray "start point" of the ray in the world
  19686. */
  19687. readonly rayFromWorld: Vector3;
  19688. /**
  19689. * Gets the ray "end point" of the ray in the world
  19690. */
  19691. readonly rayToWorld: Vector3;
  19692. /**
  19693. * Sets the hit data (normal & point in world space)
  19694. * @param hitNormalWorld defines the normal in world space
  19695. * @param hitPointWorld defines the point in world space
  19696. */
  19697. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19698. /**
  19699. * Sets the distance from the start point to the hit point
  19700. * @param distance
  19701. */
  19702. setHitDistance(distance: number): void;
  19703. /**
  19704. * Calculates the distance manually
  19705. */
  19706. calculateHitDistance(): void;
  19707. /**
  19708. * Resets all the values to default
  19709. * @param from The from point on world space
  19710. * @param to The to point on world space
  19711. */
  19712. reset(from?: Vector3, to?: Vector3): void;
  19713. }
  19714. /**
  19715. * Interface for the size containing width and height
  19716. */
  19717. interface IXYZ {
  19718. /**
  19719. * X
  19720. */
  19721. x: number;
  19722. /**
  19723. * Y
  19724. */
  19725. y: number;
  19726. /**
  19727. * Z
  19728. */
  19729. z: number;
  19730. }
  19731. }
  19732. declare module BABYLON {
  19733. /**
  19734. * Interface used to describe a physics joint
  19735. */
  19736. export interface PhysicsImpostorJoint {
  19737. /** Defines the main impostor to which the joint is linked */
  19738. mainImpostor: PhysicsImpostor;
  19739. /** Defines the impostor that is connected to the main impostor using this joint */
  19740. connectedImpostor: PhysicsImpostor;
  19741. /** Defines the joint itself */
  19742. joint: PhysicsJoint;
  19743. }
  19744. /** @hidden */
  19745. export interface IPhysicsEnginePlugin {
  19746. world: any;
  19747. name: string;
  19748. setGravity(gravity: Vector3): void;
  19749. setTimeStep(timeStep: number): void;
  19750. getTimeStep(): number;
  19751. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19752. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19753. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19754. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19755. removePhysicsBody(impostor: PhysicsImpostor): void;
  19756. generateJoint(joint: PhysicsImpostorJoint): void;
  19757. removeJoint(joint: PhysicsImpostorJoint): void;
  19758. isSupported(): boolean;
  19759. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19760. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19761. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19762. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19763. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19764. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19766. getBodyMass(impostor: PhysicsImpostor): number;
  19767. getBodyFriction(impostor: PhysicsImpostor): number;
  19768. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19769. getBodyRestitution(impostor: PhysicsImpostor): number;
  19770. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19771. getBodyPressure?(impostor: PhysicsImpostor): number;
  19772. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19773. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19774. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19775. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19776. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19777. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19778. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19779. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19780. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19781. sleepBody(impostor: PhysicsImpostor): void;
  19782. wakeUpBody(impostor: PhysicsImpostor): void;
  19783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19784. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19785. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19786. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19787. getRadius(impostor: PhysicsImpostor): number;
  19788. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19789. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19790. dispose(): void;
  19791. }
  19792. /**
  19793. * Interface used to define a physics engine
  19794. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19795. */
  19796. export interface IPhysicsEngine {
  19797. /**
  19798. * Gets the gravity vector used by the simulation
  19799. */
  19800. gravity: Vector3;
  19801. /**
  19802. * Sets the gravity vector used by the simulation
  19803. * @param gravity defines the gravity vector to use
  19804. */
  19805. setGravity(gravity: Vector3): void;
  19806. /**
  19807. * Set the time step of the physics engine.
  19808. * Default is 1/60.
  19809. * To slow it down, enter 1/600 for example.
  19810. * To speed it up, 1/30
  19811. * @param newTimeStep the new timestep to apply to this world.
  19812. */
  19813. setTimeStep(newTimeStep: number): void;
  19814. /**
  19815. * Get the time step of the physics engine.
  19816. * @returns the current time step
  19817. */
  19818. getTimeStep(): number;
  19819. /**
  19820. * Release all resources
  19821. */
  19822. dispose(): void;
  19823. /**
  19824. * Gets the name of the current physics plugin
  19825. * @returns the name of the plugin
  19826. */
  19827. getPhysicsPluginName(): string;
  19828. /**
  19829. * Adding a new impostor for the impostor tracking.
  19830. * This will be done by the impostor itself.
  19831. * @param impostor the impostor to add
  19832. */
  19833. addImpostor(impostor: PhysicsImpostor): void;
  19834. /**
  19835. * Remove an impostor from the engine.
  19836. * This impostor and its mesh will not longer be updated by the physics engine.
  19837. * @param impostor the impostor to remove
  19838. */
  19839. removeImpostor(impostor: PhysicsImpostor): void;
  19840. /**
  19841. * Add a joint to the physics engine
  19842. * @param mainImpostor defines the main impostor to which the joint is added.
  19843. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19844. * @param joint defines the joint that will connect both impostors.
  19845. */
  19846. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19847. /**
  19848. * Removes a joint from the simulation
  19849. * @param mainImpostor defines the impostor used with the joint
  19850. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19851. * @param joint defines the joint to remove
  19852. */
  19853. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19854. /**
  19855. * Gets the current plugin used to run the simulation
  19856. * @returns current plugin
  19857. */
  19858. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19859. /**
  19860. * Gets the list of physic impostors
  19861. * @returns an array of PhysicsImpostor
  19862. */
  19863. getImpostors(): Array<PhysicsImpostor>;
  19864. /**
  19865. * Gets the impostor for a physics enabled object
  19866. * @param object defines the object impersonated by the impostor
  19867. * @returns the PhysicsImpostor or null if not found
  19868. */
  19869. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19870. /**
  19871. * Gets the impostor for a physics body object
  19872. * @param body defines physics body used by the impostor
  19873. * @returns the PhysicsImpostor or null if not found
  19874. */
  19875. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19876. /**
  19877. * Does a raycast in the physics world
  19878. * @param from when should the ray start?
  19879. * @param to when should the ray end?
  19880. * @returns PhysicsRaycastResult
  19881. */
  19882. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19883. /**
  19884. * Called by the scene. No need to call it.
  19885. * @param delta defines the timespam between frames
  19886. */ step(delta: number): void;
  19887. }
  19888. }
  19889. declare module BABYLON {
  19890. /**
  19891. * The interface for the physics imposter parameters
  19892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19893. */
  19894. export interface PhysicsImpostorParameters {
  19895. /**
  19896. * The mass of the physics imposter
  19897. */
  19898. mass: number;
  19899. /**
  19900. * The friction of the physics imposter
  19901. */
  19902. friction?: number;
  19903. /**
  19904. * The coefficient of restitution of the physics imposter
  19905. */
  19906. restitution?: number;
  19907. /**
  19908. * The native options of the physics imposter
  19909. */
  19910. nativeOptions?: any;
  19911. /**
  19912. * Specifies if the parent should be ignored
  19913. */
  19914. ignoreParent?: boolean;
  19915. /**
  19916. * Specifies if bi-directional transformations should be disabled
  19917. */
  19918. disableBidirectionalTransformation?: boolean;
  19919. /**
  19920. * The pressure inside the physics imposter, soft object only
  19921. */
  19922. pressure?: number;
  19923. /**
  19924. * The stiffness the physics imposter, soft object only
  19925. */
  19926. stiffness?: number;
  19927. /**
  19928. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19929. */
  19930. velocityIterations?: number;
  19931. /**
  19932. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19933. */
  19934. positionIterations?: number;
  19935. /**
  19936. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19937. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19938. * Add to fix multiple points
  19939. */
  19940. fixedPoints?: number;
  19941. /**
  19942. * The collision margin around a soft object
  19943. */
  19944. margin?: number;
  19945. /**
  19946. * The collision margin around a soft object
  19947. */
  19948. damping?: number;
  19949. /**
  19950. * The path for a rope based on an extrusion
  19951. */
  19952. path?: any;
  19953. /**
  19954. * The shape of an extrusion used for a rope based on an extrusion
  19955. */
  19956. shape?: any;
  19957. }
  19958. /**
  19959. * Interface for a physics-enabled object
  19960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19961. */
  19962. export interface IPhysicsEnabledObject {
  19963. /**
  19964. * The position of the physics-enabled object
  19965. */
  19966. position: Vector3;
  19967. /**
  19968. * The rotation of the physics-enabled object
  19969. */
  19970. rotationQuaternion: Nullable<Quaternion>;
  19971. /**
  19972. * The scale of the physics-enabled object
  19973. */
  19974. scaling: Vector3;
  19975. /**
  19976. * The rotation of the physics-enabled object
  19977. */
  19978. rotation?: Vector3;
  19979. /**
  19980. * The parent of the physics-enabled object
  19981. */
  19982. parent?: any;
  19983. /**
  19984. * The bounding info of the physics-enabled object
  19985. * @returns The bounding info of the physics-enabled object
  19986. */
  19987. getBoundingInfo(): BoundingInfo;
  19988. /**
  19989. * Computes the world matrix
  19990. * @param force Specifies if the world matrix should be computed by force
  19991. * @returns A world matrix
  19992. */
  19993. computeWorldMatrix(force: boolean): Matrix;
  19994. /**
  19995. * Gets the world matrix
  19996. * @returns A world matrix
  19997. */
  19998. getWorldMatrix?(): Matrix;
  19999. /**
  20000. * Gets the child meshes
  20001. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20002. * @returns An array of abstract meshes
  20003. */
  20004. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20005. /**
  20006. * Gets the vertex data
  20007. * @param kind The type of vertex data
  20008. * @returns A nullable array of numbers, or a float32 array
  20009. */
  20010. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20011. /**
  20012. * Gets the indices from the mesh
  20013. * @returns A nullable array of index arrays
  20014. */
  20015. getIndices?(): Nullable<IndicesArray>;
  20016. /**
  20017. * Gets the scene from the mesh
  20018. * @returns the indices array or null
  20019. */
  20020. getScene?(): Scene;
  20021. /**
  20022. * Gets the absolute position from the mesh
  20023. * @returns the absolute position
  20024. */
  20025. getAbsolutePosition(): Vector3;
  20026. /**
  20027. * Gets the absolute pivot point from the mesh
  20028. * @returns the absolute pivot point
  20029. */
  20030. getAbsolutePivotPoint(): Vector3;
  20031. /**
  20032. * Rotates the mesh
  20033. * @param axis The axis of rotation
  20034. * @param amount The amount of rotation
  20035. * @param space The space of the rotation
  20036. * @returns The rotation transform node
  20037. */
  20038. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20039. /**
  20040. * Translates the mesh
  20041. * @param axis The axis of translation
  20042. * @param distance The distance of translation
  20043. * @param space The space of the translation
  20044. * @returns The transform node
  20045. */
  20046. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20047. /**
  20048. * Sets the absolute position of the mesh
  20049. * @param absolutePosition The absolute position of the mesh
  20050. * @returns The transform node
  20051. */
  20052. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20053. /**
  20054. * Gets the class name of the mesh
  20055. * @returns The class name
  20056. */
  20057. getClassName(): string;
  20058. }
  20059. /**
  20060. * Represents a physics imposter
  20061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20062. */
  20063. export class PhysicsImpostor {
  20064. /**
  20065. * The physics-enabled object used as the physics imposter
  20066. */
  20067. object: IPhysicsEnabledObject;
  20068. /**
  20069. * The type of the physics imposter
  20070. */
  20071. type: number;
  20072. private _options;
  20073. private _scene?;
  20074. /**
  20075. * The default object size of the imposter
  20076. */
  20077. static DEFAULT_OBJECT_SIZE: Vector3;
  20078. /**
  20079. * The identity quaternion of the imposter
  20080. */
  20081. static IDENTITY_QUATERNION: Quaternion;
  20082. /** @hidden */ pluginData: any;
  20083. private _physicsEngine;
  20084. private _physicsBody;
  20085. private _bodyUpdateRequired;
  20086. private _onBeforePhysicsStepCallbacks;
  20087. private _onAfterPhysicsStepCallbacks;
  20088. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  20089. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20090. otherImpostors: Array<PhysicsImpostor>;
  20091. }>;
  20092. private _deltaPosition;
  20093. private _deltaRotation;
  20094. private _deltaRotationConjugated;
  20095. /** hidden */ isFromLine: boolean;
  20096. private _parent;
  20097. private _isDisposed;
  20098. private static _tmpVecs;
  20099. private static _tmpQuat;
  20100. /**
  20101. * Specifies if the physics imposter is disposed
  20102. */
  20103. readonly isDisposed: boolean;
  20104. /**
  20105. * Gets the mass of the physics imposter
  20106. */
  20107. mass: number;
  20108. /**
  20109. * Gets the coefficient of friction
  20110. */
  20111. /**
  20112. * Sets the coefficient of friction
  20113. */
  20114. friction: number;
  20115. /**
  20116. * Gets the coefficient of restitution
  20117. */
  20118. /**
  20119. * Sets the coefficient of restitution
  20120. */
  20121. restitution: number;
  20122. /**
  20123. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20124. */
  20125. /**
  20126. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20127. */
  20128. pressure: number;
  20129. /**
  20130. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20131. */
  20132. /**
  20133. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20134. */
  20135. stiffness: number;
  20136. /**
  20137. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20138. */
  20139. /**
  20140. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20141. */
  20142. velocityIterations: number;
  20143. /**
  20144. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20145. */
  20146. /**
  20147. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20148. */
  20149. positionIterations: number;
  20150. /**
  20151. * The unique id of the physics imposter
  20152. * set by the physics engine when adding this impostor to the array
  20153. */
  20154. uniqueId: number;
  20155. /**
  20156. * @hidden
  20157. */
  20158. soft: boolean;
  20159. /**
  20160. * @hidden
  20161. */
  20162. segments: number;
  20163. private _joints;
  20164. /**
  20165. * Initializes the physics imposter
  20166. * @param object The physics-enabled object used as the physics imposter
  20167. * @param type The type of the physics imposter
  20168. * @param _options The options for the physics imposter
  20169. * @param _scene The Babylon scene
  20170. */
  20171. constructor(
  20172. /**
  20173. * The physics-enabled object used as the physics imposter
  20174. */
  20175. object: IPhysicsEnabledObject,
  20176. /**
  20177. * The type of the physics imposter
  20178. */
  20179. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20180. /**
  20181. * This function will completly initialize this impostor.
  20182. * It will create a new body - but only if this mesh has no parent.
  20183. * If it has, this impostor will not be used other than to define the impostor
  20184. * of the child mesh.
  20185. * @hidden
  20186. */ init(): void;
  20187. private _getPhysicsParent;
  20188. /**
  20189. * Should a new body be generated.
  20190. * @returns boolean specifying if body initialization is required
  20191. */
  20192. isBodyInitRequired(): boolean;
  20193. /**
  20194. * Sets the updated scaling
  20195. * @param updated Specifies if the scaling is updated
  20196. */
  20197. setScalingUpdated(): void;
  20198. /**
  20199. * Force a regeneration of this or the parent's impostor's body.
  20200. * Use under cautious - This will remove all joints already implemented.
  20201. */
  20202. forceUpdate(): void;
  20203. /**
  20204. * Gets the body that holds this impostor. Either its own, or its parent.
  20205. */
  20206. /**
  20207. * Set the physics body. Used mainly by the physics engine/plugin
  20208. */
  20209. physicsBody: any;
  20210. /**
  20211. * Get the parent of the physics imposter
  20212. * @returns Physics imposter or null
  20213. */
  20214. /**
  20215. * Sets the parent of the physics imposter
  20216. */
  20217. parent: Nullable<PhysicsImpostor>;
  20218. /**
  20219. * Resets the update flags
  20220. */
  20221. resetUpdateFlags(): void;
  20222. /**
  20223. * Gets the object extend size
  20224. * @returns the object extend size
  20225. */
  20226. getObjectExtendSize(): Vector3;
  20227. /**
  20228. * Gets the object center
  20229. * @returns The object center
  20230. */
  20231. getObjectCenter(): Vector3;
  20232. /**
  20233. * Get a specific parametes from the options parameter
  20234. * @param paramName The object parameter name
  20235. * @returns The object parameter
  20236. */
  20237. getParam(paramName: string): any;
  20238. /**
  20239. * Sets a specific parameter in the options given to the physics plugin
  20240. * @param paramName The parameter name
  20241. * @param value The value of the parameter
  20242. */
  20243. setParam(paramName: string, value: number): void;
  20244. /**
  20245. * Specifically change the body's mass option. Won't recreate the physics body object
  20246. * @param mass The mass of the physics imposter
  20247. */
  20248. setMass(mass: number): void;
  20249. /**
  20250. * Gets the linear velocity
  20251. * @returns linear velocity or null
  20252. */
  20253. getLinearVelocity(): Nullable<Vector3>;
  20254. /**
  20255. * Sets the linear velocity
  20256. * @param velocity linear velocity or null
  20257. */
  20258. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20259. /**
  20260. * Gets the angular velocity
  20261. * @returns angular velocity or null
  20262. */
  20263. getAngularVelocity(): Nullable<Vector3>;
  20264. /**
  20265. * Sets the angular velocity
  20266. * @param velocity The velocity or null
  20267. */
  20268. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20269. /**
  20270. * Execute a function with the physics plugin native code
  20271. * Provide a function the will have two variables - the world object and the physics body object
  20272. * @param func The function to execute with the physics plugin native code
  20273. */
  20274. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20275. /**
  20276. * Register a function that will be executed before the physics world is stepping forward
  20277. * @param func The function to execute before the physics world is stepped forward
  20278. */
  20279. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20280. /**
  20281. * Unregister a function that will be executed before the physics world is stepping forward
  20282. * @param func The function to execute before the physics world is stepped forward
  20283. */
  20284. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20285. /**
  20286. * Register a function that will be executed after the physics step
  20287. * @param func The function to execute after physics step
  20288. */
  20289. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20290. /**
  20291. * Unregisters a function that will be executed after the physics step
  20292. * @param func The function to execute after physics step
  20293. */
  20294. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20295. /**
  20296. * register a function that will be executed when this impostor collides against a different body
  20297. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20298. * @param func Callback that is executed on collision
  20299. */
  20300. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20301. /**
  20302. * Unregisters the physics imposter on contact
  20303. * @param collideAgainst The physics object to collide against
  20304. * @param func Callback to execute on collision
  20305. */
  20306. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20307. private _tmpQuat;
  20308. private _tmpQuat2;
  20309. /**
  20310. * Get the parent rotation
  20311. * @returns The parent rotation
  20312. */
  20313. getParentsRotation(): Quaternion;
  20314. /**
  20315. * this function is executed by the physics engine.
  20316. */
  20317. beforeStep: () => void;
  20318. /**
  20319. * this function is executed by the physics engine
  20320. */
  20321. afterStep: () => void;
  20322. /**
  20323. * Legacy collision detection event support
  20324. */
  20325. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20326. /**
  20327. * event and body object due to cannon's event-based architecture.
  20328. */
  20329. onCollide: (e: {
  20330. body: any;
  20331. }) => void;
  20332. /**
  20333. * Apply a force
  20334. * @param force The force to apply
  20335. * @param contactPoint The contact point for the force
  20336. * @returns The physics imposter
  20337. */
  20338. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20339. /**
  20340. * Apply an impulse
  20341. * @param force The impulse force
  20342. * @param contactPoint The contact point for the impulse force
  20343. * @returns The physics imposter
  20344. */
  20345. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20346. /**
  20347. * A help function to create a joint
  20348. * @param otherImpostor A physics imposter used to create a joint
  20349. * @param jointType The type of joint
  20350. * @param jointData The data for the joint
  20351. * @returns The physics imposter
  20352. */
  20353. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20354. /**
  20355. * Add a joint to this impostor with a different impostor
  20356. * @param otherImpostor A physics imposter used to add a joint
  20357. * @param joint The joint to add
  20358. * @returns The physics imposter
  20359. */
  20360. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20361. /**
  20362. * Add an anchor to a cloth impostor
  20363. * @param otherImpostor rigid impostor to anchor to
  20364. * @param width ratio across width from 0 to 1
  20365. * @param height ratio up height from 0 to 1
  20366. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20367. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20368. * @returns impostor the soft imposter
  20369. */
  20370. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20371. /**
  20372. * Add a hook to a rope impostor
  20373. * @param otherImpostor rigid impostor to anchor to
  20374. * @param length ratio across rope from 0 to 1
  20375. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20376. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20377. * @returns impostor the rope imposter
  20378. */
  20379. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20380. /**
  20381. * Will keep this body still, in a sleep mode.
  20382. * @returns the physics imposter
  20383. */
  20384. sleep(): PhysicsImpostor;
  20385. /**
  20386. * Wake the body up.
  20387. * @returns The physics imposter
  20388. */
  20389. wakeUp(): PhysicsImpostor;
  20390. /**
  20391. * Clones the physics imposter
  20392. * @param newObject The physics imposter clones to this physics-enabled object
  20393. * @returns A nullable physics imposter
  20394. */
  20395. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20396. /**
  20397. * Disposes the physics imposter
  20398. */
  20399. dispose(): void;
  20400. /**
  20401. * Sets the delta position
  20402. * @param position The delta position amount
  20403. */
  20404. setDeltaPosition(position: Vector3): void;
  20405. /**
  20406. * Sets the delta rotation
  20407. * @param rotation The delta rotation amount
  20408. */
  20409. setDeltaRotation(rotation: Quaternion): void;
  20410. /**
  20411. * Gets the box size of the physics imposter and stores the result in the input parameter
  20412. * @param result Stores the box size
  20413. * @returns The physics imposter
  20414. */
  20415. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20416. /**
  20417. * Gets the radius of the physics imposter
  20418. * @returns Radius of the physics imposter
  20419. */
  20420. getRadius(): number;
  20421. /**
  20422. * Sync a bone with this impostor
  20423. * @param bone The bone to sync to the impostor.
  20424. * @param boneMesh The mesh that the bone is influencing.
  20425. * @param jointPivot The pivot of the joint / bone in local space.
  20426. * @param distToJoint Optional distance from the impostor to the joint.
  20427. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20428. */
  20429. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20430. /**
  20431. * Sync impostor to a bone
  20432. * @param bone The bone that the impostor will be synced to.
  20433. * @param boneMesh The mesh that the bone is influencing.
  20434. * @param jointPivot The pivot of the joint / bone in local space.
  20435. * @param distToJoint Optional distance from the impostor to the joint.
  20436. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20437. * @param boneAxis Optional vector3 axis the bone is aligned with
  20438. */
  20439. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20440. /**
  20441. * No-Imposter type
  20442. */
  20443. static NoImpostor: number;
  20444. /**
  20445. * Sphere-Imposter type
  20446. */
  20447. static SphereImpostor: number;
  20448. /**
  20449. * Box-Imposter type
  20450. */
  20451. static BoxImpostor: number;
  20452. /**
  20453. * Plane-Imposter type
  20454. */
  20455. static PlaneImpostor: number;
  20456. /**
  20457. * Mesh-imposter type
  20458. */
  20459. static MeshImpostor: number;
  20460. /**
  20461. * Cylinder-Imposter type
  20462. */
  20463. static CylinderImpostor: number;
  20464. /**
  20465. * Particle-Imposter type
  20466. */
  20467. static ParticleImpostor: number;
  20468. /**
  20469. * Heightmap-Imposter type
  20470. */
  20471. static HeightmapImpostor: number;
  20472. /**
  20473. * ConvexHull-Impostor type (Ammo.js plugin only)
  20474. */
  20475. static ConvexHullImpostor: number;
  20476. /**
  20477. * Rope-Imposter type
  20478. */
  20479. static RopeImpostor: number;
  20480. /**
  20481. * Cloth-Imposter type
  20482. */
  20483. static ClothImpostor: number;
  20484. /**
  20485. * Softbody-Imposter type
  20486. */
  20487. static SoftbodyImpostor: number;
  20488. }
  20489. }
  20490. declare module BABYLON {
  20491. /**
  20492. * @hidden
  20493. **/
  20494. export class _CreationDataStorage {
  20495. closePath?: boolean;
  20496. closeArray?: boolean;
  20497. idx: number[];
  20498. dashSize: number;
  20499. gapSize: number;
  20500. path3D: Path3D;
  20501. pathArray: Vector3[][];
  20502. arc: number;
  20503. radius: number;
  20504. cap: number;
  20505. tessellation: number;
  20506. }
  20507. /**
  20508. * @hidden
  20509. **/ private class _InstanceDataStorage {
  20510. visibleInstances: any;
  20511. batchCache: _InstancesBatch;
  20512. instancesBufferSize: number;
  20513. instancesBuffer: Nullable<Buffer>;
  20514. instancesData: Float32Array;
  20515. overridenInstanceCount: number;
  20516. isFrozen: boolean;
  20517. previousBatch: _InstancesBatch;
  20518. hardwareInstancedRendering: boolean;
  20519. sideOrientation: number;
  20520. }
  20521. /**
  20522. * @hidden
  20523. **/
  20524. export class _InstancesBatch {
  20525. mustReturn: boolean;
  20526. visibleInstances: Nullable<InstancedMesh[]>[];
  20527. renderSelf: boolean[];
  20528. hardwareInstancedRendering: boolean[];
  20529. }
  20530. /**
  20531. * Class used to represent renderable models
  20532. */
  20533. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20534. /**
  20535. * Mesh side orientation : usually the external or front surface
  20536. */
  20537. static readonly FRONTSIDE: number;
  20538. /**
  20539. * Mesh side orientation : usually the internal or back surface
  20540. */
  20541. static readonly BACKSIDE: number;
  20542. /**
  20543. * Mesh side orientation : both internal and external or front and back surfaces
  20544. */
  20545. static readonly DOUBLESIDE: number;
  20546. /**
  20547. * Mesh side orientation : by default, `FRONTSIDE`
  20548. */
  20549. static readonly DEFAULTSIDE: number;
  20550. /**
  20551. * Mesh cap setting : no cap
  20552. */
  20553. static readonly NO_CAP: number;
  20554. /**
  20555. * Mesh cap setting : one cap at the beginning of the mesh
  20556. */
  20557. static readonly CAP_START: number;
  20558. /**
  20559. * Mesh cap setting : one cap at the end of the mesh
  20560. */
  20561. static readonly CAP_END: number;
  20562. /**
  20563. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20564. */
  20565. static readonly CAP_ALL: number;
  20566. /**
  20567. * Gets the default side orientation.
  20568. * @param orientation the orientation to value to attempt to get
  20569. * @returns the default orientation
  20570. * @hidden
  20571. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20572. private _internalMeshDataInfo;
  20573. /**
  20574. * An event triggered before rendering the mesh
  20575. */
  20576. readonly onBeforeRenderObservable: Observable<Mesh>;
  20577. /**
  20578. * An event triggered before binding the mesh
  20579. */
  20580. readonly onBeforeBindObservable: Observable<Mesh>;
  20581. /**
  20582. * An event triggered after rendering the mesh
  20583. */
  20584. readonly onAfterRenderObservable: Observable<Mesh>;
  20585. /**
  20586. * An event triggered before drawing the mesh
  20587. */
  20588. readonly onBeforeDrawObservable: Observable<Mesh>;
  20589. private _onBeforeDrawObserver;
  20590. /**
  20591. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20592. */
  20593. onBeforeDraw: () => void;
  20594. /**
  20595. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20596. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20597. */
  20598. delayLoadState: number;
  20599. /**
  20600. * Gets the list of instances created from this mesh
  20601. * it is not supposed to be modified manually.
  20602. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20603. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20604. */
  20605. instances: InstancedMesh[];
  20606. /**
  20607. * Gets the file containing delay loading data for this mesh
  20608. */
  20609. delayLoadingFile: string;
  20610. /** @hidden */ binaryInfo: any;
  20611. /**
  20612. * User defined function used to change how LOD level selection is done
  20613. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20614. */
  20615. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20616. /**
  20617. * Gets or sets the morph target manager
  20618. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20619. */
  20620. morphTargetManager: Nullable<MorphTargetManager>;
  20621. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20622. /** @hidden */ geometry: Nullable<Geometry>;
  20623. /** @hidden */ delayInfo: Array<string>;
  20624. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20625. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20626. private _effectiveMaterial;
  20627. /** @hidden */ shouldGenerateFlatShading: boolean;
  20628. /** @hidden */ originalBuilderSideOrientation: number;
  20629. /**
  20630. * Use this property to change the original side orientation defined at construction time
  20631. */
  20632. overrideMaterialSideOrientation: Nullable<number>;
  20633. /**
  20634. * Gets the source mesh (the one used to clone this one from)
  20635. */
  20636. readonly source: Nullable<Mesh>;
  20637. /**
  20638. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20639. */
  20640. isUnIndexed: boolean;
  20641. /**
  20642. * @constructor
  20643. * @param name The value used by scene.getMeshByName() to do a lookup.
  20644. * @param scene The scene to add this mesh to.
  20645. * @param parent The parent of this mesh, if it has one
  20646. * @param source An optional Mesh from which geometry is shared, cloned.
  20647. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20648. * When false, achieved by calling a clone(), also passing False.
  20649. * This will make creation of children, recursive.
  20650. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20651. */
  20652. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20653. /**
  20654. * Gets the class name
  20655. * @returns the string "Mesh".
  20656. */
  20657. getClassName(): string;
  20658. /** @hidden */ protected readonly _isMesh: boolean;
  20659. /**
  20660. * Returns a description of this mesh
  20661. * @param fullDetails define if full details about this mesh must be used
  20662. * @returns a descriptive string representing this mesh
  20663. */
  20664. toString(fullDetails?: boolean): string;
  20665. /** @hidden */ unBindEffect(): void;
  20666. /**
  20667. * Gets a boolean indicating if this mesh has LOD
  20668. */
  20669. readonly hasLODLevels: boolean;
  20670. /**
  20671. * Gets the list of MeshLODLevel associated with the current mesh
  20672. * @returns an array of MeshLODLevel
  20673. */
  20674. getLODLevels(): MeshLODLevel[];
  20675. private _sortLODLevels;
  20676. /**
  20677. * Add a mesh as LOD level triggered at the given distance.
  20678. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20679. * @param distance The distance from the center of the object to show this level
  20680. * @param mesh The mesh to be added as LOD level (can be null)
  20681. * @return This mesh (for chaining)
  20682. */
  20683. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20684. /**
  20685. * Returns the LOD level mesh at the passed distance or null if not found.
  20686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20687. * @param distance The distance from the center of the object to show this level
  20688. * @returns a Mesh or `null`
  20689. */
  20690. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20691. /**
  20692. * Remove a mesh from the LOD array
  20693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20694. * @param mesh defines the mesh to be removed
  20695. * @return This mesh (for chaining)
  20696. */
  20697. removeLODLevel(mesh: Mesh): Mesh;
  20698. /**
  20699. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20700. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20701. * @param camera defines the camera to use to compute distance
  20702. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20703. * @return This mesh (for chaining)
  20704. */
  20705. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20706. /**
  20707. * Gets the mesh internal Geometry object
  20708. */
  20709. readonly geometry: Nullable<Geometry>;
  20710. /**
  20711. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20712. * @returns the total number of vertices
  20713. */
  20714. getTotalVertices(): number;
  20715. /**
  20716. * Returns the content of an associated vertex buffer
  20717. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20718. * - VertexBuffer.PositionKind
  20719. * - VertexBuffer.UVKind
  20720. * - VertexBuffer.UV2Kind
  20721. * - VertexBuffer.UV3Kind
  20722. * - VertexBuffer.UV4Kind
  20723. * - VertexBuffer.UV5Kind
  20724. * - VertexBuffer.UV6Kind
  20725. * - VertexBuffer.ColorKind
  20726. * - VertexBuffer.MatricesIndicesKind
  20727. * - VertexBuffer.MatricesIndicesExtraKind
  20728. * - VertexBuffer.MatricesWeightsKind
  20729. * - VertexBuffer.MatricesWeightsExtraKind
  20730. * @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
  20731. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20732. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20733. */
  20734. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20735. /**
  20736. * Returns the mesh VertexBuffer object from the requested `kind`
  20737. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20738. * - VertexBuffer.PositionKind
  20739. * - VertexBuffer.UVKind
  20740. * - VertexBuffer.UV2Kind
  20741. * - VertexBuffer.UV3Kind
  20742. * - VertexBuffer.UV4Kind
  20743. * - VertexBuffer.UV5Kind
  20744. * - VertexBuffer.UV6Kind
  20745. * - VertexBuffer.ColorKind
  20746. * - VertexBuffer.MatricesIndicesKind
  20747. * - VertexBuffer.MatricesIndicesExtraKind
  20748. * - VertexBuffer.MatricesWeightsKind
  20749. * - VertexBuffer.MatricesWeightsExtraKind
  20750. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20751. */
  20752. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20753. /**
  20754. * Tests if a specific vertex buffer is associated with this mesh
  20755. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20756. * - VertexBuffer.PositionKind
  20757. * - VertexBuffer.UVKind
  20758. * - VertexBuffer.UV2Kind
  20759. * - VertexBuffer.UV3Kind
  20760. * - VertexBuffer.UV4Kind
  20761. * - VertexBuffer.UV5Kind
  20762. * - VertexBuffer.UV6Kind
  20763. * - VertexBuffer.ColorKind
  20764. * - VertexBuffer.MatricesIndicesKind
  20765. * - VertexBuffer.MatricesIndicesExtraKind
  20766. * - VertexBuffer.MatricesWeightsKind
  20767. * - VertexBuffer.MatricesWeightsExtraKind
  20768. * @returns a boolean
  20769. */
  20770. isVerticesDataPresent(kind: string): boolean;
  20771. /**
  20772. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20773. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20774. * - VertexBuffer.PositionKind
  20775. * - VertexBuffer.UVKind
  20776. * - VertexBuffer.UV2Kind
  20777. * - VertexBuffer.UV3Kind
  20778. * - VertexBuffer.UV4Kind
  20779. * - VertexBuffer.UV5Kind
  20780. * - VertexBuffer.UV6Kind
  20781. * - VertexBuffer.ColorKind
  20782. * - VertexBuffer.MatricesIndicesKind
  20783. * - VertexBuffer.MatricesIndicesExtraKind
  20784. * - VertexBuffer.MatricesWeightsKind
  20785. * - VertexBuffer.MatricesWeightsExtraKind
  20786. * @returns a boolean
  20787. */
  20788. isVertexBufferUpdatable(kind: string): boolean;
  20789. /**
  20790. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20791. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20792. * - VertexBuffer.PositionKind
  20793. * - VertexBuffer.UVKind
  20794. * - VertexBuffer.UV2Kind
  20795. * - VertexBuffer.UV3Kind
  20796. * - VertexBuffer.UV4Kind
  20797. * - VertexBuffer.UV5Kind
  20798. * - VertexBuffer.UV6Kind
  20799. * - VertexBuffer.ColorKind
  20800. * - VertexBuffer.MatricesIndicesKind
  20801. * - VertexBuffer.MatricesIndicesExtraKind
  20802. * - VertexBuffer.MatricesWeightsKind
  20803. * - VertexBuffer.MatricesWeightsExtraKind
  20804. * @returns an array of strings
  20805. */
  20806. getVerticesDataKinds(): string[];
  20807. /**
  20808. * Returns a positive integer : the total number of indices in this mesh geometry.
  20809. * @returns the numner of indices or zero if the mesh has no geometry.
  20810. */
  20811. getTotalIndices(): number;
  20812. /**
  20813. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20814. * @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.
  20815. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20816. * @returns the indices array or an empty array if the mesh has no geometry
  20817. */
  20818. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20819. readonly isBlocked: boolean;
  20820. /**
  20821. * Determine if the current mesh is ready to be rendered
  20822. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20823. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20824. * @returns true if all associated assets are ready (material, textures, shaders)
  20825. */
  20826. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20827. /**
  20828. * 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.
  20829. */
  20830. readonly areNormalsFrozen: boolean;
  20831. /**
  20832. * 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.
  20833. * @returns the current mesh
  20834. */
  20835. freezeNormals(): Mesh;
  20836. /**
  20837. * 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
  20838. * @returns the current mesh
  20839. */
  20840. unfreezeNormals(): Mesh;
  20841. /**
  20842. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20843. */
  20844. overridenInstanceCount: number;
  20845. /** @hidden */ preActivate(): Mesh;
  20846. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20847. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20848. /**
  20849. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20850. * This means the mesh underlying bounding box and sphere are recomputed.
  20851. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20852. * @returns the current mesh
  20853. */
  20854. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20855. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20856. /**
  20857. * This function will subdivide the mesh into multiple submeshes
  20858. * @param count defines the expected number of submeshes
  20859. */
  20860. subdivide(count: number): void;
  20861. /**
  20862. * Copy a FloatArray into a specific associated vertex buffer
  20863. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20864. * - VertexBuffer.PositionKind
  20865. * - VertexBuffer.UVKind
  20866. * - VertexBuffer.UV2Kind
  20867. * - VertexBuffer.UV3Kind
  20868. * - VertexBuffer.UV4Kind
  20869. * - VertexBuffer.UV5Kind
  20870. * - VertexBuffer.UV6Kind
  20871. * - VertexBuffer.ColorKind
  20872. * - VertexBuffer.MatricesIndicesKind
  20873. * - VertexBuffer.MatricesIndicesExtraKind
  20874. * - VertexBuffer.MatricesWeightsKind
  20875. * - VertexBuffer.MatricesWeightsExtraKind
  20876. * @param data defines the data source
  20877. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20878. * @param stride defines the data stride size (can be null)
  20879. * @returns the current mesh
  20880. */
  20881. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20882. /**
  20883. * Flags an associated vertex buffer as updatable
  20884. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20885. * - VertexBuffer.PositionKind
  20886. * - VertexBuffer.UVKind
  20887. * - VertexBuffer.UV2Kind
  20888. * - VertexBuffer.UV3Kind
  20889. * - VertexBuffer.UV4Kind
  20890. * - VertexBuffer.UV5Kind
  20891. * - VertexBuffer.UV6Kind
  20892. * - VertexBuffer.ColorKind
  20893. * - VertexBuffer.MatricesIndicesKind
  20894. * - VertexBuffer.MatricesIndicesExtraKind
  20895. * - VertexBuffer.MatricesWeightsKind
  20896. * - VertexBuffer.MatricesWeightsExtraKind
  20897. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20898. */
  20899. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20900. /**
  20901. * Sets the mesh global Vertex Buffer
  20902. * @param buffer defines the buffer to use
  20903. * @returns the current mesh
  20904. */
  20905. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20906. /**
  20907. * Update a specific associated vertex buffer
  20908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20909. * - VertexBuffer.PositionKind
  20910. * - VertexBuffer.UVKind
  20911. * - VertexBuffer.UV2Kind
  20912. * - VertexBuffer.UV3Kind
  20913. * - VertexBuffer.UV4Kind
  20914. * - VertexBuffer.UV5Kind
  20915. * - VertexBuffer.UV6Kind
  20916. * - VertexBuffer.ColorKind
  20917. * - VertexBuffer.MatricesIndicesKind
  20918. * - VertexBuffer.MatricesIndicesExtraKind
  20919. * - VertexBuffer.MatricesWeightsKind
  20920. * - VertexBuffer.MatricesWeightsExtraKind
  20921. * @param data defines the data source
  20922. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20923. * @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)
  20924. * @returns the current mesh
  20925. */
  20926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20927. /**
  20928. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20929. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20930. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20931. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20932. * @returns the current mesh
  20933. */
  20934. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20935. /**
  20936. * Creates a un-shared specific occurence of the geometry for the mesh.
  20937. * @returns the current mesh
  20938. */
  20939. makeGeometryUnique(): Mesh;
  20940. /**
  20941. * Set the index buffer of this mesh
  20942. * @param indices defines the source data
  20943. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20944. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20945. * @returns the current mesh
  20946. */
  20947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20948. /**
  20949. * Update the current index buffer
  20950. * @param indices defines the source data
  20951. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20952. * @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)
  20953. * @returns the current mesh
  20954. */
  20955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20956. /**
  20957. * Invert the geometry to move from a right handed system to a left handed one.
  20958. * @returns the current mesh
  20959. */
  20960. toLeftHanded(): Mesh;
  20961. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20962. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20963. /**
  20964. * Registers for this mesh a javascript function called just before the rendering process
  20965. * @param func defines the function to call before rendering this mesh
  20966. * @returns the current mesh
  20967. */
  20968. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20969. /**
  20970. * Disposes a previously registered javascript function called before the rendering
  20971. * @param func defines the function to remove
  20972. * @returns the current mesh
  20973. */
  20974. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20975. /**
  20976. * Registers for this mesh a javascript function called just after the rendering is complete
  20977. * @param func defines the function to call after rendering this mesh
  20978. * @returns the current mesh
  20979. */
  20980. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20981. /**
  20982. * Disposes a previously registered javascript function called after the rendering.
  20983. * @param func defines the function to remove
  20984. * @returns the current mesh
  20985. */
  20986. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20987. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20988. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20989. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20990. /** @hidden */ freeze(): void;
  20991. /** @hidden */ unFreeze(): void;
  20992. /**
  20993. * 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
  20994. * @param subMesh defines the subMesh to render
  20995. * @param enableAlphaMode defines if alpha mode can be changed
  20996. * @returns the current mesh
  20997. */
  20998. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20999. private _onBeforeDraw;
  21000. /**
  21001. * Renormalize the mesh and patch it up if there are no weights
  21002. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21003. * However in the case of zero weights then we set just a single influence to 1.
  21004. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21005. */
  21006. cleanMatrixWeights(): void;
  21007. private normalizeSkinFourWeights;
  21008. private normalizeSkinWeightsAndExtra;
  21009. /**
  21010. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21011. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21012. * the user know there was an issue with importing the mesh
  21013. * @returns a validation object with skinned, valid and report string
  21014. */
  21015. validateSkinning(): {
  21016. skinned: boolean;
  21017. valid: boolean;
  21018. report: string;
  21019. };
  21020. /** @hidden */ checkDelayState(): Mesh;
  21021. private _queueLoad;
  21022. /**
  21023. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21024. * A mesh is in the frustum if its bounding box intersects the frustum
  21025. * @param frustumPlanes defines the frustum to test
  21026. * @returns true if the mesh is in the frustum planes
  21027. */
  21028. isInFrustum(frustumPlanes: Plane[]): boolean;
  21029. /**
  21030. * Sets the mesh material by the material or multiMaterial `id` property
  21031. * @param id is a string identifying the material or the multiMaterial
  21032. * @returns the current mesh
  21033. */
  21034. setMaterialByID(id: string): Mesh;
  21035. /**
  21036. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21037. * @returns an array of IAnimatable
  21038. */
  21039. getAnimatables(): IAnimatable[];
  21040. /**
  21041. * Modifies the mesh geometry according to the passed transformation matrix.
  21042. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21043. * The mesh normals are modified using the same transformation.
  21044. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21045. * @param transform defines the transform matrix to use
  21046. * @see http://doc.babylonjs.com/resources/baking_transformations
  21047. * @returns the current mesh
  21048. */
  21049. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21050. /**
  21051. * Modifies the mesh geometry according to its own current World Matrix.
  21052. * The mesh World Matrix is then reset.
  21053. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21054. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21055. * @see http://doc.babylonjs.com/resources/baking_transformations
  21056. * @returns the current mesh
  21057. */
  21058. bakeCurrentTransformIntoVertices(): Mesh;
  21059. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  21060. /** @hidden */ resetPointsArrayCache(): Mesh;
  21061. /** @hidden */ generatePointsArray(): boolean;
  21062. /**
  21063. * Returns a new Mesh object generated from the current mesh properties.
  21064. * This method must not get confused with createInstance()
  21065. * @param name is a string, the name given to the new mesh
  21066. * @param newParent can be any Node object (default `null`)
  21067. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21068. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21069. * @returns a new mesh
  21070. */
  21071. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21072. /**
  21073. * Releases resources associated with this mesh.
  21074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21076. */
  21077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21078. /**
  21079. * Modifies the mesh geometry according to a displacement map.
  21080. * 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.
  21081. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21082. * @param url is a string, the URL from the image file is to be downloaded.
  21083. * @param minHeight is the lower limit of the displacement.
  21084. * @param maxHeight is the upper limit of the displacement.
  21085. * @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.
  21086. * @param uvOffset is an optional vector2 used to offset UV.
  21087. * @param uvScale is an optional vector2 used to scale UV.
  21088. * @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.
  21089. * @returns the Mesh.
  21090. */
  21091. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21092. /**
  21093. * Modifies the mesh geometry according to a displacementMap buffer.
  21094. * 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.
  21095. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21096. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21097. * @param heightMapWidth is the width of the buffer image.
  21098. * @param heightMapHeight is the height of the buffer image.
  21099. * @param minHeight is the lower limit of the displacement.
  21100. * @param maxHeight is the upper limit of the displacement.
  21101. * @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.
  21102. * @param uvOffset is an optional vector2 used to offset UV.
  21103. * @param uvScale is an optional vector2 used to scale UV.
  21104. * @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.
  21105. * @returns the Mesh.
  21106. */
  21107. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21108. /**
  21109. * Modify the mesh to get a flat shading rendering.
  21110. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21111. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21112. * @returns current mesh
  21113. */
  21114. convertToFlatShadedMesh(): Mesh;
  21115. /**
  21116. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21117. * In other words, more vertices, no more indices and a single bigger VBO.
  21118. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21119. * @returns current mesh
  21120. */
  21121. convertToUnIndexedMesh(): Mesh;
  21122. /**
  21123. * Inverses facet orientations.
  21124. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21125. * @param flipNormals will also inverts the normals
  21126. * @returns current mesh
  21127. */
  21128. flipFaces(flipNormals?: boolean): Mesh;
  21129. /**
  21130. * Increase the number of facets and hence vertices in a mesh
  21131. * Vertex normals are interpolated from existing vertex normals
  21132. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21133. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21134. */
  21135. increaseVertices(numberPerEdge: number): void;
  21136. /**
  21137. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21138. * This will undo any application of covertToFlatShadedMesh
  21139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21140. */
  21141. forceSharedVertices(): void;
  21142. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21143. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21144. /**
  21145. * Creates a new InstancedMesh object from the mesh model.
  21146. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21147. * @param name defines the name of the new instance
  21148. * @returns a new InstancedMesh
  21149. */
  21150. createInstance(name: string): InstancedMesh;
  21151. /**
  21152. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21153. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21154. * @returns the current mesh
  21155. */
  21156. synchronizeInstances(): Mesh;
  21157. /**
  21158. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21159. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21160. * This should be used together with the simplification to avoid disappearing triangles.
  21161. * @param successCallback an optional success callback to be called after the optimization finished.
  21162. * @returns the current mesh
  21163. */
  21164. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21165. /**
  21166. * Serialize current mesh
  21167. * @param serializationObject defines the object which will receive the serialization data
  21168. */
  21169. serialize(serializationObject: any): void;
  21170. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  21171. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21172. /**
  21173. * Returns a new Mesh object parsed from the source provided.
  21174. * @param parsedMesh is the source
  21175. * @param scene defines the hosting scene
  21176. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21177. * @returns a new Mesh
  21178. */
  21179. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21180. /**
  21181. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21182. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21183. * @param name defines the name of the mesh to create
  21184. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21185. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21186. * @param closePath creates a seam between the first and the last points of each path of the path array
  21187. * @param offset is taken in account only if the `pathArray` is containing a single path
  21188. * @param scene defines the hosting scene
  21189. * @param updatable defines if the mesh must be flagged as updatable
  21190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21191. * @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)
  21192. * @returns a new Mesh
  21193. */
  21194. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21195. /**
  21196. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21197. * @param name defines the name of the mesh to create
  21198. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21199. * @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
  21200. * @param scene defines the hosting scene
  21201. * @param updatable defines if the mesh must be flagged as updatable
  21202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21203. * @returns a new Mesh
  21204. */
  21205. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21206. /**
  21207. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21208. * @param name defines the name of the mesh to create
  21209. * @param size sets the size (float) of each box side (default 1)
  21210. * @param scene defines the hosting scene
  21211. * @param updatable defines if the mesh must be flagged as updatable
  21212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21213. * @returns a new Mesh
  21214. */
  21215. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21216. /**
  21217. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21218. * @param name defines the name of the mesh to create
  21219. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21220. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21221. * @param scene defines the hosting scene
  21222. * @param updatable defines if the mesh must be flagged as updatable
  21223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21224. * @returns a new Mesh
  21225. */
  21226. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21227. /**
  21228. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21229. * @param name defines the name of the mesh to create
  21230. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21231. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21232. * @param scene defines the hosting scene
  21233. * @returns a new Mesh
  21234. */
  21235. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21236. /**
  21237. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21238. * @param name defines the name of the mesh to create
  21239. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21240. * @param diameterTop set the top cap diameter (floats, default 1)
  21241. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21242. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21243. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21244. * @param scene defines the hosting scene
  21245. * @param updatable defines if the mesh must be flagged as updatable
  21246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21247. * @returns a new Mesh
  21248. */
  21249. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21250. /**
  21251. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21252. * @param name defines the name of the mesh to create
  21253. * @param diameter sets the diameter size (float) of the torus (default 1)
  21254. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21255. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21256. * @param scene defines the hosting scene
  21257. * @param updatable defines if the mesh must be flagged as updatable
  21258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21259. * @returns a new Mesh
  21260. */
  21261. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21262. /**
  21263. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21264. * @param name defines the name of the mesh to create
  21265. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21266. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21267. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21268. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21269. * @param p the number of windings on X axis (positive integers, default 2)
  21270. * @param q the number of windings on Y axis (positive integers, default 3)
  21271. * @param scene defines the hosting scene
  21272. * @param updatable defines if the mesh must be flagged as updatable
  21273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21274. * @returns a new Mesh
  21275. */
  21276. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21277. /**
  21278. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21279. * @param name defines the name of the mesh to create
  21280. * @param points is an array successive Vector3
  21281. * @param scene defines the hosting scene
  21282. * @param updatable defines if the mesh must be flagged as updatable
  21283. * @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).
  21284. * @returns a new Mesh
  21285. */
  21286. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21287. /**
  21288. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21289. * @param name defines the name of the mesh to create
  21290. * @param points is an array successive Vector3
  21291. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21292. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21293. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21294. * @param scene defines the hosting scene
  21295. * @param updatable defines if the mesh must be flagged as updatable
  21296. * @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)
  21297. * @returns a new Mesh
  21298. */
  21299. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21300. /**
  21301. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21302. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21303. * 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.
  21304. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21305. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21306. * Remember you can only change the shape positions, not their number when updating a polygon.
  21307. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21308. * @param name defines the name of the mesh to create
  21309. * @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
  21310. * @param scene defines the hosting scene
  21311. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21312. * @param updatable defines if the mesh must be flagged as updatable
  21313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21314. * @param earcutInjection can be used to inject your own earcut reference
  21315. * @returns a new Mesh
  21316. */
  21317. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21318. /**
  21319. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21320. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21321. * @param name defines the name of the mesh to create
  21322. * @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
  21323. * @param depth defines the height of extrusion
  21324. * @param scene defines the hosting scene
  21325. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21326. * @param updatable defines if the mesh must be flagged as updatable
  21327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21328. * @param earcutInjection can be used to inject your own earcut reference
  21329. * @returns a new Mesh
  21330. */
  21331. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21332. /**
  21333. * Creates an extruded shape mesh.
  21334. * 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
  21335. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21336. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21337. * @param name defines the name of the mesh to create
  21338. * @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
  21339. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21340. * @param scale is the value to scale the shape
  21341. * @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
  21342. * @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
  21343. * @param scene defines the hosting scene
  21344. * @param updatable defines if the mesh must be flagged as updatable
  21345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21346. * @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)
  21347. * @returns a new Mesh
  21348. */
  21349. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21350. /**
  21351. * Creates an custom extruded shape mesh.
  21352. * The custom extrusion is a parametric shape.
  21353. * It has no predefined shape. Its final shape will depend on the input parameters.
  21354. * Please consider using the same method from the MeshBuilder class instead
  21355. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21356. * @param name defines the name of the mesh to create
  21357. * @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
  21358. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21359. * @param scaleFunction is a custom Javascript function called on each path point
  21360. * @param rotationFunction is a custom Javascript function called on each path point
  21361. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21362. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21363. * @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
  21364. * @param scene defines the hosting scene
  21365. * @param updatable defines if the mesh must be flagged as updatable
  21366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21367. * @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)
  21368. * @returns a new Mesh
  21369. */
  21370. 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;
  21371. /**
  21372. * Creates lathe mesh.
  21373. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21374. * Please consider using the same method from the MeshBuilder class instead
  21375. * @param name defines the name of the mesh to create
  21376. * @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
  21377. * @param radius is the radius value of the lathe
  21378. * @param tessellation is the side number of the lathe.
  21379. * @param scene defines the hosting scene
  21380. * @param updatable defines if the mesh must be flagged as updatable
  21381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21382. * @returns a new Mesh
  21383. */
  21384. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21385. /**
  21386. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21387. * @param name defines the name of the mesh to create
  21388. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21389. * @param scene defines the hosting scene
  21390. * @param updatable defines if the mesh must be flagged as updatable
  21391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21392. * @returns a new Mesh
  21393. */
  21394. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21395. /**
  21396. * Creates a ground mesh.
  21397. * Please consider using the same method from the MeshBuilder class instead
  21398. * @param name defines the name of the mesh to create
  21399. * @param width set the width of the ground
  21400. * @param height set the height of the ground
  21401. * @param subdivisions sets the number of subdivisions per side
  21402. * @param scene defines the hosting scene
  21403. * @param updatable defines if the mesh must be flagged as updatable
  21404. * @returns a new Mesh
  21405. */
  21406. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21407. /**
  21408. * Creates a tiled ground mesh.
  21409. * Please consider using the same method from the MeshBuilder class instead
  21410. * @param name defines the name of the mesh to create
  21411. * @param xmin set the ground minimum X coordinate
  21412. * @param zmin set the ground minimum Y coordinate
  21413. * @param xmax set the ground maximum X coordinate
  21414. * @param zmax set the ground maximum Z coordinate
  21415. * @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
  21416. * @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
  21417. * @param scene defines the hosting scene
  21418. * @param updatable defines if the mesh must be flagged as updatable
  21419. * @returns a new Mesh
  21420. */
  21421. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21422. w: number;
  21423. h: number;
  21424. }, precision: {
  21425. w: number;
  21426. h: number;
  21427. }, scene: Scene, updatable?: boolean): Mesh;
  21428. /**
  21429. * Creates a ground mesh from a height map.
  21430. * Please consider using the same method from the MeshBuilder class instead
  21431. * @see http://doc.babylonjs.com/babylon101/height_map
  21432. * @param name defines the name of the mesh to create
  21433. * @param url sets the URL of the height map image resource
  21434. * @param width set the ground width size
  21435. * @param height set the ground height size
  21436. * @param subdivisions sets the number of subdivision per side
  21437. * @param minHeight is the minimum altitude on the ground
  21438. * @param maxHeight is the maximum altitude on the ground
  21439. * @param scene defines the hosting scene
  21440. * @param updatable defines if the mesh must be flagged as updatable
  21441. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21442. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21443. * @returns a new Mesh
  21444. */
  21445. 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;
  21446. /**
  21447. * Creates a tube mesh.
  21448. * The tube is a parametric shape.
  21449. * It has no predefined shape. Its final shape will depend on the input parameters.
  21450. * Please consider using the same method from the MeshBuilder class instead
  21451. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21452. * @param name defines the name of the mesh to create
  21453. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21454. * @param radius sets the tube radius size
  21455. * @param tessellation is the number of sides on the tubular surface
  21456. * @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
  21457. * @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
  21458. * @param scene defines the hosting scene
  21459. * @param updatable defines if the mesh must be flagged as updatable
  21460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21461. * @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)
  21462. * @returns a new Mesh
  21463. */
  21464. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21465. (i: number, distance: number): number;
  21466. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21467. /**
  21468. * Creates a polyhedron mesh.
  21469. * Please consider using the same method from the MeshBuilder class instead.
  21470. * * 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
  21471. * * The parameter `size` (positive float, default 1) sets the polygon size
  21472. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21473. * * 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`
  21474. * * 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
  21475. * * 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)`)
  21476. * * 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
  21477. * * 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
  21478. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21479. * * 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
  21480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21481. * @param name defines the name of the mesh to create
  21482. * @param options defines the options used to create the mesh
  21483. * @param scene defines the hosting scene
  21484. * @returns a new Mesh
  21485. */
  21486. static CreatePolyhedron(name: string, options: {
  21487. type?: number;
  21488. size?: number;
  21489. sizeX?: number;
  21490. sizeY?: number;
  21491. sizeZ?: number;
  21492. custom?: any;
  21493. faceUV?: Vector4[];
  21494. faceColors?: Color4[];
  21495. updatable?: boolean;
  21496. sideOrientation?: number;
  21497. }, scene: Scene): Mesh;
  21498. /**
  21499. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21500. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21501. * * 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`)
  21502. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21503. * * 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
  21504. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21505. * * 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
  21506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21507. * @param name defines the name of the mesh
  21508. * @param options defines the options used to create the mesh
  21509. * @param scene defines the hosting scene
  21510. * @returns a new Mesh
  21511. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21512. */
  21513. static CreateIcoSphere(name: string, options: {
  21514. radius?: number;
  21515. flat?: boolean;
  21516. subdivisions?: number;
  21517. sideOrientation?: number;
  21518. updatable?: boolean;
  21519. }, scene: Scene): Mesh;
  21520. /**
  21521. * Creates a decal mesh.
  21522. * Please consider using the same method from the MeshBuilder class instead.
  21523. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21524. * @param name defines the name of the mesh
  21525. * @param sourceMesh defines the mesh receiving the decal
  21526. * @param position sets the position of the decal in world coordinates
  21527. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21528. * @param size sets the decal scaling
  21529. * @param angle sets the angle to rotate the decal
  21530. * @returns a new Mesh
  21531. */
  21532. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21533. /**
  21534. * Prepare internal position array for software CPU skinning
  21535. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21536. */
  21537. setPositionsForCPUSkinning(): Float32Array;
  21538. /**
  21539. * Prepare internal normal array for software CPU skinning
  21540. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21541. */
  21542. setNormalsForCPUSkinning(): Float32Array;
  21543. /**
  21544. * Updates the vertex buffer by applying transformation from the bones
  21545. * @param skeleton defines the skeleton to apply to current mesh
  21546. * @returns the current mesh
  21547. */
  21548. applySkeleton(skeleton: Skeleton): Mesh;
  21549. /**
  21550. * 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
  21551. * @param meshes defines the list of meshes to scan
  21552. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21553. */
  21554. static MinMax(meshes: AbstractMesh[]): {
  21555. min: Vector3;
  21556. max: Vector3;
  21557. };
  21558. /**
  21559. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21560. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21561. * @returns a vector3
  21562. */
  21563. static Center(meshesOrMinMaxVector: {
  21564. min: Vector3;
  21565. max: Vector3;
  21566. } | AbstractMesh[]): Vector3;
  21567. /**
  21568. * Merge the array of meshes into a single mesh for performance reasons.
  21569. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21570. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21571. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21572. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21573. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21574. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21575. * @returns a new mesh
  21576. */
  21577. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21578. /** @hidden */
  21579. addInstance(instance: InstancedMesh): void;
  21580. /** @hidden */
  21581. removeInstance(instance: InstancedMesh): void;
  21582. }
  21583. }
  21584. declare module BABYLON {
  21585. /**
  21586. * Base class for the main features of a material in Babylon.js
  21587. */
  21588. export class Material implements IAnimatable {
  21589. /**
  21590. * Returns the triangle fill mode
  21591. */
  21592. static readonly TriangleFillMode: number;
  21593. /**
  21594. * Returns the wireframe mode
  21595. */
  21596. static readonly WireFrameFillMode: number;
  21597. /**
  21598. * Returns the point fill mode
  21599. */
  21600. static readonly PointFillMode: number;
  21601. /**
  21602. * Returns the point list draw mode
  21603. */
  21604. static readonly PointListDrawMode: number;
  21605. /**
  21606. * Returns the line list draw mode
  21607. */
  21608. static readonly LineListDrawMode: number;
  21609. /**
  21610. * Returns the line loop draw mode
  21611. */
  21612. static readonly LineLoopDrawMode: number;
  21613. /**
  21614. * Returns the line strip draw mode
  21615. */
  21616. static readonly LineStripDrawMode: number;
  21617. /**
  21618. * Returns the triangle strip draw mode
  21619. */
  21620. static readonly TriangleStripDrawMode: number;
  21621. /**
  21622. * Returns the triangle fan draw mode
  21623. */
  21624. static readonly TriangleFanDrawMode: number;
  21625. /**
  21626. * Stores the clock-wise side orientation
  21627. */
  21628. static readonly ClockWiseSideOrientation: number;
  21629. /**
  21630. * Stores the counter clock-wise side orientation
  21631. */
  21632. static readonly CounterClockWiseSideOrientation: number;
  21633. /**
  21634. * The dirty texture flag value
  21635. */
  21636. static readonly TextureDirtyFlag: number;
  21637. /**
  21638. * The dirty light flag value
  21639. */
  21640. static readonly LightDirtyFlag: number;
  21641. /**
  21642. * The dirty fresnel flag value
  21643. */
  21644. static readonly FresnelDirtyFlag: number;
  21645. /**
  21646. * The dirty attribute flag value
  21647. */
  21648. static readonly AttributesDirtyFlag: number;
  21649. /**
  21650. * The dirty misc flag value
  21651. */
  21652. static readonly MiscDirtyFlag: number;
  21653. /**
  21654. * The all dirty flag value
  21655. */
  21656. static readonly AllDirtyFlag: number;
  21657. /**
  21658. * The ID of the material
  21659. */
  21660. id: string;
  21661. /**
  21662. * Gets or sets the unique id of the material
  21663. */
  21664. uniqueId: number;
  21665. /**
  21666. * The name of the material
  21667. */
  21668. name: string;
  21669. /**
  21670. * Gets or sets user defined metadata
  21671. */
  21672. metadata: any;
  21673. /**
  21674. * For internal use only. Please do not use.
  21675. */
  21676. reservedDataStore: any;
  21677. /**
  21678. * Specifies if the ready state should be checked on each call
  21679. */
  21680. checkReadyOnEveryCall: boolean;
  21681. /**
  21682. * Specifies if the ready state should be checked once
  21683. */
  21684. checkReadyOnlyOnce: boolean;
  21685. /**
  21686. * The state of the material
  21687. */
  21688. state: string;
  21689. /**
  21690. * The alpha value of the material
  21691. */
  21692. protected _alpha: number;
  21693. /**
  21694. * List of inspectable custom properties (used by the Inspector)
  21695. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21696. */
  21697. inspectableCustomProperties: IInspectable[];
  21698. /**
  21699. * Sets the alpha value of the material
  21700. */
  21701. /**
  21702. * Gets the alpha value of the material
  21703. */
  21704. alpha: number;
  21705. /**
  21706. * Specifies if back face culling is enabled
  21707. */
  21708. protected _backFaceCulling: boolean;
  21709. /**
  21710. * Sets the back-face culling state
  21711. */
  21712. /**
  21713. * Gets the back-face culling state
  21714. */
  21715. backFaceCulling: boolean;
  21716. /**
  21717. * Stores the value for side orientation
  21718. */
  21719. sideOrientation: number;
  21720. /**
  21721. * Callback triggered when the material is compiled
  21722. */
  21723. onCompiled: Nullable<(effect: Effect) => void>;
  21724. /**
  21725. * Callback triggered when an error occurs
  21726. */
  21727. onError: Nullable<(effect: Effect, errors: string) => void>;
  21728. /**
  21729. * Callback triggered to get the render target textures
  21730. */
  21731. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21732. /**
  21733. * Gets a boolean indicating that current material needs to register RTT
  21734. */
  21735. readonly hasRenderTargetTextures: boolean;
  21736. /**
  21737. * Specifies if the material should be serialized
  21738. */
  21739. doNotSerialize: boolean;
  21740. /**
  21741. * @hidden
  21742. */ storeEffectOnSubMeshes: boolean;
  21743. /**
  21744. * Stores the animations for the material
  21745. */
  21746. animations: Nullable<Array<Animation>>;
  21747. /**
  21748. * An event triggered when the material is disposed
  21749. */
  21750. onDisposeObservable: Observable<Material>;
  21751. /**
  21752. * An observer which watches for dispose events
  21753. */
  21754. private _onDisposeObserver;
  21755. private _onUnBindObservable;
  21756. /**
  21757. * Called during a dispose event
  21758. */
  21759. onDispose: () => void;
  21760. private _onBindObservable;
  21761. /**
  21762. * An event triggered when the material is bound
  21763. */
  21764. readonly onBindObservable: Observable<AbstractMesh>;
  21765. /**
  21766. * An observer which watches for bind events
  21767. */
  21768. private _onBindObserver;
  21769. /**
  21770. * Called during a bind event
  21771. */
  21772. onBind: (Mesh: AbstractMesh) => void;
  21773. /**
  21774. * An event triggered when the material is unbound
  21775. */
  21776. readonly onUnBindObservable: Observable<Material>;
  21777. /**
  21778. * Stores the value of the alpha mode
  21779. */
  21780. private _alphaMode;
  21781. /**
  21782. * Sets the value of the alpha mode.
  21783. *
  21784. * | Value | Type | Description |
  21785. * | --- | --- | --- |
  21786. * | 0 | ALPHA_DISABLE | |
  21787. * | 1 | ALPHA_ADD | |
  21788. * | 2 | ALPHA_COMBINE | |
  21789. * | 3 | ALPHA_SUBTRACT | |
  21790. * | 4 | ALPHA_MULTIPLY | |
  21791. * | 5 | ALPHA_MAXIMIZED | |
  21792. * | 6 | ALPHA_ONEONE | |
  21793. * | 7 | ALPHA_PREMULTIPLIED | |
  21794. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21795. * | 9 | ALPHA_INTERPOLATE | |
  21796. * | 10 | ALPHA_SCREENMODE | |
  21797. *
  21798. */
  21799. /**
  21800. * Gets the value of the alpha mode
  21801. */
  21802. alphaMode: number;
  21803. /**
  21804. * Stores the state of the need depth pre-pass value
  21805. */
  21806. private _needDepthPrePass;
  21807. /**
  21808. * Sets the need depth pre-pass value
  21809. */
  21810. /**
  21811. * Gets the depth pre-pass value
  21812. */
  21813. needDepthPrePass: boolean;
  21814. /**
  21815. * Specifies if depth writing should be disabled
  21816. */
  21817. disableDepthWrite: boolean;
  21818. /**
  21819. * Specifies if depth writing should be forced
  21820. */
  21821. forceDepthWrite: boolean;
  21822. /**
  21823. * Specifies if there should be a separate pass for culling
  21824. */
  21825. separateCullingPass: boolean;
  21826. /**
  21827. * Stores the state specifing if fog should be enabled
  21828. */
  21829. private _fogEnabled;
  21830. /**
  21831. * Sets the state for enabling fog
  21832. */
  21833. /**
  21834. * Gets the value of the fog enabled state
  21835. */
  21836. fogEnabled: boolean;
  21837. /**
  21838. * Stores the size of points
  21839. */
  21840. pointSize: number;
  21841. /**
  21842. * Stores the z offset value
  21843. */
  21844. zOffset: number;
  21845. /**
  21846. * Gets a value specifying if wireframe mode is enabled
  21847. */
  21848. /**
  21849. * Sets the state of wireframe mode
  21850. */
  21851. wireframe: boolean;
  21852. /**
  21853. * Gets the value specifying if point clouds are enabled
  21854. */
  21855. /**
  21856. * Sets the state of point cloud mode
  21857. */
  21858. pointsCloud: boolean;
  21859. /**
  21860. * Gets the material fill mode
  21861. */
  21862. /**
  21863. * Sets the material fill mode
  21864. */
  21865. fillMode: number;
  21866. /**
  21867. * @hidden
  21868. * Stores the effects for the material
  21869. */ effect: Nullable<Effect>;
  21870. /**
  21871. * @hidden
  21872. * Specifies if the material was previously ready
  21873. */ wasPreviouslyReady: boolean;
  21874. /**
  21875. * Specifies if uniform buffers should be used
  21876. */
  21877. private _useUBO;
  21878. /**
  21879. * Stores a reference to the scene
  21880. */
  21881. private _scene;
  21882. /**
  21883. * Stores the fill mode state
  21884. */
  21885. private _fillMode;
  21886. /**
  21887. * Specifies if the depth write state should be cached
  21888. */
  21889. private _cachedDepthWriteState;
  21890. /**
  21891. * Stores the uniform buffer
  21892. */
  21893. protected _uniformBuffer: UniformBuffer;
  21894. /** @hidden */ indexInSceneMaterialArray: number;
  21895. /** @hidden */
  21896. meshMap: Nullable<{
  21897. [id: string]: AbstractMesh | undefined;
  21898. }>;
  21899. /**
  21900. * Creates a material instance
  21901. * @param name defines the name of the material
  21902. * @param scene defines the scene to reference
  21903. * @param doNotAdd specifies if the material should be added to the scene
  21904. */
  21905. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21906. /**
  21907. * Returns a string representation of the current material
  21908. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21909. * @returns a string with material information
  21910. */
  21911. toString(fullDetails?: boolean): string;
  21912. /**
  21913. * Gets the class name of the material
  21914. * @returns a string with the class name of the material
  21915. */
  21916. getClassName(): string;
  21917. /**
  21918. * Specifies if updates for the material been locked
  21919. */
  21920. readonly isFrozen: boolean;
  21921. /**
  21922. * Locks updates for the material
  21923. */
  21924. freeze(): void;
  21925. /**
  21926. * Unlocks updates for the material
  21927. */
  21928. unfreeze(): void;
  21929. /**
  21930. * Specifies if the material is ready to be used
  21931. * @param mesh defines the mesh to check
  21932. * @param useInstances specifies if instances should be used
  21933. * @returns a boolean indicating if the material is ready to be used
  21934. */
  21935. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21936. /**
  21937. * Specifies that the submesh is ready to be used
  21938. * @param mesh defines the mesh to check
  21939. * @param subMesh defines which submesh to check
  21940. * @param useInstances specifies that instances should be used
  21941. * @returns a boolean indicating that the submesh is ready or not
  21942. */
  21943. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21944. /**
  21945. * Returns the material effect
  21946. * @returns the effect associated with the material
  21947. */
  21948. getEffect(): Nullable<Effect>;
  21949. /**
  21950. * Returns the current scene
  21951. * @returns a Scene
  21952. */
  21953. getScene(): Scene;
  21954. /**
  21955. * Specifies if the material will require alpha blending
  21956. * @returns a boolean specifying if alpha blending is needed
  21957. */
  21958. needAlphaBlending(): boolean;
  21959. /**
  21960. * Specifies if the mesh will require alpha blending
  21961. * @param mesh defines the mesh to check
  21962. * @returns a boolean specifying if alpha blending is needed for the mesh
  21963. */
  21964. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21965. /**
  21966. * Specifies if this material should be rendered in alpha test mode
  21967. * @returns a boolean specifying if an alpha test is needed.
  21968. */
  21969. needAlphaTesting(): boolean;
  21970. /**
  21971. * Gets the texture used for the alpha test
  21972. * @returns the texture to use for alpha testing
  21973. */
  21974. getAlphaTestTexture(): Nullable<BaseTexture>;
  21975. /**
  21976. * Marks the material to indicate that it needs to be re-calculated
  21977. */
  21978. markDirty(): void;
  21979. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21980. /**
  21981. * Binds the material to the mesh
  21982. * @param world defines the world transformation matrix
  21983. * @param mesh defines the mesh to bind the material to
  21984. */
  21985. bind(world: Matrix, mesh?: Mesh): void;
  21986. /**
  21987. * Binds the submesh to the material
  21988. * @param world defines the world transformation matrix
  21989. * @param mesh defines the mesh containing the submesh
  21990. * @param subMesh defines the submesh to bind the material to
  21991. */
  21992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21993. /**
  21994. * Binds the world matrix to the material
  21995. * @param world defines the world transformation matrix
  21996. */
  21997. bindOnlyWorldMatrix(world: Matrix): void;
  21998. /**
  21999. * Binds the scene's uniform buffer to the effect.
  22000. * @param effect defines the effect to bind to the scene uniform buffer
  22001. * @param sceneUbo defines the uniform buffer storing scene data
  22002. */
  22003. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22004. /**
  22005. * Binds the view matrix to the effect
  22006. * @param effect defines the effect to bind the view matrix to
  22007. */
  22008. bindView(effect: Effect): void;
  22009. /**
  22010. * Binds the view projection matrix to the effect
  22011. * @param effect defines the effect to bind the view projection matrix to
  22012. */
  22013. bindViewProjection(effect: Effect): void;
  22014. /**
  22015. * Specifies if material alpha testing should be turned on for the mesh
  22016. * @param mesh defines the mesh to check
  22017. */
  22018. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22019. /**
  22020. * Processes to execute after binding the material to a mesh
  22021. * @param mesh defines the rendered mesh
  22022. */
  22023. protected _afterBind(mesh?: Mesh): void;
  22024. /**
  22025. * Unbinds the material from the mesh
  22026. */
  22027. unbind(): void;
  22028. /**
  22029. * Gets the active textures from the material
  22030. * @returns an array of textures
  22031. */
  22032. getActiveTextures(): BaseTexture[];
  22033. /**
  22034. * Specifies if the material uses a texture
  22035. * @param texture defines the texture to check against the material
  22036. * @returns a boolean specifying if the material uses the texture
  22037. */
  22038. hasTexture(texture: BaseTexture): boolean;
  22039. /**
  22040. * Makes a duplicate of the material, and gives it a new name
  22041. * @param name defines the new name for the duplicated material
  22042. * @returns the cloned material
  22043. */
  22044. clone(name: string): Nullable<Material>;
  22045. /**
  22046. * Gets the meshes bound to the material
  22047. * @returns an array of meshes bound to the material
  22048. */
  22049. getBindedMeshes(): AbstractMesh[];
  22050. /**
  22051. * Force shader compilation
  22052. * @param mesh defines the mesh associated with this material
  22053. * @param onCompiled defines a function to execute once the material is compiled
  22054. * @param options defines the options to configure the compilation
  22055. */
  22056. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22057. clipPlane: boolean;
  22058. }>): void;
  22059. /**
  22060. * Force shader compilation
  22061. * @param mesh defines the mesh that will use this material
  22062. * @param options defines additional options for compiling the shaders
  22063. * @returns a promise that resolves when the compilation completes
  22064. */
  22065. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22066. clipPlane: boolean;
  22067. }>): Promise<void>;
  22068. private static readonly _ImageProcessingDirtyCallBack;
  22069. private static readonly _TextureDirtyCallBack;
  22070. private static readonly _FresnelDirtyCallBack;
  22071. private static readonly _MiscDirtyCallBack;
  22072. private static readonly _LightsDirtyCallBack;
  22073. private static readonly _AttributeDirtyCallBack;
  22074. private static _FresnelAndMiscDirtyCallBack;
  22075. private static _TextureAndMiscDirtyCallBack;
  22076. private static readonly _DirtyCallbackArray;
  22077. private static readonly _RunDirtyCallBacks;
  22078. /**
  22079. * Marks a define in the material to indicate that it needs to be re-computed
  22080. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22081. */
  22082. markAsDirty(flag: number): void;
  22083. /**
  22084. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22085. * @param func defines a function which checks material defines against the submeshes
  22086. */
  22087. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22088. /**
  22089. * Indicates that image processing needs to be re-calculated for all submeshes
  22090. */
  22091. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22092. /**
  22093. * Indicates that textures need to be re-calculated for all submeshes
  22094. */
  22095. protected _markAllSubMeshesAsTexturesDirty(): void;
  22096. /**
  22097. * Indicates that fresnel needs to be re-calculated for all submeshes
  22098. */
  22099. protected _markAllSubMeshesAsFresnelDirty(): void;
  22100. /**
  22101. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22102. */
  22103. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22104. /**
  22105. * Indicates that lights need to be re-calculated for all submeshes
  22106. */
  22107. protected _markAllSubMeshesAsLightsDirty(): void;
  22108. /**
  22109. * Indicates that attributes need to be re-calculated for all submeshes
  22110. */
  22111. protected _markAllSubMeshesAsAttributesDirty(): void;
  22112. /**
  22113. * Indicates that misc needs to be re-calculated for all submeshes
  22114. */
  22115. protected _markAllSubMeshesAsMiscDirty(): void;
  22116. /**
  22117. * Indicates that textures and misc need to be re-calculated for all submeshes
  22118. */
  22119. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22120. /**
  22121. * Disposes the material
  22122. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22123. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22124. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22125. */
  22126. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22127. /** @hidden */
  22128. private releaseVertexArrayObject;
  22129. /**
  22130. * Serializes this material
  22131. * @returns the serialized material object
  22132. */
  22133. serialize(): any;
  22134. /**
  22135. * Creates a material from parsed material data
  22136. * @param parsedMaterial defines parsed material data
  22137. * @param scene defines the hosting scene
  22138. * @param rootUrl defines the root URL to use to load textures
  22139. * @returns a new material
  22140. */
  22141. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22142. }
  22143. }
  22144. declare module BABYLON {
  22145. /**
  22146. * Base class for submeshes
  22147. */
  22148. export class BaseSubMesh {
  22149. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  22150. /** @hidden */ materialEffect: Nullable<Effect>;
  22151. /**
  22152. * Gets associated effect
  22153. */
  22154. readonly effect: Nullable<Effect>;
  22155. /**
  22156. * Sets associated effect (effect used to render this submesh)
  22157. * @param effect defines the effect to associate with
  22158. * @param defines defines the set of defines used to compile this effect
  22159. */
  22160. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22161. }
  22162. /**
  22163. * Defines a subdivision inside a mesh
  22164. */
  22165. export class SubMesh extends BaseSubMesh implements ICullable {
  22166. /** the material index to use */
  22167. materialIndex: number;
  22168. /** vertex index start */
  22169. verticesStart: number;
  22170. /** vertices count */
  22171. verticesCount: number;
  22172. /** index start */
  22173. indexStart: number;
  22174. /** indices count */
  22175. indexCount: number;
  22176. /** @hidden */ linesIndexCount: number;
  22177. private _mesh;
  22178. private _renderingMesh;
  22179. private _boundingInfo;
  22180. private _linesIndexBuffer;
  22181. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  22182. /** @hidden */ trianglePlanes: Plane[];
  22183. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  22184. /** @hidden */ renderId: number;
  22185. /** @hidden */ alphaIndex: number;
  22186. /** @hidden */ distanceToCamera: number;
  22187. /** @hidden */ id: number;
  22188. private _currentMaterial;
  22189. /**
  22190. * Add a new submesh to a mesh
  22191. * @param materialIndex defines the material index to use
  22192. * @param verticesStart defines vertex index start
  22193. * @param verticesCount defines vertices count
  22194. * @param indexStart defines index start
  22195. * @param indexCount defines indices count
  22196. * @param mesh defines the parent mesh
  22197. * @param renderingMesh defines an optional rendering mesh
  22198. * @param createBoundingBox defines if bounding box should be created for this submesh
  22199. * @returns the new submesh
  22200. */
  22201. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22202. /**
  22203. * Creates a new submesh
  22204. * @param materialIndex defines the material index to use
  22205. * @param verticesStart defines vertex index start
  22206. * @param verticesCount defines vertices count
  22207. * @param indexStart defines index start
  22208. * @param indexCount defines indices count
  22209. * @param mesh defines the parent mesh
  22210. * @param renderingMesh defines an optional rendering mesh
  22211. * @param createBoundingBox defines if bounding box should be created for this submesh
  22212. */
  22213. constructor(
  22214. /** the material index to use */
  22215. materialIndex: number,
  22216. /** vertex index start */
  22217. verticesStart: number,
  22218. /** vertices count */
  22219. verticesCount: number,
  22220. /** index start */
  22221. indexStart: number,
  22222. /** indices count */
  22223. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22224. /**
  22225. * Returns true if this submesh covers the entire parent mesh
  22226. * @ignorenaming
  22227. */
  22228. readonly IsGlobal: boolean;
  22229. /**
  22230. * Returns the submesh BoudingInfo object
  22231. * @returns current bounding info (or mesh's one if the submesh is global)
  22232. */
  22233. getBoundingInfo(): BoundingInfo;
  22234. /**
  22235. * Sets the submesh BoundingInfo
  22236. * @param boundingInfo defines the new bounding info to use
  22237. * @returns the SubMesh
  22238. */
  22239. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22240. /**
  22241. * Returns the mesh of the current submesh
  22242. * @return the parent mesh
  22243. */
  22244. getMesh(): AbstractMesh;
  22245. /**
  22246. * Returns the rendering mesh of the submesh
  22247. * @returns the rendering mesh (could be different from parent mesh)
  22248. */
  22249. getRenderingMesh(): Mesh;
  22250. /**
  22251. * Returns the submesh material
  22252. * @returns null or the current material
  22253. */
  22254. getMaterial(): Nullable<Material>;
  22255. /**
  22256. * Sets a new updated BoundingInfo object to the submesh
  22257. * @param data defines an optional position array to use to determine the bounding info
  22258. * @returns the SubMesh
  22259. */
  22260. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22261. /** @hidden */ checkCollision(collider: Collider): boolean;
  22262. /**
  22263. * Updates the submesh BoundingInfo
  22264. * @param world defines the world matrix to use to update the bounding info
  22265. * @returns the submesh
  22266. */
  22267. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22268. /**
  22269. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22270. * @param frustumPlanes defines the frustum planes
  22271. * @returns true if the submesh is intersecting with the frustum
  22272. */
  22273. isInFrustum(frustumPlanes: Plane[]): boolean;
  22274. /**
  22275. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22276. * @param frustumPlanes defines the frustum planes
  22277. * @returns true if the submesh is inside the frustum
  22278. */
  22279. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22280. /**
  22281. * Renders the submesh
  22282. * @param enableAlphaMode defines if alpha needs to be used
  22283. * @returns the submesh
  22284. */
  22285. render(enableAlphaMode: boolean): SubMesh;
  22286. /**
  22287. * @hidden
  22288. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22289. /**
  22290. * Checks if the submesh intersects with a ray
  22291. * @param ray defines the ray to test
  22292. * @returns true is the passed ray intersects the submesh bounding box
  22293. */
  22294. canIntersects(ray: Ray): boolean;
  22295. /**
  22296. * Intersects current submesh with a ray
  22297. * @param ray defines the ray to test
  22298. * @param positions defines mesh's positions array
  22299. * @param indices defines mesh's indices array
  22300. * @param fastCheck defines if only bounding info should be used
  22301. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22302. * @returns intersection info or null if no intersection
  22303. */
  22304. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22305. /** @hidden */
  22306. private _intersectLines;
  22307. /** @hidden */
  22308. private _intersectTriangles;
  22309. /** @hidden */
  22310. private _intersectUnIndexedTriangles;
  22311. /** @hidden */ rebuild(): void;
  22312. /**
  22313. * Creates a new submesh from the passed mesh
  22314. * @param newMesh defines the new hosting mesh
  22315. * @param newRenderingMesh defines an optional rendering mesh
  22316. * @returns the new submesh
  22317. */
  22318. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22319. /**
  22320. * Release associated resources
  22321. */
  22322. dispose(): void;
  22323. /**
  22324. * Gets the class name
  22325. * @returns the string "SubMesh".
  22326. */
  22327. getClassName(): string;
  22328. /**
  22329. * Creates a new submesh from indices data
  22330. * @param materialIndex the index of the main mesh material
  22331. * @param startIndex the index where to start the copy in the mesh indices array
  22332. * @param indexCount the number of indices to copy then from the startIndex
  22333. * @param mesh the main mesh to create the submesh from
  22334. * @param renderingMesh the optional rendering mesh
  22335. * @returns a new submesh
  22336. */
  22337. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22338. }
  22339. }
  22340. declare module BABYLON {
  22341. /**
  22342. * Class used to store geometry data (vertex buffers + index buffer)
  22343. */
  22344. export class Geometry implements IGetSetVerticesData {
  22345. /**
  22346. * Gets or sets the ID of the geometry
  22347. */
  22348. id: string;
  22349. /**
  22350. * Gets or sets the unique ID of the geometry
  22351. */
  22352. uniqueId: number;
  22353. /**
  22354. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22355. */
  22356. delayLoadState: number;
  22357. /**
  22358. * Gets the file containing the data to load when running in delay load state
  22359. */
  22360. delayLoadingFile: Nullable<string>;
  22361. /**
  22362. * Callback called when the geometry is updated
  22363. */
  22364. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22365. private _scene;
  22366. private _engine;
  22367. private _meshes;
  22368. private _totalVertices;
  22369. /** @hidden */ indices: IndicesArray;
  22370. /** @hidden */ vertexBuffers: {
  22371. [key: string]: VertexBuffer;
  22372. };
  22373. private _isDisposed;
  22374. private _extend;
  22375. private _boundingBias;
  22376. /** @hidden */ delayInfo: Array<string>;
  22377. private _indexBuffer;
  22378. private _indexBufferIsUpdatable;
  22379. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22380. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22381. /** @hidden */ softwareSkinningFrameId: number;
  22382. private _vertexArrayObjects;
  22383. private _updatable;
  22384. /** @hidden */ positions: Nullable<Vector3[]>;
  22385. /**
  22386. * 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
  22387. */
  22388. /**
  22389. * 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
  22390. */
  22391. boundingBias: Vector2;
  22392. /**
  22393. * Static function used to attach a new empty geometry to a mesh
  22394. * @param mesh defines the mesh to attach the geometry to
  22395. * @returns the new Geometry
  22396. */
  22397. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22398. /**
  22399. * Creates a new geometry
  22400. * @param id defines the unique ID
  22401. * @param scene defines the hosting scene
  22402. * @param vertexData defines the VertexData used to get geometry data
  22403. * @param updatable defines if geometry must be updatable (false by default)
  22404. * @param mesh defines the mesh that will be associated with the geometry
  22405. */
  22406. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22407. /**
  22408. * Gets the current extend of the geometry
  22409. */
  22410. readonly extend: {
  22411. minimum: Vector3;
  22412. maximum: Vector3;
  22413. };
  22414. /**
  22415. * Gets the hosting scene
  22416. * @returns the hosting Scene
  22417. */
  22418. getScene(): Scene;
  22419. /**
  22420. * Gets the hosting engine
  22421. * @returns the hosting Engine
  22422. */
  22423. getEngine(): Engine;
  22424. /**
  22425. * Defines if the geometry is ready to use
  22426. * @returns true if the geometry is ready to be used
  22427. */
  22428. isReady(): boolean;
  22429. /**
  22430. * Gets a value indicating that the geometry should not be serialized
  22431. */
  22432. readonly doNotSerialize: boolean;
  22433. /** @hidden */ rebuild(): void;
  22434. /**
  22435. * Affects all geometry data in one call
  22436. * @param vertexData defines the geometry data
  22437. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22438. */
  22439. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22440. /**
  22441. * Set specific vertex data
  22442. * @param kind defines the data kind (Position, normal, etc...)
  22443. * @param data defines the vertex data to use
  22444. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22445. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22446. */
  22447. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22448. /**
  22449. * Removes a specific vertex data
  22450. * @param kind defines the data kind (Position, normal, etc...)
  22451. */
  22452. removeVerticesData(kind: string): void;
  22453. /**
  22454. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22455. * @param buffer defines the vertex buffer to use
  22456. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22457. */
  22458. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22459. /**
  22460. * Update a specific vertex buffer
  22461. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22462. * It will do nothing if the buffer is not updatable
  22463. * @param kind defines the data kind (Position, normal, etc...)
  22464. * @param data defines the data to use
  22465. * @param offset defines the offset in the target buffer where to store the data
  22466. * @param useBytes set to true if the offset is in bytes
  22467. */
  22468. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22469. /**
  22470. * Update a specific vertex buffer
  22471. * This function will create a new buffer if the current one is not updatable
  22472. * @param kind defines the data kind (Position, normal, etc...)
  22473. * @param data defines the data to use
  22474. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22475. */
  22476. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22477. private _updateBoundingInfo;
  22478. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22479. /**
  22480. * Gets total number of vertices
  22481. * @returns the total number of vertices
  22482. */
  22483. getTotalVertices(): number;
  22484. /**
  22485. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22486. * @param kind defines the data kind (Position, normal, etc...)
  22487. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22488. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22489. * @returns a float array containing vertex data
  22490. */
  22491. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22492. /**
  22493. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22494. * @param kind defines the data kind (Position, normal, etc...)
  22495. * @returns true if the vertex buffer with the specified kind is updatable
  22496. */
  22497. isVertexBufferUpdatable(kind: string): boolean;
  22498. /**
  22499. * Gets a specific vertex buffer
  22500. * @param kind defines the data kind (Position, normal, etc...)
  22501. * @returns a VertexBuffer
  22502. */
  22503. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22504. /**
  22505. * Returns all vertex buffers
  22506. * @return an object holding all vertex buffers indexed by kind
  22507. */
  22508. getVertexBuffers(): Nullable<{
  22509. [key: string]: VertexBuffer;
  22510. }>;
  22511. /**
  22512. * Gets a boolean indicating if specific vertex buffer is present
  22513. * @param kind defines the data kind (Position, normal, etc...)
  22514. * @returns true if data is present
  22515. */
  22516. isVerticesDataPresent(kind: string): boolean;
  22517. /**
  22518. * Gets a list of all attached data kinds (Position, normal, etc...)
  22519. * @returns a list of string containing all kinds
  22520. */
  22521. getVerticesDataKinds(): string[];
  22522. /**
  22523. * Update index buffer
  22524. * @param indices defines the indices to store in the index buffer
  22525. * @param offset defines the offset in the target buffer where to store the data
  22526. * @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)
  22527. */
  22528. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22529. /**
  22530. * Creates a new index buffer
  22531. * @param indices defines the indices to store in the index buffer
  22532. * @param totalVertices defines the total number of vertices (could be null)
  22533. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22534. */
  22535. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22536. /**
  22537. * Return the total number of indices
  22538. * @returns the total number of indices
  22539. */
  22540. getTotalIndices(): number;
  22541. /**
  22542. * Gets the index buffer array
  22543. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22544. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22545. * @returns the index buffer array
  22546. */
  22547. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22548. /**
  22549. * Gets the index buffer
  22550. * @return the index buffer
  22551. */
  22552. getIndexBuffer(): Nullable<DataBuffer>;
  22553. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22554. /**
  22555. * Release the associated resources for a specific mesh
  22556. * @param mesh defines the source mesh
  22557. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22558. */
  22559. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22560. /**
  22561. * Apply current geometry to a given mesh
  22562. * @param mesh defines the mesh to apply geometry to
  22563. */
  22564. applyToMesh(mesh: Mesh): void;
  22565. private _updateExtend;
  22566. private _applyToMesh;
  22567. private notifyUpdate;
  22568. /**
  22569. * Load the geometry if it was flagged as delay loaded
  22570. * @param scene defines the hosting scene
  22571. * @param onLoaded defines a callback called when the geometry is loaded
  22572. */
  22573. load(scene: Scene, onLoaded?: () => void): void;
  22574. private _queueLoad;
  22575. /**
  22576. * Invert the geometry to move from a right handed system to a left handed one.
  22577. */
  22578. toLeftHanded(): void;
  22579. /** @hidden */ resetPointsArrayCache(): void;
  22580. /** @hidden */ generatePointsArray(): boolean;
  22581. /**
  22582. * Gets a value indicating if the geometry is disposed
  22583. * @returns true if the geometry was disposed
  22584. */
  22585. isDisposed(): boolean;
  22586. private _disposeVertexArrayObjects;
  22587. /**
  22588. * Free all associated resources
  22589. */
  22590. dispose(): void;
  22591. /**
  22592. * Clone the current geometry into a new geometry
  22593. * @param id defines the unique ID of the new geometry
  22594. * @returns a new geometry object
  22595. */
  22596. copy(id: string): Geometry;
  22597. /**
  22598. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22599. * @return a JSON representation of the current geometry data (without the vertices data)
  22600. */
  22601. serialize(): any;
  22602. private toNumberArray;
  22603. /**
  22604. * Serialize all vertices data into a JSON oject
  22605. * @returns a JSON representation of the current geometry data
  22606. */
  22607. serializeVerticeData(): any;
  22608. /**
  22609. * Extracts a clone of a mesh geometry
  22610. * @param mesh defines the source mesh
  22611. * @param id defines the unique ID of the new geometry object
  22612. * @returns the new geometry object
  22613. */
  22614. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22615. /**
  22616. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22617. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22618. * Be aware Math.random() could cause collisions, but:
  22619. * "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"
  22620. * @returns a string containing a new GUID
  22621. */
  22622. static RandomId(): string;
  22623. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22624. private static _CleanMatricesWeights;
  22625. /**
  22626. * Create a new geometry from persisted data (Using .babylon file format)
  22627. * @param parsedVertexData defines the persisted data
  22628. * @param scene defines the hosting scene
  22629. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22630. * @returns the new geometry object
  22631. */
  22632. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22633. }
  22634. }
  22635. declare module BABYLON {
  22636. /**
  22637. * Define an interface for all classes that will get and set the data on vertices
  22638. */
  22639. export interface IGetSetVerticesData {
  22640. /**
  22641. * Gets a boolean indicating if specific vertex data is present
  22642. * @param kind defines the vertex data kind to use
  22643. * @returns true is data kind is present
  22644. */
  22645. isVerticesDataPresent(kind: string): boolean;
  22646. /**
  22647. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22648. * @param kind defines the data kind (Position, normal, etc...)
  22649. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22651. * @returns a float array containing vertex data
  22652. */
  22653. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22654. /**
  22655. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22656. * @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.
  22657. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22658. * @returns the indices array or an empty array if the mesh has no geometry
  22659. */
  22660. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22661. /**
  22662. * Set specific vertex data
  22663. * @param kind defines the data kind (Position, normal, etc...)
  22664. * @param data defines the vertex data to use
  22665. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22666. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22667. */
  22668. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22669. /**
  22670. * Update a specific associated vertex buffer
  22671. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22672. * - VertexBuffer.PositionKind
  22673. * - VertexBuffer.UVKind
  22674. * - VertexBuffer.UV2Kind
  22675. * - VertexBuffer.UV3Kind
  22676. * - VertexBuffer.UV4Kind
  22677. * - VertexBuffer.UV5Kind
  22678. * - VertexBuffer.UV6Kind
  22679. * - VertexBuffer.ColorKind
  22680. * - VertexBuffer.MatricesIndicesKind
  22681. * - VertexBuffer.MatricesIndicesExtraKind
  22682. * - VertexBuffer.MatricesWeightsKind
  22683. * - VertexBuffer.MatricesWeightsExtraKind
  22684. * @param data defines the data source
  22685. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22686. * @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)
  22687. */
  22688. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22689. /**
  22690. * Creates a new index buffer
  22691. * @param indices defines the indices to store in the index buffer
  22692. * @param totalVertices defines the total number of vertices (could be null)
  22693. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22694. */
  22695. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22696. }
  22697. /**
  22698. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22699. */
  22700. export class VertexData {
  22701. /**
  22702. * Mesh side orientation : usually the external or front surface
  22703. */
  22704. static readonly FRONTSIDE: number;
  22705. /**
  22706. * Mesh side orientation : usually the internal or back surface
  22707. */
  22708. static readonly BACKSIDE: number;
  22709. /**
  22710. * Mesh side orientation : both internal and external or front and back surfaces
  22711. */
  22712. static readonly DOUBLESIDE: number;
  22713. /**
  22714. * Mesh side orientation : by default, `FRONTSIDE`
  22715. */
  22716. static readonly DEFAULTSIDE: number;
  22717. /**
  22718. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22719. */
  22720. positions: Nullable<FloatArray>;
  22721. /**
  22722. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22723. */
  22724. normals: Nullable<FloatArray>;
  22725. /**
  22726. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22727. */
  22728. tangents: Nullable<FloatArray>;
  22729. /**
  22730. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22731. */
  22732. uvs: Nullable<FloatArray>;
  22733. /**
  22734. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22735. */
  22736. uvs2: Nullable<FloatArray>;
  22737. /**
  22738. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22739. */
  22740. uvs3: Nullable<FloatArray>;
  22741. /**
  22742. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22743. */
  22744. uvs4: Nullable<FloatArray>;
  22745. /**
  22746. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22747. */
  22748. uvs5: Nullable<FloatArray>;
  22749. /**
  22750. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22751. */
  22752. uvs6: Nullable<FloatArray>;
  22753. /**
  22754. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22755. */
  22756. colors: Nullable<FloatArray>;
  22757. /**
  22758. * 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).
  22759. */
  22760. matricesIndices: Nullable<FloatArray>;
  22761. /**
  22762. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22763. */
  22764. matricesWeights: Nullable<FloatArray>;
  22765. /**
  22766. * An array extending the number of possible indices
  22767. */
  22768. matricesIndicesExtra: Nullable<FloatArray>;
  22769. /**
  22770. * An array extending the number of possible weights when the number of indices is extended
  22771. */
  22772. matricesWeightsExtra: Nullable<FloatArray>;
  22773. /**
  22774. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22775. */
  22776. indices: Nullable<IndicesArray>;
  22777. /**
  22778. * Uses the passed data array to set the set the values for the specified kind of data
  22779. * @param data a linear array of floating numbers
  22780. * @param kind the type of data that is being set, eg positions, colors etc
  22781. */
  22782. set(data: FloatArray, kind: string): void;
  22783. /**
  22784. * Associates the vertexData to the passed Mesh.
  22785. * Sets it as updatable or not (default `false`)
  22786. * @param mesh the mesh the vertexData is applied to
  22787. * @param updatable when used and having the value true allows new data to update the vertexData
  22788. * @returns the VertexData
  22789. */
  22790. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22791. /**
  22792. * Associates the vertexData to the passed Geometry.
  22793. * Sets it as updatable or not (default `false`)
  22794. * @param geometry the geometry the vertexData is applied to
  22795. * @param updatable when used and having the value true allows new data to update the vertexData
  22796. * @returns VertexData
  22797. */
  22798. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22799. /**
  22800. * Updates the associated mesh
  22801. * @param mesh the mesh to be updated
  22802. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22803. * @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
  22804. * @returns VertexData
  22805. */
  22806. updateMesh(mesh: Mesh): VertexData;
  22807. /**
  22808. * Updates the associated geometry
  22809. * @param geometry the geometry to be updated
  22810. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22811. * @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
  22812. * @returns VertexData.
  22813. */
  22814. updateGeometry(geometry: Geometry): VertexData;
  22815. private _applyTo;
  22816. private _update;
  22817. /**
  22818. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22819. * @param matrix the transforming matrix
  22820. * @returns the VertexData
  22821. */
  22822. transform(matrix: Matrix): VertexData;
  22823. /**
  22824. * Merges the passed VertexData into the current one
  22825. * @param other the VertexData to be merged into the current one
  22826. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22827. * @returns the modified VertexData
  22828. */
  22829. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22830. private _mergeElement;
  22831. private _validate;
  22832. /**
  22833. * Serializes the VertexData
  22834. * @returns a serialized object
  22835. */
  22836. serialize(): any;
  22837. /**
  22838. * Extracts the vertexData from a mesh
  22839. * @param mesh the mesh from which to extract the VertexData
  22840. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22841. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22842. * @returns the object VertexData associated to the passed mesh
  22843. */
  22844. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22845. /**
  22846. * Extracts the vertexData from the geometry
  22847. * @param geometry the geometry from which to extract the VertexData
  22848. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22849. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22850. * @returns the object VertexData associated to the passed mesh
  22851. */
  22852. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22853. private static _ExtractFrom;
  22854. /**
  22855. * Creates the VertexData for a Ribbon
  22856. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22857. * * pathArray array of paths, each of which an array of successive Vector3
  22858. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22859. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22860. * * 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
  22861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22862. * * 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)
  22863. * * 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)
  22864. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22865. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22866. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22867. * @returns the VertexData of the ribbon
  22868. */
  22869. static CreateRibbon(options: {
  22870. pathArray: Vector3[][];
  22871. closeArray?: boolean;
  22872. closePath?: boolean;
  22873. offset?: number;
  22874. sideOrientation?: number;
  22875. frontUVs?: Vector4;
  22876. backUVs?: Vector4;
  22877. invertUV?: boolean;
  22878. uvs?: Vector2[];
  22879. colors?: Color4[];
  22880. }): VertexData;
  22881. /**
  22882. * Creates the VertexData for a box
  22883. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22884. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22885. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22886. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22887. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22888. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22889. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22891. * * 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)
  22892. * * 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)
  22893. * @returns the VertexData of the box
  22894. */
  22895. static CreateBox(options: {
  22896. size?: number;
  22897. width?: number;
  22898. height?: number;
  22899. depth?: number;
  22900. faceUV?: Vector4[];
  22901. faceColors?: Color4[];
  22902. sideOrientation?: number;
  22903. frontUVs?: Vector4;
  22904. backUVs?: Vector4;
  22905. }): VertexData;
  22906. /**
  22907. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22908. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22909. * * segments sets the number of horizontal strips optional, default 32
  22910. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22911. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22912. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22913. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22914. * * 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
  22915. * * 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
  22916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22917. * * 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)
  22918. * * 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)
  22919. * @returns the VertexData of the ellipsoid
  22920. */
  22921. static CreateSphere(options: {
  22922. segments?: number;
  22923. diameter?: number;
  22924. diameterX?: number;
  22925. diameterY?: number;
  22926. diameterZ?: number;
  22927. arc?: number;
  22928. slice?: number;
  22929. sideOrientation?: number;
  22930. frontUVs?: Vector4;
  22931. backUVs?: Vector4;
  22932. }): VertexData;
  22933. /**
  22934. * Creates the VertexData for a cylinder, cone or prism
  22935. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22936. * * height sets the height (y direction) of the cylinder, optional, default 2
  22937. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22938. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22939. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22940. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22941. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22942. * * 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
  22943. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22944. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22945. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22946. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22948. * * 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)
  22949. * * 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)
  22950. * @returns the VertexData of the cylinder, cone or prism
  22951. */
  22952. static CreateCylinder(options: {
  22953. height?: number;
  22954. diameterTop?: number;
  22955. diameterBottom?: number;
  22956. diameter?: number;
  22957. tessellation?: number;
  22958. subdivisions?: number;
  22959. arc?: number;
  22960. faceColors?: Color4[];
  22961. faceUV?: Vector4[];
  22962. hasRings?: boolean;
  22963. enclose?: boolean;
  22964. sideOrientation?: number;
  22965. frontUVs?: Vector4;
  22966. backUVs?: Vector4;
  22967. }): VertexData;
  22968. /**
  22969. * Creates the VertexData for a torus
  22970. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22971. * * diameter the diameter of the torus, optional default 1
  22972. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22973. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22975. * * 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)
  22976. * * 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)
  22977. * @returns the VertexData of the torus
  22978. */
  22979. static CreateTorus(options: {
  22980. diameter?: number;
  22981. thickness?: number;
  22982. tessellation?: number;
  22983. sideOrientation?: number;
  22984. frontUVs?: Vector4;
  22985. backUVs?: Vector4;
  22986. }): VertexData;
  22987. /**
  22988. * Creates the VertexData of the LineSystem
  22989. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22990. * - lines an array of lines, each line being an array of successive Vector3
  22991. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22992. * @returns the VertexData of the LineSystem
  22993. */
  22994. static CreateLineSystem(options: {
  22995. lines: Vector3[][];
  22996. colors?: Nullable<Color4[][]>;
  22997. }): VertexData;
  22998. /**
  22999. * Create the VertexData for a DashedLines
  23000. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23001. * - points an array successive Vector3
  23002. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23003. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23004. * - dashNb the intended total number of dashes, optional, default 200
  23005. * @returns the VertexData for the DashedLines
  23006. */
  23007. static CreateDashedLines(options: {
  23008. points: Vector3[];
  23009. dashSize?: number;
  23010. gapSize?: number;
  23011. dashNb?: number;
  23012. }): VertexData;
  23013. /**
  23014. * Creates the VertexData for a Ground
  23015. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23016. * - width the width (x direction) of the ground, optional, default 1
  23017. * - height the height (z direction) of the ground, optional, default 1
  23018. * - subdivisions the number of subdivisions per side, optional, default 1
  23019. * @returns the VertexData of the Ground
  23020. */
  23021. static CreateGround(options: {
  23022. width?: number;
  23023. height?: number;
  23024. subdivisions?: number;
  23025. subdivisionsX?: number;
  23026. subdivisionsY?: number;
  23027. }): VertexData;
  23028. /**
  23029. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23030. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23031. * * xmin the ground minimum X coordinate, optional, default -1
  23032. * * zmin the ground minimum Z coordinate, optional, default -1
  23033. * * xmax the ground maximum X coordinate, optional, default 1
  23034. * * zmax the ground maximum Z coordinate, optional, default 1
  23035. * * 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}
  23036. * * 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}
  23037. * @returns the VertexData of the TiledGround
  23038. */
  23039. static CreateTiledGround(options: {
  23040. xmin: number;
  23041. zmin: number;
  23042. xmax: number;
  23043. zmax: number;
  23044. subdivisions?: {
  23045. w: number;
  23046. h: number;
  23047. };
  23048. precision?: {
  23049. w: number;
  23050. h: number;
  23051. };
  23052. }): VertexData;
  23053. /**
  23054. * Creates the VertexData of the Ground designed from a heightmap
  23055. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23056. * * width the width (x direction) of the ground
  23057. * * height the height (z direction) of the ground
  23058. * * subdivisions the number of subdivisions per side
  23059. * * minHeight the minimum altitude on the ground, optional, default 0
  23060. * * maxHeight the maximum altitude on the ground, optional default 1
  23061. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23062. * * buffer the array holding the image color data
  23063. * * bufferWidth the width of image
  23064. * * bufferHeight the height of image
  23065. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23066. * @returns the VertexData of the Ground designed from a heightmap
  23067. */
  23068. static CreateGroundFromHeightMap(options: {
  23069. width: number;
  23070. height: number;
  23071. subdivisions: number;
  23072. minHeight: number;
  23073. maxHeight: number;
  23074. colorFilter: Color3;
  23075. buffer: Uint8Array;
  23076. bufferWidth: number;
  23077. bufferHeight: number;
  23078. alphaFilter: number;
  23079. }): VertexData;
  23080. /**
  23081. * Creates the VertexData for a Plane
  23082. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23083. * * size sets the width and height of the plane to the value of size, optional default 1
  23084. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23085. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23087. * * 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)
  23088. * * 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)
  23089. * @returns the VertexData of the box
  23090. */
  23091. static CreatePlane(options: {
  23092. size?: number;
  23093. width?: number;
  23094. height?: number;
  23095. sideOrientation?: number;
  23096. frontUVs?: Vector4;
  23097. backUVs?: Vector4;
  23098. }): VertexData;
  23099. /**
  23100. * Creates the VertexData of the Disc or regular Polygon
  23101. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23102. * * radius the radius of the disc, optional default 0.5
  23103. * * tessellation the number of polygon sides, optional, default 64
  23104. * * 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
  23105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23106. * * 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)
  23107. * * 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)
  23108. * @returns the VertexData of the box
  23109. */
  23110. static CreateDisc(options: {
  23111. radius?: number;
  23112. tessellation?: number;
  23113. arc?: number;
  23114. sideOrientation?: number;
  23115. frontUVs?: Vector4;
  23116. backUVs?: Vector4;
  23117. }): VertexData;
  23118. /**
  23119. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23120. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23121. * @param polygon a mesh built from polygonTriangulation.build()
  23122. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23123. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23124. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23125. * @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)
  23126. * @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)
  23127. * @returns the VertexData of the Polygon
  23128. */
  23129. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23130. /**
  23131. * Creates the VertexData of the IcoSphere
  23132. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23133. * * radius the radius of the IcoSphere, optional default 1
  23134. * * radiusX allows stretching in the x direction, optional, default radius
  23135. * * radiusY allows stretching in the y direction, optional, default radius
  23136. * * radiusZ allows stretching in the z direction, optional, default radius
  23137. * * flat when true creates a flat shaded mesh, optional, default true
  23138. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23140. * * 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)
  23141. * * 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)
  23142. * @returns the VertexData of the IcoSphere
  23143. */
  23144. static CreateIcoSphere(options: {
  23145. radius?: number;
  23146. radiusX?: number;
  23147. radiusY?: number;
  23148. radiusZ?: number;
  23149. flat?: boolean;
  23150. subdivisions?: number;
  23151. sideOrientation?: number;
  23152. frontUVs?: Vector4;
  23153. backUVs?: Vector4;
  23154. }): VertexData;
  23155. /**
  23156. * Creates the VertexData for a Polyhedron
  23157. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23158. * * type provided types are:
  23159. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23160. * * 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)
  23161. * * size the size of the IcoSphere, optional default 1
  23162. * * sizeX allows stretching in the x direction, optional, default size
  23163. * * sizeY allows stretching in the y direction, optional, default size
  23164. * * sizeZ allows stretching in the z direction, optional, default size
  23165. * * 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
  23166. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23167. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23168. * * flat when true creates a flat shaded mesh, optional, default true
  23169. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23171. * * 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)
  23172. * * 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)
  23173. * @returns the VertexData of the Polyhedron
  23174. */
  23175. static CreatePolyhedron(options: {
  23176. type?: number;
  23177. size?: number;
  23178. sizeX?: number;
  23179. sizeY?: number;
  23180. sizeZ?: number;
  23181. custom?: any;
  23182. faceUV?: Vector4[];
  23183. faceColors?: Color4[];
  23184. flat?: boolean;
  23185. sideOrientation?: number;
  23186. frontUVs?: Vector4;
  23187. backUVs?: Vector4;
  23188. }): VertexData;
  23189. /**
  23190. * Creates the VertexData for a TorusKnot
  23191. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23192. * * radius the radius of the torus knot, optional, default 2
  23193. * * tube the thickness of the tube, optional, default 0.5
  23194. * * radialSegments the number of sides on each tube segments, optional, default 32
  23195. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23196. * * p the number of windings around the z axis, optional, default 2
  23197. * * q the number of windings around the x axis, optional, default 3
  23198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23199. * * 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)
  23200. * * 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)
  23201. * @returns the VertexData of the Torus Knot
  23202. */
  23203. static CreateTorusKnot(options: {
  23204. radius?: number;
  23205. tube?: number;
  23206. radialSegments?: number;
  23207. tubularSegments?: number;
  23208. p?: number;
  23209. q?: number;
  23210. sideOrientation?: number;
  23211. frontUVs?: Vector4;
  23212. backUVs?: Vector4;
  23213. }): VertexData;
  23214. /**
  23215. * Compute normals for given positions and indices
  23216. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23217. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23218. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23219. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23220. * * facetNormals : optional array of facet normals (vector3)
  23221. * * facetPositions : optional array of facet positions (vector3)
  23222. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23223. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23224. * * bInfo : optional bounding info, required for facetPartitioning computation
  23225. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23226. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23227. * * useRightHandedSystem: optional boolean to for right handed system computation
  23228. * * depthSort : optional boolean to enable the facet depth sort computation
  23229. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23230. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23231. */
  23232. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23233. facetNormals?: any;
  23234. facetPositions?: any;
  23235. facetPartitioning?: any;
  23236. ratio?: number;
  23237. bInfo?: any;
  23238. bbSize?: Vector3;
  23239. subDiv?: any;
  23240. useRightHandedSystem?: boolean;
  23241. depthSort?: boolean;
  23242. distanceTo?: Vector3;
  23243. depthSortedFacets?: any;
  23244. }): void;
  23245. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23246. /**
  23247. * Applies VertexData created from the imported parameters to the geometry
  23248. * @param parsedVertexData the parsed data from an imported file
  23249. * @param geometry the geometry to apply the VertexData to
  23250. */
  23251. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23252. }
  23253. }
  23254. declare module BABYLON {
  23255. /**
  23256. * Class containing static functions to help procedurally build meshes
  23257. */
  23258. export class DiscBuilder {
  23259. /**
  23260. * Creates a plane polygonal mesh. By default, this is a disc
  23261. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23262. * * 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
  23263. * * 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
  23264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23265. * * 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
  23266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23267. * @param name defines the name of the mesh
  23268. * @param options defines the options used to create the mesh
  23269. * @param scene defines the hosting scene
  23270. * @returns the plane polygonal mesh
  23271. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23272. */
  23273. static CreateDisc(name: string, options: {
  23274. radius?: number;
  23275. tessellation?: number;
  23276. arc?: number;
  23277. updatable?: boolean;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }, scene?: Nullable<Scene>): Mesh;
  23282. }
  23283. }
  23284. declare module BABYLON {
  23285. /**
  23286. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23287. *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.
  23288. * The SPS is also a particle system. It provides some methods to manage the particles.
  23289. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23290. *
  23291. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23292. */
  23293. export class SolidParticleSystem implements IDisposable {
  23294. /**
  23295. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23296. * Example : var p = SPS.particles[i];
  23297. */
  23298. particles: SolidParticle[];
  23299. /**
  23300. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23301. */
  23302. nbParticles: number;
  23303. /**
  23304. * If the particles must ever face the camera (default false). Useful for planar particles.
  23305. */
  23306. billboard: boolean;
  23307. /**
  23308. * Recompute normals when adding a shape
  23309. */
  23310. recomputeNormals: boolean;
  23311. /**
  23312. * This a counter ofr your own usage. It's not set by any SPS functions.
  23313. */
  23314. counter: number;
  23315. /**
  23316. * The SPS name. This name is also given to the underlying mesh.
  23317. */
  23318. name: string;
  23319. /**
  23320. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23321. */
  23322. mesh: Mesh;
  23323. /**
  23324. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23325. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23326. */
  23327. vars: any;
  23328. /**
  23329. * This array is populated when the SPS is set as 'pickable'.
  23330. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23331. * Each element of this array is an object `{idx: int, faceId: int}`.
  23332. * `idx` is the picked particle index in the `SPS.particles` array
  23333. * `faceId` is the picked face index counted within this particle.
  23334. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23335. */
  23336. pickedParticles: {
  23337. idx: number;
  23338. faceId: number;
  23339. }[];
  23340. /**
  23341. * This array is populated when `enableDepthSort` is set to true.
  23342. * Each element of this array is an instance of the class DepthSortedParticle.
  23343. */
  23344. depthSortedParticles: DepthSortedParticle[];
  23345. /**
  23346. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23347. * @hidden
  23348. */ bSphereOnly: boolean;
  23349. /**
  23350. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23351. * @hidden
  23352. */ bSphereRadiusFactor: number;
  23353. private _scene;
  23354. private _positions;
  23355. private _indices;
  23356. private _normals;
  23357. private _colors;
  23358. private _uvs;
  23359. private _indices32;
  23360. private _positions32;
  23361. private _normals32;
  23362. private _fixedNormal32;
  23363. private _colors32;
  23364. private _uvs32;
  23365. private _index;
  23366. private _updatable;
  23367. private _pickable;
  23368. private _isVisibilityBoxLocked;
  23369. private _alwaysVisible;
  23370. private _depthSort;
  23371. private _shapeCounter;
  23372. private _copy;
  23373. private _color;
  23374. private _computeParticleColor;
  23375. private _computeParticleTexture;
  23376. private _computeParticleRotation;
  23377. private _computeParticleVertex;
  23378. private _computeBoundingBox;
  23379. private _depthSortParticles;
  23380. private _camera;
  23381. private _mustUnrotateFixedNormals;
  23382. private _particlesIntersect;
  23383. private _needs32Bits;
  23384. /**
  23385. * Creates a SPS (Solid Particle System) object.
  23386. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23387. * @param scene (Scene) is the scene in which the SPS is added.
  23388. * @param options defines the options of the sps e.g.
  23389. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23390. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23391. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23392. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23393. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23394. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23395. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23396. */
  23397. constructor(name: string, scene: Scene, options?: {
  23398. updatable?: boolean;
  23399. isPickable?: boolean;
  23400. enableDepthSort?: boolean;
  23401. particleIntersection?: boolean;
  23402. boundingSphereOnly?: boolean;
  23403. bSphereRadiusFactor?: number;
  23404. });
  23405. /**
  23406. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23407. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23408. * @returns the created mesh
  23409. */
  23410. buildMesh(): Mesh;
  23411. /**
  23412. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23413. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23414. * Thus the particles generated from `digest()` have their property `position` set yet.
  23415. * @param mesh ( Mesh ) is the mesh to be digested
  23416. * @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
  23417. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23418. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23419. * @returns the current SPS
  23420. */
  23421. digest(mesh: Mesh, options?: {
  23422. facetNb?: number;
  23423. number?: number;
  23424. delta?: number;
  23425. }): SolidParticleSystem;
  23426. private _unrotateFixedNormals;
  23427. private _resetCopy;
  23428. private _meshBuilder;
  23429. private _posToShape;
  23430. private _uvsToShapeUV;
  23431. private _addParticle;
  23432. /**
  23433. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23434. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23435. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23436. * @param nb (positive integer) the number of particles to be created from this model
  23437. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23438. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23439. * @returns the number of shapes in the system
  23440. */
  23441. addShape(mesh: Mesh, nb: number, options?: {
  23442. positionFunction?: any;
  23443. vertexFunction?: any;
  23444. }): number;
  23445. private _rebuildParticle;
  23446. /**
  23447. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23448. * @returns the SPS.
  23449. */
  23450. rebuildMesh(): SolidParticleSystem;
  23451. /**
  23452. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23453. * This method calls `updateParticle()` for each particle of the SPS.
  23454. * For an animated SPS, it is usually called within the render loop.
  23455. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23456. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23457. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23458. * @returns the SPS.
  23459. */
  23460. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23461. /**
  23462. * Disposes the SPS.
  23463. */
  23464. dispose(): void;
  23465. /**
  23466. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23468. * @returns the SPS.
  23469. */
  23470. refreshVisibleSize(): SolidParticleSystem;
  23471. /**
  23472. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23473. * @param size the size (float) of the visibility box
  23474. * note : this doesn't lock the SPS mesh bounding box.
  23475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23476. */
  23477. setVisibilityBox(size: number): void;
  23478. /**
  23479. * Gets whether the SPS as always visible or not
  23480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23481. */
  23482. /**
  23483. * Sets the SPS as always visible or not
  23484. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23485. */
  23486. isAlwaysVisible: boolean;
  23487. /**
  23488. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23489. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23490. */
  23491. /**
  23492. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23493. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23494. */
  23495. isVisibilityBoxLocked: boolean;
  23496. /**
  23497. * Tells to `setParticles()` to compute the particle rotations or not.
  23498. * Default value : true. The SPS is faster when it's set to false.
  23499. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23500. */
  23501. /**
  23502. * Gets if `setParticles()` computes the particle rotations or not.
  23503. * Default value : true. The SPS is faster when it's set to false.
  23504. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23505. */
  23506. computeParticleRotation: boolean;
  23507. /**
  23508. * Tells to `setParticles()` to compute the particle colors or not.
  23509. * Default value : true. The SPS is faster when it's set to false.
  23510. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23511. */
  23512. /**
  23513. * Gets if `setParticles()` computes the particle colors or not.
  23514. * Default value : true. The SPS is faster when it's set to false.
  23515. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23516. */
  23517. computeParticleColor: boolean;
  23518. /**
  23519. * Gets if `setParticles()` computes the particle textures or not.
  23520. * Default value : true. The SPS is faster when it's set to false.
  23521. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23522. */
  23523. computeParticleTexture: boolean;
  23524. /**
  23525. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23526. * Default value : false. The SPS is faster when it's set to false.
  23527. * Note : the particle custom vertex positions aren't stored values.
  23528. */
  23529. /**
  23530. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23531. * Default value : false. The SPS is faster when it's set to false.
  23532. * Note : the particle custom vertex positions aren't stored values.
  23533. */
  23534. computeParticleVertex: boolean;
  23535. /**
  23536. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23537. */
  23538. /**
  23539. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23540. */
  23541. computeBoundingBox: boolean;
  23542. /**
  23543. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23544. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23545. * Default : `true`
  23546. */
  23547. /**
  23548. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23549. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23550. * Default : `true`
  23551. */
  23552. depthSortParticles: boolean;
  23553. /**
  23554. * This function does nothing. It may be overwritten to set all the particle first values.
  23555. * The SPS doesn't call this function, you may have to call it by your own.
  23556. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23557. */
  23558. initParticles(): void;
  23559. /**
  23560. * This function does nothing. It may be overwritten to recycle a particle.
  23561. * The SPS doesn't call this function, you may have to call it by your own.
  23562. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23563. * @param particle The particle to recycle
  23564. * @returns the recycled particle
  23565. */
  23566. recycleParticle(particle: SolidParticle): SolidParticle;
  23567. /**
  23568. * Updates a particle : this function should be overwritten by the user.
  23569. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23570. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23571. * @example : just set a particle position or velocity and recycle conditions
  23572. * @param particle The particle to update
  23573. * @returns the updated particle
  23574. */
  23575. updateParticle(particle: SolidParticle): SolidParticle;
  23576. /**
  23577. * Updates a vertex of a particle : it can be overwritten by the user.
  23578. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23579. * @param particle the current particle
  23580. * @param vertex the current index of the current particle
  23581. * @param pt the index of the current vertex in the particle shape
  23582. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23583. * @example : just set a vertex particle position
  23584. * @returns the updated vertex
  23585. */
  23586. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23587. /**
  23588. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23589. * This does nothing and may be overwritten by the user.
  23590. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23592. * @param update the boolean update value actually passed to setParticles()
  23593. */
  23594. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23595. /**
  23596. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23597. * This will be passed three parameters.
  23598. * This does nothing and may be overwritten by the user.
  23599. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23600. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23601. * @param update the boolean update value actually passed to setParticles()
  23602. */
  23603. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23604. }
  23605. }
  23606. declare module BABYLON {
  23607. /**
  23608. * Represents one particle of a solid particle system.
  23609. */
  23610. export class SolidParticle {
  23611. /**
  23612. * particle global index
  23613. */
  23614. idx: number;
  23615. /**
  23616. * The color of the particle
  23617. */
  23618. color: Nullable<Color4>;
  23619. /**
  23620. * The world space position of the particle.
  23621. */
  23622. position: Vector3;
  23623. /**
  23624. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23625. */
  23626. rotation: Vector3;
  23627. /**
  23628. * The world space rotation quaternion of the particle.
  23629. */
  23630. rotationQuaternion: Nullable<Quaternion>;
  23631. /**
  23632. * The scaling of the particle.
  23633. */
  23634. scaling: Vector3;
  23635. /**
  23636. * The uvs of the particle.
  23637. */
  23638. uvs: Vector4;
  23639. /**
  23640. * The current speed of the particle.
  23641. */
  23642. velocity: Vector3;
  23643. /**
  23644. * The pivot point in the particle local space.
  23645. */
  23646. pivot: Vector3;
  23647. /**
  23648. * Must the particle be translated from its pivot point in its local space ?
  23649. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23650. * Default : false
  23651. */
  23652. translateFromPivot: boolean;
  23653. /**
  23654. * Is the particle active or not ?
  23655. */
  23656. alive: boolean;
  23657. /**
  23658. * Is the particle visible or not ?
  23659. */
  23660. isVisible: boolean;
  23661. /**
  23662. * Index of this particle in the global "positions" array (Internal use)
  23663. * @hidden
  23664. */ pos: number;
  23665. /**
  23666. * @hidden Index of this particle in the global "indices" array (Internal use)
  23667. */ ind: number;
  23668. /**
  23669. * @hidden ModelShape of this particle (Internal use)
  23670. */ model: ModelShape;
  23671. /**
  23672. * ModelShape id of this particle
  23673. */
  23674. shapeId: number;
  23675. /**
  23676. * Index of the particle in its shape id (Internal use)
  23677. */
  23678. idxInShape: number;
  23679. /**
  23680. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23681. */ modelBoundingInfo: BoundingInfo;
  23682. /**
  23683. * @hidden Particle BoundingInfo object (Internal use)
  23684. */ boundingInfo: BoundingInfo;
  23685. /**
  23686. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23687. */ sps: SolidParticleSystem;
  23688. /**
  23689. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23690. */ stillInvisible: boolean;
  23691. /**
  23692. * @hidden Last computed particle rotation matrix
  23693. */ rotationMatrix: number[];
  23694. /**
  23695. * Parent particle Id, if any.
  23696. * Default null.
  23697. */
  23698. parentId: Nullable<number>;
  23699. /**
  23700. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23701. * The possible values are :
  23702. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23703. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23704. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23705. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23706. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23707. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23708. * */
  23709. cullingStrategy: number;
  23710. /**
  23711. * @hidden Internal global position in the SPS.
  23712. */ globalPosition: Vector3;
  23713. /**
  23714. * Creates a Solid Particle object.
  23715. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23716. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23717. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23718. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23719. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23720. * @param shapeId (integer) is the model shape identifier in the SPS.
  23721. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23722. * @param sps defines the sps it is associated to
  23723. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23724. */
  23725. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23726. /**
  23727. * Legacy support, changed scale to scaling
  23728. */
  23729. /**
  23730. * Legacy support, changed scale to scaling
  23731. */
  23732. scale: Vector3;
  23733. /**
  23734. * Legacy support, changed quaternion to rotationQuaternion
  23735. */
  23736. /**
  23737. * Legacy support, changed quaternion to rotationQuaternion
  23738. */
  23739. quaternion: Nullable<Quaternion>;
  23740. /**
  23741. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23742. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23743. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23744. * @returns true if it intersects
  23745. */
  23746. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23747. /**
  23748. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23749. * A particle is in the frustum if its bounding box intersects the frustum
  23750. * @param frustumPlanes defines the frustum to test
  23751. * @returns true if the particle is in the frustum planes
  23752. */
  23753. isInFrustum(frustumPlanes: Plane[]): boolean;
  23754. /**
  23755. * get the rotation matrix of the particle
  23756. * @hidden
  23757. */
  23758. getRotationMatrix(m: Matrix): void;
  23759. }
  23760. /**
  23761. * Represents the shape of the model used by one particle of a solid particle system.
  23762. * SPS internal tool, don't use it manually.
  23763. */
  23764. export class ModelShape {
  23765. /**
  23766. * The shape id
  23767. * @hidden
  23768. */
  23769. shapeID: number;
  23770. /**
  23771. * flat array of model positions (internal use)
  23772. * @hidden
  23773. */ shape: Vector3[];
  23774. /**
  23775. * flat array of model UVs (internal use)
  23776. * @hidden
  23777. */ shapeUV: number[];
  23778. /**
  23779. * length of the shape in the model indices array (internal use)
  23780. * @hidden
  23781. */ indicesLength: number;
  23782. /**
  23783. * Custom position function (internal use)
  23784. * @hidden
  23785. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23786. /**
  23787. * Custom vertex function (internal use)
  23788. * @hidden
  23789. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23790. /**
  23791. * 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.
  23792. * SPS internal tool, don't use it manually.
  23793. * @hidden
  23794. */
  23795. 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>);
  23796. }
  23797. /**
  23798. * Represents a Depth Sorted Particle in the solid particle system.
  23799. */
  23800. export class DepthSortedParticle {
  23801. /**
  23802. * Index of the particle in the "indices" array
  23803. */
  23804. ind: number;
  23805. /**
  23806. * Length of the particle shape in the "indices" array
  23807. */
  23808. indicesLength: number;
  23809. /**
  23810. * Squared distance from the particle to the camera
  23811. */
  23812. sqDistance: number;
  23813. }
  23814. }
  23815. declare module BABYLON {
  23816. /**
  23817. * @hidden
  23818. */
  23819. export class _MeshCollisionData { checkCollisions: boolean; collisionMask: number; collisionGroup: number; collider: Nullable<Collider>; oldPositionForCollisions: Vector3; diffPositionForCollisions: Vector3; onCollideObserver: Nullable<Observer<AbstractMesh>>; onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  23820. }
  23821. }
  23822. declare module BABYLON {
  23823. /**
  23824. * Class used to store all common mesh properties
  23825. */
  23826. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23827. /** No occlusion */
  23828. static OCCLUSION_TYPE_NONE: number;
  23829. /** Occlusion set to optimisitic */
  23830. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23831. /** Occlusion set to strict */
  23832. static OCCLUSION_TYPE_STRICT: number;
  23833. /** Use an accurante occlusion algorithm */
  23834. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23835. /** Use a conservative occlusion algorithm */
  23836. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23837. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23838. * Test order :
  23839. * Is the bounding sphere outside the frustum ?
  23840. * If not, are the bounding box vertices outside the frustum ?
  23841. * It not, then the cullable object is in the frustum.
  23842. */
  23843. static readonly CULLINGSTRATEGY_STANDARD: number;
  23844. /** Culling strategy : Bounding Sphere Only.
  23845. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23846. * It's also less accurate than the standard because some not visible objects can still be selected.
  23847. * Test : is the bounding sphere outside the frustum ?
  23848. * If not, then the cullable object is in the frustum.
  23849. */
  23850. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23851. /** Culling strategy : Optimistic Inclusion.
  23852. * This in an inclusion test first, then the standard exclusion test.
  23853. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23854. * 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.
  23855. * Anyway, it's as accurate as the standard strategy.
  23856. * Test :
  23857. * Is the cullable object bounding sphere center in the frustum ?
  23858. * If not, apply the default culling strategy.
  23859. */
  23860. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23861. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23862. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23863. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23864. * 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.
  23865. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23866. * Test :
  23867. * Is the cullable object bounding sphere center in the frustum ?
  23868. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23869. */
  23870. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23871. /**
  23872. * No billboard
  23873. */
  23874. static readonly BILLBOARDMODE_NONE: number;
  23875. /** Billboard on X axis */
  23876. static readonly BILLBOARDMODE_X: number;
  23877. /** Billboard on Y axis */
  23878. static readonly BILLBOARDMODE_Y: number;
  23879. /** Billboard on Z axis */
  23880. static readonly BILLBOARDMODE_Z: number;
  23881. /** Billboard on all axes */
  23882. static readonly BILLBOARDMODE_ALL: number;
  23883. private _internalAbstractMeshDataInfo;
  23884. /**
  23885. * The culling strategy to use to check whether the mesh must be rendered or not.
  23886. * This value can be changed at any time and will be used on the next render mesh selection.
  23887. * The possible values are :
  23888. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23889. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23890. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23891. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23892. * Please read each static variable documentation to get details about the culling process.
  23893. * */
  23894. cullingStrategy: number;
  23895. /**
  23896. * Gets the number of facets in the mesh
  23897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23898. */
  23899. readonly facetNb: number;
  23900. /**
  23901. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23903. */
  23904. partitioningSubdivisions: number;
  23905. /**
  23906. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23907. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23909. */
  23910. partitioningBBoxRatio: number;
  23911. /**
  23912. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23913. * Works only for updatable meshes.
  23914. * Doesn't work with multi-materials
  23915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23916. */
  23917. mustDepthSortFacets: boolean;
  23918. /**
  23919. * The location (Vector3) where the facet depth sort must be computed from.
  23920. * By default, the active camera position.
  23921. * Used only when facet depth sort is enabled
  23922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23923. */
  23924. facetDepthSortFrom: Vector3;
  23925. /**
  23926. * gets a boolean indicating if facetData is enabled
  23927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23928. */
  23929. readonly isFacetDataEnabled: boolean;
  23930. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23931. /**
  23932. * An event triggered when this mesh collides with another one
  23933. */
  23934. onCollideObservable: Observable<AbstractMesh>;
  23935. /** Set a function to call when this mesh collides with another one */
  23936. onCollide: () => void;
  23937. /**
  23938. * An event triggered when the collision's position changes
  23939. */
  23940. onCollisionPositionChangeObservable: Observable<Vector3>;
  23941. /** Set a function to call when the collision's position changes */
  23942. onCollisionPositionChange: () => void;
  23943. /**
  23944. * An event triggered when material is changed
  23945. */
  23946. onMaterialChangedObservable: Observable<AbstractMesh>;
  23947. /**
  23948. * Gets or sets the orientation for POV movement & rotation
  23949. */
  23950. definedFacingForward: boolean;
  23951. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23952. /** @hidden */ isActive: boolean;
  23953. /** @hidden */ onlyForInstances: boolean;
  23954. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23955. /**
  23956. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23957. */
  23958. /**
  23959. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23960. */
  23961. visibility: number;
  23962. /** Gets or sets the alpha index used to sort transparent meshes
  23963. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23964. */
  23965. alphaIndex: number;
  23966. /**
  23967. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23968. */
  23969. isVisible: boolean;
  23970. /**
  23971. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23972. */
  23973. isPickable: boolean;
  23974. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23975. showSubMeshesBoundingBox: boolean;
  23976. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23977. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23978. */
  23979. isBlocker: boolean;
  23980. /**
  23981. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23982. */
  23983. enablePointerMoveEvents: boolean;
  23984. /**
  23985. * Specifies the rendering group id for this mesh (0 by default)
  23986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23987. */
  23988. renderingGroupId: number;
  23989. private _material;
  23990. /** Gets or sets current material */
  23991. material: Nullable<Material>;
  23992. /**
  23993. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23994. * @see http://doc.babylonjs.com/babylon101/shadows
  23995. */
  23996. receiveShadows: boolean;
  23997. /** Defines color to use when rendering outline */
  23998. outlineColor: Color3;
  23999. /** Define width to use when rendering outline */
  24000. outlineWidth: number;
  24001. /** Defines color to use when rendering overlay */
  24002. overlayColor: Color3;
  24003. /** Defines alpha to use when rendering overlay */
  24004. overlayAlpha: number;
  24005. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24006. hasVertexAlpha: boolean;
  24007. /** 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) */
  24008. useVertexColors: boolean;
  24009. /**
  24010. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24011. */
  24012. computeBonesUsingShaders: boolean;
  24013. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24014. numBoneInfluencers: number;
  24015. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24016. applyFog: boolean;
  24017. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24018. useOctreeForRenderingSelection: boolean;
  24019. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24020. useOctreeForPicking: boolean;
  24021. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24022. useOctreeForCollisions: boolean;
  24023. /**
  24024. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24025. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24026. */
  24027. layerMask: number;
  24028. /**
  24029. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24030. */
  24031. alwaysSelectAsActiveMesh: boolean;
  24032. /**
  24033. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24034. */
  24035. doNotSyncBoundingInfo: boolean;
  24036. /**
  24037. * Gets or sets the current action manager
  24038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24039. */
  24040. actionManager: Nullable<AbstractActionManager>;
  24041. private _meshCollisionData;
  24042. /**
  24043. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24044. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24045. */
  24046. ellipsoid: Vector3;
  24047. /**
  24048. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24050. */
  24051. ellipsoidOffset: Vector3;
  24052. /**
  24053. * Gets or sets a collision mask used to mask collisions (default is -1).
  24054. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24055. */
  24056. collisionMask: number;
  24057. /**
  24058. * Gets or sets the current collision group mask (-1 by default).
  24059. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24060. */
  24061. collisionGroup: number;
  24062. /**
  24063. * Defines edge width used when edgesRenderer is enabled
  24064. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24065. */
  24066. edgesWidth: number;
  24067. /**
  24068. * Defines edge color used when edgesRenderer is enabled
  24069. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24070. */
  24071. edgesColor: Color4;
  24072. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  24073. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  24074. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  24075. /** @hidden */ renderId: number;
  24076. /**
  24077. * Gets or sets the list of subMeshes
  24078. * @see http://doc.babylonjs.com/how_to/multi_materials
  24079. */
  24080. subMeshes: SubMesh[];
  24081. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  24082. /** @hidden */ unIndexed: boolean;
  24083. /** @hidden */ lightSources: Light[];
  24084. /** Gets the list of lights affecting that mesh */
  24085. readonly lightSources: Light[];
  24086. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24087. /** @hidden */ waitingData: {
  24088. lods: Nullable<any>;
  24089. actions: Nullable<any>;
  24090. freezeWorldMatrix: Nullable<boolean>;
  24091. };
  24092. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  24093. /**
  24094. * Gets or sets a skeleton to apply skining transformations
  24095. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24096. */
  24097. skeleton: Nullable<Skeleton>;
  24098. /**
  24099. * An event triggered when the mesh is rebuilt.
  24100. */
  24101. onRebuildObservable: Observable<AbstractMesh>;
  24102. /**
  24103. * Creates a new AbstractMesh
  24104. * @param name defines the name of the mesh
  24105. * @param scene defines the hosting scene
  24106. */
  24107. constructor(name: string, scene?: Nullable<Scene>);
  24108. /**
  24109. * Returns the string "AbstractMesh"
  24110. * @returns "AbstractMesh"
  24111. */
  24112. getClassName(): string;
  24113. /**
  24114. * Gets a string representation of the current mesh
  24115. * @param fullDetails defines a boolean indicating if full details must be included
  24116. * @returns a string representation of the current mesh
  24117. */
  24118. toString(fullDetails?: boolean): string;
  24119. /**
  24120. * @hidden
  24121. */
  24122. protected _getEffectiveParent(): Nullable<Node>;
  24123. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24124. /** @hidden */ rebuild(): void;
  24125. /** @hidden */ resyncLightSources(): void;
  24126. /** @hidden */ resyncLighSource(light: Light): void;
  24127. /** @hidden */ unBindEffect(): void;
  24128. /** @hidden */ removeLightSource(light: Light): void;
  24129. private _markSubMeshesAsDirty;
  24130. /** @hidden */ markSubMeshesAsLightDirty(): void;
  24131. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  24132. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  24133. /**
  24134. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24135. */
  24136. scaling: Vector3;
  24137. /**
  24138. * Returns true if the mesh is blocked. Implemented by child classes
  24139. */
  24140. readonly isBlocked: boolean;
  24141. /**
  24142. * Returns the mesh itself by default. Implemented by child classes
  24143. * @param camera defines the camera to use to pick the right LOD level
  24144. * @returns the currentAbstractMesh
  24145. */
  24146. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24147. /**
  24148. * Returns 0 by default. Implemented by child classes
  24149. * @returns an integer
  24150. */
  24151. getTotalVertices(): number;
  24152. /**
  24153. * Returns a positive integer : the total number of indices in this mesh geometry.
  24154. * @returns the numner of indices or zero if the mesh has no geometry.
  24155. */
  24156. getTotalIndices(): number;
  24157. /**
  24158. * Returns null by default. Implemented by child classes
  24159. * @returns null
  24160. */
  24161. getIndices(): Nullable<IndicesArray>;
  24162. /**
  24163. * Returns the array of the requested vertex data kind. Implemented by child classes
  24164. * @param kind defines the vertex data kind to use
  24165. * @returns null
  24166. */
  24167. getVerticesData(kind: string): Nullable<FloatArray>;
  24168. /**
  24169. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24170. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24171. * Note that a new underlying VertexBuffer object is created each call.
  24172. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24173. * @param kind defines vertex data kind:
  24174. * * VertexBuffer.PositionKind
  24175. * * VertexBuffer.UVKind
  24176. * * VertexBuffer.UV2Kind
  24177. * * VertexBuffer.UV3Kind
  24178. * * VertexBuffer.UV4Kind
  24179. * * VertexBuffer.UV5Kind
  24180. * * VertexBuffer.UV6Kind
  24181. * * VertexBuffer.ColorKind
  24182. * * VertexBuffer.MatricesIndicesKind
  24183. * * VertexBuffer.MatricesIndicesExtraKind
  24184. * * VertexBuffer.MatricesWeightsKind
  24185. * * VertexBuffer.MatricesWeightsExtraKind
  24186. * @param data defines the data source
  24187. * @param updatable defines if the data must be flagged as updatable (or static)
  24188. * @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
  24189. * @returns the current mesh
  24190. */
  24191. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24192. /**
  24193. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24194. * If the mesh has no geometry, it is simply returned as it is.
  24195. * @param kind defines vertex data kind:
  24196. * * VertexBuffer.PositionKind
  24197. * * VertexBuffer.UVKind
  24198. * * VertexBuffer.UV2Kind
  24199. * * VertexBuffer.UV3Kind
  24200. * * VertexBuffer.UV4Kind
  24201. * * VertexBuffer.UV5Kind
  24202. * * VertexBuffer.UV6Kind
  24203. * * VertexBuffer.ColorKind
  24204. * * VertexBuffer.MatricesIndicesKind
  24205. * * VertexBuffer.MatricesIndicesExtraKind
  24206. * * VertexBuffer.MatricesWeightsKind
  24207. * * VertexBuffer.MatricesWeightsExtraKind
  24208. * @param data defines the data source
  24209. * @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
  24210. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24211. * @returns the current mesh
  24212. */
  24213. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24214. /**
  24215. * Sets the mesh indices,
  24216. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24217. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24218. * @param totalVertices Defines the total number of vertices
  24219. * @returns the current mesh
  24220. */
  24221. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24222. /**
  24223. * Gets a boolean indicating if specific vertex data is present
  24224. * @param kind defines the vertex data kind to use
  24225. * @returns true is data kind is present
  24226. */
  24227. isVerticesDataPresent(kind: string): boolean;
  24228. /**
  24229. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24230. * @returns a BoundingInfo
  24231. */
  24232. getBoundingInfo(): BoundingInfo;
  24233. /**
  24234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24237. * @returns the current mesh
  24238. */
  24239. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24240. /**
  24241. * Overwrite the current bounding info
  24242. * @param boundingInfo defines the new bounding info
  24243. * @returns the current mesh
  24244. */
  24245. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24246. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24247. readonly useBones: boolean;
  24248. /** @hidden */ preActivate(): void;
  24249. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  24250. /** @hidden */ activate(renderId: number): boolean;
  24251. /** @hidden */ postActivate(): void;
  24252. /** @hidden */ freeze(): void;
  24253. /** @hidden */ unFreeze(): void;
  24254. /**
  24255. * Gets the current world matrix
  24256. * @returns a Matrix
  24257. */
  24258. getWorldMatrix(): Matrix;
  24259. /** @hidden */ getWorldMatrixDeterminant(): number;
  24260. /**
  24261. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24262. */
  24263. readonly isAnInstance: boolean;
  24264. /**
  24265. * Perform relative position change from the point of view of behind the front of the mesh.
  24266. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24267. * Supports definition of mesh facing forward or backward
  24268. * @param amountRight defines the distance on the right axis
  24269. * @param amountUp defines the distance on the up axis
  24270. * @param amountForward defines the distance on the forward axis
  24271. * @returns the current mesh
  24272. */
  24273. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24274. /**
  24275. * Calculate relative position change from the point of view of behind the front of the mesh.
  24276. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24277. * Supports definition of mesh facing forward or backward
  24278. * @param amountRight defines the distance on the right axis
  24279. * @param amountUp defines the distance on the up axis
  24280. * @param amountForward defines the distance on the forward axis
  24281. * @returns the new displacement vector
  24282. */
  24283. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24284. /**
  24285. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24286. * Supports definition of mesh facing forward or backward
  24287. * @param flipBack defines the flip
  24288. * @param twirlClockwise defines the twirl
  24289. * @param tiltRight defines the tilt
  24290. * @returns the current mesh
  24291. */
  24292. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24293. /**
  24294. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24295. * Supports definition of mesh facing forward or backward.
  24296. * @param flipBack defines the flip
  24297. * @param twirlClockwise defines the twirl
  24298. * @param tiltRight defines the tilt
  24299. * @returns the new rotation vector
  24300. */
  24301. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24302. /**
  24303. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24304. * This means the mesh underlying bounding box and sphere are recomputed.
  24305. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24306. * @returns the current mesh
  24307. */
  24308. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24309. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24310. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24311. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  24312. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24313. /** @hidden */
  24314. protected _afterComputeWorldMatrix(): void;
  24315. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24316. /**
  24317. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24318. * A mesh is in the frustum if its bounding box intersects the frustum
  24319. * @param frustumPlanes defines the frustum to test
  24320. * @returns true if the mesh is in the frustum planes
  24321. */
  24322. isInFrustum(frustumPlanes: Plane[]): boolean;
  24323. /**
  24324. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24325. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24326. * @param frustumPlanes defines the frustum to test
  24327. * @returns true if the mesh is completely in the frustum planes
  24328. */
  24329. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24330. /**
  24331. * True if the mesh intersects another mesh or a SolidParticle object
  24332. * @param mesh defines a target mesh or SolidParticle to test
  24333. * @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)
  24334. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24335. * @returns true if there is an intersection
  24336. */
  24337. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24338. /**
  24339. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24340. * @param point defines the point to test
  24341. * @returns true if there is an intersection
  24342. */
  24343. intersectsPoint(point: Vector3): boolean;
  24344. /**
  24345. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24347. */
  24348. checkCollisions: boolean;
  24349. /**
  24350. * Gets Collider object used to compute collisions (not physics)
  24351. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24352. */
  24353. readonly collider: Nullable<Collider>;
  24354. /**
  24355. * Move the mesh using collision engine
  24356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24357. * @param displacement defines the requested displacement vector
  24358. * @returns the current mesh
  24359. */
  24360. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24361. private _onCollisionPositionChange;
  24362. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24363. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24364. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24365. /** @hidden */ generatePointsArray(): boolean;
  24366. /**
  24367. * Checks if the passed Ray intersects with the mesh
  24368. * @param ray defines the ray to use
  24369. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24370. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24371. * @returns the picking info
  24372. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24373. */
  24374. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24375. /**
  24376. * Clones the current mesh
  24377. * @param name defines the mesh name
  24378. * @param newParent defines the new mesh parent
  24379. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24380. * @returns the new mesh
  24381. */
  24382. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24383. /**
  24384. * Disposes all the submeshes of the current meshnp
  24385. * @returns the current mesh
  24386. */
  24387. releaseSubMeshes(): AbstractMesh;
  24388. /**
  24389. * Releases resources associated with this abstract mesh.
  24390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24392. */
  24393. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24394. /**
  24395. * Adds the passed mesh as a child to the current mesh
  24396. * @param mesh defines the child mesh
  24397. * @returns the current mesh
  24398. */
  24399. addChild(mesh: AbstractMesh): AbstractMesh;
  24400. /**
  24401. * Removes the passed mesh from the current mesh children list
  24402. * @param mesh defines the child mesh
  24403. * @returns the current mesh
  24404. */
  24405. removeChild(mesh: AbstractMesh): AbstractMesh;
  24406. /** @hidden */
  24407. private _initFacetData;
  24408. /**
  24409. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24410. * This method can be called within the render loop.
  24411. * 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
  24412. * @returns the current mesh
  24413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24414. */
  24415. updateFacetData(): AbstractMesh;
  24416. /**
  24417. * Returns the facetLocalNormals array.
  24418. * The normals are expressed in the mesh local spac
  24419. * @returns an array of Vector3
  24420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24421. */
  24422. getFacetLocalNormals(): Vector3[];
  24423. /**
  24424. * Returns the facetLocalPositions array.
  24425. * The facet positions are expressed in the mesh local space
  24426. * @returns an array of Vector3
  24427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24428. */
  24429. getFacetLocalPositions(): Vector3[];
  24430. /**
  24431. * Returns the facetLocalPartioning array
  24432. * @returns an array of array of numbers
  24433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24434. */
  24435. getFacetLocalPartitioning(): number[][];
  24436. /**
  24437. * Returns the i-th facet position in the world system.
  24438. * This method allocates a new Vector3 per call
  24439. * @param i defines the facet index
  24440. * @returns a new Vector3
  24441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24442. */
  24443. getFacetPosition(i: number): Vector3;
  24444. /**
  24445. * Sets the reference Vector3 with the i-th facet position in the world system
  24446. * @param i defines the facet index
  24447. * @param ref defines the target vector
  24448. * @returns the current mesh
  24449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24450. */
  24451. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24452. /**
  24453. * Returns the i-th facet normal in the world system.
  24454. * This method allocates a new Vector3 per call
  24455. * @param i defines the facet index
  24456. * @returns a new Vector3
  24457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24458. */
  24459. getFacetNormal(i: number): Vector3;
  24460. /**
  24461. * Sets the reference Vector3 with the i-th facet normal in the world system
  24462. * @param i defines the facet index
  24463. * @param ref defines the target vector
  24464. * @returns the current mesh
  24465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24466. */
  24467. getFacetNormalToRef(i: number, ref: Vector3): this;
  24468. /**
  24469. * 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)
  24470. * @param x defines x coordinate
  24471. * @param y defines y coordinate
  24472. * @param z defines z coordinate
  24473. * @returns the array of facet indexes
  24474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24475. */
  24476. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24477. /**
  24478. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24479. * @param projected sets as the (x,y,z) world projection on the facet
  24480. * @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
  24481. * @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
  24482. * @param x defines x coordinate
  24483. * @param y defines y coordinate
  24484. * @param z defines z coordinate
  24485. * @returns the face index if found (or null instead)
  24486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24487. */
  24488. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24489. /**
  24490. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24491. * @param projected sets as the (x,y,z) local projection on the facet
  24492. * @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
  24493. * @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
  24494. * @param x defines x coordinate
  24495. * @param y defines y coordinate
  24496. * @param z defines z coordinate
  24497. * @returns the face index if found (or null instead)
  24498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24499. */
  24500. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24501. /**
  24502. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24503. * @returns the parameters
  24504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24505. */
  24506. getFacetDataParameters(): any;
  24507. /**
  24508. * Disables the feature FacetData and frees the related memory
  24509. * @returns the current mesh
  24510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24511. */
  24512. disableFacetData(): AbstractMesh;
  24513. /**
  24514. * Updates the AbstractMesh indices array
  24515. * @param indices defines the data source
  24516. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24517. * @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)
  24518. * @returns the current mesh
  24519. */
  24520. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24521. /**
  24522. * Creates new normals data for the mesh
  24523. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24524. * @returns the current mesh
  24525. */
  24526. createNormals(updatable: boolean): AbstractMesh;
  24527. /**
  24528. * Align the mesh with a normal
  24529. * @param normal defines the normal to use
  24530. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24531. * @returns the current mesh
  24532. */
  24533. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24534. /** @hidden */ checkOcclusionQuery(): boolean;
  24535. }
  24536. }
  24537. declare module BABYLON {
  24538. /**
  24539. * Interface used to define ActionEvent
  24540. */
  24541. export interface IActionEvent {
  24542. /** The mesh or sprite that triggered the action */
  24543. source: any;
  24544. /** The X mouse cursor position at the time of the event */
  24545. pointerX: number;
  24546. /** The Y mouse cursor position at the time of the event */
  24547. pointerY: number;
  24548. /** The mesh that is currently pointed at (can be null) */
  24549. meshUnderPointer: Nullable<AbstractMesh>;
  24550. /** the original (browser) event that triggered the ActionEvent */
  24551. sourceEvent?: any;
  24552. /** additional data for the event */
  24553. additionalData?: any;
  24554. }
  24555. /**
  24556. * ActionEvent is the event being sent when an action is triggered.
  24557. */
  24558. export class ActionEvent implements IActionEvent {
  24559. /** The mesh or sprite that triggered the action */
  24560. source: any;
  24561. /** The X mouse cursor position at the time of the event */
  24562. pointerX: number;
  24563. /** The Y mouse cursor position at the time of the event */
  24564. pointerY: number;
  24565. /** The mesh that is currently pointed at (can be null) */
  24566. meshUnderPointer: Nullable<AbstractMesh>;
  24567. /** the original (browser) event that triggered the ActionEvent */
  24568. sourceEvent?: any;
  24569. /** additional data for the event */
  24570. additionalData?: any;
  24571. /**
  24572. * Creates a new ActionEvent
  24573. * @param source The mesh or sprite that triggered the action
  24574. * @param pointerX The X mouse cursor position at the time of the event
  24575. * @param pointerY The Y mouse cursor position at the time of the event
  24576. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24577. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24578. * @param additionalData additional data for the event
  24579. */
  24580. constructor(
  24581. /** The mesh or sprite that triggered the action */
  24582. source: any,
  24583. /** The X mouse cursor position at the time of the event */
  24584. pointerX: number,
  24585. /** The Y mouse cursor position at the time of the event */
  24586. pointerY: number,
  24587. /** The mesh that is currently pointed at (can be null) */
  24588. meshUnderPointer: Nullable<AbstractMesh>,
  24589. /** the original (browser) event that triggered the ActionEvent */
  24590. sourceEvent?: any,
  24591. /** additional data for the event */
  24592. additionalData?: any);
  24593. /**
  24594. * Helper function to auto-create an ActionEvent from a source mesh.
  24595. * @param source The source mesh that triggered the event
  24596. * @param evt The original (browser) event
  24597. * @param additionalData additional data for the event
  24598. * @returns the new ActionEvent
  24599. */
  24600. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24601. /**
  24602. * Helper function to auto-create an ActionEvent from a source sprite
  24603. * @param source The source sprite that triggered the event
  24604. * @param scene Scene associated with the sprite
  24605. * @param evt The original (browser) event
  24606. * @param additionalData additional data for the event
  24607. * @returns the new ActionEvent
  24608. */
  24609. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24610. /**
  24611. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24612. * @param scene the scene where the event occurred
  24613. * @param evt The original (browser) event
  24614. * @returns the new ActionEvent
  24615. */
  24616. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24617. /**
  24618. * Helper function to auto-create an ActionEvent from a primitive
  24619. * @param prim defines the target primitive
  24620. * @param pointerPos defines the pointer position
  24621. * @param evt The original (browser) event
  24622. * @param additionalData additional data for the event
  24623. * @returns the new ActionEvent
  24624. */
  24625. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24626. }
  24627. }
  24628. declare module BABYLON {
  24629. /**
  24630. * Abstract class used to decouple action Manager from scene and meshes.
  24631. * Do not instantiate.
  24632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24633. */
  24634. export abstract class AbstractActionManager implements IDisposable {
  24635. /** Gets the list of active triggers */
  24636. static Triggers: {
  24637. [key: string]: number;
  24638. };
  24639. /** Gets the cursor to use when hovering items */
  24640. hoverCursor: string;
  24641. /** Gets the list of actions */
  24642. actions: IAction[];
  24643. /**
  24644. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24645. */
  24646. isRecursive: boolean;
  24647. /**
  24648. * Releases all associated resources
  24649. */
  24650. abstract dispose(): void;
  24651. /**
  24652. * Does this action manager has pointer triggers
  24653. */
  24654. abstract readonly hasPointerTriggers: boolean;
  24655. /**
  24656. * Does this action manager has pick triggers
  24657. */
  24658. abstract readonly hasPickTriggers: boolean;
  24659. /**
  24660. * Process a specific trigger
  24661. * @param trigger defines the trigger to process
  24662. * @param evt defines the event details to be processed
  24663. */
  24664. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24665. /**
  24666. * Does this action manager handles actions of any of the given triggers
  24667. * @param triggers defines the triggers to be tested
  24668. * @return a boolean indicating whether one (or more) of the triggers is handled
  24669. */
  24670. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24671. /**
  24672. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24673. * speed.
  24674. * @param triggerA defines the trigger to be tested
  24675. * @param triggerB defines the trigger to be tested
  24676. * @return a boolean indicating whether one (or more) of the triggers is handled
  24677. */
  24678. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24679. /**
  24680. * Does this action manager handles actions of a given trigger
  24681. * @param trigger defines the trigger to be tested
  24682. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24683. * @return whether the trigger is handled
  24684. */
  24685. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24686. /**
  24687. * Serialize this manager to a JSON object
  24688. * @param name defines the property name to store this manager
  24689. * @returns a JSON representation of this manager
  24690. */
  24691. abstract serialize(name: string): any;
  24692. /**
  24693. * Registers an action to this action manager
  24694. * @param action defines the action to be registered
  24695. * @return the action amended (prepared) after registration
  24696. */
  24697. abstract registerAction(action: IAction): Nullable<IAction>;
  24698. /**
  24699. * Unregisters an action to this action manager
  24700. * @param action defines the action to be unregistered
  24701. * @return a boolean indicating whether the action has been unregistered
  24702. */
  24703. abstract unregisterAction(action: IAction): Boolean;
  24704. /**
  24705. * Does exist one action manager with at least one trigger
  24706. **/
  24707. static readonly HasTriggers: boolean;
  24708. /**
  24709. * Does exist one action manager with at least one pick trigger
  24710. **/
  24711. static readonly HasPickTriggers: boolean;
  24712. /**
  24713. * Does exist one action manager that handles actions of a given trigger
  24714. * @param trigger defines the trigger to be tested
  24715. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24716. **/
  24717. static HasSpecificTrigger(trigger: number): boolean;
  24718. }
  24719. }
  24720. declare module BABYLON {
  24721. /**
  24722. * Defines how a node can be built from a string name.
  24723. */
  24724. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24725. /**
  24726. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24727. */
  24728. export class Node implements IBehaviorAware<Node> {
  24729. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24730. private static _NodeConstructors;
  24731. /**
  24732. * Add a new node constructor
  24733. * @param type defines the type name of the node to construct
  24734. * @param constructorFunc defines the constructor function
  24735. */
  24736. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24737. /**
  24738. * Returns a node constructor based on type name
  24739. * @param type defines the type name
  24740. * @param name defines the new node name
  24741. * @param scene defines the hosting scene
  24742. * @param options defines optional options to transmit to constructors
  24743. * @returns the new constructor or null
  24744. */
  24745. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24746. /**
  24747. * Gets or sets the name of the node
  24748. */
  24749. name: string;
  24750. /**
  24751. * Gets or sets the id of the node
  24752. */
  24753. id: string;
  24754. /**
  24755. * Gets or sets the unique id of the node
  24756. */
  24757. uniqueId: number;
  24758. /**
  24759. * Gets or sets a string used to store user defined state for the node
  24760. */
  24761. state: string;
  24762. /**
  24763. * Gets or sets an object used to store user defined information for the node
  24764. */
  24765. metadata: any;
  24766. /**
  24767. * For internal use only. Please do not use.
  24768. */
  24769. reservedDataStore: any;
  24770. /**
  24771. * List of inspectable custom properties (used by the Inspector)
  24772. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24773. */
  24774. inspectableCustomProperties: IInspectable[];
  24775. /**
  24776. * Gets or sets a boolean used to define if the node must be serialized
  24777. */
  24778. doNotSerialize: boolean;
  24779. /** @hidden */ isDisposed: boolean;
  24780. /**
  24781. * Gets a list of Animations associated with the node
  24782. */
  24783. animations: Animation[];
  24784. protected _ranges: {
  24785. [name: string]: Nullable<AnimationRange>;
  24786. };
  24787. /**
  24788. * Callback raised when the node is ready to be used
  24789. */
  24790. onReady: Nullable<(node: Node) => void>;
  24791. private _isEnabled;
  24792. private _isParentEnabled;
  24793. private _isReady;
  24794. /** @hidden */ currentRenderId: number;
  24795. private _parentUpdateId;
  24796. /** @hidden */ childUpdateId: number;
  24797. /** @hidden */ waitingParentId: Nullable<string>;
  24798. /** @hidden */ scene: Scene;
  24799. /** @hidden */ cache: any;
  24800. private _parentNode;
  24801. private _children;
  24802. /** @hidden */ worldMatrix: Matrix;
  24803. /** @hidden */ worldMatrixDeterminant: number;
  24804. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24805. /** @hidden */
  24806. private _sceneRootNodesIndex;
  24807. /**
  24808. * Gets a boolean indicating if the node has been disposed
  24809. * @returns true if the node was disposed
  24810. */
  24811. isDisposed(): boolean;
  24812. /**
  24813. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24814. * @see https://doc.babylonjs.com/how_to/parenting
  24815. */
  24816. parent: Nullable<Node>;
  24817. private addToSceneRootNodes;
  24818. private removeFromSceneRootNodes;
  24819. private _animationPropertiesOverride;
  24820. /**
  24821. * Gets or sets the animation properties override
  24822. */
  24823. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24824. /**
  24825. * Gets a string idenfifying the name of the class
  24826. * @returns "Node" string
  24827. */
  24828. getClassName(): string;
  24829. /** @hidden */ protected readonly _isNode: boolean;
  24830. /**
  24831. * An event triggered when the mesh is disposed
  24832. */
  24833. onDisposeObservable: Observable<Node>;
  24834. private _onDisposeObserver;
  24835. /**
  24836. * Sets a callback that will be raised when the node will be disposed
  24837. */
  24838. onDispose: () => void;
  24839. /**
  24840. * Creates a new Node
  24841. * @param name the name and id to be given to this node
  24842. * @param scene the scene this node will be added to
  24843. * @param addToRootNodes the node will be added to scene.rootNodes
  24844. */
  24845. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24846. /**
  24847. * Gets the scene of the node
  24848. * @returns a scene
  24849. */
  24850. getScene(): Scene;
  24851. /**
  24852. * Gets the engine of the node
  24853. * @returns a Engine
  24854. */
  24855. getEngine(): Engine;
  24856. private _behaviors;
  24857. /**
  24858. * Attach a behavior to the node
  24859. * @see http://doc.babylonjs.com/features/behaviour
  24860. * @param behavior defines the behavior to attach
  24861. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24862. * @returns the current Node
  24863. */
  24864. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24865. /**
  24866. * Remove an attached behavior
  24867. * @see http://doc.babylonjs.com/features/behaviour
  24868. * @param behavior defines the behavior to attach
  24869. * @returns the current Node
  24870. */
  24871. removeBehavior(behavior: Behavior<Node>): Node;
  24872. /**
  24873. * Gets the list of attached behaviors
  24874. * @see http://doc.babylonjs.com/features/behaviour
  24875. */
  24876. readonly behaviors: Behavior<Node>[];
  24877. /**
  24878. * Gets an attached behavior by name
  24879. * @param name defines the name of the behavior to look for
  24880. * @see http://doc.babylonjs.com/features/behaviour
  24881. * @returns null if behavior was not found else the requested behavior
  24882. */
  24883. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24884. /**
  24885. * Returns the latest update of the World matrix
  24886. * @returns a Matrix
  24887. */
  24888. getWorldMatrix(): Matrix;
  24889. /** @hidden */ getWorldMatrixDeterminant(): number;
  24890. /**
  24891. * Returns directly the latest state of the mesh World matrix.
  24892. * A Matrix is returned.
  24893. */
  24894. readonly worldMatrixFromCache: Matrix;
  24895. /** @hidden */ initCache(): void;
  24896. /** @hidden */
  24897. updateCache(force?: boolean): void;
  24898. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24899. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24900. /** @hidden */ isSynchronized(): boolean;
  24901. /** @hidden */ markSyncedWithParent(): void;
  24902. /** @hidden */
  24903. isSynchronizedWithParent(): boolean;
  24904. /** @hidden */
  24905. isSynchronized(): boolean;
  24906. /**
  24907. * Is this node ready to be used/rendered
  24908. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24909. * @return true if the node is ready
  24910. */
  24911. isReady(completeCheck?: boolean): boolean;
  24912. /**
  24913. * Is this node enabled?
  24914. * 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
  24915. * @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
  24916. * @return whether this node (and its parent) is enabled
  24917. */
  24918. isEnabled(checkAncestors?: boolean): boolean;
  24919. /** @hidden */
  24920. protected _syncParentEnabledState(): void;
  24921. /**
  24922. * Set the enabled state of this node
  24923. * @param value defines the new enabled state
  24924. */
  24925. setEnabled(value: boolean): void;
  24926. /**
  24927. * Is this node a descendant of the given node?
  24928. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24929. * @param ancestor defines the parent node to inspect
  24930. * @returns a boolean indicating if this node is a descendant of the given node
  24931. */
  24932. isDescendantOf(ancestor: Node): boolean;
  24933. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24934. /**
  24935. * Will return all nodes that have this node as ascendant
  24936. * @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
  24937. * @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
  24938. * @return all children nodes of all types
  24939. */
  24940. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24941. /**
  24942. * Get all child-meshes of this node
  24943. * @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)
  24944. * @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
  24945. * @returns an array of AbstractMesh
  24946. */
  24947. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24948. /**
  24949. * Get all direct children of this node
  24950. * @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
  24951. * @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)
  24952. * @returns an array of Node
  24953. */
  24954. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24955. /** @hidden */ setReady(state: boolean): void;
  24956. /**
  24957. * Get an animation by name
  24958. * @param name defines the name of the animation to look for
  24959. * @returns null if not found else the requested animation
  24960. */
  24961. getAnimationByName(name: string): Nullable<Animation>;
  24962. /**
  24963. * Creates an animation range for this node
  24964. * @param name defines the name of the range
  24965. * @param from defines the starting key
  24966. * @param to defines the end key
  24967. */
  24968. createAnimationRange(name: string, from: number, to: number): void;
  24969. /**
  24970. * Delete a specific animation range
  24971. * @param name defines the name of the range to delete
  24972. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24973. */
  24974. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24975. /**
  24976. * Get an animation range by name
  24977. * @param name defines the name of the animation range to look for
  24978. * @returns null if not found else the requested animation range
  24979. */
  24980. getAnimationRange(name: string): Nullable<AnimationRange>;
  24981. /**
  24982. * Gets the list of all animation ranges defined on this node
  24983. * @returns an array
  24984. */
  24985. getAnimationRanges(): Nullable<AnimationRange>[];
  24986. /**
  24987. * Will start the animation sequence
  24988. * @param name defines the range frames for animation sequence
  24989. * @param loop defines if the animation should loop (false by default)
  24990. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24991. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24992. * @returns the object created for this animation. If range does not exist, it will return null
  24993. */
  24994. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24995. /**
  24996. * Serialize animation ranges into a JSON compatible object
  24997. * @returns serialization object
  24998. */
  24999. serializeAnimationRanges(): any;
  25000. /**
  25001. * Computes the world matrix of the node
  25002. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25003. * @returns the world matrix
  25004. */
  25005. computeWorldMatrix(force?: boolean): Matrix;
  25006. /**
  25007. * Releases resources associated with this node.
  25008. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25009. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25010. */
  25011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25012. /**
  25013. * Parse animation range data from a serialization object and store them into a given node
  25014. * @param node defines where to store the animation ranges
  25015. * @param parsedNode defines the serialization object to read data from
  25016. * @param scene defines the hosting scene
  25017. */
  25018. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25019. /**
  25020. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25021. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25022. * @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
  25023. * @returns the new bounding vectors
  25024. */
  25025. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25026. min: Vector3;
  25027. max: Vector3;
  25028. };
  25029. }
  25030. }
  25031. declare module BABYLON {
  25032. /**
  25033. * @hidden
  25034. */
  25035. export class _IAnimationState {
  25036. key: number;
  25037. repeatCount: number;
  25038. workValue?: any;
  25039. loopMode?: number;
  25040. offsetValue?: any;
  25041. highLimitValue?: any;
  25042. }
  25043. /**
  25044. * Class used to store any kind of animation
  25045. */
  25046. export class Animation {
  25047. /**Name of the animation */
  25048. name: string;
  25049. /**Property to animate */
  25050. targetProperty: string;
  25051. /**The frames per second of the animation */
  25052. framePerSecond: number;
  25053. /**The data type of the animation */
  25054. dataType: number;
  25055. /**The loop mode of the animation */
  25056. loopMode?: number | undefined;
  25057. /**Specifies if blending should be enabled */
  25058. enableBlending?: boolean | undefined;
  25059. /**
  25060. * Use matrix interpolation instead of using direct key value when animating matrices
  25061. */
  25062. static AllowMatricesInterpolation: boolean;
  25063. /**
  25064. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25065. */
  25066. static AllowMatrixDecomposeForInterpolation: boolean;
  25067. /**
  25068. * Stores the key frames of the animation
  25069. */
  25070. private _keys;
  25071. /**
  25072. * Stores the easing function of the animation
  25073. */
  25074. private _easingFunction;
  25075. /**
  25076. * @hidden Internal use only
  25077. */ runtimeAnimations: RuntimeAnimation[];
  25078. /**
  25079. * The set of event that will be linked to this animation
  25080. */
  25081. private _events;
  25082. /**
  25083. * Stores an array of target property paths
  25084. */
  25085. targetPropertyPath: string[];
  25086. /**
  25087. * Stores the blending speed of the animation
  25088. */
  25089. blendingSpeed: number;
  25090. /**
  25091. * Stores the animation ranges for the animation
  25092. */
  25093. private _ranges;
  25094. /**
  25095. * @hidden Internal use
  25096. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25097. /**
  25098. * Sets up an animation
  25099. * @param property The property to animate
  25100. * @param animationType The animation type to apply
  25101. * @param framePerSecond The frames per second of the animation
  25102. * @param easingFunction The easing function used in the animation
  25103. * @returns The created animation
  25104. */
  25105. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25106. /**
  25107. * Create and start an animation on a node
  25108. * @param name defines the name of the global animation that will be run on all nodes
  25109. * @param node defines the root node where the animation will take place
  25110. * @param targetProperty defines property to animate
  25111. * @param framePerSecond defines the number of frame per second yo use
  25112. * @param totalFrame defines the number of frames in total
  25113. * @param from defines the initial value
  25114. * @param to defines the final value
  25115. * @param loopMode defines which loop mode you want to use (off by default)
  25116. * @param easingFunction defines the easing function to use (linear by default)
  25117. * @param onAnimationEnd defines the callback to call when animation end
  25118. * @returns the animatable created for this animation
  25119. */
  25120. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25121. /**
  25122. * Create and start an animation on a node and its descendants
  25123. * @param name defines the name of the global animation that will be run on all nodes
  25124. * @param node defines the root node where the animation will take place
  25125. * @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
  25126. * @param targetProperty defines property to animate
  25127. * @param framePerSecond defines the number of frame per second to use
  25128. * @param totalFrame defines the number of frames in total
  25129. * @param from defines the initial value
  25130. * @param to defines the final value
  25131. * @param loopMode defines which loop mode you want to use (off by default)
  25132. * @param easingFunction defines the easing function to use (linear by default)
  25133. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25134. * @returns the list of animatables created for all nodes
  25135. * @example https://www.babylonjs-playground.com/#MH0VLI
  25136. */
  25137. 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[]>;
  25138. /**
  25139. * Creates a new animation, merges it with the existing animations and starts it
  25140. * @param name Name of the animation
  25141. * @param node Node which contains the scene that begins the animations
  25142. * @param targetProperty Specifies which property to animate
  25143. * @param framePerSecond The frames per second of the animation
  25144. * @param totalFrame The total number of frames
  25145. * @param from The frame at the beginning of the animation
  25146. * @param to The frame at the end of the animation
  25147. * @param loopMode Specifies the loop mode of the animation
  25148. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25149. * @param onAnimationEnd Callback to run once the animation is complete
  25150. * @returns Nullable animation
  25151. */
  25152. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25153. /**
  25154. * Transition property of an host to the target Value
  25155. * @param property The property to transition
  25156. * @param targetValue The target Value of the property
  25157. * @param host The object where the property to animate belongs
  25158. * @param scene Scene used to run the animation
  25159. * @param frameRate Framerate (in frame/s) to use
  25160. * @param transition The transition type we want to use
  25161. * @param duration The duration of the animation, in milliseconds
  25162. * @param onAnimationEnd Callback trigger at the end of the animation
  25163. * @returns Nullable animation
  25164. */
  25165. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25166. /**
  25167. * Return the array of runtime animations currently using this animation
  25168. */
  25169. readonly runtimeAnimations: RuntimeAnimation[];
  25170. /**
  25171. * Specifies if any of the runtime animations are currently running
  25172. */
  25173. readonly hasRunningRuntimeAnimations: boolean;
  25174. /**
  25175. * Initializes the animation
  25176. * @param name Name of the animation
  25177. * @param targetProperty Property to animate
  25178. * @param framePerSecond The frames per second of the animation
  25179. * @param dataType The data type of the animation
  25180. * @param loopMode The loop mode of the animation
  25181. * @param enableBlending Specifies if blending should be enabled
  25182. */
  25183. constructor(
  25184. /**Name of the animation */
  25185. name: string,
  25186. /**Property to animate */
  25187. targetProperty: string,
  25188. /**The frames per second of the animation */
  25189. framePerSecond: number,
  25190. /**The data type of the animation */
  25191. dataType: number,
  25192. /**The loop mode of the animation */
  25193. loopMode?: number | undefined,
  25194. /**Specifies if blending should be enabled */
  25195. enableBlending?: boolean | undefined);
  25196. /**
  25197. * Converts the animation to a string
  25198. * @param fullDetails support for multiple levels of logging within scene loading
  25199. * @returns String form of the animation
  25200. */
  25201. toString(fullDetails?: boolean): string;
  25202. /**
  25203. * Add an event to this animation
  25204. * @param event Event to add
  25205. */
  25206. addEvent(event: AnimationEvent): void;
  25207. /**
  25208. * Remove all events found at the given frame
  25209. * @param frame The frame to remove events from
  25210. */
  25211. removeEvents(frame: number): void;
  25212. /**
  25213. * Retrieves all the events from the animation
  25214. * @returns Events from the animation
  25215. */
  25216. getEvents(): AnimationEvent[];
  25217. /**
  25218. * Creates an animation range
  25219. * @param name Name of the animation range
  25220. * @param from Starting frame of the animation range
  25221. * @param to Ending frame of the animation
  25222. */
  25223. createRange(name: string, from: number, to: number): void;
  25224. /**
  25225. * Deletes an animation range by name
  25226. * @param name Name of the animation range to delete
  25227. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25228. */
  25229. deleteRange(name: string, deleteFrames?: boolean): void;
  25230. /**
  25231. * Gets the animation range by name, or null if not defined
  25232. * @param name Name of the animation range
  25233. * @returns Nullable animation range
  25234. */
  25235. getRange(name: string): Nullable<AnimationRange>;
  25236. /**
  25237. * Gets the key frames from the animation
  25238. * @returns The key frames of the animation
  25239. */
  25240. getKeys(): Array<IAnimationKey>;
  25241. /**
  25242. * Gets the highest frame rate of the animation
  25243. * @returns Highest frame rate of the animation
  25244. */
  25245. getHighestFrame(): number;
  25246. /**
  25247. * Gets the easing function of the animation
  25248. * @returns Easing function of the animation
  25249. */
  25250. getEasingFunction(): IEasingFunction;
  25251. /**
  25252. * Sets the easing function of the animation
  25253. * @param easingFunction A custom mathematical formula for animation
  25254. */
  25255. setEasingFunction(easingFunction: EasingFunction): void;
  25256. /**
  25257. * Interpolates a scalar linearly
  25258. * @param startValue Start value of the animation curve
  25259. * @param endValue End value of the animation curve
  25260. * @param gradient Scalar amount to interpolate
  25261. * @returns Interpolated scalar value
  25262. */
  25263. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25264. /**
  25265. * Interpolates a scalar cubically
  25266. * @param startValue Start value of the animation curve
  25267. * @param outTangent End tangent of the animation
  25268. * @param endValue End value of the animation curve
  25269. * @param inTangent Start tangent of the animation curve
  25270. * @param gradient Scalar amount to interpolate
  25271. * @returns Interpolated scalar value
  25272. */
  25273. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25274. /**
  25275. * Interpolates a quaternion using a spherical linear interpolation
  25276. * @param startValue Start value of the animation curve
  25277. * @param endValue End value of the animation curve
  25278. * @param gradient Scalar amount to interpolate
  25279. * @returns Interpolated quaternion value
  25280. */
  25281. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25282. /**
  25283. * Interpolates a quaternion cubically
  25284. * @param startValue Start value of the animation curve
  25285. * @param outTangent End tangent of the animation curve
  25286. * @param endValue End value of the animation curve
  25287. * @param inTangent Start tangent of the animation curve
  25288. * @param gradient Scalar amount to interpolate
  25289. * @returns Interpolated quaternion value
  25290. */
  25291. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25292. /**
  25293. * Interpolates a Vector3 linearl
  25294. * @param startValue Start value of the animation curve
  25295. * @param endValue End value of the animation curve
  25296. * @param gradient Scalar amount to interpolate
  25297. * @returns Interpolated scalar value
  25298. */
  25299. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25300. /**
  25301. * Interpolates a Vector3 cubically
  25302. * @param startValue Start value of the animation curve
  25303. * @param outTangent End tangent of the animation
  25304. * @param endValue End value of the animation curve
  25305. * @param inTangent Start tangent of the animation curve
  25306. * @param gradient Scalar amount to interpolate
  25307. * @returns InterpolatedVector3 value
  25308. */
  25309. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25310. /**
  25311. * Interpolates a Vector2 linearly
  25312. * @param startValue Start value of the animation curve
  25313. * @param endValue End value of the animation curve
  25314. * @param gradient Scalar amount to interpolate
  25315. * @returns Interpolated Vector2 value
  25316. */
  25317. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25318. /**
  25319. * Interpolates a Vector2 cubically
  25320. * @param startValue Start value of the animation curve
  25321. * @param outTangent End tangent of the animation
  25322. * @param endValue End value of the animation curve
  25323. * @param inTangent Start tangent of the animation curve
  25324. * @param gradient Scalar amount to interpolate
  25325. * @returns Interpolated Vector2 value
  25326. */
  25327. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25328. /**
  25329. * Interpolates a size linearly
  25330. * @param startValue Start value of the animation curve
  25331. * @param endValue End value of the animation curve
  25332. * @param gradient Scalar amount to interpolate
  25333. * @returns Interpolated Size value
  25334. */
  25335. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25336. /**
  25337. * Interpolates a Color3 linearly
  25338. * @param startValue Start value of the animation curve
  25339. * @param endValue End value of the animation curve
  25340. * @param gradient Scalar amount to interpolate
  25341. * @returns Interpolated Color3 value
  25342. */
  25343. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25344. /**
  25345. * @hidden Internal use only
  25346. */ getKeyValue(value: any): any;
  25347. /**
  25348. * @hidden Internal use only
  25349. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  25350. /**
  25351. * Defines the function to use to interpolate matrices
  25352. * @param startValue defines the start matrix
  25353. * @param endValue defines the end matrix
  25354. * @param gradient defines the gradient between both matrices
  25355. * @param result defines an optional target matrix where to store the interpolation
  25356. * @returns the interpolated matrix
  25357. */
  25358. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25359. /**
  25360. * Makes a copy of the animation
  25361. * @returns Cloned animation
  25362. */
  25363. clone(): Animation;
  25364. /**
  25365. * Sets the key frames of the animation
  25366. * @param values The animation key frames to set
  25367. */
  25368. setKeys(values: Array<IAnimationKey>): void;
  25369. /**
  25370. * Serializes the animation to an object
  25371. * @returns Serialized object
  25372. */
  25373. serialize(): any;
  25374. /**
  25375. * Float animation type
  25376. */
  25377. private static _ANIMATIONTYPE_FLOAT;
  25378. /**
  25379. * Vector3 animation type
  25380. */
  25381. private static _ANIMATIONTYPE_VECTOR3;
  25382. /**
  25383. * Quaternion animation type
  25384. */
  25385. private static _ANIMATIONTYPE_QUATERNION;
  25386. /**
  25387. * Matrix animation type
  25388. */
  25389. private static _ANIMATIONTYPE_MATRIX;
  25390. /**
  25391. * Color3 animation type
  25392. */
  25393. private static _ANIMATIONTYPE_COLOR3;
  25394. /**
  25395. * Vector2 animation type
  25396. */
  25397. private static _ANIMATIONTYPE_VECTOR2;
  25398. /**
  25399. * Size animation type
  25400. */
  25401. private static _ANIMATIONTYPE_SIZE;
  25402. /**
  25403. * Relative Loop Mode
  25404. */
  25405. private static _ANIMATIONLOOPMODE_RELATIVE;
  25406. /**
  25407. * Cycle Loop Mode
  25408. */
  25409. private static _ANIMATIONLOOPMODE_CYCLE;
  25410. /**
  25411. * Constant Loop Mode
  25412. */
  25413. private static _ANIMATIONLOOPMODE_CONSTANT;
  25414. /**
  25415. * Get the float animation type
  25416. */
  25417. static readonly ANIMATIONTYPE_FLOAT: number;
  25418. /**
  25419. * Get the Vector3 animation type
  25420. */
  25421. static readonly ANIMATIONTYPE_VECTOR3: number;
  25422. /**
  25423. * Get the Vector2 animation type
  25424. */
  25425. static readonly ANIMATIONTYPE_VECTOR2: number;
  25426. /**
  25427. * Get the Size animation type
  25428. */
  25429. static readonly ANIMATIONTYPE_SIZE: number;
  25430. /**
  25431. * Get the Quaternion animation type
  25432. */
  25433. static readonly ANIMATIONTYPE_QUATERNION: number;
  25434. /**
  25435. * Get the Matrix animation type
  25436. */
  25437. static readonly ANIMATIONTYPE_MATRIX: number;
  25438. /**
  25439. * Get the Color3 animation type
  25440. */
  25441. static readonly ANIMATIONTYPE_COLOR3: number;
  25442. /**
  25443. * Get the Relative Loop Mode
  25444. */
  25445. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25446. /**
  25447. * Get the Cycle Loop Mode
  25448. */
  25449. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25450. /**
  25451. * Get the Constant Loop Mode
  25452. */
  25453. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25454. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25455. /**
  25456. * Parses an animation object and creates an animation
  25457. * @param parsedAnimation Parsed animation object
  25458. * @returns Animation object
  25459. */
  25460. static Parse(parsedAnimation: any): Animation;
  25461. /**
  25462. * Appends the serialized animations from the source animations
  25463. * @param source Source containing the animations
  25464. * @param destination Target to store the animations
  25465. */
  25466. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25467. }
  25468. }
  25469. declare module BABYLON {
  25470. /**
  25471. * Base class of all the textures in babylon.
  25472. * It groups all the common properties the materials, post process, lights... might need
  25473. * in order to make a correct use of the texture.
  25474. */
  25475. export class BaseTexture implements IAnimatable {
  25476. /**
  25477. * Default anisotropic filtering level for the application.
  25478. * It is set to 4 as a good tradeoff between perf and quality.
  25479. */
  25480. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25481. /**
  25482. * Gets or sets the unique id of the texture
  25483. */
  25484. uniqueId: number;
  25485. /**
  25486. * Define the name of the texture.
  25487. */
  25488. name: string;
  25489. /**
  25490. * Gets or sets an object used to store user defined information.
  25491. */
  25492. metadata: any;
  25493. /**
  25494. * For internal use only. Please do not use.
  25495. */
  25496. reservedDataStore: any;
  25497. private _hasAlpha;
  25498. /**
  25499. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25500. */
  25501. hasAlpha: boolean;
  25502. /**
  25503. * Defines if the alpha value should be determined via the rgb values.
  25504. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25505. */
  25506. getAlphaFromRGB: boolean;
  25507. /**
  25508. * Intensity or strength of the texture.
  25509. * It is commonly used by materials to fine tune the intensity of the texture
  25510. */
  25511. level: number;
  25512. /**
  25513. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25514. * This is part of the texture as textures usually maps to one uv set.
  25515. */
  25516. coordinatesIndex: number;
  25517. private _coordinatesMode;
  25518. /**
  25519. * How a texture is mapped.
  25520. *
  25521. * | Value | Type | Description |
  25522. * | ----- | ----------------------------------- | ----------- |
  25523. * | 0 | EXPLICIT_MODE | |
  25524. * | 1 | SPHERICAL_MODE | |
  25525. * | 2 | PLANAR_MODE | |
  25526. * | 3 | CUBIC_MODE | |
  25527. * | 4 | PROJECTION_MODE | |
  25528. * | 5 | SKYBOX_MODE | |
  25529. * | 6 | INVCUBIC_MODE | |
  25530. * | 7 | EQUIRECTANGULAR_MODE | |
  25531. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25532. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25533. */
  25534. coordinatesMode: number;
  25535. /**
  25536. * | Value | Type | Description |
  25537. * | ----- | ------------------ | ----------- |
  25538. * | 0 | CLAMP_ADDRESSMODE | |
  25539. * | 1 | WRAP_ADDRESSMODE | |
  25540. * | 2 | MIRROR_ADDRESSMODE | |
  25541. */
  25542. wrapU: number;
  25543. /**
  25544. * | Value | Type | Description |
  25545. * | ----- | ------------------ | ----------- |
  25546. * | 0 | CLAMP_ADDRESSMODE | |
  25547. * | 1 | WRAP_ADDRESSMODE | |
  25548. * | 2 | MIRROR_ADDRESSMODE | |
  25549. */
  25550. wrapV: number;
  25551. /**
  25552. * | Value | Type | Description |
  25553. * | ----- | ------------------ | ----------- |
  25554. * | 0 | CLAMP_ADDRESSMODE | |
  25555. * | 1 | WRAP_ADDRESSMODE | |
  25556. * | 2 | MIRROR_ADDRESSMODE | |
  25557. */
  25558. wrapR: number;
  25559. /**
  25560. * With compliant hardware and browser (supporting anisotropic filtering)
  25561. * this defines the level of anisotropic filtering in the texture.
  25562. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25563. */
  25564. anisotropicFilteringLevel: number;
  25565. /**
  25566. * Define if the texture is a cube texture or if false a 2d texture.
  25567. */
  25568. isCube: boolean;
  25569. /**
  25570. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25571. */
  25572. is3D: boolean;
  25573. /**
  25574. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25575. * HDR texture are usually stored in linear space.
  25576. * This only impacts the PBR and Background materials
  25577. */
  25578. gammaSpace: boolean;
  25579. /**
  25580. * Gets whether or not the texture contains RGBD data.
  25581. */
  25582. readonly isRGBD: boolean;
  25583. /**
  25584. * Is Z inverted in the texture (useful in a cube texture).
  25585. */
  25586. invertZ: boolean;
  25587. /**
  25588. * Are mip maps generated for this texture or not.
  25589. */
  25590. readonly noMipmap: boolean;
  25591. /**
  25592. * @hidden
  25593. */
  25594. lodLevelInAlpha: boolean;
  25595. /**
  25596. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25597. */
  25598. lodGenerationOffset: number;
  25599. /**
  25600. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25601. */
  25602. lodGenerationScale: number;
  25603. /**
  25604. * Define if the texture is a render target.
  25605. */
  25606. isRenderTarget: boolean;
  25607. /**
  25608. * Define the unique id of the texture in the scene.
  25609. */
  25610. readonly uid: string;
  25611. /**
  25612. * Return a string representation of the texture.
  25613. * @returns the texture as a string
  25614. */
  25615. toString(): string;
  25616. /**
  25617. * Get the class name of the texture.
  25618. * @returns "BaseTexture"
  25619. */
  25620. getClassName(): string;
  25621. /**
  25622. * Define the list of animation attached to the texture.
  25623. */
  25624. animations: Animation[];
  25625. /**
  25626. * An event triggered when the texture is disposed.
  25627. */
  25628. onDisposeObservable: Observable<BaseTexture>;
  25629. private _onDisposeObserver;
  25630. /**
  25631. * Callback triggered when the texture has been disposed.
  25632. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25633. */
  25634. onDispose: () => void;
  25635. /**
  25636. * Define the current state of the loading sequence when in delayed load mode.
  25637. */
  25638. delayLoadState: number;
  25639. private _scene;
  25640. /** @hidden */ texture: Nullable<InternalTexture>;
  25641. private _uid;
  25642. /**
  25643. * Define if the texture is preventinga material to render or not.
  25644. * If not and the texture is not ready, the engine will use a default black texture instead.
  25645. */
  25646. readonly isBlocking: boolean;
  25647. /**
  25648. * Instantiates a new BaseTexture.
  25649. * Base class of all the textures in babylon.
  25650. * It groups all the common properties the materials, post process, lights... might need
  25651. * in order to make a correct use of the texture.
  25652. * @param scene Define the scene the texture blongs to
  25653. */
  25654. constructor(scene: Nullable<Scene>);
  25655. /**
  25656. * Get the scene the texture belongs to.
  25657. * @returns the scene or null if undefined
  25658. */
  25659. getScene(): Nullable<Scene>;
  25660. /**
  25661. * Get the texture transform matrix used to offset tile the texture for istance.
  25662. * @returns the transformation matrix
  25663. */
  25664. getTextureMatrix(): Matrix;
  25665. /**
  25666. * Get the texture reflection matrix used to rotate/transform the reflection.
  25667. * @returns the reflection matrix
  25668. */
  25669. getReflectionTextureMatrix(): Matrix;
  25670. /**
  25671. * Get the underlying lower level texture from Babylon.
  25672. * @returns the insternal texture
  25673. */
  25674. getInternalTexture(): Nullable<InternalTexture>;
  25675. /**
  25676. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25677. * @returns true if ready or not blocking
  25678. */
  25679. isReadyOrNotBlocking(): boolean;
  25680. /**
  25681. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25682. * @returns true if fully ready
  25683. */
  25684. isReady(): boolean;
  25685. private _cachedSize;
  25686. /**
  25687. * Get the size of the texture.
  25688. * @returns the texture size.
  25689. */
  25690. getSize(): ISize;
  25691. /**
  25692. * Get the base size of the texture.
  25693. * It can be different from the size if the texture has been resized for POT for instance
  25694. * @returns the base size
  25695. */
  25696. getBaseSize(): ISize;
  25697. /**
  25698. * Update the sampling mode of the texture.
  25699. * Default is Trilinear mode.
  25700. *
  25701. * | Value | Type | Description |
  25702. * | ----- | ------------------ | ----------- |
  25703. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25704. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25705. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25706. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25707. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25708. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25709. * | 7 | NEAREST_LINEAR | |
  25710. * | 8 | NEAREST_NEAREST | |
  25711. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25712. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25713. * | 11 | LINEAR_LINEAR | |
  25714. * | 12 | LINEAR_NEAREST | |
  25715. *
  25716. * > _mag_: magnification filter (close to the viewer)
  25717. * > _min_: minification filter (far from the viewer)
  25718. * > _mip_: filter used between mip map levels
  25719. *@param samplingMode Define the new sampling mode of the texture
  25720. */
  25721. updateSamplingMode(samplingMode: number): void;
  25722. /**
  25723. * Scales the texture if is `canRescale()`
  25724. * @param ratio the resize factor we want to use to rescale
  25725. */
  25726. scale(ratio: number): void;
  25727. /**
  25728. * Get if the texture can rescale.
  25729. */
  25730. readonly canRescale: boolean;
  25731. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25732. /** @hidden */ rebuild(): void;
  25733. /**
  25734. * Triggers the load sequence in delayed load mode.
  25735. */
  25736. delayLoad(): void;
  25737. /**
  25738. * Clones the texture.
  25739. * @returns the cloned texture
  25740. */
  25741. clone(): Nullable<BaseTexture>;
  25742. /**
  25743. * Get the texture underlying type (INT, FLOAT...)
  25744. */
  25745. readonly textureType: number;
  25746. /**
  25747. * Get the texture underlying format (RGB, RGBA...)
  25748. */
  25749. readonly textureFormat: number;
  25750. /**
  25751. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25752. * This will returns an RGBA array buffer containing either in values (0-255) or
  25753. * float values (0-1) depending of the underlying buffer type.
  25754. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25755. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25756. * @param buffer defines a user defined buffer to fill with data (can be null)
  25757. * @returns The Array buffer containing the pixels data.
  25758. */
  25759. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25760. /**
  25761. * Release and destroy the underlying lower level texture aka internalTexture.
  25762. */
  25763. releaseInternalTexture(): void;
  25764. /**
  25765. * Get the polynomial representation of the texture data.
  25766. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25767. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25768. */
  25769. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25770. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25771. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25772. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25773. /**
  25774. * Dispose the texture and release its associated resources.
  25775. */
  25776. dispose(): void;
  25777. /**
  25778. * Serialize the texture into a JSON representation that can be parsed later on.
  25779. * @returns the JSON representation of the texture
  25780. */
  25781. serialize(): any;
  25782. /**
  25783. * Helper function to be called back once a list of texture contains only ready textures.
  25784. * @param textures Define the list of textures to wait for
  25785. * @param callback Define the callback triggered once the entire list will be ready
  25786. */
  25787. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25788. }
  25789. }
  25790. declare module BABYLON {
  25791. /**
  25792. * Uniform buffer objects.
  25793. *
  25794. * Handles blocks of uniform on the GPU.
  25795. *
  25796. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25797. *
  25798. * For more information, please refer to :
  25799. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25800. */
  25801. export class UniformBuffer {
  25802. private _engine;
  25803. private _buffer;
  25804. private _data;
  25805. private _bufferData;
  25806. private _dynamic?;
  25807. private _uniformLocations;
  25808. private _uniformSizes;
  25809. private _uniformLocationPointer;
  25810. private _needSync;
  25811. private _noUBO;
  25812. private _currentEffect;
  25813. private static _MAX_UNIFORM_SIZE;
  25814. private static _tempBuffer;
  25815. /**
  25816. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25817. * This is dynamic to allow compat with webgl 1 and 2.
  25818. * You will need to pass the name of the uniform as well as the value.
  25819. */
  25820. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25821. /**
  25822. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25823. * This is dynamic to allow compat with webgl 1 and 2.
  25824. * You will need to pass the name of the uniform as well as the value.
  25825. */
  25826. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25827. /**
  25828. * Lambda to Update a single float in a uniform buffer.
  25829. * This is dynamic to allow compat with webgl 1 and 2.
  25830. * You will need to pass the name of the uniform as well as the value.
  25831. */
  25832. updateFloat: (name: string, x: number) => void;
  25833. /**
  25834. * Lambda to Update a vec2 of float in a uniform buffer.
  25835. * This is dynamic to allow compat with webgl 1 and 2.
  25836. * You will need to pass the name of the uniform as well as the value.
  25837. */
  25838. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25839. /**
  25840. * Lambda to Update a vec3 of float in a uniform buffer.
  25841. * This is dynamic to allow compat with webgl 1 and 2.
  25842. * You will need to pass the name of the uniform as well as the value.
  25843. */
  25844. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25845. /**
  25846. * Lambda to Update a vec4 of float in a uniform buffer.
  25847. * This is dynamic to allow compat with webgl 1 and 2.
  25848. * You will need to pass the name of the uniform as well as the value.
  25849. */
  25850. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25851. /**
  25852. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25853. * This is dynamic to allow compat with webgl 1 and 2.
  25854. * You will need to pass the name of the uniform as well as the value.
  25855. */
  25856. updateMatrix: (name: string, mat: Matrix) => void;
  25857. /**
  25858. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25859. * This is dynamic to allow compat with webgl 1 and 2.
  25860. * You will need to pass the name of the uniform as well as the value.
  25861. */
  25862. updateVector3: (name: string, vector: Vector3) => void;
  25863. /**
  25864. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25865. * This is dynamic to allow compat with webgl 1 and 2.
  25866. * You will need to pass the name of the uniform as well as the value.
  25867. */
  25868. updateVector4: (name: string, vector: Vector4) => void;
  25869. /**
  25870. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25871. * This is dynamic to allow compat with webgl 1 and 2.
  25872. * You will need to pass the name of the uniform as well as the value.
  25873. */
  25874. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25875. /**
  25876. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25877. * This is dynamic to allow compat with webgl 1 and 2.
  25878. * You will need to pass the name of the uniform as well as the value.
  25879. */
  25880. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25881. /**
  25882. * Instantiates a new Uniform buffer objects.
  25883. *
  25884. * Handles blocks of uniform on the GPU.
  25885. *
  25886. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25887. *
  25888. * For more information, please refer to :
  25889. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25890. * @param engine Define the engine the buffer is associated with
  25891. * @param data Define the data contained in the buffer
  25892. * @param dynamic Define if the buffer is updatable
  25893. */
  25894. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25895. /**
  25896. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25897. * or just falling back on setUniformXXX calls.
  25898. */
  25899. readonly useUbo: boolean;
  25900. /**
  25901. * Indicates if the WebGL underlying uniform buffer is in sync
  25902. * with the javascript cache data.
  25903. */
  25904. readonly isSync: boolean;
  25905. /**
  25906. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25907. * Also, a dynamic UniformBuffer will disable cache verification and always
  25908. * update the underlying WebGL uniform buffer to the GPU.
  25909. * @returns if Dynamic, otherwise false
  25910. */
  25911. isDynamic(): boolean;
  25912. /**
  25913. * The data cache on JS side.
  25914. * @returns the underlying data as a float array
  25915. */
  25916. getData(): Float32Array;
  25917. /**
  25918. * The underlying WebGL Uniform buffer.
  25919. * @returns the webgl buffer
  25920. */
  25921. getBuffer(): Nullable<DataBuffer>;
  25922. /**
  25923. * std140 layout specifies how to align data within an UBO structure.
  25924. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25925. * for specs.
  25926. */
  25927. private _fillAlignment;
  25928. /**
  25929. * Adds an uniform in the buffer.
  25930. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25931. * for the layout to be correct !
  25932. * @param name Name of the uniform, as used in the uniform block in the shader.
  25933. * @param size Data size, or data directly.
  25934. */
  25935. addUniform(name: string, size: number | number[]): void;
  25936. /**
  25937. * Adds a Matrix 4x4 to the uniform buffer.
  25938. * @param name Name of the uniform, as used in the uniform block in the shader.
  25939. * @param mat A 4x4 matrix.
  25940. */
  25941. addMatrix(name: string, mat: Matrix): void;
  25942. /**
  25943. * Adds a vec2 to the uniform buffer.
  25944. * @param name Name of the uniform, as used in the uniform block in the shader.
  25945. * @param x Define the x component value of the vec2
  25946. * @param y Define the y component value of the vec2
  25947. */
  25948. addFloat2(name: string, x: number, y: number): void;
  25949. /**
  25950. * Adds a vec3 to the uniform buffer.
  25951. * @param name Name of the uniform, as used in the uniform block in the shader.
  25952. * @param x Define the x component value of the vec3
  25953. * @param y Define the y component value of the vec3
  25954. * @param z Define the z component value of the vec3
  25955. */
  25956. addFloat3(name: string, x: number, y: number, z: number): void;
  25957. /**
  25958. * Adds a vec3 to the uniform buffer.
  25959. * @param name Name of the uniform, as used in the uniform block in the shader.
  25960. * @param color Define the vec3 from a Color
  25961. */
  25962. addColor3(name: string, color: Color3): void;
  25963. /**
  25964. * Adds a vec4 to the uniform buffer.
  25965. * @param name Name of the uniform, as used in the uniform block in the shader.
  25966. * @param color Define the rgb components from a Color
  25967. * @param alpha Define the a component of the vec4
  25968. */
  25969. addColor4(name: string, color: Color3, alpha: number): void;
  25970. /**
  25971. * Adds a vec3 to the uniform buffer.
  25972. * @param name Name of the uniform, as used in the uniform block in the shader.
  25973. * @param vector Define the vec3 components from a Vector
  25974. */
  25975. addVector3(name: string, vector: Vector3): void;
  25976. /**
  25977. * Adds a Matrix 3x3 to the uniform buffer.
  25978. * @param name Name of the uniform, as used in the uniform block in the shader.
  25979. */
  25980. addMatrix3x3(name: string): void;
  25981. /**
  25982. * Adds a Matrix 2x2 to the uniform buffer.
  25983. * @param name Name of the uniform, as used in the uniform block in the shader.
  25984. */
  25985. addMatrix2x2(name: string): void;
  25986. /**
  25987. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25988. */
  25989. create(): void;
  25990. /** @hidden */ rebuild(): void;
  25991. /**
  25992. * Updates the WebGL Uniform Buffer on the GPU.
  25993. * If the `dynamic` flag is set to true, no cache comparison is done.
  25994. * Otherwise, the buffer will be updated only if the cache differs.
  25995. */
  25996. update(): void;
  25997. /**
  25998. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25999. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26000. * @param data Define the flattened data
  26001. * @param size Define the size of the data.
  26002. */
  26003. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26004. private _updateMatrix3x3ForUniform;
  26005. private _updateMatrix3x3ForEffect;
  26006. private _updateMatrix2x2ForEffect;
  26007. private _updateMatrix2x2ForUniform;
  26008. private _updateFloatForEffect;
  26009. private _updateFloatForUniform;
  26010. private _updateFloat2ForEffect;
  26011. private _updateFloat2ForUniform;
  26012. private _updateFloat3ForEffect;
  26013. private _updateFloat3ForUniform;
  26014. private _updateFloat4ForEffect;
  26015. private _updateFloat4ForUniform;
  26016. private _updateMatrixForEffect;
  26017. private _updateMatrixForUniform;
  26018. private _updateVector3ForEffect;
  26019. private _updateVector3ForUniform;
  26020. private _updateVector4ForEffect;
  26021. private _updateVector4ForUniform;
  26022. private _updateColor3ForEffect;
  26023. private _updateColor3ForUniform;
  26024. private _updateColor4ForEffect;
  26025. private _updateColor4ForUniform;
  26026. /**
  26027. * Sets a sampler uniform on the effect.
  26028. * @param name Define the name of the sampler.
  26029. * @param texture Define the texture to set in the sampler
  26030. */
  26031. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26032. /**
  26033. * Directly updates the value of the uniform in the cache AND on the GPU.
  26034. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26035. * @param data Define the flattened data
  26036. */
  26037. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26038. /**
  26039. * Binds this uniform buffer to an effect.
  26040. * @param effect Define the effect to bind the buffer to
  26041. * @param name Name of the uniform block in the shader.
  26042. */
  26043. bindToEffect(effect: Effect, name: string): void;
  26044. /**
  26045. * Disposes the uniform buffer.
  26046. */
  26047. dispose(): void;
  26048. }
  26049. }
  26050. declare module BABYLON {
  26051. /**
  26052. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26054. */
  26055. export class Analyser {
  26056. /**
  26057. * Gets or sets the smoothing
  26058. * @ignorenaming
  26059. */
  26060. SMOOTHING: number;
  26061. /**
  26062. * Gets or sets the FFT table size
  26063. * @ignorenaming
  26064. */
  26065. FFT_SIZE: number;
  26066. /**
  26067. * Gets or sets the bar graph amplitude
  26068. * @ignorenaming
  26069. */
  26070. BARGRAPHAMPLITUDE: number;
  26071. /**
  26072. * Gets or sets the position of the debug canvas
  26073. * @ignorenaming
  26074. */
  26075. DEBUGCANVASPOS: {
  26076. x: number;
  26077. y: number;
  26078. };
  26079. /**
  26080. * Gets or sets the debug canvas size
  26081. * @ignorenaming
  26082. */
  26083. DEBUGCANVASSIZE: {
  26084. width: number;
  26085. height: number;
  26086. };
  26087. private _byteFreqs;
  26088. private _byteTime;
  26089. private _floatFreqs;
  26090. private _webAudioAnalyser;
  26091. private _debugCanvas;
  26092. private _debugCanvasContext;
  26093. private _scene;
  26094. private _registerFunc;
  26095. private _audioEngine;
  26096. /**
  26097. * Creates a new analyser
  26098. * @param scene defines hosting scene
  26099. */
  26100. constructor(scene: Scene);
  26101. /**
  26102. * Get the number of data values you will have to play with for the visualization
  26103. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26104. * @returns a number
  26105. */
  26106. getFrequencyBinCount(): number;
  26107. /**
  26108. * Gets the current frequency data as a byte array
  26109. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26110. * @returns a Uint8Array
  26111. */
  26112. getByteFrequencyData(): Uint8Array;
  26113. /**
  26114. * Gets the current waveform as a byte array
  26115. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26116. * @returns a Uint8Array
  26117. */
  26118. getByteTimeDomainData(): Uint8Array;
  26119. /**
  26120. * Gets the current frequency data as a float array
  26121. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26122. * @returns a Float32Array
  26123. */
  26124. getFloatFrequencyData(): Float32Array;
  26125. /**
  26126. * Renders the debug canvas
  26127. */
  26128. drawDebugCanvas(): void;
  26129. /**
  26130. * Stops rendering the debug canvas and removes it
  26131. */
  26132. stopDebugCanvas(): void;
  26133. /**
  26134. * Connects two audio nodes
  26135. * @param inputAudioNode defines first node to connect
  26136. * @param outputAudioNode defines second node to connect
  26137. */
  26138. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26139. /**
  26140. * Releases all associated resources
  26141. */
  26142. dispose(): void;
  26143. }
  26144. }
  26145. declare module BABYLON {
  26146. /**
  26147. * This represents an audio engine and it is responsible
  26148. * to play, synchronize and analyse sounds throughout the application.
  26149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26150. */
  26151. export interface IAudioEngine extends IDisposable {
  26152. /**
  26153. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26154. */
  26155. readonly canUseWebAudio: boolean;
  26156. /**
  26157. * Gets the current AudioContext if available.
  26158. */
  26159. readonly audioContext: Nullable<AudioContext>;
  26160. /**
  26161. * The master gain node defines the global audio volume of your audio engine.
  26162. */
  26163. readonly masterGain: GainNode;
  26164. /**
  26165. * Gets whether or not mp3 are supported by your browser.
  26166. */
  26167. readonly isMP3supported: boolean;
  26168. /**
  26169. * Gets whether or not ogg are supported by your browser.
  26170. */
  26171. readonly isOGGsupported: boolean;
  26172. /**
  26173. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26174. * @ignoreNaming
  26175. */
  26176. WarnedWebAudioUnsupported: boolean;
  26177. /**
  26178. * Defines if the audio engine relies on a custom unlocked button.
  26179. * In this case, the embedded button will not be displayed.
  26180. */
  26181. useCustomUnlockedButton: boolean;
  26182. /**
  26183. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26184. */
  26185. readonly unlocked: boolean;
  26186. /**
  26187. * Event raised when audio has been unlocked on the browser.
  26188. */
  26189. onAudioUnlockedObservable: Observable<AudioEngine>;
  26190. /**
  26191. * Event raised when audio has been locked on the browser.
  26192. */
  26193. onAudioLockedObservable: Observable<AudioEngine>;
  26194. /**
  26195. * Flags the audio engine in Locked state.
  26196. * This happens due to new browser policies preventing audio to autoplay.
  26197. */
  26198. lock(): void;
  26199. /**
  26200. * Unlocks the audio engine once a user action has been done on the dom.
  26201. * This is helpful to resume play once browser policies have been satisfied.
  26202. */
  26203. unlock(): void;
  26204. }
  26205. /**
  26206. * This represents the default audio engine used in babylon.
  26207. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26209. */
  26210. export class AudioEngine implements IAudioEngine {
  26211. private _audioContext;
  26212. private _audioContextInitialized;
  26213. private _muteButton;
  26214. private _hostElement;
  26215. /**
  26216. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26217. */
  26218. canUseWebAudio: boolean;
  26219. /**
  26220. * The master gain node defines the global audio volume of your audio engine.
  26221. */
  26222. masterGain: GainNode;
  26223. /**
  26224. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26225. * @ignoreNaming
  26226. */
  26227. WarnedWebAudioUnsupported: boolean;
  26228. /**
  26229. * Gets whether or not mp3 are supported by your browser.
  26230. */
  26231. isMP3supported: boolean;
  26232. /**
  26233. * Gets whether or not ogg are supported by your browser.
  26234. */
  26235. isOGGsupported: boolean;
  26236. /**
  26237. * Gets whether audio has been unlocked on the device.
  26238. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26239. * a user interaction has happened.
  26240. */
  26241. unlocked: boolean;
  26242. /**
  26243. * Defines if the audio engine relies on a custom unlocked button.
  26244. * In this case, the embedded button will not be displayed.
  26245. */
  26246. useCustomUnlockedButton: boolean;
  26247. /**
  26248. * Event raised when audio has been unlocked on the browser.
  26249. */
  26250. onAudioUnlockedObservable: Observable<AudioEngine>;
  26251. /**
  26252. * Event raised when audio has been locked on the browser.
  26253. */
  26254. onAudioLockedObservable: Observable<AudioEngine>;
  26255. /**
  26256. * Gets the current AudioContext if available.
  26257. */
  26258. readonly audioContext: Nullable<AudioContext>;
  26259. private _connectedAnalyser;
  26260. /**
  26261. * Instantiates a new audio engine.
  26262. *
  26263. * There should be only one per page as some browsers restrict the number
  26264. * of audio contexts you can create.
  26265. * @param hostElement defines the host element where to display the mute icon if necessary
  26266. */
  26267. constructor(hostElement?: Nullable<HTMLElement>);
  26268. /**
  26269. * Flags the audio engine in Locked state.
  26270. * This happens due to new browser policies preventing audio to autoplay.
  26271. */
  26272. lock(): void;
  26273. /**
  26274. * Unlocks the audio engine once a user action has been done on the dom.
  26275. * This is helpful to resume play once browser policies have been satisfied.
  26276. */
  26277. unlock(): void;
  26278. private _resumeAudioContext;
  26279. private _initializeAudioContext;
  26280. private _tryToRun;
  26281. private _triggerRunningState;
  26282. private _triggerSuspendedState;
  26283. private _displayMuteButton;
  26284. private _moveButtonToTopLeft;
  26285. private _onResize;
  26286. private _hideMuteButton;
  26287. /**
  26288. * Destroy and release the resources associated with the audio ccontext.
  26289. */
  26290. dispose(): void;
  26291. /**
  26292. * Gets the global volume sets on the master gain.
  26293. * @returns the global volume if set or -1 otherwise
  26294. */
  26295. getGlobalVolume(): number;
  26296. /**
  26297. * Sets the global volume of your experience (sets on the master gain).
  26298. * @param newVolume Defines the new global volume of the application
  26299. */
  26300. setGlobalVolume(newVolume: number): void;
  26301. /**
  26302. * Connect the audio engine to an audio analyser allowing some amazing
  26303. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26305. * @param analyser The analyser to connect to the engine
  26306. */
  26307. connectToAnalyser(analyser: Analyser): void;
  26308. }
  26309. }
  26310. declare module BABYLON {
  26311. /**
  26312. * Interface used to present a loading screen while loading a scene
  26313. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26314. */
  26315. export interface ILoadingScreen {
  26316. /**
  26317. * Function called to display the loading screen
  26318. */
  26319. displayLoadingUI: () => void;
  26320. /**
  26321. * Function called to hide the loading screen
  26322. */
  26323. hideLoadingUI: () => void;
  26324. /**
  26325. * Gets or sets the color to use for the background
  26326. */
  26327. loadingUIBackgroundColor: string;
  26328. /**
  26329. * Gets or sets the text to display while loading
  26330. */
  26331. loadingUIText: string;
  26332. }
  26333. /**
  26334. * Class used for the default loading screen
  26335. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26336. */
  26337. export class DefaultLoadingScreen implements ILoadingScreen {
  26338. private _renderingCanvas;
  26339. private _loadingText;
  26340. private _loadingDivBackgroundColor;
  26341. private _loadingDiv;
  26342. private _loadingTextDiv;
  26343. /**
  26344. * Creates a new default loading screen
  26345. * @param _renderingCanvas defines the canvas used to render the scene
  26346. * @param _loadingText defines the default text to display
  26347. * @param _loadingDivBackgroundColor defines the default background color
  26348. */
  26349. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26350. /**
  26351. * Function called to display the loading screen
  26352. */
  26353. displayLoadingUI(): void;
  26354. /**
  26355. * Function called to hide the loading screen
  26356. */
  26357. hideLoadingUI(): void;
  26358. /**
  26359. * Gets or sets the text to display while loading
  26360. */
  26361. loadingUIText: string;
  26362. /**
  26363. * Gets or sets the color to use for the background
  26364. */
  26365. loadingUIBackgroundColor: string;
  26366. private _resizeLoadingUI;
  26367. }
  26368. }
  26369. declare module BABYLON {
  26370. /** @hidden */
  26371. export class WebGLPipelineContext implements IPipelineContext {
  26372. engine: Engine;
  26373. program: Nullable<WebGLProgram>;
  26374. context?: WebGLRenderingContext;
  26375. vertexShader?: WebGLShader;
  26376. fragmentShader?: WebGLShader;
  26377. isParallelCompiled: boolean;
  26378. onCompiled?: () => void;
  26379. transformFeedback?: WebGLTransformFeedback | null;
  26380. readonly isAsync: boolean;
  26381. readonly isReady: boolean; handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26382. }
  26383. }
  26384. declare module BABYLON {
  26385. /** @hidden */
  26386. export class WebGLDataBuffer extends DataBuffer {
  26387. private _buffer;
  26388. constructor(resource: WebGLBuffer);
  26389. readonly underlyingResource: any;
  26390. }
  26391. }
  26392. declare module BABYLON {
  26393. /**
  26394. * Settings for finer control over video usage
  26395. */
  26396. export interface VideoTextureSettings {
  26397. /**
  26398. * Applies `autoplay` to video, if specified
  26399. */
  26400. autoPlay?: boolean;
  26401. /**
  26402. * Applies `loop` to video, if specified
  26403. */
  26404. loop?: boolean;
  26405. /**
  26406. * Automatically updates internal texture from video at every frame in the render loop
  26407. */
  26408. autoUpdateTexture: boolean;
  26409. /**
  26410. * Image src displayed during the video loading or until the user interacts with the video.
  26411. */
  26412. poster?: string;
  26413. }
  26414. /**
  26415. * If you want to display a video in your scene, this is the special texture for that.
  26416. * This special texture works similar to other textures, with the exception of a few parameters.
  26417. * @see https://doc.babylonjs.com/how_to/video_texture
  26418. */
  26419. export class VideoTexture extends Texture {
  26420. /**
  26421. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26422. */
  26423. readonly autoUpdateTexture: boolean;
  26424. /**
  26425. * The video instance used by the texture internally
  26426. */
  26427. readonly video: HTMLVideoElement;
  26428. private _onUserActionRequestedObservable;
  26429. /**
  26430. * Event triggerd when a dom action is required by the user to play the video.
  26431. * This happens due to recent changes in browser policies preventing video to auto start.
  26432. */
  26433. readonly onUserActionRequestedObservable: Observable<Texture>;
  26434. private _generateMipMaps;
  26435. private _engine;
  26436. private _stillImageCaptured;
  26437. private _displayingPosterTexture;
  26438. private _settings;
  26439. private _createInternalTextureOnEvent;
  26440. /**
  26441. * Creates a video texture.
  26442. * If you want to display a video in your scene, this is the special texture for that.
  26443. * This special texture works similar to other textures, with the exception of a few parameters.
  26444. * @see https://doc.babylonjs.com/how_to/video_texture
  26445. * @param name optional name, will detect from video source, if not defined
  26446. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26447. * @param scene is obviously the current scene.
  26448. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26449. * @param invertY is false by default but can be used to invert video on Y axis
  26450. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26451. * @param settings allows finer control over video usage
  26452. */
  26453. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26454. private _getName;
  26455. private _getVideo;
  26456. private _createInternalTexture;
  26457. private reset;
  26458. /**
  26459. * @hidden Internal method to initiate `update`.
  26460. */ rebuild(): void;
  26461. /**
  26462. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26463. */
  26464. update(): void;
  26465. /**
  26466. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26467. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26468. */
  26469. updateTexture(isVisible: boolean): void;
  26470. protected _updateInternalTexture: () => void;
  26471. /**
  26472. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26473. * @param url New url.
  26474. */
  26475. updateURL(url: string): void;
  26476. /**
  26477. * Dispose the texture and release its associated resources.
  26478. */
  26479. dispose(): void;
  26480. /**
  26481. * Creates a video texture straight from a stream.
  26482. * @param scene Define the scene the texture should be created in
  26483. * @param stream Define the stream the texture should be created from
  26484. * @returns The created video texture as a promise
  26485. */
  26486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26487. /**
  26488. * Creates a video texture straight from your WebCam video feed.
  26489. * @param scene Define the scene the texture should be created in
  26490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26492. * @returns The created video texture as a promise
  26493. */
  26494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26495. minWidth: number;
  26496. maxWidth: number;
  26497. minHeight: number;
  26498. maxHeight: number;
  26499. deviceId: string;
  26500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26501. /**
  26502. * Creates a video texture straight from your WebCam video feed.
  26503. * @param scene Define the scene the texture should be created in
  26504. * @param onReady Define a callback to triggered once the texture will be ready
  26505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26507. */
  26508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26509. minWidth: number;
  26510. maxWidth: number;
  26511. minHeight: number;
  26512. maxHeight: number;
  26513. deviceId: string;
  26514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26515. }
  26516. }
  26517. declare module BABYLON {
  26518. /**
  26519. * Interface for attribute information associated with buffer instanciation
  26520. */
  26521. export class InstancingAttributeInfo {
  26522. /**
  26523. * Index/offset of the attribute in the vertex shader
  26524. */
  26525. index: number;
  26526. /**
  26527. * size of the attribute, 1, 2, 3 or 4
  26528. */
  26529. attributeSize: number;
  26530. /**
  26531. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26532. * default is FLOAT
  26533. */
  26534. attribyteType: number;
  26535. /**
  26536. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26537. */
  26538. normalized: boolean;
  26539. /**
  26540. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26541. */
  26542. offset: number;
  26543. /**
  26544. * Name of the GLSL attribute, for debugging purpose only
  26545. */
  26546. attributeName: string;
  26547. }
  26548. /**
  26549. * Define options used to create a depth texture
  26550. */
  26551. export class DepthTextureCreationOptions {
  26552. /** Specifies whether or not a stencil should be allocated in the texture */
  26553. generateStencil?: boolean;
  26554. /** Specifies whether or not bilinear filtering is enable on the texture */
  26555. bilinearFiltering?: boolean;
  26556. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26557. comparisonFunction?: number;
  26558. /** Specifies if the created texture is a cube texture */
  26559. isCube?: boolean;
  26560. }
  26561. /**
  26562. * Class used to describe the capabilities of the engine relatively to the current browser
  26563. */
  26564. export class EngineCapabilities {
  26565. /** Maximum textures units per fragment shader */
  26566. maxTexturesImageUnits: number;
  26567. /** Maximum texture units per vertex shader */
  26568. maxVertexTextureImageUnits: number;
  26569. /** Maximum textures units in the entire pipeline */
  26570. maxCombinedTexturesImageUnits: number;
  26571. /** Maximum texture size */
  26572. maxTextureSize: number;
  26573. /** Maximum cube texture size */
  26574. maxCubemapTextureSize: number;
  26575. /** Maximum render texture size */
  26576. maxRenderTextureSize: number;
  26577. /** Maximum number of vertex attributes */
  26578. maxVertexAttribs: number;
  26579. /** Maximum number of varyings */
  26580. maxVaryingVectors: number;
  26581. /** Maximum number of uniforms per vertex shader */
  26582. maxVertexUniformVectors: number;
  26583. /** Maximum number of uniforms per fragment shader */
  26584. maxFragmentUniformVectors: number;
  26585. /** Defines if standard derivates (dx/dy) are supported */
  26586. standardDerivatives: boolean;
  26587. /** Defines if s3tc texture compression is supported */
  26588. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26589. /** Defines if pvrtc texture compression is supported */
  26590. pvrtc: any;
  26591. /** Defines if etc1 texture compression is supported */
  26592. etc1: any;
  26593. /** Defines if etc2 texture compression is supported */
  26594. etc2: any;
  26595. /** Defines if astc texture compression is supported */
  26596. astc: any;
  26597. /** Defines if float textures are supported */
  26598. textureFloat: boolean;
  26599. /** Defines if vertex array objects are supported */
  26600. vertexArrayObject: boolean;
  26601. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26602. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26603. /** Gets the maximum level of anisotropy supported */
  26604. maxAnisotropy: number;
  26605. /** Defines if instancing is supported */
  26606. instancedArrays: boolean;
  26607. /** Defines if 32 bits indices are supported */
  26608. uintIndices: boolean;
  26609. /** Defines if high precision shaders are supported */
  26610. highPrecisionShaderSupported: boolean;
  26611. /** Defines if depth reading in the fragment shader is supported */
  26612. fragmentDepthSupported: boolean;
  26613. /** Defines if float texture linear filtering is supported*/
  26614. textureFloatLinearFiltering: boolean;
  26615. /** Defines if rendering to float textures is supported */
  26616. textureFloatRender: boolean;
  26617. /** Defines if half float textures are supported*/
  26618. textureHalfFloat: boolean;
  26619. /** Defines if half float texture linear filtering is supported*/
  26620. textureHalfFloatLinearFiltering: boolean;
  26621. /** Defines if rendering to half float textures is supported */
  26622. textureHalfFloatRender: boolean;
  26623. /** Defines if textureLOD shader command is supported */
  26624. textureLOD: boolean;
  26625. /** Defines if draw buffers extension is supported */
  26626. drawBuffersExtension: boolean;
  26627. /** Defines if depth textures are supported */
  26628. depthTextureExtension: boolean;
  26629. /** Defines if float color buffer are supported */
  26630. colorBufferFloat: boolean;
  26631. /** Gets disjoint timer query extension (null if not supported) */
  26632. timerQuery: EXT_disjoint_timer_query;
  26633. /** Defines if timestamp can be used with timer query */
  26634. canUseTimestampForTimerQuery: boolean;
  26635. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26636. multiview: any;
  26637. /** Function used to let the system compiles shaders in background */
  26638. parallelShaderCompile: {
  26639. COMPLETION_STATUS_KHR: number;
  26640. };
  26641. }
  26642. /** Interface defining initialization parameters for Engine class */
  26643. export interface EngineOptions extends WebGLContextAttributes {
  26644. /**
  26645. * Defines if the engine should no exceed a specified device ratio
  26646. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26647. */
  26648. limitDeviceRatio?: number;
  26649. /**
  26650. * Defines if webvr should be enabled automatically
  26651. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26652. */
  26653. autoEnableWebVR?: boolean;
  26654. /**
  26655. * Defines if webgl2 should be turned off even if supported
  26656. * @see http://doc.babylonjs.com/features/webgl2
  26657. */
  26658. disableWebGL2Support?: boolean;
  26659. /**
  26660. * Defines if webaudio should be initialized as well
  26661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26662. */
  26663. audioEngine?: boolean;
  26664. /**
  26665. * Defines if animations should run using a deterministic lock step
  26666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26667. */
  26668. deterministicLockstep?: boolean;
  26669. /** Defines the maximum steps to use with deterministic lock step mode */
  26670. lockstepMaxSteps?: number;
  26671. /**
  26672. * Defines that engine should ignore context lost events
  26673. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26674. */
  26675. doNotHandleContextLost?: boolean;
  26676. /**
  26677. * Defines that engine should ignore modifying touch action attribute and style
  26678. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26679. */
  26680. doNotHandleTouchAction?: boolean;
  26681. /**
  26682. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26683. */
  26684. useHighPrecisionFloats?: boolean;
  26685. }
  26686. /**
  26687. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26688. */
  26689. export class Engine {
  26690. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26691. static ExceptionList: ({
  26692. key: string;
  26693. capture: string;
  26694. captureConstraint: number;
  26695. targets: string[];
  26696. } | {
  26697. key: string;
  26698. capture: null;
  26699. captureConstraint: null;
  26700. targets: string[];
  26701. })[];
  26702. /** Gets the list of created engines */
  26703. static readonly Instances: Engine[];
  26704. /**
  26705. * Gets the latest created engine
  26706. */
  26707. static readonly LastCreatedEngine: Nullable<Engine>;
  26708. /**
  26709. * Gets the latest created scene
  26710. */
  26711. static readonly LastCreatedScene: Nullable<Scene>;
  26712. /**
  26713. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26714. * @param flag defines which part of the materials must be marked as dirty
  26715. * @param predicate defines a predicate used to filter which materials should be affected
  26716. */
  26717. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26718. /**
  26719. * Hidden
  26720. */ private static _TextureLoaders: IInternalTextureLoader[];
  26721. /** Defines that alpha blending is disabled */
  26722. static readonly ALPHA_DISABLE: number;
  26723. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26724. static readonly ALPHA_ADD: number;
  26725. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26726. static readonly ALPHA_COMBINE: number;
  26727. /** Defines that alpha blending to DEST - SRC * DEST */
  26728. static readonly ALPHA_SUBTRACT: number;
  26729. /** Defines that alpha blending to SRC * DEST */
  26730. static readonly ALPHA_MULTIPLY: number;
  26731. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26732. static readonly ALPHA_MAXIMIZED: number;
  26733. /** Defines that alpha blending to SRC + DEST */
  26734. static readonly ALPHA_ONEONE: number;
  26735. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26736. static readonly ALPHA_PREMULTIPLIED: number;
  26737. /**
  26738. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26739. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26740. */
  26741. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26742. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26743. static readonly ALPHA_INTERPOLATE: number;
  26744. /**
  26745. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26746. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26747. */
  26748. static readonly ALPHA_SCREENMODE: number;
  26749. /** Defines that the ressource is not delayed*/
  26750. static readonly DELAYLOADSTATE_NONE: number;
  26751. /** Defines that the ressource was successfully delay loaded */
  26752. static readonly DELAYLOADSTATE_LOADED: number;
  26753. /** Defines that the ressource is currently delay loading */
  26754. static readonly DELAYLOADSTATE_LOADING: number;
  26755. /** Defines that the ressource is delayed and has not started loading */
  26756. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26757. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26758. static readonly NEVER: number;
  26759. /** 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 */
  26760. static readonly ALWAYS: number;
  26761. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26762. static readonly LESS: number;
  26763. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26764. static readonly EQUAL: number;
  26765. /** 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 */
  26766. static readonly LEQUAL: number;
  26767. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26768. static readonly GREATER: number;
  26769. /** 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 */
  26770. static readonly GEQUAL: number;
  26771. /** 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 */
  26772. static readonly NOTEQUAL: number;
  26773. /** Passed to stencilOperation to specify that stencil value must be kept */
  26774. static readonly KEEP: number;
  26775. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26776. static readonly REPLACE: number;
  26777. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26778. static readonly INCR: number;
  26779. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26780. static readonly DECR: number;
  26781. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26782. static readonly INVERT: number;
  26783. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26784. static readonly INCR_WRAP: number;
  26785. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26786. static readonly DECR_WRAP: number;
  26787. /** Texture is not repeating outside of 0..1 UVs */
  26788. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26789. /** Texture is repeating outside of 0..1 UVs */
  26790. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26791. /** Texture is repeating and mirrored */
  26792. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26793. /** ALPHA */
  26794. static readonly TEXTUREFORMAT_ALPHA: number;
  26795. /** LUMINANCE */
  26796. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26797. /** LUMINANCE_ALPHA */
  26798. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26799. /** RGB */
  26800. static readonly TEXTUREFORMAT_RGB: number;
  26801. /** RGBA */
  26802. static readonly TEXTUREFORMAT_RGBA: number;
  26803. /** RED */
  26804. static readonly TEXTUREFORMAT_RED: number;
  26805. /** RED (2nd reference) */
  26806. static readonly TEXTUREFORMAT_R: number;
  26807. /** RG */
  26808. static readonly TEXTUREFORMAT_RG: number;
  26809. /** RED_INTEGER */
  26810. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26811. /** RED_INTEGER (2nd reference) */
  26812. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26813. /** RG_INTEGER */
  26814. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26815. /** RGB_INTEGER */
  26816. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26817. /** RGBA_INTEGER */
  26818. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26819. /** UNSIGNED_BYTE */
  26820. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26821. /** UNSIGNED_BYTE (2nd reference) */
  26822. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26823. /** FLOAT */
  26824. static readonly TEXTURETYPE_FLOAT: number;
  26825. /** HALF_FLOAT */
  26826. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26827. /** BYTE */
  26828. static readonly TEXTURETYPE_BYTE: number;
  26829. /** SHORT */
  26830. static readonly TEXTURETYPE_SHORT: number;
  26831. /** UNSIGNED_SHORT */
  26832. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26833. /** INT */
  26834. static readonly TEXTURETYPE_INT: number;
  26835. /** UNSIGNED_INT */
  26836. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26837. /** UNSIGNED_SHORT_4_4_4_4 */
  26838. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26839. /** UNSIGNED_SHORT_5_5_5_1 */
  26840. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26841. /** UNSIGNED_SHORT_5_6_5 */
  26842. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26843. /** UNSIGNED_INT_2_10_10_10_REV */
  26844. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26845. /** UNSIGNED_INT_24_8 */
  26846. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26847. /** UNSIGNED_INT_10F_11F_11F_REV */
  26848. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26849. /** UNSIGNED_INT_5_9_9_9_REV */
  26850. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26851. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26852. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26853. /** nearest is mag = nearest and min = nearest and mip = linear */
  26854. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26855. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26856. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26857. /** Trilinear is mag = linear and min = linear and mip = linear */
  26858. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26859. /** nearest is mag = nearest and min = nearest and mip = linear */
  26860. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26861. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26862. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26863. /** Trilinear is mag = linear and min = linear and mip = linear */
  26864. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26865. /** mag = nearest and min = nearest and mip = nearest */
  26866. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26867. /** mag = nearest and min = linear and mip = nearest */
  26868. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26869. /** mag = nearest and min = linear and mip = linear */
  26870. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26871. /** mag = nearest and min = linear and mip = none */
  26872. static readonly TEXTURE_NEAREST_LINEAR: number;
  26873. /** mag = nearest and min = nearest and mip = none */
  26874. static readonly TEXTURE_NEAREST_NEAREST: number;
  26875. /** mag = linear and min = nearest and mip = nearest */
  26876. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26877. /** mag = linear and min = nearest and mip = linear */
  26878. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26879. /** mag = linear and min = linear and mip = none */
  26880. static readonly TEXTURE_LINEAR_LINEAR: number;
  26881. /** mag = linear and min = nearest and mip = none */
  26882. static readonly TEXTURE_LINEAR_NEAREST: number;
  26883. /** Explicit coordinates mode */
  26884. static readonly TEXTURE_EXPLICIT_MODE: number;
  26885. /** Spherical coordinates mode */
  26886. static readonly TEXTURE_SPHERICAL_MODE: number;
  26887. /** Planar coordinates mode */
  26888. static readonly TEXTURE_PLANAR_MODE: number;
  26889. /** Cubic coordinates mode */
  26890. static readonly TEXTURE_CUBIC_MODE: number;
  26891. /** Projection coordinates mode */
  26892. static readonly TEXTURE_PROJECTION_MODE: number;
  26893. /** Skybox coordinates mode */
  26894. static readonly TEXTURE_SKYBOX_MODE: number;
  26895. /** Inverse Cubic coordinates mode */
  26896. static readonly TEXTURE_INVCUBIC_MODE: number;
  26897. /** Equirectangular coordinates mode */
  26898. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26899. /** Equirectangular Fixed coordinates mode */
  26900. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26901. /** Equirectangular Fixed Mirrored coordinates mode */
  26902. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26903. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26904. static readonly SCALEMODE_FLOOR: number;
  26905. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26906. static readonly SCALEMODE_NEAREST: number;
  26907. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26908. static readonly SCALEMODE_CEILING: number;
  26909. /**
  26910. * Returns the current npm package of the sdk
  26911. */
  26912. static readonly NpmPackage: string;
  26913. /**
  26914. * Returns the current version of the framework
  26915. */
  26916. static readonly Version: string;
  26917. /**
  26918. * Returns a string describing the current engine
  26919. */
  26920. readonly description: string;
  26921. /**
  26922. * Gets or sets the epsilon value used by collision engine
  26923. */
  26924. static CollisionsEpsilon: number;
  26925. /**
  26926. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26927. */
  26928. static ShadersRepository: string;
  26929. /**
  26930. * Method called to create the default loading screen.
  26931. * This can be overriden in your own app.
  26932. * @param canvas The rendering canvas element
  26933. * @returns The loading screen
  26934. */
  26935. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26936. /**
  26937. * Method called to create the default rescale post process on each engine.
  26938. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26939. /**
  26940. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26941. */
  26942. forcePOTTextures: boolean;
  26943. /**
  26944. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26945. */
  26946. isFullscreen: boolean;
  26947. /**
  26948. * Gets a boolean indicating if the pointer is currently locked
  26949. */
  26950. isPointerLock: boolean;
  26951. /**
  26952. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26953. */
  26954. cullBackFaces: boolean;
  26955. /**
  26956. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26957. */
  26958. renderEvenInBackground: boolean;
  26959. /**
  26960. * Gets or sets a boolean indicating that cache can be kept between frames
  26961. */
  26962. preventCacheWipeBetweenFrames: boolean;
  26963. /**
  26964. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26965. **/
  26966. enableOfflineSupport: boolean;
  26967. /**
  26968. * 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)
  26969. **/
  26970. disableManifestCheck: boolean;
  26971. /**
  26972. * Gets the list of created scenes
  26973. */
  26974. scenes: Scene[];
  26975. /**
  26976. * Event raised when a new scene is created
  26977. */
  26978. onNewSceneAddedObservable: Observable<Scene>;
  26979. /**
  26980. * Gets the list of created postprocesses
  26981. */
  26982. postProcesses: PostProcess[];
  26983. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26984. validateShaderPrograms: boolean;
  26985. /**
  26986. * Observable event triggered each time the rendering canvas is resized
  26987. */
  26988. onResizeObservable: Observable<Engine>;
  26989. /**
  26990. * Observable event triggered each time the canvas loses focus
  26991. */
  26992. onCanvasBlurObservable: Observable<Engine>;
  26993. /**
  26994. * Observable event triggered each time the canvas gains focus
  26995. */
  26996. onCanvasFocusObservable: Observable<Engine>;
  26997. /**
  26998. * Observable event triggered each time the canvas receives pointerout event
  26999. */
  27000. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27001. /**
  27002. * Observable event triggered before each texture is initialized
  27003. */
  27004. onBeforeTextureInitObservable: Observable<Texture>;
  27005. /**
  27006. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27007. */
  27008. disableUniformBuffers: boolean;
  27009. /** @hidden */ uniformBuffers: UniformBuffer[];
  27010. /**
  27011. * Gets a boolean indicating that the engine supports uniform buffers
  27012. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27013. */
  27014. readonly supportsUniformBuffers: boolean;
  27015. /**
  27016. * Observable raised when the engine begins a new frame
  27017. */
  27018. onBeginFrameObservable: Observable<Engine>;
  27019. /**
  27020. * If set, will be used to request the next animation frame for the render loop
  27021. */
  27022. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27023. /**
  27024. * Observable raised when the engine ends the current frame
  27025. */
  27026. onEndFrameObservable: Observable<Engine>;
  27027. /**
  27028. * Observable raised when the engine is about to compile a shader
  27029. */
  27030. onBeforeShaderCompilationObservable: Observable<Engine>;
  27031. /**
  27032. * Observable raised when the engine has jsut compiled a shader
  27033. */
  27034. onAfterShaderCompilationObservable: Observable<Engine>;
  27035. /** @hidden */ gl: WebGLRenderingContext;
  27036. private _renderingCanvas;
  27037. private _windowIsBackground;
  27038. private _webGLVersion;
  27039. protected _highPrecisionShadersAllowed: boolean;
  27040. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27041. /**
  27042. * Gets a boolean indicating that only power of 2 textures are supported
  27043. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27044. */
  27045. readonly needPOTTextures: boolean;
  27046. /** @hidden */ badOS: boolean;
  27047. /** @hidden */ badDesktopOS: boolean;
  27048. /**
  27049. * Gets the audio engine
  27050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27051. * @ignorenaming
  27052. */
  27053. static audioEngine: IAudioEngine;
  27054. /**
  27055. * Default AudioEngine factory responsible of creating the Audio Engine.
  27056. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27057. */
  27058. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27059. /**
  27060. * Default offline support factory responsible of creating a tool used to store data locally.
  27061. * By default, this will create a Database object if the workload has been embedded.
  27062. */
  27063. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27064. private _onFocus;
  27065. private _onBlur;
  27066. private _onCanvasPointerOut;
  27067. private _onCanvasBlur;
  27068. private _onCanvasFocus;
  27069. private _onFullscreenChange;
  27070. private _onPointerLockChange;
  27071. private _hardwareScalingLevel;
  27072. /** @hidden */ caps: EngineCapabilities;
  27073. private _pointerLockRequested;
  27074. private _isStencilEnable;
  27075. private _colorWrite;
  27076. private _loadingScreen;
  27077. /** @hidden */ drawCalls: PerfCounter;
  27078. private _glVersion;
  27079. private _glRenderer;
  27080. private _glVendor;
  27081. private _videoTextureSupported;
  27082. private _renderingQueueLaunched;
  27083. private _activeRenderLoops;
  27084. private _deterministicLockstep;
  27085. private _lockstepMaxSteps;
  27086. /**
  27087. * Observable signaled when a context lost event is raised
  27088. */
  27089. onContextLostObservable: Observable<Engine>;
  27090. /**
  27091. * Observable signaled when a context restored event is raised
  27092. */
  27093. onContextRestoredObservable: Observable<Engine>;
  27094. private _onContextLost;
  27095. private _onContextRestored;
  27096. private _contextWasLost;
  27097. /** @hidden */ doNotHandleContextLost: boolean;
  27098. /**
  27099. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27101. */
  27102. doNotHandleContextLost: boolean;
  27103. private _performanceMonitor;
  27104. private _fps;
  27105. private _deltaTime;
  27106. /**
  27107. * Turn this value on if you want to pause FPS computation when in background
  27108. */
  27109. disablePerformanceMonitorInBackground: boolean;
  27110. /**
  27111. * Gets the performance monitor attached to this engine
  27112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27113. */
  27114. readonly performanceMonitor: PerformanceMonitor;
  27115. /**
  27116. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27117. */
  27118. disableVertexArrayObjects: boolean;
  27119. /** @hidden */
  27120. protected _depthCullingState: _DepthCullingState;
  27121. /** @hidden */
  27122. protected _stencilState: _StencilState;
  27123. /** @hidden */
  27124. protected _alphaState: _AlphaState;
  27125. /** @hidden */
  27126. protected _alphaMode: number;
  27127. /** @hidden */ internalTexturesCache: InternalTexture[];
  27128. /** @hidden */
  27129. protected _activeChannel: number;
  27130. private _currentTextureChannel;
  27131. /** @hidden */
  27132. protected _boundTexturesCache: {
  27133. [key: string]: Nullable<InternalTexture>;
  27134. };
  27135. /** @hidden */
  27136. protected _currentEffect: Nullable<Effect>;
  27137. /** @hidden */
  27138. protected _currentProgram: Nullable<WebGLProgram>;
  27139. private _compiledEffects;
  27140. private _vertexAttribArraysEnabled;
  27141. /** @hidden */
  27142. protected _cachedViewport: Nullable<Viewport>;
  27143. private _cachedVertexArrayObject;
  27144. /** @hidden */
  27145. protected _cachedVertexBuffers: any;
  27146. /** @hidden */
  27147. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27148. /** @hidden */
  27149. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27150. /** @hidden */ currentRenderTarget: Nullable<InternalTexture>;
  27151. private _uintIndicesCurrentlySet;
  27152. private _currentBoundBuffer;
  27153. /** @hidden */
  27154. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27155. private _currentBufferPointers;
  27156. private _currentInstanceLocations;
  27157. private _currentInstanceBuffers;
  27158. private _textureUnits;
  27159. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  27160. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  27161. private _rescalePostProcess;
  27162. private _dummyFramebuffer;
  27163. private _externalData;
  27164. /** @hidden */ bindedRenderFunction: any;
  27165. private _vaoRecordInProgress;
  27166. private _mustWipeVertexAttributes;
  27167. private _emptyTexture;
  27168. private _emptyCubeTexture;
  27169. private _emptyTexture3D;
  27170. /** @hidden */ frameHandler: number;
  27171. private _nextFreeTextureSlots;
  27172. private _maxSimultaneousTextures;
  27173. private _activeRequests;
  27174. private _texturesSupported;
  27175. /** @hidden */ textureFormatInUse: Nullable<string>;
  27176. /**
  27177. * Gets the list of texture formats supported
  27178. */
  27179. readonly texturesSupported: Array<string>;
  27180. /**
  27181. * Gets the list of texture formats in use
  27182. */
  27183. readonly textureFormatInUse: Nullable<string>;
  27184. /**
  27185. * Gets the current viewport
  27186. */
  27187. readonly currentViewport: Nullable<Viewport>;
  27188. /**
  27189. * Gets the default empty texture
  27190. */
  27191. readonly emptyTexture: InternalTexture;
  27192. /**
  27193. * Gets the default empty 3D texture
  27194. */
  27195. readonly emptyTexture3D: InternalTexture;
  27196. /**
  27197. * Gets the default empty cube texture
  27198. */
  27199. readonly emptyCubeTexture: InternalTexture;
  27200. /**
  27201. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27202. */
  27203. readonly premultipliedAlpha: boolean;
  27204. /**
  27205. * Creates a new engine
  27206. * @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
  27207. * @param antialias defines enable antialiasing (default: false)
  27208. * @param options defines further options to be sent to the getContext() function
  27209. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27210. */
  27211. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27212. /**
  27213. * Initializes a webVR display and starts listening to display change events
  27214. * The onVRDisplayChangedObservable will be notified upon these changes
  27215. * @returns The onVRDisplayChangedObservable
  27216. */
  27217. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27218. /** @hidden */ prepareVRComponent(): void;
  27219. /** @hidden */ connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27220. /** @hidden */ submitVRFrame(): void;
  27221. /**
  27222. * Call this function to leave webVR mode
  27223. * Will do nothing if webVR is not supported or if there is no webVR device
  27224. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27225. */
  27226. disableVR(): void;
  27227. /**
  27228. * Gets a boolean indicating that the system is in VR mode and is presenting
  27229. * @returns true if VR mode is engaged
  27230. */
  27231. isVRPresenting(): boolean;
  27232. /** @hidden */ requestVRFrame(): void;
  27233. private _disableTouchAction;
  27234. private _rebuildInternalTextures;
  27235. private _rebuildEffects;
  27236. /**
  27237. * Gets a boolean indicating if all created effects are ready
  27238. * @returns true if all effects are ready
  27239. */
  27240. areAllEffectsReady(): boolean;
  27241. private _rebuildBuffers;
  27242. private _initGLContext;
  27243. /**
  27244. * Gets version of the current webGL context
  27245. */
  27246. readonly webGLVersion: number;
  27247. /**
  27248. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27249. */
  27250. readonly isStencilEnable: boolean;
  27251. /** @hidden */ prepareWorkingCanvas(): void;
  27252. /**
  27253. * Reset the texture cache to empty state
  27254. */
  27255. resetTextureCache(): void;
  27256. /**
  27257. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27259. * @returns true if engine is in deterministic lock step mode
  27260. */
  27261. isDeterministicLockStep(): boolean;
  27262. /**
  27263. * Gets the max steps when engine is running in deterministic lock step
  27264. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27265. * @returns the max steps
  27266. */
  27267. getLockstepMaxSteps(): number;
  27268. /**
  27269. * Gets an object containing information about the current webGL context
  27270. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27271. */
  27272. getGlInfo(): {
  27273. vendor: string;
  27274. renderer: string;
  27275. version: string;
  27276. };
  27277. /**
  27278. * Gets current aspect ratio
  27279. * @param camera defines the camera to use to get the aspect ratio
  27280. * @param useScreen defines if screen size must be used (or the current render target if any)
  27281. * @returns a number defining the aspect ratio
  27282. */
  27283. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27284. /**
  27285. * Gets current screen aspect ratio
  27286. * @returns a number defining the aspect ratio
  27287. */
  27288. getScreenAspectRatio(): number;
  27289. /**
  27290. * Gets the current render width
  27291. * @param useScreen defines if screen size must be used (or the current render target if any)
  27292. * @returns a number defining the current render width
  27293. */
  27294. getRenderWidth(useScreen?: boolean): number;
  27295. /**
  27296. * Gets the current render height
  27297. * @param useScreen defines if screen size must be used (or the current render target if any)
  27298. * @returns a number defining the current render height
  27299. */
  27300. getRenderHeight(useScreen?: boolean): number;
  27301. /**
  27302. * Gets the HTML canvas attached with the current webGL context
  27303. * @returns a HTML canvas
  27304. */
  27305. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27306. /**
  27307. * Gets the client rect of the HTML canvas attached with the current webGL context
  27308. * @returns a client rectanglee
  27309. */
  27310. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27311. /**
  27312. * Defines the hardware scaling level.
  27313. * By default the hardware scaling level is computed from the window device ratio.
  27314. * 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.
  27315. * @param level defines the level to use
  27316. */
  27317. setHardwareScalingLevel(level: number): void;
  27318. /**
  27319. * Gets the current hardware scaling level.
  27320. * By default the hardware scaling level is computed from the window device ratio.
  27321. * 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.
  27322. * @returns a number indicating the current hardware scaling level
  27323. */
  27324. getHardwareScalingLevel(): number;
  27325. /**
  27326. * Gets the list of loaded textures
  27327. * @returns an array containing all loaded textures
  27328. */
  27329. getLoadedTexturesCache(): InternalTexture[];
  27330. /**
  27331. * Gets the object containing all engine capabilities
  27332. * @returns the EngineCapabilities object
  27333. */
  27334. getCaps(): EngineCapabilities;
  27335. /**
  27336. * Gets the current depth function
  27337. * @returns a number defining the depth function
  27338. */
  27339. getDepthFunction(): Nullable<number>;
  27340. /**
  27341. * Sets the current depth function
  27342. * @param depthFunc defines the function to use
  27343. */
  27344. setDepthFunction(depthFunc: number): void;
  27345. /**
  27346. * Sets the current depth function to GREATER
  27347. */
  27348. setDepthFunctionToGreater(): void;
  27349. /**
  27350. * Sets the current depth function to GEQUAL
  27351. */
  27352. setDepthFunctionToGreaterOrEqual(): void;
  27353. /**
  27354. * Sets the current depth function to LESS
  27355. */
  27356. setDepthFunctionToLess(): void;
  27357. private _cachedStencilBuffer;
  27358. private _cachedStencilFunction;
  27359. private _cachedStencilMask;
  27360. private _cachedStencilOperationPass;
  27361. private _cachedStencilOperationFail;
  27362. private _cachedStencilOperationDepthFail;
  27363. private _cachedStencilReference;
  27364. /**
  27365. * Caches the the state of the stencil buffer
  27366. */
  27367. cacheStencilState(): void;
  27368. /**
  27369. * Restores the state of the stencil buffer
  27370. */
  27371. restoreStencilState(): void;
  27372. /**
  27373. * Sets the current depth function to LEQUAL
  27374. */
  27375. setDepthFunctionToLessOrEqual(): void;
  27376. /**
  27377. * Gets a boolean indicating if stencil buffer is enabled
  27378. * @returns the current stencil buffer state
  27379. */
  27380. getStencilBuffer(): boolean;
  27381. /**
  27382. * Enable or disable the stencil buffer
  27383. * @param enable defines if the stencil buffer must be enabled or disabled
  27384. */
  27385. setStencilBuffer(enable: boolean): void;
  27386. /**
  27387. * Gets the current stencil mask
  27388. * @returns a number defining the new stencil mask to use
  27389. */
  27390. getStencilMask(): number;
  27391. /**
  27392. * Sets the current stencil mask
  27393. * @param mask defines the new stencil mask to use
  27394. */
  27395. setStencilMask(mask: number): void;
  27396. /**
  27397. * Gets the current stencil function
  27398. * @returns a number defining the stencil function to use
  27399. */
  27400. getStencilFunction(): number;
  27401. /**
  27402. * Gets the current stencil reference value
  27403. * @returns a number defining the stencil reference value to use
  27404. */
  27405. getStencilFunctionReference(): number;
  27406. /**
  27407. * Gets the current stencil mask
  27408. * @returns a number defining the stencil mask to use
  27409. */
  27410. getStencilFunctionMask(): number;
  27411. /**
  27412. * Sets the current stencil function
  27413. * @param stencilFunc defines the new stencil function to use
  27414. */
  27415. setStencilFunction(stencilFunc: number): void;
  27416. /**
  27417. * Sets the current stencil reference
  27418. * @param reference defines the new stencil reference to use
  27419. */
  27420. setStencilFunctionReference(reference: number): void;
  27421. /**
  27422. * Sets the current stencil mask
  27423. * @param mask defines the new stencil mask to use
  27424. */
  27425. setStencilFunctionMask(mask: number): void;
  27426. /**
  27427. * Gets the current stencil operation when stencil fails
  27428. * @returns a number defining stencil operation to use when stencil fails
  27429. */
  27430. getStencilOperationFail(): number;
  27431. /**
  27432. * Gets the current stencil operation when depth fails
  27433. * @returns a number defining stencil operation to use when depth fails
  27434. */
  27435. getStencilOperationDepthFail(): number;
  27436. /**
  27437. * Gets the current stencil operation when stencil passes
  27438. * @returns a number defining stencil operation to use when stencil passes
  27439. */
  27440. getStencilOperationPass(): number;
  27441. /**
  27442. * Sets the stencil operation to use when stencil fails
  27443. * @param operation defines the stencil operation to use when stencil fails
  27444. */
  27445. setStencilOperationFail(operation: number): void;
  27446. /**
  27447. * Sets the stencil operation to use when depth fails
  27448. * @param operation defines the stencil operation to use when depth fails
  27449. */
  27450. setStencilOperationDepthFail(operation: number): void;
  27451. /**
  27452. * Sets the stencil operation to use when stencil passes
  27453. * @param operation defines the stencil operation to use when stencil passes
  27454. */
  27455. setStencilOperationPass(operation: number): void;
  27456. /**
  27457. * Sets a boolean indicating if the dithering state is enabled or disabled
  27458. * @param value defines the dithering state
  27459. */
  27460. setDitheringState(value: boolean): void;
  27461. /**
  27462. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27463. * @param value defines the rasterizer state
  27464. */
  27465. setRasterizerState(value: boolean): void;
  27466. /**
  27467. * stop executing a render loop function and remove it from the execution array
  27468. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27469. */
  27470. stopRenderLoop(renderFunction?: () => void): void;
  27471. /** @hidden */ renderLoop(): void;
  27472. /**
  27473. * Register and execute a render loop. The engine can have more than one render function
  27474. * @param renderFunction defines the function to continuously execute
  27475. */
  27476. runRenderLoop(renderFunction: () => void): void;
  27477. /**
  27478. * Toggle full screen mode
  27479. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27480. */
  27481. switchFullscreen(requestPointerLock: boolean): void;
  27482. /**
  27483. * Enters full screen mode
  27484. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27485. */
  27486. enterFullscreen(requestPointerLock: boolean): void;
  27487. /**
  27488. * Exits full screen mode
  27489. */
  27490. exitFullscreen(): void;
  27491. /**
  27492. * Clear the current render buffer or the current render target (if any is set up)
  27493. * @param color defines the color to use
  27494. * @param backBuffer defines if the back buffer must be cleared
  27495. * @param depth defines if the depth buffer must be cleared
  27496. * @param stencil defines if the stencil buffer must be cleared
  27497. */
  27498. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27499. /**
  27500. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27501. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27502. * @param y defines the y-coordinate of the corner of the clear rectangle
  27503. * @param width defines the width of the clear rectangle
  27504. * @param height defines the height of the clear rectangle
  27505. * @param clearColor defines the clear color
  27506. */
  27507. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27508. /**
  27509. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27510. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27511. * @param y defines the y-coordinate of the corner of the clear rectangle
  27512. * @param width defines the width of the clear rectangle
  27513. * @param height defines the height of the clear rectangle
  27514. */
  27515. enableScissor(x: number, y: number, width: number, height: number): void;
  27516. /**
  27517. * Disable previously set scissor test rectangle
  27518. */
  27519. disableScissor(): void;
  27520. private _viewportCached;
  27521. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27522. /**
  27523. * Set the WebGL's viewport
  27524. * @param viewport defines the viewport element to be used
  27525. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27526. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27527. */
  27528. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27529. /**
  27530. * Directly set the WebGL Viewport
  27531. * @param x defines the x coordinate of the viewport (in screen space)
  27532. * @param y defines the y coordinate of the viewport (in screen space)
  27533. * @param width defines the width of the viewport (in screen space)
  27534. * @param height defines the height of the viewport (in screen space)
  27535. * @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
  27536. */
  27537. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27538. /**
  27539. * Begin a new frame
  27540. */
  27541. beginFrame(): void;
  27542. /**
  27543. * Enf the current frame
  27544. */
  27545. endFrame(): void;
  27546. /**
  27547. * Resize the view according to the canvas' size
  27548. */
  27549. resize(): void;
  27550. /**
  27551. * Force a specific size of the canvas
  27552. * @param width defines the new canvas' width
  27553. * @param height defines the new canvas' height
  27554. */
  27555. setSize(width: number, height: number): void;
  27556. /**
  27557. * Binds the frame buffer to the specified texture.
  27558. * @param texture The texture to render to or null for the default canvas
  27559. * @param faceIndex The face of the texture to render to in case of cube texture
  27560. * @param requiredWidth The width of the target to render to
  27561. * @param requiredHeight The height of the target to render to
  27562. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27563. * @param depthStencilTexture The depth stencil texture to use to render
  27564. * @param lodLevel defines le lod level to bind to the frame buffer
  27565. */
  27566. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27567. /** @hidden */ bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27568. /**
  27569. * Unbind the current render target texture from the webGL context
  27570. * @param texture defines the render target texture to unbind
  27571. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27572. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27573. */
  27574. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27575. /**
  27576. * Force the mipmap generation for the given render target texture
  27577. * @param texture defines the render target texture to use
  27578. */
  27579. generateMipMapsForCubemap(texture: InternalTexture): void;
  27580. /**
  27581. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27582. */
  27583. flushFramebuffer(): void;
  27584. /**
  27585. * Unbind the current render target and bind the default framebuffer
  27586. */
  27587. restoreDefaultFramebuffer(): void;
  27588. /**
  27589. * Create an uniform buffer
  27590. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27591. * @param elements defines the content of the uniform buffer
  27592. * @returns the webGL uniform buffer
  27593. */
  27594. createUniformBuffer(elements: FloatArray): DataBuffer;
  27595. /**
  27596. * Create a dynamic uniform buffer
  27597. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27598. * @param elements defines the content of the uniform buffer
  27599. * @returns the webGL uniform buffer
  27600. */
  27601. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27602. /**
  27603. * Update an existing uniform buffer
  27604. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27605. * @param uniformBuffer defines the target uniform buffer
  27606. * @param elements defines the content to update
  27607. * @param offset defines the offset in the uniform buffer where update should start
  27608. * @param count defines the size of the data to update
  27609. */
  27610. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27611. private _resetVertexBufferBinding;
  27612. /**
  27613. * Creates a vertex buffer
  27614. * @param data the data for the vertex buffer
  27615. * @returns the new WebGL static buffer
  27616. */
  27617. createVertexBuffer(data: DataArray): DataBuffer;
  27618. /**
  27619. * Creates a dynamic vertex buffer
  27620. * @param data the data for the dynamic vertex buffer
  27621. * @returns the new WebGL dynamic buffer
  27622. */
  27623. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27624. /**
  27625. * Update a dynamic index buffer
  27626. * @param indexBuffer defines the target index buffer
  27627. * @param indices defines the data to update
  27628. * @param offset defines the offset in the target index buffer where update should start
  27629. */
  27630. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27631. /**
  27632. * Updates a dynamic vertex buffer.
  27633. * @param vertexBuffer the vertex buffer to update
  27634. * @param data the data used to update the vertex buffer
  27635. * @param byteOffset the byte offset of the data
  27636. * @param byteLength the byte length of the data
  27637. */
  27638. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27639. private _resetIndexBufferBinding;
  27640. /**
  27641. * Creates a new index buffer
  27642. * @param indices defines the content of the index buffer
  27643. * @param updatable defines if the index buffer must be updatable
  27644. * @returns a new webGL buffer
  27645. */
  27646. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27647. /**
  27648. * Bind a webGL buffer to the webGL context
  27649. * @param buffer defines the buffer to bind
  27650. */
  27651. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27652. /**
  27653. * Bind an uniform buffer to the current webGL context
  27654. * @param buffer defines the buffer to bind
  27655. */
  27656. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27657. /**
  27658. * Bind a buffer to the current webGL context at a given location
  27659. * @param buffer defines the buffer to bind
  27660. * @param location defines the index where to bind the buffer
  27661. */
  27662. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27663. /**
  27664. * Bind a specific block at a given index in a specific shader program
  27665. * @param pipelineContext defines the pipeline context to use
  27666. * @param blockName defines the block name
  27667. * @param index defines the index where to bind the block
  27668. */
  27669. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27670. private bindIndexBuffer;
  27671. private bindBuffer;
  27672. /**
  27673. * update the bound buffer with the given data
  27674. * @param data defines the data to update
  27675. */
  27676. updateArrayBuffer(data: Float32Array): void;
  27677. private _vertexAttribPointer;
  27678. private _bindIndexBufferWithCache;
  27679. private _bindVertexBuffersAttributes;
  27680. /**
  27681. * Records a vertex array object
  27682. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27683. * @param vertexBuffers defines the list of vertex buffers to store
  27684. * @param indexBuffer defines the index buffer to store
  27685. * @param effect defines the effect to store
  27686. * @returns the new vertex array object
  27687. */
  27688. recordVertexArrayObject(vertexBuffers: {
  27689. [key: string]: VertexBuffer;
  27690. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27691. /**
  27692. * Bind a specific vertex array object
  27693. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27694. * @param vertexArrayObject defines the vertex array object to bind
  27695. * @param indexBuffer defines the index buffer to bind
  27696. */
  27697. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27698. /**
  27699. * Bind webGl buffers directly to the webGL context
  27700. * @param vertexBuffer defines the vertex buffer to bind
  27701. * @param indexBuffer defines the index buffer to bind
  27702. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27703. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27704. * @param effect defines the effect associated with the vertex buffer
  27705. */
  27706. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27707. private _unbindVertexArrayObject;
  27708. /**
  27709. * Bind a list of vertex buffers to the webGL context
  27710. * @param vertexBuffers defines the list of vertex buffers to bind
  27711. * @param indexBuffer defines the index buffer to bind
  27712. * @param effect defines the effect associated with the vertex buffers
  27713. */
  27714. bindBuffers(vertexBuffers: {
  27715. [key: string]: Nullable<VertexBuffer>;
  27716. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27717. /**
  27718. * Unbind all instance attributes
  27719. */
  27720. unbindInstanceAttributes(): void;
  27721. /**
  27722. * Release and free the memory of a vertex array object
  27723. * @param vao defines the vertex array object to delete
  27724. */
  27725. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27726. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  27727. /**
  27728. * Creates a webGL buffer to use with instanciation
  27729. * @param capacity defines the size of the buffer
  27730. * @returns the webGL buffer
  27731. */
  27732. createInstancesBuffer(capacity: number): DataBuffer;
  27733. /**
  27734. * Delete a webGL buffer used with instanciation
  27735. * @param buffer defines the webGL buffer to delete
  27736. */
  27737. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27738. /**
  27739. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27740. * @param instancesBuffer defines the webGL buffer to update and bind
  27741. * @param data defines the data to store in the buffer
  27742. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27743. */
  27744. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27745. /**
  27746. * Apply all cached states (depth, culling, stencil and alpha)
  27747. */
  27748. applyStates(): void;
  27749. /**
  27750. * Send a draw order
  27751. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27752. * @param indexStart defines the starting index
  27753. * @param indexCount defines the number of index to draw
  27754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27755. */
  27756. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27757. /**
  27758. * Draw a list of points
  27759. * @param verticesStart defines the index of first vertex to draw
  27760. * @param verticesCount defines the count of vertices to draw
  27761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27762. */
  27763. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27764. /**
  27765. * Draw a list of unindexed primitives
  27766. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27767. * @param verticesStart defines the index of first vertex to draw
  27768. * @param verticesCount defines the count of vertices to draw
  27769. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27770. */
  27771. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27772. /**
  27773. * Draw a list of indexed primitives
  27774. * @param fillMode defines the primitive to use
  27775. * @param indexStart defines the starting index
  27776. * @param indexCount defines the number of index to draw
  27777. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27778. */
  27779. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27780. /**
  27781. * Draw a list of unindexed primitives
  27782. * @param fillMode defines the primitive to use
  27783. * @param verticesStart defines the index of first vertex to draw
  27784. * @param verticesCount defines the count of vertices to draw
  27785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27786. */
  27787. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27788. private _drawMode;
  27789. /** @hidden */ releaseEffect(effect: Effect): void;
  27790. /** @hidden */ deletePipelineContext(pipelineContext: IPipelineContext): void;
  27791. /**
  27792. * Create a new effect (used to store vertex/fragment shaders)
  27793. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27794. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27795. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27796. * @param samplers defines an array of string used to represent textures
  27797. * @param defines defines the string containing the defines to use to compile the shaders
  27798. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27799. * @param onCompiled defines a function to call when the effect creation is successful
  27800. * @param onError defines a function to call when the effect creation has failed
  27801. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27802. * @returns the new Effect
  27803. */
  27804. 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;
  27805. private _compileShader;
  27806. private _compileRawShader;
  27807. /**
  27808. * Directly creates a webGL program
  27809. * @param pipelineContext defines the pipeline context to attach to
  27810. * @param vertexCode defines the vertex shader code to use
  27811. * @param fragmentCode defines the fragment shader code to use
  27812. * @param context defines the webGL context to use (if not set, the current one will be used)
  27813. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27814. * @returns the new webGL program
  27815. */
  27816. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27817. /**
  27818. * Creates a webGL program
  27819. * @param pipelineContext defines the pipeline context to attach to
  27820. * @param vertexCode defines the vertex shader code to use
  27821. * @param fragmentCode defines the fragment shader code to use
  27822. * @param defines defines the string containing the defines to use to compile the shaders
  27823. * @param context defines the webGL context to use (if not set, the current one will be used)
  27824. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27825. * @returns the new webGL program
  27826. */
  27827. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27828. /**
  27829. * Creates a new pipeline context
  27830. * @returns the new pipeline
  27831. */
  27832. createPipelineContext(): WebGLPipelineContext;
  27833. private _createShaderProgram;
  27834. private _finalizePipelineContext;
  27835. /** @hidden */ preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27836. /** @hidden */ isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27837. /** @hidden */ executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27838. /**
  27839. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27840. * @param pipelineContext defines the pipeline context to use
  27841. * @param uniformsNames defines the list of uniform names
  27842. * @returns an array of webGL uniform locations
  27843. */
  27844. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27845. /**
  27846. * Gets the lsit of active attributes for a given webGL program
  27847. * @param pipelineContext defines the pipeline context to use
  27848. * @param attributesNames defines the list of attribute names to get
  27849. * @returns an array of indices indicating the offset of each attribute
  27850. */
  27851. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27852. /**
  27853. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27854. * @param effect defines the effect to activate
  27855. */
  27856. enableEffect(effect: Nullable<Effect>): void;
  27857. /**
  27858. * Set the value of an uniform to an array of int32
  27859. * @param uniform defines the webGL uniform location where to store the value
  27860. * @param array defines the array of int32 to store
  27861. */
  27862. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27863. /**
  27864. * Set the value of an uniform to an array of int32 (stored as vec2)
  27865. * @param uniform defines the webGL uniform location where to store the value
  27866. * @param array defines the array of int32 to store
  27867. */
  27868. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27869. /**
  27870. * Set the value of an uniform to an array of int32 (stored as vec3)
  27871. * @param uniform defines the webGL uniform location where to store the value
  27872. * @param array defines the array of int32 to store
  27873. */
  27874. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27875. /**
  27876. * Set the value of an uniform to an array of int32 (stored as vec4)
  27877. * @param uniform defines the webGL uniform location where to store the value
  27878. * @param array defines the array of int32 to store
  27879. */
  27880. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27881. /**
  27882. * Set the value of an uniform to an array of float32
  27883. * @param uniform defines the webGL uniform location where to store the value
  27884. * @param array defines the array of float32 to store
  27885. */
  27886. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27887. /**
  27888. * Set the value of an uniform to an array of float32 (stored as vec2)
  27889. * @param uniform defines the webGL uniform location where to store the value
  27890. * @param array defines the array of float32 to store
  27891. */
  27892. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27893. /**
  27894. * Set the value of an uniform to an array of float32 (stored as vec3)
  27895. * @param uniform defines the webGL uniform location where to store the value
  27896. * @param array defines the array of float32 to store
  27897. */
  27898. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27899. /**
  27900. * Set the value of an uniform to an array of float32 (stored as vec4)
  27901. * @param uniform defines the webGL uniform location where to store the value
  27902. * @param array defines the array of float32 to store
  27903. */
  27904. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27905. /**
  27906. * Set the value of an uniform to an array of number
  27907. * @param uniform defines the webGL uniform location where to store the value
  27908. * @param array defines the array of number to store
  27909. */
  27910. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27911. /**
  27912. * Set the value of an uniform to an array of number (stored as vec2)
  27913. * @param uniform defines the webGL uniform location where to store the value
  27914. * @param array defines the array of number to store
  27915. */
  27916. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27917. /**
  27918. * Set the value of an uniform to an array of number (stored as vec3)
  27919. * @param uniform defines the webGL uniform location where to store the value
  27920. * @param array defines the array of number to store
  27921. */
  27922. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27923. /**
  27924. * Set the value of an uniform to an array of number (stored as vec4)
  27925. * @param uniform defines the webGL uniform location where to store the value
  27926. * @param array defines the array of number to store
  27927. */
  27928. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27929. /**
  27930. * Set the value of an uniform to an array of float32 (stored as matrices)
  27931. * @param uniform defines the webGL uniform location where to store the value
  27932. * @param matrices defines the array of float32 to store
  27933. */
  27934. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27935. /**
  27936. * Set the value of an uniform to a matrix
  27937. * @param uniform defines the webGL uniform location where to store the value
  27938. * @param matrix defines the matrix to store
  27939. */
  27940. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27941. /**
  27942. * Set the value of an uniform to a matrix (3x3)
  27943. * @param uniform defines the webGL uniform location where to store the value
  27944. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27945. */
  27946. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27947. /**
  27948. * Set the value of an uniform to a matrix (2x2)
  27949. * @param uniform defines the webGL uniform location where to store the value
  27950. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27951. */
  27952. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27953. /**
  27954. * Set the value of an uniform to a number (int)
  27955. * @param uniform defines the webGL uniform location where to store the value
  27956. * @param value defines the int number to store
  27957. */
  27958. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27959. /**
  27960. * Set the value of an uniform to a number (float)
  27961. * @param uniform defines the webGL uniform location where to store the value
  27962. * @param value defines the float number to store
  27963. */
  27964. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27965. /**
  27966. * Set the value of an uniform to a vec2
  27967. * @param uniform defines the webGL uniform location where to store the value
  27968. * @param x defines the 1st component of the value
  27969. * @param y defines the 2nd component of the value
  27970. */
  27971. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27972. /**
  27973. * Set the value of an uniform to a vec3
  27974. * @param uniform defines the webGL uniform location where to store the value
  27975. * @param x defines the 1st component of the value
  27976. * @param y defines the 2nd component of the value
  27977. * @param z defines the 3rd component of the value
  27978. */
  27979. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27980. /**
  27981. * Set the value of an uniform to a boolean
  27982. * @param uniform defines the webGL uniform location where to store the value
  27983. * @param bool defines the boolean to store
  27984. */
  27985. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27986. /**
  27987. * Set the value of an uniform to a vec4
  27988. * @param uniform defines the webGL uniform location where to store the value
  27989. * @param x defines the 1st component of the value
  27990. * @param y defines the 2nd component of the value
  27991. * @param z defines the 3rd component of the value
  27992. * @param w defines the 4th component of the value
  27993. */
  27994. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27995. /**
  27996. * Set the value of an uniform to a Color3
  27997. * @param uniform defines the webGL uniform location where to store the value
  27998. * @param color3 defines the color to store
  27999. */
  28000. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28001. /**
  28002. * Set the value of an uniform to a Color3 and an alpha value
  28003. * @param uniform defines the webGL uniform location where to store the value
  28004. * @param color3 defines the color to store
  28005. * @param alpha defines the alpha component to store
  28006. */
  28007. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28008. /**
  28009. * Sets a Color4 on a uniform variable
  28010. * @param uniform defines the uniform location
  28011. * @param color4 defines the value to be set
  28012. */
  28013. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28014. /**
  28015. * Set various states to the webGL context
  28016. * @param culling defines backface culling state
  28017. * @param zOffset defines the value to apply to zOffset (0 by default)
  28018. * @param force defines if states must be applied even if cache is up to date
  28019. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28020. */
  28021. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28022. /**
  28023. * Set the z offset to apply to current rendering
  28024. * @param value defines the offset to apply
  28025. */
  28026. setZOffset(value: number): void;
  28027. /**
  28028. * Gets the current value of the zOffset
  28029. * @returns the current zOffset state
  28030. */
  28031. getZOffset(): number;
  28032. /**
  28033. * Enable or disable depth buffering
  28034. * @param enable defines the state to set
  28035. */
  28036. setDepthBuffer(enable: boolean): void;
  28037. /**
  28038. * Gets a boolean indicating if depth writing is enabled
  28039. * @returns the current depth writing state
  28040. */
  28041. getDepthWrite(): boolean;
  28042. /**
  28043. * Enable or disable depth writing
  28044. * @param enable defines the state to set
  28045. */
  28046. setDepthWrite(enable: boolean): void;
  28047. /**
  28048. * Enable or disable color writing
  28049. * @param enable defines the state to set
  28050. */
  28051. setColorWrite(enable: boolean): void;
  28052. /**
  28053. * Gets a boolean indicating if color writing is enabled
  28054. * @returns the current color writing state
  28055. */
  28056. getColorWrite(): boolean;
  28057. /**
  28058. * Sets alpha constants used by some alpha blending modes
  28059. * @param r defines the red component
  28060. * @param g defines the green component
  28061. * @param b defines the blue component
  28062. * @param a defines the alpha component
  28063. */
  28064. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28065. /**
  28066. * Sets the current alpha mode
  28067. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28068. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28070. */
  28071. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28072. /**
  28073. * Gets the current alpha mode
  28074. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28075. * @returns the current alpha mode
  28076. */
  28077. getAlphaMode(): number;
  28078. /**
  28079. * Clears the list of texture accessible through engine.
  28080. * This can help preventing texture load conflict due to name collision.
  28081. */
  28082. clearInternalTexturesCache(): void;
  28083. /**
  28084. * Force the entire cache to be cleared
  28085. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28086. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28087. */
  28088. wipeCaches(bruteForce?: boolean): void;
  28089. /**
  28090. * Set the compressed texture format to use, based on the formats you have, and the formats
  28091. * supported by the hardware / browser.
  28092. *
  28093. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28094. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28095. * to API arguments needed to compressed textures. This puts the burden on the container
  28096. * generator to house the arcane code for determining these for current & future formats.
  28097. *
  28098. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28099. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28100. *
  28101. * Note: The result of this call is not taken into account when a texture is base64.
  28102. *
  28103. * @param formatsAvailable defines the list of those format families you have created
  28104. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28105. *
  28106. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28107. * @returns The extension selected.
  28108. */
  28109. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28110. /** @hidden */ getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28111. min: number;
  28112. mag: number;
  28113. };
  28114. /** @hidden */ createTexture(): WebGLTexture;
  28115. /**
  28116. * Usually called from Texture.ts.
  28117. * Passed information to create a WebGLTexture
  28118. * @param urlArg defines a value which contains one of the following:
  28119. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28120. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28121. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28122. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28123. * @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)
  28124. * @param scene needed for loading to the correct scene
  28125. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28126. * @param onLoad optional callback to be called upon successful completion
  28127. * @param onError optional callback to be called upon failure
  28128. * @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
  28129. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28130. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28131. * @param forcedExtension defines the extension to use to pick the right loader
  28132. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28133. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28134. */
  28135. 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;
  28136. private _rescaleTexture;
  28137. private _unpackFlipYCached;
  28138. /**
  28139. * In case you are sharing the context with other applications, it might
  28140. * be interested to not cache the unpack flip y state to ensure a consistent
  28141. * value would be set.
  28142. */
  28143. enableUnpackFlipYCached: boolean;
  28144. /** @hidden */ unpackFlipY(value: boolean): void;
  28145. /** @hidden */ getUnpackAlignement(): number;
  28146. /**
  28147. * Creates a dynamic texture
  28148. * @param width defines the width of the texture
  28149. * @param height defines the height of the texture
  28150. * @param generateMipMaps defines if the engine should generate the mip levels
  28151. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28152. * @returns the dynamic texture inside an InternalTexture
  28153. */
  28154. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28155. /**
  28156. * Update the sampling mode of a given texture
  28157. * @param samplingMode defines the required sampling mode
  28158. * @param texture defines the texture to update
  28159. */
  28160. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28161. /**
  28162. * Update the content of a dynamic texture
  28163. * @param texture defines the texture to update
  28164. * @param canvas defines the canvas containing the source
  28165. * @param invertY defines if data must be stored with Y axis inverted
  28166. * @param premulAlpha defines if alpha is stored as premultiplied
  28167. * @param format defines the format of the data
  28168. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28169. */
  28170. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28171. /**
  28172. * Update a video texture
  28173. * @param texture defines the texture to update
  28174. * @param video defines the video element to use
  28175. * @param invertY defines if data must be stored with Y axis inverted
  28176. */
  28177. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28178. /**
  28179. * Updates a depth texture Comparison Mode and Function.
  28180. * If the comparison Function is equal to 0, the mode will be set to none.
  28181. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28182. * @param texture The texture to set the comparison function for
  28183. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28184. */
  28185. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28186. /** @hidden */ setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28187. width: number;
  28188. height: number;
  28189. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28190. /**
  28191. * Creates a depth stencil texture.
  28192. * This is only available in WebGL 2 or with the depth texture extension available.
  28193. * @param size The size of face edge in the texture.
  28194. * @param options The options defining the texture.
  28195. * @returns The texture
  28196. */
  28197. createDepthStencilTexture(size: number | {
  28198. width: number;
  28199. height: number;
  28200. }, options: DepthTextureCreationOptions): InternalTexture;
  28201. /**
  28202. * Creates a depth stencil texture.
  28203. * This is only available in WebGL 2 or with the depth texture extension available.
  28204. * @param size The size of face edge in the texture.
  28205. * @param options The options defining the texture.
  28206. * @returns The texture
  28207. */
  28208. private _createDepthStencilTexture;
  28209. /**
  28210. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28211. * @param renderTarget The render target to set the frame buffer for
  28212. */
  28213. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28214. /**
  28215. * Creates a new render target texture
  28216. * @param size defines the size of the texture
  28217. * @param options defines the options used to create the texture
  28218. * @returns a new render target texture stored in an InternalTexture
  28219. */
  28220. createRenderTargetTexture(size: number | {
  28221. width: number;
  28222. height: number;
  28223. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28224. /** @hidden */ setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28225. /**
  28226. * Updates the sample count of a render target texture
  28227. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28228. * @param texture defines the texture to update
  28229. * @param samples defines the sample count to set
  28230. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28231. */
  28232. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28233. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28234. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28235. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28236. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28237. /**
  28238. * @hidden
  28239. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28240. private _prepareWebGLTextureContinuation;
  28241. private _prepareWebGLTexture;
  28242. /** @hidden */ convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28243. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28244. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28245. private setProgram;
  28246. private _boundUniforms;
  28247. /**
  28248. * Binds an effect to the webGL context
  28249. * @param effect defines the effect to bind
  28250. */
  28251. bindSamplers(effect: Effect): void;
  28252. private _activateCurrentTexture;
  28253. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28254. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28255. /**
  28256. * Sets a texture to the webGL context from a postprocess
  28257. * @param channel defines the channel to use
  28258. * @param postProcess defines the source postprocess
  28259. */
  28260. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28261. /**
  28262. * Binds the output of the passed in post process to the texture channel specified
  28263. * @param channel The channel the texture should be bound to
  28264. * @param postProcess The post process which's output should be bound
  28265. */
  28266. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28267. /**
  28268. * Unbind all textures from the webGL context
  28269. */
  28270. unbindAllTextures(): void;
  28271. /**
  28272. * Sets a texture to the according uniform.
  28273. * @param channel The texture channel
  28274. * @param uniform The uniform to set
  28275. * @param texture The texture to apply
  28276. */
  28277. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28278. /**
  28279. * Sets a depth stencil texture from a render target to the according uniform.
  28280. * @param channel The texture channel
  28281. * @param uniform The uniform to set
  28282. * @param texture The render target texture containing the depth stencil texture to apply
  28283. */
  28284. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28285. private _bindSamplerUniformToChannel;
  28286. private _getTextureWrapMode;
  28287. private _setTexture;
  28288. /**
  28289. * Sets an array of texture to the webGL context
  28290. * @param channel defines the channel where the texture array must be set
  28291. * @param uniform defines the associated uniform location
  28292. * @param textures defines the array of textures to bind
  28293. */
  28294. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28295. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28296. private _setTextureParameterFloat;
  28297. private _setTextureParameterInteger;
  28298. /**
  28299. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28300. * @param x defines the x coordinate of the rectangle where pixels must be read
  28301. * @param y defines the y coordinate of the rectangle where pixels must be read
  28302. * @param width defines the width of the rectangle where pixels must be read
  28303. * @param height defines the height of the rectangle where pixels must be read
  28304. * @returns a Uint8Array containing RGBA colors
  28305. */
  28306. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28307. /**
  28308. * Add an externaly attached data from its key.
  28309. * This method call will fail and return false, if such key already exists.
  28310. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28311. * @param key the unique key that identifies the data
  28312. * @param data the data object to associate to the key for this Engine instance
  28313. * @return true if no such key were already present and the data was added successfully, false otherwise
  28314. */
  28315. addExternalData<T>(key: string, data: T): boolean;
  28316. /**
  28317. * Get an externaly attached data from its key
  28318. * @param key the unique key that identifies the data
  28319. * @return the associated data, if present (can be null), or undefined if not present
  28320. */
  28321. getExternalData<T>(key: string): T;
  28322. /**
  28323. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28324. * @param key the unique key that identifies the data
  28325. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28326. * @return the associated data, can be null if the factory returned null.
  28327. */
  28328. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28329. /**
  28330. * Remove an externaly attached data from the Engine instance
  28331. * @param key the unique key that identifies the data
  28332. * @return true if the data was successfully removed, false if it doesn't exist
  28333. */
  28334. removeExternalData(key: string): boolean;
  28335. /**
  28336. * Unbind all vertex attributes from the webGL context
  28337. */
  28338. unbindAllAttributes(): void;
  28339. /**
  28340. * 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
  28341. */
  28342. releaseEffects(): void;
  28343. /**
  28344. * Dispose and release all associated resources
  28345. */
  28346. dispose(): void;
  28347. /**
  28348. * Display the loading screen
  28349. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28350. */
  28351. displayLoadingUI(): void;
  28352. /**
  28353. * Hide the loading screen
  28354. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28355. */
  28356. hideLoadingUI(): void;
  28357. /**
  28358. * Gets the current loading screen object
  28359. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28360. */
  28361. /**
  28362. * Sets the current loading screen object
  28363. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28364. */
  28365. loadingScreen: ILoadingScreen;
  28366. /**
  28367. * Sets the current loading screen text
  28368. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28369. */
  28370. loadingUIText: string;
  28371. /**
  28372. * Sets the current loading screen background color
  28373. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28374. */
  28375. loadingUIBackgroundColor: string;
  28376. /**
  28377. * Attach a new callback raised when context lost event is fired
  28378. * @param callback defines the callback to call
  28379. */
  28380. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28381. /**
  28382. * Attach a new callback raised when context restored event is fired
  28383. * @param callback defines the callback to call
  28384. */
  28385. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28386. /**
  28387. * Gets the source code of the vertex shader associated with a specific webGL program
  28388. * @param program defines the program to use
  28389. * @returns a string containing the source code of the vertex shader associated with the program
  28390. */
  28391. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28392. /**
  28393. * Gets the source code of the fragment shader associated with a specific webGL program
  28394. * @param program defines the program to use
  28395. * @returns a string containing the source code of the fragment shader associated with the program
  28396. */
  28397. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28398. /**
  28399. * Get the current error code of the webGL context
  28400. * @returns the error code
  28401. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28402. */
  28403. getError(): number;
  28404. /**
  28405. * Gets the current framerate
  28406. * @returns a number representing the framerate
  28407. */
  28408. getFps(): number;
  28409. /**
  28410. * Gets the time spent between current and previous frame
  28411. * @returns a number representing the delta time in ms
  28412. */
  28413. getDeltaTime(): number;
  28414. private _measureFps;
  28415. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28416. private _canRenderToFloatFramebuffer;
  28417. private _canRenderToHalfFloatFramebuffer;
  28418. private _canRenderToFramebuffer;
  28419. /** @hidden */ getWebGLTextureType(type: number): number;
  28420. /** @hidden */ getInternalFormat(format: number): number;
  28421. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28422. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28423. /** @hidden */ 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;
  28424. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28425. /**
  28426. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28427. * @returns true if the engine can be created
  28428. * @ignorenaming
  28429. */
  28430. static isSupported(): boolean;
  28431. }
  28432. }
  28433. declare module BABYLON {
  28434. /**
  28435. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28436. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28437. */
  28438. export class EffectFallbacks {
  28439. private _defines;
  28440. private _currentRank;
  28441. private _maxRank;
  28442. private _mesh;
  28443. /**
  28444. * Removes the fallback from the bound mesh.
  28445. */
  28446. unBindMesh(): void;
  28447. /**
  28448. * Adds a fallback on the specified property.
  28449. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28450. * @param define The name of the define in the shader
  28451. */
  28452. addFallback(rank: number, define: string): void;
  28453. /**
  28454. * Sets the mesh to use CPU skinning when needing to fallback.
  28455. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28456. * @param mesh The mesh to use the fallbacks.
  28457. */
  28458. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28459. /**
  28460. * Checks to see if more fallbacks are still availible.
  28461. */
  28462. readonly isMoreFallbacks: boolean;
  28463. /**
  28464. * Removes the defines that shoould be removed when falling back.
  28465. * @param currentDefines defines the current define statements for the shader.
  28466. * @param effect defines the current effect we try to compile
  28467. * @returns The resulting defines with defines of the current rank removed.
  28468. */
  28469. reduce(currentDefines: string, effect: Effect): string;
  28470. }
  28471. /**
  28472. * Options to be used when creating an effect.
  28473. */
  28474. export class EffectCreationOptions {
  28475. /**
  28476. * Atrributes that will be used in the shader.
  28477. */
  28478. attributes: string[];
  28479. /**
  28480. * Uniform varible names that will be set in the shader.
  28481. */
  28482. uniformsNames: string[];
  28483. /**
  28484. * Uniform buffer varible names that will be set in the shader.
  28485. */
  28486. uniformBuffersNames: string[];
  28487. /**
  28488. * Sampler texture variable names that will be set in the shader.
  28489. */
  28490. samplers: string[];
  28491. /**
  28492. * Define statements that will be set in the shader.
  28493. */
  28494. defines: any;
  28495. /**
  28496. * Possible fallbacks for this effect to improve performance when needed.
  28497. */
  28498. fallbacks: Nullable<EffectFallbacks>;
  28499. /**
  28500. * Callback that will be called when the shader is compiled.
  28501. */
  28502. onCompiled: Nullable<(effect: Effect) => void>;
  28503. /**
  28504. * Callback that will be called if an error occurs during shader compilation.
  28505. */
  28506. onError: Nullable<(effect: Effect, errors: string) => void>;
  28507. /**
  28508. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28509. */
  28510. indexParameters: any;
  28511. /**
  28512. * Max number of lights that can be used in the shader.
  28513. */
  28514. maxSimultaneousLights: number;
  28515. /**
  28516. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28517. */
  28518. transformFeedbackVaryings: Nullable<string[]>;
  28519. }
  28520. /**
  28521. * Effect containing vertex and fragment shader that can be executed on an object.
  28522. */
  28523. export class Effect implements IDisposable {
  28524. /**
  28525. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28526. */
  28527. static ShadersRepository: string;
  28528. /**
  28529. * Name of the effect.
  28530. */
  28531. name: any;
  28532. /**
  28533. * String container all the define statements that should be set on the shader.
  28534. */
  28535. defines: string;
  28536. /**
  28537. * Callback that will be called when the shader is compiled.
  28538. */
  28539. onCompiled: Nullable<(effect: Effect) => void>;
  28540. /**
  28541. * Callback that will be called if an error occurs during shader compilation.
  28542. */
  28543. onError: Nullable<(effect: Effect, errors: string) => void>;
  28544. /**
  28545. * Callback that will be called when effect is bound.
  28546. */
  28547. onBind: Nullable<(effect: Effect) => void>;
  28548. /**
  28549. * Unique ID of the effect.
  28550. */
  28551. uniqueId: number;
  28552. /**
  28553. * Observable that will be called when the shader is compiled.
  28554. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28555. */
  28556. onCompileObservable: Observable<Effect>;
  28557. /**
  28558. * Observable that will be called if an error occurs during shader compilation.
  28559. */
  28560. onErrorObservable: Observable<Effect>;
  28561. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28562. /**
  28563. * Observable that will be called when effect is bound.
  28564. */
  28565. readonly onBindObservable: Observable<Effect>;
  28566. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28567. private static _uniqueIdSeed;
  28568. private _engine;
  28569. private _uniformBuffersNames;
  28570. private _uniformsNames;
  28571. private _samplerList;
  28572. private _samplers;
  28573. private _isReady;
  28574. private _compilationError;
  28575. private _attributesNames;
  28576. private _attributes;
  28577. private _uniforms;
  28578. /**
  28579. * Key for the effect.
  28580. * @hidden
  28581. */ key: string;
  28582. private _indexParameters;
  28583. private _fallbacks;
  28584. private _vertexSourceCode;
  28585. private _fragmentSourceCode;
  28586. private _vertexSourceCodeOverride;
  28587. private _fragmentSourceCodeOverride;
  28588. private _transformFeedbackVaryings;
  28589. /**
  28590. * Compiled shader to webGL program.
  28591. * @hidden
  28592. */ pipelineContext: Nullable<IPipelineContext>;
  28593. private _valueCache;
  28594. private static _baseCache;
  28595. /**
  28596. * Instantiates an effect.
  28597. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28598. * @param baseName Name of the effect.
  28599. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28600. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28601. * @param samplers List of sampler variables that will be passed to the shader.
  28602. * @param engine Engine to be used to render the effect
  28603. * @param defines Define statements to be added to the shader.
  28604. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28605. * @param onCompiled Callback that will be called when the shader is compiled.
  28606. * @param onError Callback that will be called if an error occurs during shader compilation.
  28607. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28608. */
  28609. 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);
  28610. /**
  28611. * Unique key for this effect
  28612. */
  28613. readonly key: string;
  28614. /**
  28615. * If the effect has been compiled and prepared.
  28616. * @returns if the effect is compiled and prepared.
  28617. */
  28618. isReady(): boolean;
  28619. /**
  28620. * The engine the effect was initialized with.
  28621. * @returns the engine.
  28622. */
  28623. getEngine(): Engine;
  28624. /**
  28625. * The pipeline context for this effect
  28626. * @returns the associated pipeline context
  28627. */
  28628. getPipelineContext(): Nullable<IPipelineContext>;
  28629. /**
  28630. * The set of names of attribute variables for the shader.
  28631. * @returns An array of attribute names.
  28632. */
  28633. getAttributesNames(): string[];
  28634. /**
  28635. * Returns the attribute at the given index.
  28636. * @param index The index of the attribute.
  28637. * @returns The location of the attribute.
  28638. */
  28639. getAttributeLocation(index: number): number;
  28640. /**
  28641. * Returns the attribute based on the name of the variable.
  28642. * @param name of the attribute to look up.
  28643. * @returns the attribute location.
  28644. */
  28645. getAttributeLocationByName(name: string): number;
  28646. /**
  28647. * The number of attributes.
  28648. * @returns the numnber of attributes.
  28649. */
  28650. getAttributesCount(): number;
  28651. /**
  28652. * Gets the index of a uniform variable.
  28653. * @param uniformName of the uniform to look up.
  28654. * @returns the index.
  28655. */
  28656. getUniformIndex(uniformName: string): number;
  28657. /**
  28658. * Returns the attribute based on the name of the variable.
  28659. * @param uniformName of the uniform to look up.
  28660. * @returns the location of the uniform.
  28661. */
  28662. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28663. /**
  28664. * Returns an array of sampler variable names
  28665. * @returns The array of sampler variable neames.
  28666. */
  28667. getSamplers(): string[];
  28668. /**
  28669. * The error from the last compilation.
  28670. * @returns the error string.
  28671. */
  28672. getCompilationError(): string;
  28673. /**
  28674. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28675. * @param func The callback to be used.
  28676. */
  28677. executeWhenCompiled(func: (effect: Effect) => void): void;
  28678. private _checkIsReady;
  28679. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28680. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28681. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28682. private _processShaderConversion;
  28683. private _processIncludes;
  28684. private _processPrecision;
  28685. /**
  28686. * Recompiles the webGL program
  28687. * @param vertexSourceCode The source code for the vertex shader.
  28688. * @param fragmentSourceCode The source code for the fragment shader.
  28689. * @param onCompiled Callback called when completed.
  28690. * @param onError Callback called on error.
  28691. * @hidden
  28692. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28693. /**
  28694. * Prepares the effect
  28695. * @hidden
  28696. */ prepareEffect(): void;
  28697. /**
  28698. * Checks if the effect is supported. (Must be called after compilation)
  28699. */
  28700. readonly isSupported: boolean;
  28701. /**
  28702. * Binds a texture to the engine to be used as output of the shader.
  28703. * @param channel Name of the output variable.
  28704. * @param texture Texture to bind.
  28705. * @hidden
  28706. */ bindTexture(channel: string, texture: InternalTexture): void;
  28707. /**
  28708. * Sets a texture on the engine to be used in the shader.
  28709. * @param channel Name of the sampler variable.
  28710. * @param texture Texture to set.
  28711. */
  28712. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28713. /**
  28714. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28715. * @param channel Name of the sampler variable.
  28716. * @param texture Texture to set.
  28717. */
  28718. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28719. /**
  28720. * Sets an array of textures on the engine to be used in the shader.
  28721. * @param channel Name of the variable.
  28722. * @param textures Textures to set.
  28723. */
  28724. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28725. /**
  28726. * 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)
  28727. * @param channel Name of the sampler variable.
  28728. * @param postProcess Post process to get the input texture from.
  28729. */
  28730. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28731. /**
  28732. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28733. * 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)
  28734. * @param channel Name of the sampler variable.
  28735. * @param postProcess Post process to get the output texture from.
  28736. */
  28737. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28738. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28739. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28740. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28741. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28742. /**
  28743. * Binds a buffer to a uniform.
  28744. * @param buffer Buffer to bind.
  28745. * @param name Name of the uniform variable to bind to.
  28746. */
  28747. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28748. /**
  28749. * Binds block to a uniform.
  28750. * @param blockName Name of the block to bind.
  28751. * @param index Index to bind.
  28752. */
  28753. bindUniformBlock(blockName: string, index: number): void;
  28754. /**
  28755. * Sets an interger value on a uniform variable.
  28756. * @param uniformName Name of the variable.
  28757. * @param value Value to be set.
  28758. * @returns this effect.
  28759. */
  28760. setInt(uniformName: string, value: number): Effect;
  28761. /**
  28762. * Sets an int array on a uniform variable.
  28763. * @param uniformName Name of the variable.
  28764. * @param array array to be set.
  28765. * @returns this effect.
  28766. */
  28767. setIntArray(uniformName: string, array: Int32Array): Effect;
  28768. /**
  28769. * 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)
  28770. * @param uniformName Name of the variable.
  28771. * @param array array to be set.
  28772. * @returns this effect.
  28773. */
  28774. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28775. /**
  28776. * 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)
  28777. * @param uniformName Name of the variable.
  28778. * @param array array to be set.
  28779. * @returns this effect.
  28780. */
  28781. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28782. /**
  28783. * 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)
  28784. * @param uniformName Name of the variable.
  28785. * @param array array to be set.
  28786. * @returns this effect.
  28787. */
  28788. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28789. /**
  28790. * Sets an float array on a uniform variable.
  28791. * @param uniformName Name of the variable.
  28792. * @param array array to be set.
  28793. * @returns this effect.
  28794. */
  28795. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28796. /**
  28797. * 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)
  28798. * @param uniformName Name of the variable.
  28799. * @param array array to be set.
  28800. * @returns this effect.
  28801. */
  28802. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28803. /**
  28804. * 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)
  28805. * @param uniformName Name of the variable.
  28806. * @param array array to be set.
  28807. * @returns this effect.
  28808. */
  28809. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28810. /**
  28811. * 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)
  28812. * @param uniformName Name of the variable.
  28813. * @param array array to be set.
  28814. * @returns this effect.
  28815. */
  28816. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28817. /**
  28818. * Sets an array on a uniform variable.
  28819. * @param uniformName Name of the variable.
  28820. * @param array array to be set.
  28821. * @returns this effect.
  28822. */
  28823. setArray(uniformName: string, array: number[]): Effect;
  28824. /**
  28825. * 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)
  28826. * @param uniformName Name of the variable.
  28827. * @param array array to be set.
  28828. * @returns this effect.
  28829. */
  28830. setArray2(uniformName: string, array: number[]): Effect;
  28831. /**
  28832. * 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)
  28833. * @param uniformName Name of the variable.
  28834. * @param array array to be set.
  28835. * @returns this effect.
  28836. */
  28837. setArray3(uniformName: string, array: number[]): Effect;
  28838. /**
  28839. * 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)
  28840. * @param uniformName Name of the variable.
  28841. * @param array array to be set.
  28842. * @returns this effect.
  28843. */
  28844. setArray4(uniformName: string, array: number[]): Effect;
  28845. /**
  28846. * Sets matrices on a uniform variable.
  28847. * @param uniformName Name of the variable.
  28848. * @param matrices matrices to be set.
  28849. * @returns this effect.
  28850. */
  28851. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28852. /**
  28853. * Sets matrix on a uniform variable.
  28854. * @param uniformName Name of the variable.
  28855. * @param matrix matrix to be set.
  28856. * @returns this effect.
  28857. */
  28858. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28859. /**
  28860. * 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)
  28861. * @param uniformName Name of the variable.
  28862. * @param matrix matrix to be set.
  28863. * @returns this effect.
  28864. */
  28865. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28866. /**
  28867. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28868. * @param uniformName Name of the variable.
  28869. * @param matrix matrix to be set.
  28870. * @returns this effect.
  28871. */
  28872. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28873. /**
  28874. * Sets a float on a uniform variable.
  28875. * @param uniformName Name of the variable.
  28876. * @param value value to be set.
  28877. * @returns this effect.
  28878. */
  28879. setFloat(uniformName: string, value: number): Effect;
  28880. /**
  28881. * Sets a boolean on a uniform variable.
  28882. * @param uniformName Name of the variable.
  28883. * @param bool value to be set.
  28884. * @returns this effect.
  28885. */
  28886. setBool(uniformName: string, bool: boolean): Effect;
  28887. /**
  28888. * Sets a Vector2 on a uniform variable.
  28889. * @param uniformName Name of the variable.
  28890. * @param vector2 vector2 to be set.
  28891. * @returns this effect.
  28892. */
  28893. setVector2(uniformName: string, vector2: Vector2): Effect;
  28894. /**
  28895. * Sets a float2 on a uniform variable.
  28896. * @param uniformName Name of the variable.
  28897. * @param x First float in float2.
  28898. * @param y Second float in float2.
  28899. * @returns this effect.
  28900. */
  28901. setFloat2(uniformName: string, x: number, y: number): Effect;
  28902. /**
  28903. * Sets a Vector3 on a uniform variable.
  28904. * @param uniformName Name of the variable.
  28905. * @param vector3 Value to be set.
  28906. * @returns this effect.
  28907. */
  28908. setVector3(uniformName: string, vector3: Vector3): Effect;
  28909. /**
  28910. * Sets a float3 on a uniform variable.
  28911. * @param uniformName Name of the variable.
  28912. * @param x First float in float3.
  28913. * @param y Second float in float3.
  28914. * @param z Third float in float3.
  28915. * @returns this effect.
  28916. */
  28917. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28918. /**
  28919. * Sets a Vector4 on a uniform variable.
  28920. * @param uniformName Name of the variable.
  28921. * @param vector4 Value to be set.
  28922. * @returns this effect.
  28923. */
  28924. setVector4(uniformName: string, vector4: Vector4): Effect;
  28925. /**
  28926. * Sets a float4 on a uniform variable.
  28927. * @param uniformName Name of the variable.
  28928. * @param x First float in float4.
  28929. * @param y Second float in float4.
  28930. * @param z Third float in float4.
  28931. * @param w Fourth float in float4.
  28932. * @returns this effect.
  28933. */
  28934. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28935. /**
  28936. * Sets a Color3 on a uniform variable.
  28937. * @param uniformName Name of the variable.
  28938. * @param color3 Value to be set.
  28939. * @returns this effect.
  28940. */
  28941. setColor3(uniformName: string, color3: Color3): Effect;
  28942. /**
  28943. * Sets a Color4 on a uniform variable.
  28944. * @param uniformName Name of the variable.
  28945. * @param color3 Value to be set.
  28946. * @param alpha Alpha value to be set.
  28947. * @returns this effect.
  28948. */
  28949. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28950. /**
  28951. * Sets a Color4 on a uniform variable
  28952. * @param uniformName defines the name of the variable
  28953. * @param color4 defines the value to be set
  28954. * @returns this effect.
  28955. */
  28956. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28957. /** Release all associated resources */
  28958. dispose(): void;
  28959. /**
  28960. * This function will add a new shader to the shader store
  28961. * @param name the name of the shader
  28962. * @param pixelShader optional pixel shader content
  28963. * @param vertexShader optional vertex shader content
  28964. */
  28965. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28966. /**
  28967. * Store of each shader (The can be looked up using effect.key)
  28968. */
  28969. static ShadersStore: {
  28970. [key: string]: string;
  28971. };
  28972. /**
  28973. * Store of each included file for a shader (The can be looked up using effect.key)
  28974. */
  28975. static IncludesShadersStore: {
  28976. [key: string]: string;
  28977. };
  28978. /**
  28979. * Resets the cache of effects.
  28980. */
  28981. static ResetCache(): void;
  28982. }
  28983. }
  28984. declare module BABYLON {
  28985. /**
  28986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28988. * 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;
  28989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28990. */
  28991. export class ColorCurves {
  28992. private _dirty;
  28993. private _tempColor;
  28994. private _globalCurve;
  28995. private _highlightsCurve;
  28996. private _midtonesCurve;
  28997. private _shadowsCurve;
  28998. private _positiveCurve;
  28999. private _negativeCurve;
  29000. private _globalHue;
  29001. private _globalDensity;
  29002. private _globalSaturation;
  29003. private _globalExposure;
  29004. /**
  29005. * Gets the global Hue value.
  29006. * 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).
  29007. */
  29008. /**
  29009. * Sets the global Hue value.
  29010. * 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).
  29011. */
  29012. globalHue: number;
  29013. /**
  29014. * Gets the global Density value.
  29015. * 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.
  29016. * Values less than zero provide a filter of opposite hue.
  29017. */
  29018. /**
  29019. * Sets the global Density value.
  29020. * 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.
  29021. * Values less than zero provide a filter of opposite hue.
  29022. */
  29023. globalDensity: number;
  29024. /**
  29025. * Gets the global Saturation value.
  29026. * 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.
  29027. */
  29028. /**
  29029. * Sets the global Saturation value.
  29030. * 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.
  29031. */
  29032. globalSaturation: number;
  29033. /**
  29034. * Gets the global Exposure value.
  29035. * 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.
  29036. */
  29037. /**
  29038. * Sets the global Exposure value.
  29039. * 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.
  29040. */
  29041. globalExposure: number;
  29042. private _highlightsHue;
  29043. private _highlightsDensity;
  29044. private _highlightsSaturation;
  29045. private _highlightsExposure;
  29046. /**
  29047. * Gets the highlights Hue value.
  29048. * 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).
  29049. */
  29050. /**
  29051. * Sets the highlights Hue value.
  29052. * 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).
  29053. */
  29054. highlightsHue: number;
  29055. /**
  29056. * Gets the highlights Density value.
  29057. * 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.
  29058. * Values less than zero provide a filter of opposite hue.
  29059. */
  29060. /**
  29061. * Sets the highlights Density value.
  29062. * 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.
  29063. * Values less than zero provide a filter of opposite hue.
  29064. */
  29065. highlightsDensity: number;
  29066. /**
  29067. * Gets the highlights Saturation value.
  29068. * 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.
  29069. */
  29070. /**
  29071. * Sets the highlights Saturation value.
  29072. * 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.
  29073. */
  29074. highlightsSaturation: number;
  29075. /**
  29076. * Gets the highlights Exposure value.
  29077. * 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.
  29078. */
  29079. /**
  29080. * Sets the highlights Exposure value.
  29081. * 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.
  29082. */
  29083. highlightsExposure: number;
  29084. private _midtonesHue;
  29085. private _midtonesDensity;
  29086. private _midtonesSaturation;
  29087. private _midtonesExposure;
  29088. /**
  29089. * Gets the midtones Hue value.
  29090. * 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).
  29091. */
  29092. /**
  29093. * Sets the midtones Hue value.
  29094. * 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).
  29095. */
  29096. midtonesHue: number;
  29097. /**
  29098. * Gets the midtones Density value.
  29099. * 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.
  29100. * Values less than zero provide a filter of opposite hue.
  29101. */
  29102. /**
  29103. * Sets the midtones Density value.
  29104. * 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.
  29105. * Values less than zero provide a filter of opposite hue.
  29106. */
  29107. midtonesDensity: number;
  29108. /**
  29109. * Gets the midtones Saturation value.
  29110. * 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.
  29111. */
  29112. /**
  29113. * Sets the midtones Saturation value.
  29114. * 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.
  29115. */
  29116. midtonesSaturation: number;
  29117. /**
  29118. * Gets the midtones Exposure value.
  29119. * 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.
  29120. */
  29121. /**
  29122. * Sets the midtones Exposure value.
  29123. * 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.
  29124. */
  29125. midtonesExposure: number;
  29126. private _shadowsHue;
  29127. private _shadowsDensity;
  29128. private _shadowsSaturation;
  29129. private _shadowsExposure;
  29130. /**
  29131. * Gets the shadows Hue value.
  29132. * 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).
  29133. */
  29134. /**
  29135. * Sets the shadows Hue value.
  29136. * 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).
  29137. */
  29138. shadowsHue: number;
  29139. /**
  29140. * Gets the shadows Density value.
  29141. * 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.
  29142. * Values less than zero provide a filter of opposite hue.
  29143. */
  29144. /**
  29145. * Sets the shadows Density value.
  29146. * 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.
  29147. * Values less than zero provide a filter of opposite hue.
  29148. */
  29149. shadowsDensity: number;
  29150. /**
  29151. * Gets the shadows Saturation value.
  29152. * 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.
  29153. */
  29154. /**
  29155. * Sets the shadows Saturation value.
  29156. * 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.
  29157. */
  29158. shadowsSaturation: number;
  29159. /**
  29160. * Gets the shadows Exposure value.
  29161. * 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.
  29162. */
  29163. /**
  29164. * Sets the shadows Exposure value.
  29165. * 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.
  29166. */
  29167. shadowsExposure: number;
  29168. /**
  29169. * Returns the class name
  29170. * @returns The class name
  29171. */
  29172. getClassName(): string;
  29173. /**
  29174. * Binds the color curves to the shader.
  29175. * @param colorCurves The color curve to bind
  29176. * @param effect The effect to bind to
  29177. * @param positiveUniform The positive uniform shader parameter
  29178. * @param neutralUniform The neutral uniform shader parameter
  29179. * @param negativeUniform The negative uniform shader parameter
  29180. */
  29181. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29182. /**
  29183. * Prepare the list of uniforms associated with the ColorCurves effects.
  29184. * @param uniformsList The list of uniforms used in the effect
  29185. */
  29186. static PrepareUniforms(uniformsList: string[]): void;
  29187. /**
  29188. * Returns color grading data based on a hue, density, saturation and exposure value.
  29189. * @param filterHue The hue of the color filter.
  29190. * @param filterDensity The density of the color filter.
  29191. * @param saturation The saturation.
  29192. * @param exposure The exposure.
  29193. * @param result The result data container.
  29194. */
  29195. private getColorGradingDataToRef;
  29196. /**
  29197. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29198. * @param value The input slider value in range [-100,100].
  29199. * @returns Adjusted value.
  29200. */
  29201. private static applyColorGradingSliderNonlinear;
  29202. /**
  29203. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29204. * @param hue The hue (H) input.
  29205. * @param saturation The saturation (S) input.
  29206. * @param brightness The brightness (B) input.
  29207. * @result An RGBA color represented as Vector4.
  29208. */
  29209. private static fromHSBToRef;
  29210. /**
  29211. * Returns a value clamped between min and max
  29212. * @param value The value to clamp
  29213. * @param min The minimum of value
  29214. * @param max The maximum of value
  29215. * @returns The clamped value.
  29216. */
  29217. private static clamp;
  29218. /**
  29219. * Clones the current color curve instance.
  29220. * @return The cloned curves
  29221. */
  29222. clone(): ColorCurves;
  29223. /**
  29224. * Serializes the current color curve instance to a json representation.
  29225. * @return a JSON representation
  29226. */
  29227. serialize(): any;
  29228. /**
  29229. * Parses the color curve from a json representation.
  29230. * @param source the JSON source to parse
  29231. * @return The parsed curves
  29232. */
  29233. static Parse(source: any): ColorCurves;
  29234. }
  29235. }
  29236. declare module BABYLON {
  29237. /**
  29238. * Interface to follow in your material defines to integrate easily the
  29239. * Image proccessing functions.
  29240. * @hidden
  29241. */
  29242. export interface IImageProcessingConfigurationDefines {
  29243. IMAGEPROCESSING: boolean;
  29244. VIGNETTE: boolean;
  29245. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29246. VIGNETTEBLENDMODEOPAQUE: boolean;
  29247. TONEMAPPING: boolean;
  29248. TONEMAPPING_ACES: boolean;
  29249. CONTRAST: boolean;
  29250. EXPOSURE: boolean;
  29251. COLORCURVES: boolean;
  29252. COLORGRADING: boolean;
  29253. COLORGRADING3D: boolean;
  29254. SAMPLER3DGREENDEPTH: boolean;
  29255. SAMPLER3DBGRMAP: boolean;
  29256. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29257. }
  29258. /**
  29259. * @hidden
  29260. */
  29261. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29262. IMAGEPROCESSING: boolean;
  29263. VIGNETTE: boolean;
  29264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29265. VIGNETTEBLENDMODEOPAQUE: boolean;
  29266. TONEMAPPING: boolean;
  29267. TONEMAPPING_ACES: boolean;
  29268. CONTRAST: boolean;
  29269. COLORCURVES: boolean;
  29270. COLORGRADING: boolean;
  29271. COLORGRADING3D: boolean;
  29272. SAMPLER3DGREENDEPTH: boolean;
  29273. SAMPLER3DBGRMAP: boolean;
  29274. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29275. EXPOSURE: boolean;
  29276. constructor();
  29277. }
  29278. /**
  29279. * This groups together the common properties used for image processing either in direct forward pass
  29280. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29281. * or not.
  29282. */
  29283. export class ImageProcessingConfiguration {
  29284. /**
  29285. * Default tone mapping applied in BabylonJS.
  29286. */
  29287. static readonly TONEMAPPING_STANDARD: number;
  29288. /**
  29289. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29290. * to other engines rendering to increase portability.
  29291. */
  29292. static readonly TONEMAPPING_ACES: number;
  29293. /**
  29294. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29295. */
  29296. colorCurves: Nullable<ColorCurves>;
  29297. private _colorCurvesEnabled;
  29298. /**
  29299. * Gets wether the color curves effect is enabled.
  29300. */
  29301. /**
  29302. * Sets wether the color curves effect is enabled.
  29303. */
  29304. colorCurvesEnabled: boolean;
  29305. private _colorGradingTexture;
  29306. /**
  29307. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29308. */
  29309. /**
  29310. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29311. */
  29312. colorGradingTexture: Nullable<BaseTexture>;
  29313. private _colorGradingEnabled;
  29314. /**
  29315. * Gets wether the color grading effect is enabled.
  29316. */
  29317. /**
  29318. * Sets wether the color grading effect is enabled.
  29319. */
  29320. colorGradingEnabled: boolean;
  29321. private _colorGradingWithGreenDepth;
  29322. /**
  29323. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29324. */
  29325. /**
  29326. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29327. */
  29328. colorGradingWithGreenDepth: boolean;
  29329. private _colorGradingBGR;
  29330. /**
  29331. * Gets wether the color grading texture contains BGR values.
  29332. */
  29333. /**
  29334. * Sets wether the color grading texture contains BGR values.
  29335. */
  29336. colorGradingBGR: boolean;
  29337. /** @hidden */ exposure: number;
  29338. /**
  29339. * Gets the Exposure used in the effect.
  29340. */
  29341. /**
  29342. * Sets the Exposure used in the effect.
  29343. */
  29344. exposure: number;
  29345. private _toneMappingEnabled;
  29346. /**
  29347. * Gets wether the tone mapping effect is enabled.
  29348. */
  29349. /**
  29350. * Sets wether the tone mapping effect is enabled.
  29351. */
  29352. toneMappingEnabled: boolean;
  29353. private _toneMappingType;
  29354. /**
  29355. * Gets the type of tone mapping effect.
  29356. */
  29357. /**
  29358. * Sets the type of tone mapping effect used in BabylonJS.
  29359. */
  29360. toneMappingType: number;
  29361. protected _contrast: number;
  29362. /**
  29363. * Gets the contrast used in the effect.
  29364. */
  29365. /**
  29366. * Sets the contrast used in the effect.
  29367. */
  29368. contrast: number;
  29369. /**
  29370. * Vignette stretch size.
  29371. */
  29372. vignetteStretch: number;
  29373. /**
  29374. * Vignette centre X Offset.
  29375. */
  29376. vignetteCentreX: number;
  29377. /**
  29378. * Vignette centre Y Offset.
  29379. */
  29380. vignetteCentreY: number;
  29381. /**
  29382. * Vignette weight or intensity of the vignette effect.
  29383. */
  29384. vignetteWeight: number;
  29385. /**
  29386. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29387. * if vignetteEnabled is set to true.
  29388. */
  29389. vignetteColor: Color4;
  29390. /**
  29391. * Camera field of view used by the Vignette effect.
  29392. */
  29393. vignetteCameraFov: number;
  29394. private _vignetteBlendMode;
  29395. /**
  29396. * Gets the vignette blend mode allowing different kind of effect.
  29397. */
  29398. /**
  29399. * Sets the vignette blend mode allowing different kind of effect.
  29400. */
  29401. vignetteBlendMode: number;
  29402. private _vignetteEnabled;
  29403. /**
  29404. * Gets wether the vignette effect is enabled.
  29405. */
  29406. /**
  29407. * Sets wether the vignette effect is enabled.
  29408. */
  29409. vignetteEnabled: boolean;
  29410. private _applyByPostProcess;
  29411. /**
  29412. * Gets wether the image processing is applied through a post process or not.
  29413. */
  29414. /**
  29415. * Sets wether the image processing is applied through a post process or not.
  29416. */
  29417. applyByPostProcess: boolean;
  29418. private _isEnabled;
  29419. /**
  29420. * Gets wether the image processing is enabled or not.
  29421. */
  29422. /**
  29423. * Sets wether the image processing is enabled or not.
  29424. */
  29425. isEnabled: boolean;
  29426. /**
  29427. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29428. */
  29429. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29430. /**
  29431. * Method called each time the image processing information changes requires to recompile the effect.
  29432. */
  29433. protected _updateParameters(): void;
  29434. /**
  29435. * Gets the current class name.
  29436. * @return "ImageProcessingConfiguration"
  29437. */
  29438. getClassName(): string;
  29439. /**
  29440. * Prepare the list of uniforms associated with the Image Processing effects.
  29441. * @param uniforms The list of uniforms used in the effect
  29442. * @param defines the list of defines currently in use
  29443. */
  29444. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29445. /**
  29446. * Prepare the list of samplers associated with the Image Processing effects.
  29447. * @param samplersList The list of uniforms used in the effect
  29448. * @param defines the list of defines currently in use
  29449. */
  29450. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29451. /**
  29452. * Prepare the list of defines associated to the shader.
  29453. * @param defines the list of defines to complete
  29454. * @param forPostProcess Define if we are currently in post process mode or not
  29455. */
  29456. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29457. /**
  29458. * Returns true if all the image processing information are ready.
  29459. * @returns True if ready, otherwise, false
  29460. */
  29461. isReady(): boolean;
  29462. /**
  29463. * Binds the image processing to the shader.
  29464. * @param effect The effect to bind to
  29465. * @param aspectRatio Define the current aspect ratio of the effect
  29466. */
  29467. bind(effect: Effect, aspectRatio?: number): void;
  29468. /**
  29469. * Clones the current image processing instance.
  29470. * @return The cloned image processing
  29471. */
  29472. clone(): ImageProcessingConfiguration;
  29473. /**
  29474. * Serializes the current image processing instance to a json representation.
  29475. * @return a JSON representation
  29476. */
  29477. serialize(): any;
  29478. /**
  29479. * Parses the image processing from a json representation.
  29480. * @param source the JSON source to parse
  29481. * @return The parsed image processing
  29482. */
  29483. static Parse(source: any): ImageProcessingConfiguration;
  29484. private static _VIGNETTEMODE_MULTIPLY;
  29485. private static _VIGNETTEMODE_OPAQUE;
  29486. /**
  29487. * Used to apply the vignette as a mix with the pixel color.
  29488. */
  29489. static readonly VIGNETTEMODE_MULTIPLY: number;
  29490. /**
  29491. * Used to apply the vignette as a replacement of the pixel color.
  29492. */
  29493. static readonly VIGNETTEMODE_OPAQUE: number;
  29494. }
  29495. }
  29496. declare module BABYLON {
  29497. /**
  29498. * This represents all the required information to add a fresnel effect on a material:
  29499. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29500. */
  29501. export class FresnelParameters {
  29502. private _isEnabled;
  29503. /**
  29504. * Define if the fresnel effect is enable or not.
  29505. */
  29506. isEnabled: boolean;
  29507. /**
  29508. * Define the color used on edges (grazing angle)
  29509. */
  29510. leftColor: Color3;
  29511. /**
  29512. * Define the color used on center
  29513. */
  29514. rightColor: Color3;
  29515. /**
  29516. * Define bias applied to computed fresnel term
  29517. */
  29518. bias: number;
  29519. /**
  29520. * Defined the power exponent applied to fresnel term
  29521. */
  29522. power: number;
  29523. /**
  29524. * Clones the current fresnel and its valuues
  29525. * @returns a clone fresnel configuration
  29526. */
  29527. clone(): FresnelParameters;
  29528. /**
  29529. * Serializes the current fresnel parameters to a JSON representation.
  29530. * @return the JSON serialization
  29531. */
  29532. serialize(): any;
  29533. /**
  29534. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29535. * @param parsedFresnelParameters Define the JSON representation
  29536. * @returns the parsed parameters
  29537. */
  29538. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29539. }
  29540. }
  29541. declare module BABYLON {
  29542. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29543. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29544. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29545. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29546. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29547. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29548. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29549. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29550. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29551. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29552. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29553. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29554. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29555. /**
  29556. * Decorator used to define property that can be serialized as reference to a camera
  29557. * @param sourceName defines the name of the property to decorate
  29558. */
  29559. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29560. /**
  29561. * Class used to help serialization objects
  29562. */
  29563. export class SerializationHelper {
  29564. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29565. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29566. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29567. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29568. /**
  29569. * Appends the serialized animations from the source animations
  29570. * @param source Source containing the animations
  29571. * @param destination Target to store the animations
  29572. */
  29573. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29574. /**
  29575. * Static function used to serialized a specific entity
  29576. * @param entity defines the entity to serialize
  29577. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29578. * @returns a JSON compatible object representing the serialization of the entity
  29579. */
  29580. static Serialize<T>(entity: T, serializationObject?: any): any;
  29581. /**
  29582. * Creates a new entity from a serialization data object
  29583. * @param creationFunction defines a function used to instanciated the new entity
  29584. * @param source defines the source serialization data
  29585. * @param scene defines the hosting scene
  29586. * @param rootUrl defines the root url for resources
  29587. * @returns a new entity
  29588. */
  29589. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29590. /**
  29591. * Clones an object
  29592. * @param creationFunction defines the function used to instanciate the new object
  29593. * @param source defines the source object
  29594. * @returns the cloned object
  29595. */
  29596. static Clone<T>(creationFunction: () => T, source: T): T;
  29597. /**
  29598. * Instanciates a new object based on a source one (some data will be shared between both object)
  29599. * @param creationFunction defines the function used to instanciate the new object
  29600. * @param source defines the source object
  29601. * @returns the new object
  29602. */
  29603. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29604. }
  29605. }
  29606. declare module BABYLON {
  29607. /**
  29608. * This is the base class of all the camera used in the application.
  29609. * @see http://doc.babylonjs.com/features/cameras
  29610. */
  29611. export class Camera extends Node {
  29612. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29613. /**
  29614. * This is the default projection mode used by the cameras.
  29615. * It helps recreating a feeling of perspective and better appreciate depth.
  29616. * This is the best way to simulate real life cameras.
  29617. */
  29618. static readonly PERSPECTIVE_CAMERA: number;
  29619. /**
  29620. * This helps creating camera with an orthographic mode.
  29621. * 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.
  29622. */
  29623. static readonly ORTHOGRAPHIC_CAMERA: number;
  29624. /**
  29625. * This is the default FOV mode for perspective cameras.
  29626. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29627. */
  29628. static readonly FOVMODE_VERTICAL_FIXED: number;
  29629. /**
  29630. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29631. */
  29632. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29633. /**
  29634. * This specifies ther is no need for a camera rig.
  29635. * Basically only one eye is rendered corresponding to the camera.
  29636. */
  29637. static readonly RIG_MODE_NONE: number;
  29638. /**
  29639. * Simulates a camera Rig with one blue eye and one red eye.
  29640. * This can be use with 3d blue and red glasses.
  29641. */
  29642. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29643. /**
  29644. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29645. */
  29646. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29647. /**
  29648. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29649. */
  29650. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29651. /**
  29652. * Defines that both eyes of the camera will be rendered over under each other.
  29653. */
  29654. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29655. /**
  29656. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29657. */
  29658. static readonly RIG_MODE_VR: number;
  29659. /**
  29660. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29661. */
  29662. static readonly RIG_MODE_WEBVR: number;
  29663. /**
  29664. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29665. */
  29666. static readonly RIG_MODE_CUSTOM: number;
  29667. /**
  29668. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29669. */
  29670. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29671. /**
  29672. * Define the input manager associated with the camera.
  29673. */
  29674. inputs: CameraInputsManager<Camera>;
  29675. /** @hidden */ position: Vector3;
  29676. /**
  29677. * Define the current local position of the camera in the scene
  29678. */
  29679. position: Vector3;
  29680. /**
  29681. * The vector the camera should consider as up.
  29682. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29683. */
  29684. upVector: Vector3;
  29685. /**
  29686. * Define the current limit on the left side for an orthographic camera
  29687. * In scene unit
  29688. */
  29689. orthoLeft: Nullable<number>;
  29690. /**
  29691. * Define the current limit on the right side for an orthographic camera
  29692. * In scene unit
  29693. */
  29694. orthoRight: Nullable<number>;
  29695. /**
  29696. * Define the current limit on the bottom side for an orthographic camera
  29697. * In scene unit
  29698. */
  29699. orthoBottom: Nullable<number>;
  29700. /**
  29701. * Define the current limit on the top side for an orthographic camera
  29702. * In scene unit
  29703. */
  29704. orthoTop: Nullable<number>;
  29705. /**
  29706. * Field Of View is set in Radians. (default is 0.8)
  29707. */
  29708. fov: number;
  29709. /**
  29710. * Define the minimum distance the camera can see from.
  29711. * This is important to note that the depth buffer are not infinite and the closer it starts
  29712. * the more your scene might encounter depth fighting issue.
  29713. */
  29714. minZ: number;
  29715. /**
  29716. * Define the maximum distance the camera can see to.
  29717. * This is important to note that the depth buffer are not infinite and the further it end
  29718. * the more your scene might encounter depth fighting issue.
  29719. */
  29720. maxZ: number;
  29721. /**
  29722. * Define the default inertia of the camera.
  29723. * This helps giving a smooth feeling to the camera movement.
  29724. */
  29725. inertia: number;
  29726. /**
  29727. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29728. */
  29729. mode: number;
  29730. /**
  29731. * Define wether the camera is intermediate.
  29732. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29733. */
  29734. isIntermediate: boolean;
  29735. /**
  29736. * Define the viewport of the camera.
  29737. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29738. */
  29739. viewport: Viewport;
  29740. /**
  29741. * Restricts the camera to viewing objects with the same layerMask.
  29742. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29743. */
  29744. layerMask: number;
  29745. /**
  29746. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29747. */
  29748. fovMode: number;
  29749. /**
  29750. * Rig mode of the camera.
  29751. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29752. * This is normally controlled byt the camera themselves as internal use.
  29753. */
  29754. cameraRigMode: number;
  29755. /**
  29756. * Defines the distance between both "eyes" in case of a RIG
  29757. */
  29758. interaxialDistance: number;
  29759. /**
  29760. * Defines if stereoscopic rendering is done side by side or over under.
  29761. */
  29762. isStereoscopicSideBySide: boolean;
  29763. /**
  29764. * 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
  29765. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29766. * else in the scene.
  29767. */
  29768. customRenderTargets: RenderTargetTexture[];
  29769. /**
  29770. * When set, the camera will render to this render target instead of the default canvas
  29771. */
  29772. outputRenderTarget: Nullable<RenderTargetTexture>;
  29773. /**
  29774. * Observable triggered when the camera view matrix has changed.
  29775. */
  29776. onViewMatrixChangedObservable: Observable<Camera>;
  29777. /**
  29778. * Observable triggered when the camera Projection matrix has changed.
  29779. */
  29780. onProjectionMatrixChangedObservable: Observable<Camera>;
  29781. /**
  29782. * Observable triggered when the inputs have been processed.
  29783. */
  29784. onAfterCheckInputsObservable: Observable<Camera>;
  29785. /**
  29786. * Observable triggered when reset has been called and applied to the camera.
  29787. */
  29788. onRestoreStateObservable: Observable<Camera>;
  29789. /** @hidden */ cameraRigParams: any;
  29790. /** @hidden */ rigCameras: Camera[];
  29791. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29792. protected _webvrViewMatrix: Matrix;
  29793. /** @hidden */ skipRendering: boolean;
  29794. /** @hidden */ projectionMatrix: Matrix;
  29795. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29796. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29797. protected _globalPosition: Vector3;
  29798. /** hidden */ computedViewMatrix: Matrix;
  29799. private _doNotComputeProjectionMatrix;
  29800. private _transformMatrix;
  29801. private _frustumPlanes;
  29802. private _refreshFrustumPlanes;
  29803. private _storedFov;
  29804. private _stateStored;
  29805. /**
  29806. * Instantiates a new camera object.
  29807. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29808. * @see http://doc.babylonjs.com/features/cameras
  29809. * @param name Defines the name of the camera in the scene
  29810. * @param position Defines the position of the camera
  29811. * @param scene Defines the scene the camera belongs too
  29812. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29813. */
  29814. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29815. /**
  29816. * Store current camera state (fov, position, etc..)
  29817. * @returns the camera
  29818. */
  29819. storeState(): Camera;
  29820. /**
  29821. * Restores the camera state values if it has been stored. You must call storeState() first
  29822. */
  29823. protected _restoreStateValues(): boolean;
  29824. /**
  29825. * Restored camera state. You must call storeState() first.
  29826. * @returns true if restored and false otherwise
  29827. */
  29828. restoreState(): boolean;
  29829. /**
  29830. * Gets the class name of the camera.
  29831. * @returns the class name
  29832. */
  29833. getClassName(): string;
  29834. /** @hidden */ protected readonly _isCamera: boolean;
  29835. /**
  29836. * Gets a string representation of the camera useful for debug purpose.
  29837. * @param fullDetails Defines that a more verboe level of logging is required
  29838. * @returns the string representation
  29839. */
  29840. toString(fullDetails?: boolean): string;
  29841. /**
  29842. * Gets the current world space position of the camera.
  29843. */
  29844. readonly globalPosition: Vector3;
  29845. /**
  29846. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29847. * @returns the active meshe list
  29848. */
  29849. getActiveMeshes(): SmartArray<AbstractMesh>;
  29850. /**
  29851. * Check wether a mesh is part of the current active mesh list of the camera
  29852. * @param mesh Defines the mesh to check
  29853. * @returns true if active, false otherwise
  29854. */
  29855. isActiveMesh(mesh: Mesh): boolean;
  29856. /**
  29857. * Is this camera ready to be used/rendered
  29858. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29859. * @return true if the camera is ready
  29860. */
  29861. isReady(completeCheck?: boolean): boolean;
  29862. /** @hidden */ initCache(): void;
  29863. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29864. /** @hidden */ isSynchronized(): boolean;
  29865. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29866. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29867. /**
  29868. * Attach the input controls to a specific dom element to get the input from.
  29869. * @param element Defines the element the controls should be listened from
  29870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29871. */
  29872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29873. /**
  29874. * Detach the current controls from the specified dom element.
  29875. * @param element Defines the element to stop listening the inputs from
  29876. */
  29877. detachControl(element: HTMLElement): void;
  29878. /**
  29879. * Update the camera state according to the different inputs gathered during the frame.
  29880. */
  29881. update(): void;
  29882. /** @hidden */ checkInputs(): void;
  29883. /** @hidden */
  29884. readonly rigCameras: Camera[];
  29885. /**
  29886. * Gets the post process used by the rig cameras
  29887. */
  29888. readonly rigPostProcess: Nullable<PostProcess>;
  29889. /**
  29890. * Internal, gets the first post proces.
  29891. * @returns the first post process to be run on this camera.
  29892. */ getFirstPostProcess(): Nullable<PostProcess>;
  29893. private _cascadePostProcessesToRigCams;
  29894. /**
  29895. * Attach a post process to the camera.
  29896. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29897. * @param postProcess The post process to attach to the camera
  29898. * @param insertAt The position of the post process in case several of them are in use in the scene
  29899. * @returns the position the post process has been inserted at
  29900. */
  29901. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29902. /**
  29903. * Detach a post process to the camera.
  29904. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29905. * @param postProcess The post process to detach from the camera
  29906. */
  29907. detachPostProcess(postProcess: PostProcess): void;
  29908. /**
  29909. * Gets the current world matrix of the camera
  29910. */
  29911. getWorldMatrix(): Matrix;
  29912. /** @hidden */ getViewMatrix(): Matrix;
  29913. /**
  29914. * Gets the current view matrix of the camera.
  29915. * @param force forces the camera to recompute the matrix without looking at the cached state
  29916. * @returns the view matrix
  29917. */
  29918. getViewMatrix(force?: boolean): Matrix;
  29919. /**
  29920. * Freeze the projection matrix.
  29921. * It will prevent the cache check of the camera projection compute and can speed up perf
  29922. * if no parameter of the camera are meant to change
  29923. * @param projection Defines manually a projection if necessary
  29924. */
  29925. freezeProjectionMatrix(projection?: Matrix): void;
  29926. /**
  29927. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29928. */
  29929. unfreezeProjectionMatrix(): void;
  29930. /**
  29931. * Gets the current projection matrix of the camera.
  29932. * @param force forces the camera to recompute the matrix without looking at the cached state
  29933. * @returns the projection matrix
  29934. */
  29935. getProjectionMatrix(force?: boolean): Matrix;
  29936. /**
  29937. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29938. * @returns a Matrix
  29939. */
  29940. getTransformationMatrix(): Matrix;
  29941. private _updateFrustumPlanes;
  29942. /**
  29943. * Checks if a cullable object (mesh...) is in the camera frustum
  29944. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29945. * @param target The object to check
  29946. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29947. * @returns true if the object is in frustum otherwise false
  29948. */
  29949. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29950. /**
  29951. * Checks if a cullable object (mesh...) is in the camera frustum
  29952. * Unlike isInFrustum this cheks the full bounding box
  29953. * @param target The object to check
  29954. * @returns true if the object is in frustum otherwise false
  29955. */
  29956. isCompletelyInFrustum(target: ICullable): boolean;
  29957. /**
  29958. * Gets a ray in the forward direction from the camera.
  29959. * @param length Defines the length of the ray to create
  29960. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29961. * @param origin Defines the start point of the ray which defaults to the camera position
  29962. * @returns the forward ray
  29963. */
  29964. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29965. /**
  29966. * Releases resources associated with this node.
  29967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29969. */
  29970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29971. /** @hidden */ isLeftCamera: boolean;
  29972. /**
  29973. * Gets the left camera of a rig setup in case of Rigged Camera
  29974. */
  29975. readonly isLeftCamera: boolean;
  29976. /** @hidden */ isRightCamera: boolean;
  29977. /**
  29978. * Gets the right camera of a rig setup in case of Rigged Camera
  29979. */
  29980. readonly isRightCamera: boolean;
  29981. /**
  29982. * Gets the left camera of a rig setup in case of Rigged Camera
  29983. */
  29984. readonly leftCamera: Nullable<FreeCamera>;
  29985. /**
  29986. * Gets the right camera of a rig setup in case of Rigged Camera
  29987. */
  29988. readonly rightCamera: Nullable<FreeCamera>;
  29989. /**
  29990. * Gets the left camera target of a rig setup in case of Rigged Camera
  29991. * @returns the target position
  29992. */
  29993. getLeftTarget(): Nullable<Vector3>;
  29994. /**
  29995. * Gets the right camera target of a rig setup in case of Rigged Camera
  29996. * @returns the target position
  29997. */
  29998. getRightTarget(): Nullable<Vector3>;
  29999. /**
  30000. * @hidden
  30001. */
  30002. setCameraRigMode(mode: number, rigParams: any): void;
  30003. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30004. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30005. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30006. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30007. /** @hidden */ getVRProjectionMatrix(): Matrix;
  30008. protected _updateCameraRotationMatrix(): void;
  30009. protected _updateWebVRCameraRotationMatrix(): void;
  30010. /**
  30011. * This function MUST be overwritten by the different WebVR cameras available.
  30012. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30013. * @hidden
  30014. */ getWebVRProjectionMatrix(): Matrix;
  30015. /**
  30016. * This function MUST be overwritten by the different WebVR cameras available.
  30017. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30018. * @hidden
  30019. */ getWebVRViewMatrix(): Matrix;
  30020. /** @hidden */
  30021. setCameraRigParameter(name: string, value: any): void;
  30022. /**
  30023. * needs to be overridden by children so sub has required properties to be copied
  30024. * @hidden
  30025. */
  30026. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30027. /**
  30028. * May need to be overridden by children
  30029. * @hidden
  30030. */ updateRigCameras(): void;
  30031. /** @hidden */ setupInputs(): void;
  30032. /**
  30033. * Serialiaze the camera setup to a json represention
  30034. * @returns the JSON representation
  30035. */
  30036. serialize(): any;
  30037. /**
  30038. * Clones the current camera.
  30039. * @param name The cloned camera name
  30040. * @returns the cloned camera
  30041. */
  30042. clone(name: string): Camera;
  30043. /**
  30044. * Gets the direction of the camera relative to a given local axis.
  30045. * @param localAxis Defines the reference axis to provide a relative direction.
  30046. * @return the direction
  30047. */
  30048. getDirection(localAxis: Vector3): Vector3;
  30049. /**
  30050. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30051. * @param localAxis Defines the reference axis to provide a relative direction.
  30052. * @param result Defines the vector to store the result in
  30053. */
  30054. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30055. /**
  30056. * Gets a camera constructor for a given camera type
  30057. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30058. * @param name The name of the camera the result will be able to instantiate
  30059. * @param scene The scene the result will construct the camera in
  30060. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30061. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30062. * @returns a factory method to construc the camera
  30063. */
  30064. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30065. /**
  30066. * Compute the world matrix of the camera.
  30067. * @returns the camera workd matrix
  30068. */
  30069. computeWorldMatrix(): Matrix;
  30070. /**
  30071. * Parse a JSON and creates the camera from the parsed information
  30072. * @param parsedCamera The JSON to parse
  30073. * @param scene The scene to instantiate the camera in
  30074. * @returns the newly constructed camera
  30075. */
  30076. static Parse(parsedCamera: any, scene: Scene): Camera;
  30077. }
  30078. }
  30079. declare module BABYLON {
  30080. /**
  30081. * Interface for any object that can request an animation frame
  30082. */
  30083. export interface ICustomAnimationFrameRequester {
  30084. /**
  30085. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30086. */
  30087. renderFunction?: Function;
  30088. /**
  30089. * Called to request the next frame to render to
  30090. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30091. */
  30092. requestAnimationFrame: Function;
  30093. /**
  30094. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30095. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30096. */
  30097. requestID?: number;
  30098. }
  30099. /**
  30100. * Interface containing an array of animations
  30101. */
  30102. export interface IAnimatable {
  30103. /**
  30104. * Array of animations
  30105. */
  30106. animations: Nullable<Array<Animation>>;
  30107. }
  30108. /** Interface used by value gradients (color, factor, ...) */
  30109. export interface IValueGradient {
  30110. /**
  30111. * Gets or sets the gradient value (between 0 and 1)
  30112. */
  30113. gradient: number;
  30114. }
  30115. /** Class used to store color4 gradient */
  30116. export class ColorGradient implements IValueGradient {
  30117. /**
  30118. * Gets or sets the gradient value (between 0 and 1)
  30119. */
  30120. gradient: number;
  30121. /**
  30122. * Gets or sets first associated color
  30123. */
  30124. color1: Color4;
  30125. /**
  30126. * Gets or sets second associated color
  30127. */
  30128. color2?: Color4;
  30129. /**
  30130. * Will get a color picked randomly between color1 and color2.
  30131. * If color2 is undefined then color1 will be used
  30132. * @param result defines the target Color4 to store the result in
  30133. */
  30134. getColorToRef(result: Color4): void;
  30135. }
  30136. /** Class used to store color 3 gradient */
  30137. export class Color3Gradient implements IValueGradient {
  30138. /**
  30139. * Gets or sets the gradient value (between 0 and 1)
  30140. */
  30141. gradient: number;
  30142. /**
  30143. * Gets or sets the associated color
  30144. */
  30145. color: Color3;
  30146. }
  30147. /** Class used to store factor gradient */
  30148. export class FactorGradient implements IValueGradient {
  30149. /**
  30150. * Gets or sets the gradient value (between 0 and 1)
  30151. */
  30152. gradient: number;
  30153. /**
  30154. * Gets or sets first associated factor
  30155. */
  30156. factor1: number;
  30157. /**
  30158. * Gets or sets second associated factor
  30159. */
  30160. factor2?: number;
  30161. /**
  30162. * Will get a number picked randomly between factor1 and factor2.
  30163. * If factor2 is undefined then factor1 will be used
  30164. * @returns the picked number
  30165. */
  30166. getFactor(): number;
  30167. }
  30168. /**
  30169. * @ignore
  30170. * Application error to support additional information when loading a file
  30171. */
  30172. export class LoadFileError extends Error {
  30173. /** defines the optional web request */
  30174. request?: WebRequest | undefined;
  30175. private static _setPrototypeOf;
  30176. /**
  30177. * Creates a new LoadFileError
  30178. * @param message defines the message of the error
  30179. * @param request defines the optional web request
  30180. */
  30181. constructor(message: string,
  30182. /** defines the optional web request */
  30183. request?: WebRequest | undefined);
  30184. }
  30185. /**
  30186. * Class used to define a retry strategy when error happens while loading assets
  30187. */
  30188. export class RetryStrategy {
  30189. /**
  30190. * Function used to defines an exponential back off strategy
  30191. * @param maxRetries defines the maximum number of retries (3 by default)
  30192. * @param baseInterval defines the interval between retries
  30193. * @returns the strategy function to use
  30194. */
  30195. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30196. }
  30197. /**
  30198. * File request interface
  30199. */
  30200. export interface IFileRequest {
  30201. /**
  30202. * Raised when the request is complete (success or error).
  30203. */
  30204. onCompleteObservable: Observable<IFileRequest>;
  30205. /**
  30206. * Aborts the request for a file.
  30207. */
  30208. abort: () => void;
  30209. }
  30210. /**
  30211. * Class containing a set of static utilities functions
  30212. */
  30213. export class Tools {
  30214. /**
  30215. * Gets or sets the base URL to use to load assets
  30216. */
  30217. static BaseUrl: string;
  30218. /**
  30219. * Enable/Disable Custom HTTP Request Headers globally.
  30220. * default = false
  30221. * @see CustomRequestHeaders
  30222. */
  30223. static UseCustomRequestHeaders: boolean;
  30224. /**
  30225. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30226. * i.e. when loading files, where the server/service expects an Authorization header
  30227. */
  30228. static CustomRequestHeaders: {
  30229. [key: string]: string;
  30230. };
  30231. /**
  30232. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30233. */
  30234. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30235. /**
  30236. * Default behaviour for cors in the application.
  30237. * It can be a string if the expected behavior is identical in the entire app.
  30238. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30239. */
  30240. static CorsBehavior: string | ((url: string | string[]) => string);
  30241. /**
  30242. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30243. * @ignorenaming
  30244. */
  30245. static UseFallbackTexture: boolean;
  30246. /**
  30247. * Use this object to register external classes like custom textures or material
  30248. * to allow the laoders to instantiate them
  30249. */
  30250. static RegisteredExternalClasses: {
  30251. [key: string]: Object;
  30252. };
  30253. /**
  30254. * Texture content used if a texture cannot loaded
  30255. * @ignorenaming
  30256. */
  30257. static fallbackTexture: string;
  30258. /**
  30259. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30260. * @param u defines the coordinate on X axis
  30261. * @param v defines the coordinate on Y axis
  30262. * @param width defines the width of the source data
  30263. * @param height defines the height of the source data
  30264. * @param pixels defines the source byte array
  30265. * @param color defines the output color
  30266. */
  30267. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30268. /**
  30269. * Interpolates between a and b via alpha
  30270. * @param a The lower value (returned when alpha = 0)
  30271. * @param b The upper value (returned when alpha = 1)
  30272. * @param alpha The interpolation-factor
  30273. * @return The mixed value
  30274. */
  30275. static Mix(a: number, b: number, alpha: number): number;
  30276. /**
  30277. * Tries to instantiate a new object from a given class name
  30278. * @param className defines the class name to instantiate
  30279. * @returns the new object or null if the system was not able to do the instantiation
  30280. */
  30281. static Instantiate(className: string): any;
  30282. /**
  30283. * Provides a slice function that will work even on IE
  30284. * @param data defines the array to slice
  30285. * @param start defines the start of the data (optional)
  30286. * @param end defines the end of the data (optional)
  30287. * @returns the new sliced array
  30288. */
  30289. static Slice<T>(data: T, start?: number, end?: number): T;
  30290. /**
  30291. * Polyfill for setImmediate
  30292. * @param action defines the action to execute after the current execution block
  30293. */
  30294. static SetImmediate(action: () => void): void;
  30295. /**
  30296. * Function indicating if a number is an exponent of 2
  30297. * @param value defines the value to test
  30298. * @returns true if the value is an exponent of 2
  30299. */
  30300. static IsExponentOfTwo(value: number): boolean;
  30301. private static _tmpFloatArray;
  30302. /**
  30303. * Returns the nearest 32-bit single precision float representation of a Number
  30304. * @param value A Number. If the parameter is of a different type, it will get converted
  30305. * to a number or to NaN if it cannot be converted
  30306. * @returns number
  30307. */
  30308. static FloatRound(value: number): number;
  30309. /**
  30310. * Find the next highest power of two.
  30311. * @param x Number to start search from.
  30312. * @return Next highest power of two.
  30313. */
  30314. static CeilingPOT(x: number): number;
  30315. /**
  30316. * Find the next lowest power of two.
  30317. * @param x Number to start search from.
  30318. * @return Next lowest power of two.
  30319. */
  30320. static FloorPOT(x: number): number;
  30321. /**
  30322. * Find the nearest power of two.
  30323. * @param x Number to start search from.
  30324. * @return Next nearest power of two.
  30325. */
  30326. static NearestPOT(x: number): number;
  30327. /**
  30328. * Get the closest exponent of two
  30329. * @param value defines the value to approximate
  30330. * @param max defines the maximum value to return
  30331. * @param mode defines how to define the closest value
  30332. * @returns closest exponent of two of the given value
  30333. */
  30334. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30335. /**
  30336. * Extracts the filename from a path
  30337. * @param path defines the path to use
  30338. * @returns the filename
  30339. */
  30340. static GetFilename(path: string): string;
  30341. /**
  30342. * Extracts the "folder" part of a path (everything before the filename).
  30343. * @param uri The URI to extract the info from
  30344. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30345. * @returns The "folder" part of the path
  30346. */
  30347. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30348. /**
  30349. * Extracts text content from a DOM element hierarchy
  30350. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30351. */
  30352. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30353. /**
  30354. * Convert an angle in radians to degrees
  30355. * @param angle defines the angle to convert
  30356. * @returns the angle in degrees
  30357. */
  30358. static ToDegrees(angle: number): number;
  30359. /**
  30360. * Convert an angle in degrees to radians
  30361. * @param angle defines the angle to convert
  30362. * @returns the angle in radians
  30363. */
  30364. static ToRadians(angle: number): number;
  30365. /**
  30366. * Encode a buffer to a base64 string
  30367. * @param buffer defines the buffer to encode
  30368. * @returns the encoded string
  30369. */
  30370. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30371. /**
  30372. * Extracts minimum and maximum values from a list of indexed positions
  30373. * @param positions defines the positions to use
  30374. * @param indices defines the indices to the positions
  30375. * @param indexStart defines the start index
  30376. * @param indexCount defines the end index
  30377. * @param bias defines bias value to add to the result
  30378. * @return minimum and maximum values
  30379. */
  30380. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30381. minimum: Vector3;
  30382. maximum: Vector3;
  30383. };
  30384. /**
  30385. * Extracts minimum and maximum values from a list of positions
  30386. * @param positions defines the positions to use
  30387. * @param start defines the start index in the positions array
  30388. * @param count defines the number of positions to handle
  30389. * @param bias defines bias value to add to the result
  30390. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30391. * @return minimum and maximum values
  30392. */
  30393. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30394. minimum: Vector3;
  30395. maximum: Vector3;
  30396. };
  30397. /**
  30398. * Returns an array if obj is not an array
  30399. * @param obj defines the object to evaluate as an array
  30400. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30401. * @returns either obj directly if obj is an array or a new array containing obj
  30402. */
  30403. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30404. /**
  30405. * Gets the pointer prefix to use
  30406. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30407. */
  30408. static GetPointerPrefix(): string;
  30409. /**
  30410. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30411. * @param func - the function to be called
  30412. * @param requester - the object that will request the next frame. Falls back to window.
  30413. * @returns frame number
  30414. */
  30415. static QueueNewFrame(func: () => void, requester?: any): number;
  30416. /**
  30417. * Ask the browser to promote the current element to fullscreen rendering mode
  30418. * @param element defines the DOM element to promote
  30419. */
  30420. static RequestFullscreen(element: HTMLElement): void;
  30421. /**
  30422. * Asks the browser to exit fullscreen mode
  30423. */
  30424. static ExitFullscreen(): void;
  30425. /**
  30426. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30427. * @param url define the url we are trying
  30428. * @param element define the dom element where to configure the cors policy
  30429. */
  30430. static SetCorsBehavior(url: string | string[], element: {
  30431. crossOrigin: string | null;
  30432. }): void;
  30433. /**
  30434. * Removes unwanted characters from an url
  30435. * @param url defines the url to clean
  30436. * @returns the cleaned url
  30437. */
  30438. static CleanUrl(url: string): string;
  30439. /**
  30440. * Gets or sets a function used to pre-process url before using them to load assets
  30441. */
  30442. static PreprocessUrl: (url: string) => string;
  30443. /**
  30444. * Loads an image as an HTMLImageElement.
  30445. * @param input url string, ArrayBuffer, or Blob to load
  30446. * @param onLoad callback called when the image successfully loads
  30447. * @param onError callback called when the image fails to load
  30448. * @param offlineProvider offline provider for caching
  30449. * @returns the HTMLImageElement of the loaded image
  30450. */
  30451. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30452. /**
  30453. * Loads a file
  30454. * @param url url string, ArrayBuffer, or Blob to load
  30455. * @param onSuccess callback called when the file successfully loads
  30456. * @param onProgress callback called while file is loading (if the server supports this mode)
  30457. * @param offlineProvider defines the offline provider for caching
  30458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30459. * @param onError callback called when the file fails to load
  30460. * @returns a file request object
  30461. */
  30462. 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;
  30463. /**
  30464. * Load a script (identified by an url). When the url returns, the
  30465. * content of this file is added into a new script element, attached to the DOM (body element)
  30466. * @param scriptUrl defines the url of the script to laod
  30467. * @param onSuccess defines the callback called when the script is loaded
  30468. * @param onError defines the callback to call if an error occurs
  30469. * @param scriptId defines the id of the script element
  30470. */
  30471. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30472. /**
  30473. * Load an asynchronous script (identified by an url). When the url returns, the
  30474. * content of this file is added into a new script element, attached to the DOM (body element)
  30475. * @param scriptUrl defines the url of the script to laod
  30476. * @param scriptId defines the id of the script element
  30477. * @returns a promise request object
  30478. */
  30479. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30480. /**
  30481. * Loads a file from a blob
  30482. * @param fileToLoad defines the blob to use
  30483. * @param callback defines the callback to call when data is loaded
  30484. * @param progressCallback defines the callback to call during loading process
  30485. * @returns a file request object
  30486. */
  30487. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30488. /**
  30489. * Loads a file
  30490. * @param fileToLoad defines the file to load
  30491. * @param callback defines the callback to call when data is loaded
  30492. * @param progressCallBack defines the callback to call during loading process
  30493. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30494. * @returns a file request object
  30495. */
  30496. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30497. /**
  30498. * Creates a data url from a given string content
  30499. * @param content defines the content to convert
  30500. * @returns the new data url link
  30501. */
  30502. static FileAsURL(content: string): string;
  30503. /**
  30504. * Format the given number to a specific decimal format
  30505. * @param value defines the number to format
  30506. * @param decimals defines the number of decimals to use
  30507. * @returns the formatted string
  30508. */
  30509. static Format(value: number, decimals?: number): string;
  30510. /**
  30511. * Checks if a given vector is inside a specific range
  30512. * @param v defines the vector to test
  30513. * @param min defines the minimum range
  30514. * @param max defines the maximum range
  30515. */
  30516. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30517. /**
  30518. * Tries to copy an object by duplicating every property
  30519. * @param source defines the source object
  30520. * @param destination defines the target object
  30521. * @param doNotCopyList defines a list of properties to avoid
  30522. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30523. */
  30524. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30525. /**
  30526. * Gets a boolean indicating if the given object has no own property
  30527. * @param obj defines the object to test
  30528. * @returns true if object has no own property
  30529. */
  30530. static IsEmpty(obj: any): boolean;
  30531. /**
  30532. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30533. * @param str Source string
  30534. * @param suffix Suffix to search for in the source string
  30535. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30536. */
  30537. static EndsWith(str: string, suffix: string): boolean;
  30538. /**
  30539. * Function used to register events at window level
  30540. * @param events defines the events to register
  30541. */
  30542. static RegisterTopRootEvents(events: {
  30543. name: string;
  30544. handler: Nullable<(e: FocusEvent) => any>;
  30545. }[]): void;
  30546. /**
  30547. * Function used to unregister events from window level
  30548. * @param events defines the events to unregister
  30549. */
  30550. static UnregisterTopRootEvents(events: {
  30551. name: string;
  30552. handler: Nullable<(e: FocusEvent) => any>;
  30553. }[]): void;
  30554. /**
  30555. * @ignore
  30556. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30557. /**
  30558. * Dumps the current bound framebuffer
  30559. * @param width defines the rendering width
  30560. * @param height defines the rendering height
  30561. * @param engine defines the hosting engine
  30562. * @param successCallback defines the callback triggered once the data are available
  30563. * @param mimeType defines the mime type of the result
  30564. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30565. */
  30566. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30567. /**
  30568. * Converts the canvas data to blob.
  30569. * This acts as a polyfill for browsers not supporting the to blob function.
  30570. * @param canvas Defines the canvas to extract the data from
  30571. * @param successCallback Defines the callback triggered once the data are available
  30572. * @param mimeType Defines the mime type of the result
  30573. */
  30574. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30575. /**
  30576. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30577. * @param successCallback defines the callback triggered once the data are available
  30578. * @param mimeType defines the mime type of the result
  30579. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30580. */
  30581. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30582. /**
  30583. * Downloads a blob in the browser
  30584. * @param blob defines the blob to download
  30585. * @param fileName defines the name of the downloaded file
  30586. */
  30587. static Download(blob: Blob, fileName: string): void;
  30588. /**
  30589. * Captures a screenshot of the current rendering
  30590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30591. * @param engine defines the rendering engine
  30592. * @param camera defines the source camera
  30593. * @param size This parameter can be set to a single number or to an object with the
  30594. * following (optional) properties: precision, width, height. If a single number is passed,
  30595. * it will be used for both width and height. If an object is passed, the screenshot size
  30596. * will be derived from the parameters. The precision property is a multiplier allowing
  30597. * rendering at a higher or lower resolution
  30598. * @param successCallback defines the callback receives a single parameter which contains the
  30599. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30600. * src parameter of an <img> to display it
  30601. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30602. * Check your browser for supported MIME types
  30603. */
  30604. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30605. /**
  30606. * Generates an image screenshot from the specified camera.
  30607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30608. * @param engine The engine to use for rendering
  30609. * @param camera The camera to use for rendering
  30610. * @param size This parameter can be set to a single number or to an object with the
  30611. * following (optional) properties: precision, width, height. If a single number is passed,
  30612. * it will be used for both width and height. If an object is passed, the screenshot size
  30613. * will be derived from the parameters. The precision property is a multiplier allowing
  30614. * rendering at a higher or lower resolution
  30615. * @param successCallback The callback receives a single parameter which contains the
  30616. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30617. * src parameter of an <img> to display it
  30618. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30619. * Check your browser for supported MIME types
  30620. * @param samples Texture samples (default: 1)
  30621. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30622. * @param fileName A name for for the downloaded file.
  30623. */
  30624. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30625. /**
  30626. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30627. * Be aware Math.random() could cause collisions, but:
  30628. * "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"
  30629. * @returns a pseudo random id
  30630. */
  30631. static RandomId(): string;
  30632. /**
  30633. * Test if the given uri is a base64 string
  30634. * @param uri The uri to test
  30635. * @return True if the uri is a base64 string or false otherwise
  30636. */
  30637. static IsBase64(uri: string): boolean;
  30638. /**
  30639. * Decode the given base64 uri.
  30640. * @param uri The uri to decode
  30641. * @return The decoded base64 data.
  30642. */
  30643. static DecodeBase64(uri: string): ArrayBuffer;
  30644. /**
  30645. * Gets the absolute url.
  30646. * @param url the input url
  30647. * @return the absolute url
  30648. */
  30649. static GetAbsoluteUrl(url: string): string;
  30650. /**
  30651. * No log
  30652. */
  30653. static readonly NoneLogLevel: number;
  30654. /**
  30655. * Only message logs
  30656. */
  30657. static readonly MessageLogLevel: number;
  30658. /**
  30659. * Only warning logs
  30660. */
  30661. static readonly WarningLogLevel: number;
  30662. /**
  30663. * Only error logs
  30664. */
  30665. static readonly ErrorLogLevel: number;
  30666. /**
  30667. * All logs
  30668. */
  30669. static readonly AllLogLevel: number;
  30670. /**
  30671. * Gets a value indicating the number of loading errors
  30672. * @ignorenaming
  30673. */
  30674. static readonly errorsCount: number;
  30675. /**
  30676. * Callback called when a new log is added
  30677. */
  30678. static OnNewCacheEntry: (entry: string) => void;
  30679. /**
  30680. * Log a message to the console
  30681. * @param message defines the message to log
  30682. */
  30683. static Log(message: string): void;
  30684. /**
  30685. * Write a warning message to the console
  30686. * @param message defines the message to log
  30687. */
  30688. static Warn(message: string): void;
  30689. /**
  30690. * Write an error message to the console
  30691. * @param message defines the message to log
  30692. */
  30693. static Error(message: string): void;
  30694. /**
  30695. * Gets current log cache (list of logs)
  30696. */
  30697. static readonly LogCache: string;
  30698. /**
  30699. * Clears the log cache
  30700. */
  30701. static ClearLogCache(): void;
  30702. /**
  30703. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30704. */
  30705. static LogLevels: number;
  30706. /**
  30707. * Checks if the loaded document was accessed via `file:`-Protocol.
  30708. * @returns boolean
  30709. */
  30710. static IsFileURL(): boolean;
  30711. /**
  30712. * Checks if the window object exists
  30713. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30714. */
  30715. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30716. /**
  30717. * No performance log
  30718. */
  30719. static readonly PerformanceNoneLogLevel: number;
  30720. /**
  30721. * Use user marks to log performance
  30722. */
  30723. static readonly PerformanceUserMarkLogLevel: number;
  30724. /**
  30725. * Log performance to the console
  30726. */
  30727. static readonly PerformanceConsoleLogLevel: number;
  30728. private static _performance;
  30729. /**
  30730. * Sets the current performance log level
  30731. */
  30732. static PerformanceLogLevel: number;
  30733. private static _StartPerformanceCounterDisabled;
  30734. private static _EndPerformanceCounterDisabled;
  30735. private static _StartUserMark;
  30736. private static _EndUserMark;
  30737. private static _StartPerformanceConsole;
  30738. private static _EndPerformanceConsole;
  30739. /**
  30740. * Starts a performance counter
  30741. */
  30742. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30743. /**
  30744. * Ends a specific performance coutner
  30745. */
  30746. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30747. /**
  30748. * Gets either window.performance.now() if supported or Date.now() else
  30749. */
  30750. static readonly Now: number;
  30751. /**
  30752. * This method will return the name of the class used to create the instance of the given object.
  30753. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30754. * @param object the object to get the class name from
  30755. * @param isType defines if the object is actually a type
  30756. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30757. */
  30758. static GetClassName(object: any, isType?: boolean): string;
  30759. /**
  30760. * Gets the first element of an array satisfying a given predicate
  30761. * @param array defines the array to browse
  30762. * @param predicate defines the predicate to use
  30763. * @returns null if not found or the element
  30764. */
  30765. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30766. /**
  30767. * This method will return the name of the full name of the class, including its owning module (if any).
  30768. * 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).
  30769. * @param object the object to get the class name from
  30770. * @param isType defines if the object is actually a type
  30771. * @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.
  30772. * @ignorenaming
  30773. */
  30774. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30775. /**
  30776. * Returns a promise that resolves after the given amount of time.
  30777. * @param delay Number of milliseconds to delay
  30778. * @returns Promise that resolves after the given amount of time
  30779. */
  30780. static DelayAsync(delay: number): Promise<void>;
  30781. /**
  30782. * Gets the current gradient from an array of IValueGradient
  30783. * @param ratio defines the current ratio to get
  30784. * @param gradients defines the array of IValueGradient
  30785. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30786. */
  30787. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30788. }
  30789. /**
  30790. * This class is used to track a performance counter which is number based.
  30791. * The user has access to many properties which give statistics of different nature.
  30792. *
  30793. * The implementer can track two kinds of Performance Counter: time and count.
  30794. * 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.
  30795. * 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.
  30796. */
  30797. export class PerfCounter {
  30798. /**
  30799. * Gets or sets a global boolean to turn on and off all the counters
  30800. */
  30801. static Enabled: boolean;
  30802. /**
  30803. * Returns the smallest value ever
  30804. */
  30805. readonly min: number;
  30806. /**
  30807. * Returns the biggest value ever
  30808. */
  30809. readonly max: number;
  30810. /**
  30811. * Returns the average value since the performance counter is running
  30812. */
  30813. readonly average: number;
  30814. /**
  30815. * Returns the average value of the last second the counter was monitored
  30816. */
  30817. readonly lastSecAverage: number;
  30818. /**
  30819. * Returns the current value
  30820. */
  30821. readonly current: number;
  30822. /**
  30823. * Gets the accumulated total
  30824. */
  30825. readonly total: number;
  30826. /**
  30827. * Gets the total value count
  30828. */
  30829. readonly count: number;
  30830. /**
  30831. * Creates a new counter
  30832. */
  30833. constructor();
  30834. /**
  30835. * Call this method to start monitoring a new frame.
  30836. * 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.
  30837. */
  30838. fetchNewFrame(): void;
  30839. /**
  30840. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30841. * @param newCount the count value to add to the monitored count
  30842. * @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.
  30843. */
  30844. addCount(newCount: number, fetchResult: boolean): void;
  30845. /**
  30846. * Start monitoring this performance counter
  30847. */
  30848. beginMonitoring(): void;
  30849. /**
  30850. * Compute the time lapsed since the previous beginMonitoring() call.
  30851. * @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
  30852. */
  30853. endMonitoring(newFrame?: boolean): void;
  30854. private _fetchResult;
  30855. private _startMonitoringTime;
  30856. private _min;
  30857. private _max;
  30858. private _average;
  30859. private _current;
  30860. private _totalValueCount;
  30861. private _totalAccumulated;
  30862. private _lastSecAverage;
  30863. private _lastSecAccumulated;
  30864. private _lastSecTime;
  30865. private _lastSecValueCount;
  30866. }
  30867. /**
  30868. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30869. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30870. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30871. * @param name The name of the class, case should be preserved
  30872. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30873. */
  30874. export function className(name: string, module?: string): (target: Object) => void;
  30875. /**
  30876. * An implementation of a loop for asynchronous functions.
  30877. */
  30878. export class AsyncLoop {
  30879. /**
  30880. * Defines the number of iterations for the loop
  30881. */
  30882. iterations: number;
  30883. /**
  30884. * Defines the current index of the loop.
  30885. */
  30886. index: number;
  30887. private _done;
  30888. private _fn;
  30889. private _successCallback;
  30890. /**
  30891. * Constructor.
  30892. * @param iterations the number of iterations.
  30893. * @param func the function to run each iteration
  30894. * @param successCallback the callback that will be called upon succesful execution
  30895. * @param offset starting offset.
  30896. */
  30897. constructor(
  30898. /**
  30899. * Defines the number of iterations for the loop
  30900. */
  30901. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30902. /**
  30903. * Execute the next iteration. Must be called after the last iteration was finished.
  30904. */
  30905. executeNext(): void;
  30906. /**
  30907. * Break the loop and run the success callback.
  30908. */
  30909. breakLoop(): void;
  30910. /**
  30911. * Create and run an async loop.
  30912. * @param iterations the number of iterations.
  30913. * @param fn the function to run each iteration
  30914. * @param successCallback the callback that will be called upon succesful execution
  30915. * @param offset starting offset.
  30916. * @returns the created async loop object
  30917. */
  30918. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30919. /**
  30920. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30921. * @param iterations total number of iterations
  30922. * @param syncedIterations number of synchronous iterations in each async iteration.
  30923. * @param fn the function to call each iteration.
  30924. * @param callback a success call back that will be called when iterating stops.
  30925. * @param breakFunction a break condition (optional)
  30926. * @param timeout timeout settings for the setTimeout function. default - 0.
  30927. * @returns the created async loop object
  30928. */
  30929. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30930. }
  30931. }
  30932. declare module BABYLON {
  30933. /** @hidden */
  30934. export interface ICollisionCoordinator {
  30935. createCollider(): Collider;
  30936. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30937. init(scene: Scene): void;
  30938. }
  30939. /** @hidden */
  30940. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30941. private _scene;
  30942. private _scaledPosition;
  30943. private _scaledVelocity;
  30944. private _finalPosition;
  30945. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30946. createCollider(): Collider;
  30947. init(scene: Scene): void;
  30948. private _collideWithWorld;
  30949. }
  30950. }
  30951. declare module BABYLON {
  30952. /**
  30953. * Class used to manage all inputs for the scene.
  30954. */
  30955. export class InputManager {
  30956. /** The distance in pixel that you have to move to prevent some events */
  30957. static DragMovementThreshold: number;
  30958. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30959. static LongPressDelay: number;
  30960. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30961. static DoubleClickDelay: number;
  30962. /** If you need to check double click without raising a single click at first click, enable this flag */
  30963. static ExclusiveDoubleClickMode: boolean;
  30964. private _wheelEventName;
  30965. private _onPointerMove;
  30966. private _onPointerDown;
  30967. private _onPointerUp;
  30968. private _initClickEvent;
  30969. private _initActionManager;
  30970. private _delayedSimpleClick;
  30971. private _delayedSimpleClickTimeout;
  30972. private _previousDelayedSimpleClickTimeout;
  30973. private _meshPickProceed;
  30974. private _previousButtonPressed;
  30975. private _currentPickResult;
  30976. private _previousPickResult;
  30977. private _totalPointersPressed;
  30978. private _doubleClickOccured;
  30979. private _pointerOverMesh;
  30980. private _pickedDownMesh;
  30981. private _pickedUpMesh;
  30982. private _pointerX;
  30983. private _pointerY;
  30984. private _unTranslatedPointerX;
  30985. private _unTranslatedPointerY;
  30986. private _startingPointerPosition;
  30987. private _previousStartingPointerPosition;
  30988. private _startingPointerTime;
  30989. private _previousStartingPointerTime;
  30990. private _pointerCaptures;
  30991. private _onKeyDown;
  30992. private _onKeyUp;
  30993. private _onCanvasFocusObserver;
  30994. private _onCanvasBlurObserver;
  30995. private _scene;
  30996. /**
  30997. * Creates a new InputManager
  30998. * @param scene defines the hosting scene
  30999. */
  31000. constructor(scene: Scene);
  31001. /**
  31002. * Gets the mesh that is currently under the pointer
  31003. */
  31004. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31005. /**
  31006. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31007. */
  31008. readonly unTranslatedPointer: Vector2;
  31009. /**
  31010. * Gets or sets the current on-screen X position of the pointer
  31011. */
  31012. pointerX: number;
  31013. /**
  31014. * Gets or sets the current on-screen Y position of the pointer
  31015. */
  31016. pointerY: number;
  31017. private _updatePointerPosition;
  31018. private _processPointerMove;
  31019. private _setRayOnPointerInfo;
  31020. private _checkPrePointerObservable;
  31021. /**
  31022. * Use this method to simulate a pointer move on a mesh
  31023. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31024. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31025. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31026. */
  31027. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31028. /**
  31029. * Use this method to simulate a pointer down on a mesh
  31030. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31031. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31032. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31033. */
  31034. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31035. private _processPointerDown;
  31036. /** @hidden */ isPointerSwiping(): boolean;
  31037. /**
  31038. * Use this method to simulate a pointer up on a mesh
  31039. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31040. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31041. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31042. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31043. */
  31044. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31045. private _processPointerUp;
  31046. /**
  31047. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31048. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31049. * @returns true if the pointer was captured
  31050. */
  31051. isPointerCaptured(pointerId?: number): boolean;
  31052. /**
  31053. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31054. * @param attachUp defines if you want to attach events to pointerup
  31055. * @param attachDown defines if you want to attach events to pointerdown
  31056. * @param attachMove defines if you want to attach events to pointermove
  31057. */
  31058. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31059. /**
  31060. * Detaches all event handlers
  31061. */
  31062. detachControl(): void;
  31063. /**
  31064. * Force the value of meshUnderPointer
  31065. * @param mesh defines the mesh to use
  31066. */
  31067. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31068. /**
  31069. * Gets the mesh under the pointer
  31070. * @returns a Mesh or null if no mesh is under the pointer
  31071. */
  31072. getPointerOverMesh(): Nullable<AbstractMesh>;
  31073. }
  31074. }
  31075. declare module BABYLON {
  31076. /**
  31077. * This class defines the direct association between an animation and a target
  31078. */
  31079. export class TargetedAnimation {
  31080. /**
  31081. * Animation to perform
  31082. */
  31083. animation: Animation;
  31084. /**
  31085. * Target to animate
  31086. */
  31087. target: any;
  31088. }
  31089. /**
  31090. * Use this class to create coordinated animations on multiple targets
  31091. */
  31092. export class AnimationGroup implements IDisposable {
  31093. /** The name of the animation group */
  31094. name: string;
  31095. private _scene;
  31096. private _targetedAnimations;
  31097. private _animatables;
  31098. private _from;
  31099. private _to;
  31100. private _isStarted;
  31101. private _isPaused;
  31102. private _speedRatio;
  31103. /**
  31104. * Gets or sets the unique id of the node
  31105. */
  31106. uniqueId: number;
  31107. /**
  31108. * This observable will notify when one animation have ended
  31109. */
  31110. onAnimationEndObservable: Observable<TargetedAnimation>;
  31111. /**
  31112. * Observer raised when one animation loops
  31113. */
  31114. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31115. /**
  31116. * This observable will notify when all animations have ended.
  31117. */
  31118. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31119. /**
  31120. * This observable will notify when all animations have paused.
  31121. */
  31122. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31123. /**
  31124. * This observable will notify when all animations are playing.
  31125. */
  31126. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31127. /**
  31128. * Gets the first frame
  31129. */
  31130. readonly from: number;
  31131. /**
  31132. * Gets the last frame
  31133. */
  31134. readonly to: number;
  31135. /**
  31136. * Define if the animations are started
  31137. */
  31138. readonly isStarted: boolean;
  31139. /**
  31140. * Gets a value indicating that the current group is playing
  31141. */
  31142. readonly isPlaying: boolean;
  31143. /**
  31144. * Gets or sets the speed ratio to use for all animations
  31145. */
  31146. /**
  31147. * Gets or sets the speed ratio to use for all animations
  31148. */
  31149. speedRatio: number;
  31150. /**
  31151. * Gets the targeted animations for this animation group
  31152. */
  31153. readonly targetedAnimations: Array<TargetedAnimation>;
  31154. /**
  31155. * returning the list of animatables controlled by this animation group.
  31156. */
  31157. readonly animatables: Array<Animatable>;
  31158. /**
  31159. * Instantiates a new Animation Group.
  31160. * This helps managing several animations at once.
  31161. * @see http://doc.babylonjs.com/how_to/group
  31162. * @param name Defines the name of the group
  31163. * @param scene Defines the scene the group belongs to
  31164. */
  31165. constructor(
  31166. /** The name of the animation group */
  31167. name: string, scene?: Nullable<Scene>);
  31168. /**
  31169. * Add an animation (with its target) in the group
  31170. * @param animation defines the animation we want to add
  31171. * @param target defines the target of the animation
  31172. * @returns the TargetedAnimation object
  31173. */
  31174. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31175. /**
  31176. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31177. * It can add constant keys at begin or end
  31178. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31179. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31180. * @returns the animation group
  31181. */
  31182. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31183. /**
  31184. * Start all animations on given targets
  31185. * @param loop defines if animations must loop
  31186. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31187. * @param from defines the from key (optional)
  31188. * @param to defines the to key (optional)
  31189. * @returns the current animation group
  31190. */
  31191. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31192. /**
  31193. * Pause all animations
  31194. * @returns the animation group
  31195. */
  31196. pause(): AnimationGroup;
  31197. /**
  31198. * Play all animations to initial state
  31199. * This function will start() the animations if they were not started or will restart() them if they were paused
  31200. * @param loop defines if animations must loop
  31201. * @returns the animation group
  31202. */
  31203. play(loop?: boolean): AnimationGroup;
  31204. /**
  31205. * Reset all animations to initial state
  31206. * @returns the animation group
  31207. */
  31208. reset(): AnimationGroup;
  31209. /**
  31210. * Restart animations from key 0
  31211. * @returns the animation group
  31212. */
  31213. restart(): AnimationGroup;
  31214. /**
  31215. * Stop all animations
  31216. * @returns the animation group
  31217. */
  31218. stop(): AnimationGroup;
  31219. /**
  31220. * Set animation weight for all animatables
  31221. * @param weight defines the weight to use
  31222. * @return the animationGroup
  31223. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31224. */
  31225. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31226. /**
  31227. * Synchronize and normalize all animatables with a source animatable
  31228. * @param root defines the root animatable to synchronize with
  31229. * @return the animationGroup
  31230. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31231. */
  31232. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31233. /**
  31234. * Goes to a specific frame in this animation group
  31235. * @param frame the frame number to go to
  31236. * @return the animationGroup
  31237. */
  31238. goToFrame(frame: number): AnimationGroup;
  31239. /**
  31240. * Dispose all associated resources
  31241. */
  31242. dispose(): void;
  31243. private _checkAnimationGroupEnded;
  31244. /**
  31245. * Clone the current animation group and returns a copy
  31246. * @param newName defines the name of the new group
  31247. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31248. * @returns the new aniamtion group
  31249. */
  31250. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31251. /**
  31252. * Returns a new AnimationGroup object parsed from the source provided.
  31253. * @param parsedAnimationGroup defines the source
  31254. * @param scene defines the scene that will receive the animationGroup
  31255. * @returns a new AnimationGroup
  31256. */
  31257. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31258. /**
  31259. * Returns the string "AnimationGroup"
  31260. * @returns "AnimationGroup"
  31261. */
  31262. getClassName(): string;
  31263. /**
  31264. * Creates a detailled string about the object
  31265. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31266. * @returns a string representing the object
  31267. */
  31268. toString(fullDetails?: boolean): string;
  31269. }
  31270. }
  31271. declare module BABYLON {
  31272. /**
  31273. * Define an interface for all classes that will hold resources
  31274. */
  31275. export interface IDisposable {
  31276. /**
  31277. * Releases all held resources
  31278. */
  31279. dispose(): void;
  31280. }
  31281. /** Interface defining initialization parameters for Scene class */
  31282. export interface SceneOptions {
  31283. /**
  31284. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31285. * It will improve performance when the number of geometries becomes important.
  31286. */
  31287. useGeometryUniqueIdsMap?: boolean;
  31288. /**
  31289. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31290. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31291. */
  31292. useMaterialMeshMap?: boolean;
  31293. /**
  31294. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31295. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31296. */
  31297. useClonedMeshhMap?: boolean;
  31298. }
  31299. /**
  31300. * Represents a scene to be rendered by the engine.
  31301. * @see http://doc.babylonjs.com/features/scene
  31302. */
  31303. export class Scene extends AbstractScene implements IAnimatable {
  31304. private static _uniqueIdCounter;
  31305. /** The fog is deactivated */
  31306. static readonly FOGMODE_NONE: number;
  31307. /** The fog density is following an exponential function */
  31308. static readonly FOGMODE_EXP: number;
  31309. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31310. static readonly FOGMODE_EXP2: number;
  31311. /** The fog density is following a linear function. */
  31312. static readonly FOGMODE_LINEAR: number;
  31313. /**
  31314. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31316. */
  31317. static MinDeltaTime: number;
  31318. /**
  31319. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31321. */
  31322. static MaxDeltaTime: number;
  31323. /**
  31324. * Factory used to create the default material.
  31325. * @param name The name of the material to create
  31326. * @param scene The scene to create the material for
  31327. * @returns The default material
  31328. */
  31329. static DefaultMaterialFactory(scene: Scene): Material;
  31330. /**
  31331. * Factory used to create the a collision coordinator.
  31332. * @returns The collision coordinator
  31333. */
  31334. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31335. /** @hidden */ inputManager: InputManager;
  31336. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31337. cameraToUseForPointers: Nullable<Camera>;
  31338. /** @hidden */ protected readonly _isScene: boolean;
  31339. /**
  31340. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31341. */
  31342. autoClear: boolean;
  31343. /**
  31344. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31345. */
  31346. autoClearDepthAndStencil: boolean;
  31347. /**
  31348. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31349. */
  31350. clearColor: Color4;
  31351. /**
  31352. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31353. */
  31354. ambientColor: Color3;
  31355. /**
  31356. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31357. * It should only be one of the following (if not the default embedded one):
  31358. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31359. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31360. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31361. * The material properties need to be setup according to the type of texture in use.
  31362. */
  31363. environmentBRDFTexture: BaseTexture;
  31364. /** @hidden */
  31365. protected _environmentTexture: Nullable<BaseTexture>;
  31366. /**
  31367. * Texture used in all pbr material as the reflection texture.
  31368. * As in the majority of the scene they are the same (exception for multi room and so on),
  31369. * this is easier to reference from here than from all the materials.
  31370. */
  31371. /**
  31372. * Texture used in all pbr material as the reflection texture.
  31373. * As in the majority of the scene they are the same (exception for multi room and so on),
  31374. * this is easier to set here than in all the materials.
  31375. */
  31376. environmentTexture: Nullable<BaseTexture>;
  31377. /** @hidden */
  31378. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31379. /**
  31380. * Default image processing configuration used either in the rendering
  31381. * Forward main pass or through the imageProcessingPostProcess if present.
  31382. * As in the majority of the scene they are the same (exception for multi camera),
  31383. * this is easier to reference from here than from all the materials and post process.
  31384. *
  31385. * No setter as we it is a shared configuration, you can set the values instead.
  31386. */
  31387. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31388. private _forceWireframe;
  31389. /**
  31390. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31391. */
  31392. forceWireframe: boolean;
  31393. private _forcePointsCloud;
  31394. /**
  31395. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31396. */
  31397. forcePointsCloud: boolean;
  31398. /**
  31399. * Gets or sets the active clipplane 1
  31400. */
  31401. clipPlane: Nullable<Plane>;
  31402. /**
  31403. * Gets or sets the active clipplane 2
  31404. */
  31405. clipPlane2: Nullable<Plane>;
  31406. /**
  31407. * Gets or sets the active clipplane 3
  31408. */
  31409. clipPlane3: Nullable<Plane>;
  31410. /**
  31411. * Gets or sets the active clipplane 4
  31412. */
  31413. clipPlane4: Nullable<Plane>;
  31414. /**
  31415. * Gets or sets a boolean indicating if animations are enabled
  31416. */
  31417. animationsEnabled: boolean;
  31418. private _animationPropertiesOverride;
  31419. /**
  31420. * Gets or sets the animation properties override
  31421. */
  31422. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31423. /**
  31424. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31425. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31426. */
  31427. useConstantAnimationDeltaTime: boolean;
  31428. /**
  31429. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31430. * Please note that it requires to run a ray cast through the scene on every frame
  31431. */
  31432. constantlyUpdateMeshUnderPointer: boolean;
  31433. /**
  31434. * Defines the HTML cursor to use when hovering over interactive elements
  31435. */
  31436. hoverCursor: string;
  31437. /**
  31438. * Defines the HTML default cursor to use (empty by default)
  31439. */
  31440. defaultCursor: string;
  31441. /**
  31442. * This is used to call preventDefault() on pointer down
  31443. * in order to block unwanted artifacts like system double clicks
  31444. */
  31445. preventDefaultOnPointerDown: boolean;
  31446. /**
  31447. * This is used to call preventDefault() on pointer up
  31448. * in order to block unwanted artifacts like system double clicks
  31449. */
  31450. preventDefaultOnPointerUp: boolean;
  31451. /**
  31452. * Gets or sets user defined metadata
  31453. */
  31454. metadata: any;
  31455. /**
  31456. * For internal use only. Please do not use.
  31457. */
  31458. reservedDataStore: any;
  31459. /**
  31460. * Gets the name of the plugin used to load this scene (null by default)
  31461. */
  31462. loadingPluginName: string;
  31463. /**
  31464. * Use this array to add regular expressions used to disable offline support for specific urls
  31465. */
  31466. disableOfflineSupportExceptionRules: RegExp[];
  31467. /**
  31468. * An event triggered when the scene is disposed.
  31469. */
  31470. onDisposeObservable: Observable<Scene>;
  31471. private _onDisposeObserver;
  31472. /** Sets a function to be executed when this scene is disposed. */
  31473. onDispose: () => void;
  31474. /**
  31475. * An event triggered before rendering the scene (right after animations and physics)
  31476. */
  31477. onBeforeRenderObservable: Observable<Scene>;
  31478. private _onBeforeRenderObserver;
  31479. /** Sets a function to be executed before rendering this scene */
  31480. beforeRender: Nullable<() => void>;
  31481. /**
  31482. * An event triggered after rendering the scene
  31483. */
  31484. onAfterRenderObservable: Observable<Scene>;
  31485. private _onAfterRenderObserver;
  31486. /** Sets a function to be executed after rendering this scene */
  31487. afterRender: Nullable<() => void>;
  31488. /**
  31489. * An event triggered before animating the scene
  31490. */
  31491. onBeforeAnimationsObservable: Observable<Scene>;
  31492. /**
  31493. * An event triggered after animations processing
  31494. */
  31495. onAfterAnimationsObservable: Observable<Scene>;
  31496. /**
  31497. * An event triggered before draw calls are ready to be sent
  31498. */
  31499. onBeforeDrawPhaseObservable: Observable<Scene>;
  31500. /**
  31501. * An event triggered after draw calls have been sent
  31502. */
  31503. onAfterDrawPhaseObservable: Observable<Scene>;
  31504. /**
  31505. * An event triggered when the scene is ready
  31506. */
  31507. onReadyObservable: Observable<Scene>;
  31508. /**
  31509. * An event triggered before rendering a camera
  31510. */
  31511. onBeforeCameraRenderObservable: Observable<Camera>;
  31512. private _onBeforeCameraRenderObserver;
  31513. /** Sets a function to be executed before rendering a camera*/
  31514. beforeCameraRender: () => void;
  31515. /**
  31516. * An event triggered after rendering a camera
  31517. */
  31518. onAfterCameraRenderObservable: Observable<Camera>;
  31519. private _onAfterCameraRenderObserver;
  31520. /** Sets a function to be executed after rendering a camera*/
  31521. afterCameraRender: () => void;
  31522. /**
  31523. * An event triggered when active meshes evaluation is about to start
  31524. */
  31525. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31526. /**
  31527. * An event triggered when active meshes evaluation is done
  31528. */
  31529. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31530. /**
  31531. * An event triggered when particles rendering is about to start
  31532. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31533. */
  31534. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31535. /**
  31536. * An event triggered when particles rendering is done
  31537. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31538. */
  31539. onAfterParticlesRenderingObservable: Observable<Scene>;
  31540. /**
  31541. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31542. */
  31543. onDataLoadedObservable: Observable<Scene>;
  31544. /**
  31545. * An event triggered when a camera is created
  31546. */
  31547. onNewCameraAddedObservable: Observable<Camera>;
  31548. /**
  31549. * An event triggered when a camera is removed
  31550. */
  31551. onCameraRemovedObservable: Observable<Camera>;
  31552. /**
  31553. * An event triggered when a light is created
  31554. */
  31555. onNewLightAddedObservable: Observable<Light>;
  31556. /**
  31557. * An event triggered when a light is removed
  31558. */
  31559. onLightRemovedObservable: Observable<Light>;
  31560. /**
  31561. * An event triggered when a geometry is created
  31562. */
  31563. onNewGeometryAddedObservable: Observable<Geometry>;
  31564. /**
  31565. * An event triggered when a geometry is removed
  31566. */
  31567. onGeometryRemovedObservable: Observable<Geometry>;
  31568. /**
  31569. * An event triggered when a transform node is created
  31570. */
  31571. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31572. /**
  31573. * An event triggered when a transform node is removed
  31574. */
  31575. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31576. /**
  31577. * An event triggered when a mesh is created
  31578. */
  31579. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31580. /**
  31581. * An event triggered when a mesh is removed
  31582. */
  31583. onMeshRemovedObservable: Observable<AbstractMesh>;
  31584. /**
  31585. * An event triggered when a skeleton is created
  31586. */
  31587. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31588. /**
  31589. * An event triggered when a skeleton is removed
  31590. */
  31591. onSkeletonRemovedObservable: Observable<Skeleton>;
  31592. /**
  31593. * An event triggered when a material is created
  31594. */
  31595. onNewMaterialAddedObservable: Observable<Material>;
  31596. /**
  31597. * An event triggered when a material is removed
  31598. */
  31599. onMaterialRemovedObservable: Observable<Material>;
  31600. /**
  31601. * An event triggered when a texture is created
  31602. */
  31603. onNewTextureAddedObservable: Observable<BaseTexture>;
  31604. /**
  31605. * An event triggered when a texture is removed
  31606. */
  31607. onTextureRemovedObservable: Observable<BaseTexture>;
  31608. /**
  31609. * An event triggered when render targets are about to be rendered
  31610. * Can happen multiple times per frame.
  31611. */
  31612. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31613. /**
  31614. * An event triggered when render targets were rendered.
  31615. * Can happen multiple times per frame.
  31616. */
  31617. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31618. /**
  31619. * An event triggered before calculating deterministic simulation step
  31620. */
  31621. onBeforeStepObservable: Observable<Scene>;
  31622. /**
  31623. * An event triggered after calculating deterministic simulation step
  31624. */
  31625. onAfterStepObservable: Observable<Scene>;
  31626. /**
  31627. * An event triggered when the activeCamera property is updated
  31628. */
  31629. onActiveCameraChanged: Observable<Scene>;
  31630. /**
  31631. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31632. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31633. * 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)
  31634. */
  31635. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31636. /**
  31637. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31638. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31639. * 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)
  31640. */
  31641. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31642. /**
  31643. * This Observable will when a mesh has been imported into the scene.
  31644. */
  31645. onMeshImportedObservable: Observable<AbstractMesh>;
  31646. /**
  31647. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31648. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31649. */
  31650. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31651. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31652. /**
  31653. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31654. */
  31655. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31656. /**
  31657. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31658. */
  31659. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31660. /**
  31661. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31662. */
  31663. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31664. /** Callback called when a pointer move is detected */
  31665. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31666. /** Callback called when a pointer down is detected */
  31667. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31668. /** Callback called when a pointer up is detected */
  31669. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31670. /** Callback called when a pointer pick is detected */
  31671. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31672. /**
  31673. * 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).
  31674. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31675. */
  31676. onPrePointerObservable: Observable<PointerInfoPre>;
  31677. /**
  31678. * Observable event triggered each time an input event is received from the rendering canvas
  31679. */
  31680. onPointerObservable: Observable<PointerInfo>;
  31681. /**
  31682. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31683. */
  31684. readonly unTranslatedPointer: Vector2;
  31685. /**
  31686. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  31687. */
  31688. static DragMovementThreshold: number;
  31689. /**
  31690. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  31691. */
  31692. static LongPressDelay: number;
  31693. /**
  31694. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  31695. */
  31696. static DoubleClickDelay: number;
  31697. /** If you need to check double click without raising a single click at first click, enable this flag */
  31698. static ExclusiveDoubleClickMode: boolean;
  31699. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31700. /**
  31701. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31702. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31703. */
  31704. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31705. /**
  31706. * Observable event triggered each time an keyboard event is received from the hosting window
  31707. */
  31708. onKeyboardObservable: Observable<KeyboardInfo>;
  31709. private _useRightHandedSystem;
  31710. /**
  31711. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31712. */
  31713. useRightHandedSystem: boolean;
  31714. private _timeAccumulator;
  31715. private _currentStepId;
  31716. private _currentInternalStep;
  31717. /**
  31718. * Sets the step Id used by deterministic lock step
  31719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31720. * @param newStepId defines the step Id
  31721. */
  31722. setStepId(newStepId: number): void;
  31723. /**
  31724. * Gets the step Id used by deterministic lock step
  31725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31726. * @returns the step Id
  31727. */
  31728. getStepId(): number;
  31729. /**
  31730. * Gets the internal step used by deterministic lock step
  31731. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31732. * @returns the internal step
  31733. */
  31734. getInternalStep(): number;
  31735. private _fogEnabled;
  31736. /**
  31737. * Gets or sets a boolean indicating if fog is enabled on this scene
  31738. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31739. * (Default is true)
  31740. */
  31741. fogEnabled: boolean;
  31742. private _fogMode;
  31743. /**
  31744. * Gets or sets the fog mode to use
  31745. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31746. * | mode | value |
  31747. * | --- | --- |
  31748. * | FOGMODE_NONE | 0 |
  31749. * | FOGMODE_EXP | 1 |
  31750. * | FOGMODE_EXP2 | 2 |
  31751. * | FOGMODE_LINEAR | 3 |
  31752. */
  31753. fogMode: number;
  31754. /**
  31755. * Gets or sets the fog color to use
  31756. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31757. * (Default is Color3(0.2, 0.2, 0.3))
  31758. */
  31759. fogColor: Color3;
  31760. /**
  31761. * Gets or sets the fog density to use
  31762. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31763. * (Default is 0.1)
  31764. */
  31765. fogDensity: number;
  31766. /**
  31767. * Gets or sets the fog start distance to use
  31768. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31769. * (Default is 0)
  31770. */
  31771. fogStart: number;
  31772. /**
  31773. * Gets or sets the fog end distance to use
  31774. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31775. * (Default is 1000)
  31776. */
  31777. fogEnd: number;
  31778. private _shadowsEnabled;
  31779. /**
  31780. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31781. */
  31782. shadowsEnabled: boolean;
  31783. private _lightsEnabled;
  31784. /**
  31785. * Gets or sets a boolean indicating if lights are enabled on this scene
  31786. */
  31787. lightsEnabled: boolean;
  31788. /** All of the active cameras added to this scene. */
  31789. activeCameras: Camera[];
  31790. /** @hidden */ activeCamera: Nullable<Camera>;
  31791. /** Gets or sets the current active camera */
  31792. activeCamera: Nullable<Camera>;
  31793. private _defaultMaterial;
  31794. /** The default material used on meshes when no material is affected */
  31795. /** The default material used on meshes when no material is affected */
  31796. defaultMaterial: Material;
  31797. private _texturesEnabled;
  31798. /**
  31799. * Gets or sets a boolean indicating if textures are enabled on this scene
  31800. */
  31801. texturesEnabled: boolean;
  31802. /**
  31803. * Gets or sets a boolean indicating if particles are enabled on this scene
  31804. */
  31805. particlesEnabled: boolean;
  31806. /**
  31807. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31808. */
  31809. spritesEnabled: boolean;
  31810. private _skeletonsEnabled;
  31811. /**
  31812. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31813. */
  31814. skeletonsEnabled: boolean;
  31815. /**
  31816. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31817. */
  31818. lensFlaresEnabled: boolean;
  31819. /**
  31820. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31822. */
  31823. collisionsEnabled: boolean;
  31824. private _collisionCoordinator;
  31825. /** @hidden */
  31826. readonly collisionCoordinator: ICollisionCoordinator;
  31827. /**
  31828. * Defines the gravity applied to this scene (used only for collisions)
  31829. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31830. */
  31831. gravity: Vector3;
  31832. /**
  31833. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31834. */
  31835. postProcessesEnabled: boolean;
  31836. /**
  31837. * The list of postprocesses added to the scene
  31838. */
  31839. postProcesses: PostProcess[];
  31840. /**
  31841. * Gets the current postprocess manager
  31842. */
  31843. postProcessManager: PostProcessManager;
  31844. /**
  31845. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31846. */
  31847. renderTargetsEnabled: boolean;
  31848. /**
  31849. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31850. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31851. */
  31852. dumpNextRenderTargets: boolean;
  31853. /**
  31854. * The list of user defined render targets added to the scene
  31855. */
  31856. customRenderTargets: RenderTargetTexture[];
  31857. /**
  31858. * Defines if texture loading must be delayed
  31859. * If true, textures will only be loaded when they need to be rendered
  31860. */
  31861. useDelayedTextureLoading: boolean;
  31862. /**
  31863. * Gets the list of meshes imported to the scene through SceneLoader
  31864. */
  31865. importedMeshesFiles: String[];
  31866. /**
  31867. * Gets or sets a boolean indicating if probes are enabled on this scene
  31868. */
  31869. probesEnabled: boolean;
  31870. /**
  31871. * Gets or sets the current offline provider to use to store scene data
  31872. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31873. */
  31874. offlineProvider: IOfflineProvider;
  31875. /**
  31876. * Gets or sets the action manager associated with the scene
  31877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31878. */
  31879. actionManager: AbstractActionManager;
  31880. private _meshesForIntersections;
  31881. /**
  31882. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31883. */
  31884. proceduralTexturesEnabled: boolean;
  31885. private _engine;
  31886. private _totalVertices;
  31887. /** @hidden */ activeIndices: PerfCounter;
  31888. /** @hidden */ activeParticles: PerfCounter;
  31889. /** @hidden */ activeBones: PerfCounter;
  31890. private _animationRatio;
  31891. /** @hidden */ animationTimeLast: number;
  31892. /** @hidden */ animationTime: number;
  31893. /**
  31894. * Gets or sets a general scale for animation speed
  31895. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31896. */
  31897. animationTimeScale: number;
  31898. /** @hidden */ cachedMaterial: Nullable<Material>;
  31899. /** @hidden */ cachedEffect: Nullable<Effect>;
  31900. /** @hidden */ cachedVisibility: Nullable<number>;
  31901. private _renderId;
  31902. private _frameId;
  31903. private _executeWhenReadyTimeoutId;
  31904. private _intermediateRendering;
  31905. private _viewUpdateFlag;
  31906. private _projectionUpdateFlag;
  31907. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31908. private _activeRequests;
  31909. /** @hidden */ pendingData: any[];
  31910. private _isDisposed;
  31911. /**
  31912. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31913. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31914. */
  31915. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31916. private _activeMeshes;
  31917. private _processedMaterials;
  31918. private _renderTargets;
  31919. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31920. private _activeSkeletons;
  31921. private _softwareSkinnedMeshes;
  31922. private _renderingManager;
  31923. /** @hidden */ activeAnimatables: Animatable[];
  31924. private _transformMatrix;
  31925. private _sceneUbo;
  31926. /** @hidden */ viewMatrix: Matrix;
  31927. private _projectionMatrix;
  31928. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31929. /** @hidden */ frustumPlanes: Plane[];
  31930. /**
  31931. * Gets the list of frustum planes (built from the active camera)
  31932. */
  31933. readonly frustumPlanes: Plane[];
  31934. /**
  31935. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31936. * This is useful if there are more lights that the maximum simulteanous authorized
  31937. */
  31938. requireLightSorting: boolean;
  31939. /** @hidden */
  31940. readonly useMaterialMeshMap: boolean;
  31941. /** @hidden */
  31942. readonly useClonedMeshhMap: boolean;
  31943. private _externalData;
  31944. private _uid;
  31945. /**
  31946. * @hidden
  31947. * Backing store of defined scene components.
  31948. */ components: ISceneComponent[];
  31949. /**
  31950. * @hidden
  31951. * Backing store of defined scene components.
  31952. */ serializableComponents: ISceneSerializableComponent[];
  31953. /**
  31954. * List of components to register on the next registration step.
  31955. */
  31956. private _transientComponents;
  31957. /**
  31958. * Registers the transient components if needed.
  31959. */
  31960. private _registerTransientComponents;
  31961. /**
  31962. * @hidden
  31963. * Add a component to the scene.
  31964. * Note that the ccomponent could be registered on th next frame if this is called after
  31965. * the register component stage.
  31966. * @param component Defines the component to add to the scene
  31967. */ addComponent(component: ISceneComponent): void;
  31968. /**
  31969. * @hidden
  31970. * Gets a component from the scene.
  31971. * @param name defines the name of the component to retrieve
  31972. * @returns the component or null if not present
  31973. */ getComponent(name: string): Nullable<ISceneComponent>;
  31974. /**
  31975. * @hidden
  31976. * Defines the actions happening before camera updates.
  31977. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31978. /**
  31979. * @hidden
  31980. * Defines the actions happening before clear the canvas.
  31981. */ beforeClearStage: Stage<SimpleStageAction>;
  31982. /**
  31983. * @hidden
  31984. * Defines the actions when collecting render targets for the frame.
  31985. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31986. /**
  31987. * @hidden
  31988. * Defines the actions happening for one camera in the frame.
  31989. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31990. /**
  31991. * @hidden
  31992. * Defines the actions happening during the per mesh ready checks.
  31993. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31994. /**
  31995. * @hidden
  31996. * Defines the actions happening before evaluate active mesh checks.
  31997. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31998. /**
  31999. * @hidden
  32000. * Defines the actions happening during the evaluate sub mesh checks.
  32001. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32002. /**
  32003. * @hidden
  32004. * Defines the actions happening during the active mesh stage.
  32005. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  32006. /**
  32007. * @hidden
  32008. * Defines the actions happening during the per camera render target step.
  32009. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32010. /**
  32011. * @hidden
  32012. * Defines the actions happening just before the active camera is drawing.
  32013. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  32014. /**
  32015. * @hidden
  32016. * Defines the actions happening just before a render target is drawing.
  32017. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32018. /**
  32019. * @hidden
  32020. * Defines the actions happening just before a rendering group is drawing.
  32021. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32022. /**
  32023. * @hidden
  32024. * Defines the actions happening just before a mesh is drawing.
  32025. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32026. /**
  32027. * @hidden
  32028. * Defines the actions happening just after a mesh has been drawn.
  32029. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32030. /**
  32031. * @hidden
  32032. * Defines the actions happening just after a rendering group has been drawn.
  32033. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32034. /**
  32035. * @hidden
  32036. * Defines the actions happening just after the active camera has been drawn.
  32037. */ afterCameraDrawStage: Stage<CameraStageAction>;
  32038. /**
  32039. * @hidden
  32040. * Defines the actions happening just after a render target has been drawn.
  32041. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32042. /**
  32043. * @hidden
  32044. * Defines the actions happening just after rendering all cameras and computing intersections.
  32045. */ afterRenderStage: Stage<SimpleStageAction>;
  32046. /**
  32047. * @hidden
  32048. * Defines the actions happening when a pointer move event happens.
  32049. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  32050. /**
  32051. * @hidden
  32052. * Defines the actions happening when a pointer down event happens.
  32053. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  32054. /**
  32055. * @hidden
  32056. * Defines the actions happening when a pointer up event happens.
  32057. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  32058. /**
  32059. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32060. */
  32061. private geometriesByUniqueId;
  32062. /**
  32063. * Creates a new Scene
  32064. * @param engine defines the engine to use to render this scene
  32065. * @param options defines the scene options
  32066. */
  32067. constructor(engine: Engine, options?: SceneOptions);
  32068. /**
  32069. * Gets a string idenfifying the name of the class
  32070. * @returns "Scene" string
  32071. */
  32072. getClassName(): string;
  32073. private _defaultMeshCandidates;
  32074. /**
  32075. * @hidden
  32076. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32077. private _defaultSubMeshCandidates;
  32078. /**
  32079. * @hidden
  32080. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32081. /**
  32082. * Sets the default candidate providers for the scene.
  32083. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32084. * and getCollidingSubMeshCandidates to their default function
  32085. */
  32086. setDefaultCandidateProviders(): void;
  32087. /**
  32088. * Gets the mesh that is currently under the pointer
  32089. */
  32090. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32091. /**
  32092. * Gets or sets the current on-screen X position of the pointer
  32093. */
  32094. pointerX: number;
  32095. /**
  32096. * Gets or sets the current on-screen Y position of the pointer
  32097. */
  32098. pointerY: number;
  32099. /**
  32100. * Gets the cached material (ie. the latest rendered one)
  32101. * @returns the cached material
  32102. */
  32103. getCachedMaterial(): Nullable<Material>;
  32104. /**
  32105. * Gets the cached effect (ie. the latest rendered one)
  32106. * @returns the cached effect
  32107. */
  32108. getCachedEffect(): Nullable<Effect>;
  32109. /**
  32110. * Gets the cached visibility state (ie. the latest rendered one)
  32111. * @returns the cached visibility state
  32112. */
  32113. getCachedVisibility(): Nullable<number>;
  32114. /**
  32115. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32116. * @param material defines the current material
  32117. * @param effect defines the current effect
  32118. * @param visibility defines the current visibility state
  32119. * @returns true if one parameter is not cached
  32120. */
  32121. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32122. /**
  32123. * Gets the engine associated with the scene
  32124. * @returns an Engine
  32125. */
  32126. getEngine(): Engine;
  32127. /**
  32128. * Gets the total number of vertices rendered per frame
  32129. * @returns the total number of vertices rendered per frame
  32130. */
  32131. getTotalVertices(): number;
  32132. /**
  32133. * Gets the performance counter for total vertices
  32134. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32135. */
  32136. readonly totalVerticesPerfCounter: PerfCounter;
  32137. /**
  32138. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32139. * @returns the total number of active indices rendered per frame
  32140. */
  32141. getActiveIndices(): number;
  32142. /**
  32143. * Gets the performance counter for active indices
  32144. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32145. */
  32146. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32147. /**
  32148. * Gets the total number of active particles rendered per frame
  32149. * @returns the total number of active particles rendered per frame
  32150. */
  32151. getActiveParticles(): number;
  32152. /**
  32153. * Gets the performance counter for active particles
  32154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32155. */
  32156. readonly activeParticlesPerfCounter: PerfCounter;
  32157. /**
  32158. * Gets the total number of active bones rendered per frame
  32159. * @returns the total number of active bones rendered per frame
  32160. */
  32161. getActiveBones(): number;
  32162. /**
  32163. * Gets the performance counter for active bones
  32164. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32165. */
  32166. readonly activeBonesPerfCounter: PerfCounter;
  32167. /**
  32168. * Gets the array of active meshes
  32169. * @returns an array of AbstractMesh
  32170. */
  32171. getActiveMeshes(): SmartArray<AbstractMesh>;
  32172. /**
  32173. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32174. * @returns a number
  32175. */
  32176. getAnimationRatio(): number;
  32177. /**
  32178. * Gets an unique Id for the current render phase
  32179. * @returns a number
  32180. */
  32181. getRenderId(): number;
  32182. /**
  32183. * Gets an unique Id for the current frame
  32184. * @returns a number
  32185. */
  32186. getFrameId(): number;
  32187. /** Call this function if you want to manually increment the render Id*/
  32188. incrementRenderId(): void;
  32189. private _createUbo;
  32190. /**
  32191. * Use this method to simulate a pointer move on a mesh
  32192. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32193. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32194. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32195. * @returns the current scene
  32196. */
  32197. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32198. /**
  32199. * Use this method to simulate a pointer down on a mesh
  32200. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32201. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32202. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32203. * @returns the current scene
  32204. */
  32205. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32206. /**
  32207. * Use this method to simulate a pointer up on a mesh
  32208. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32209. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32210. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32211. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32212. * @returns the current scene
  32213. */
  32214. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32215. /**
  32216. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32217. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32218. * @returns true if the pointer was captured
  32219. */
  32220. isPointerCaptured(pointerId?: number): boolean;
  32221. /**
  32222. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32223. * @param attachUp defines if you want to attach events to pointerup
  32224. * @param attachDown defines if you want to attach events to pointerdown
  32225. * @param attachMove defines if you want to attach events to pointermove
  32226. */
  32227. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32228. /** Detaches all event handlers*/
  32229. detachControl(): void;
  32230. /**
  32231. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32232. * Delay loaded resources are not taking in account
  32233. * @return true if all required resources are ready
  32234. */
  32235. isReady(): boolean;
  32236. /** Resets all cached information relative to material (including effect and visibility) */
  32237. resetCachedMaterial(): void;
  32238. /**
  32239. * Registers a function to be called before every frame render
  32240. * @param func defines the function to register
  32241. */
  32242. registerBeforeRender(func: () => void): void;
  32243. /**
  32244. * Unregisters a function called before every frame render
  32245. * @param func defines the function to unregister
  32246. */
  32247. unregisterBeforeRender(func: () => void): void;
  32248. /**
  32249. * Registers a function to be called after every frame render
  32250. * @param func defines the function to register
  32251. */
  32252. registerAfterRender(func: () => void): void;
  32253. /**
  32254. * Unregisters a function called after every frame render
  32255. * @param func defines the function to unregister
  32256. */
  32257. unregisterAfterRender(func: () => void): void;
  32258. private _executeOnceBeforeRender;
  32259. /**
  32260. * The provided function will run before render once and will be disposed afterwards.
  32261. * A timeout delay can be provided so that the function will be executed in N ms.
  32262. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32263. * @param func The function to be executed.
  32264. * @param timeout optional delay in ms
  32265. */
  32266. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32267. /** @hidden */ addPendingData(data: any): void;
  32268. /** @hidden */ removePendingData(data: any): void;
  32269. /**
  32270. * Returns the number of items waiting to be loaded
  32271. * @returns the number of items waiting to be loaded
  32272. */
  32273. getWaitingItemsCount(): number;
  32274. /**
  32275. * Returns a boolean indicating if the scene is still loading data
  32276. */
  32277. readonly isLoading: boolean;
  32278. /**
  32279. * Registers a function to be executed when the scene is ready
  32280. * @param {Function} func - the function to be executed
  32281. */
  32282. executeWhenReady(func: () => void): void;
  32283. /**
  32284. * Returns a promise that resolves when the scene is ready
  32285. * @returns A promise that resolves when the scene is ready
  32286. */
  32287. whenReadyAsync(): Promise<void>;
  32288. /** @hidden */ checkIsReady(): void;
  32289. /**
  32290. * Gets all animatable attached to the scene
  32291. */
  32292. readonly animatables: Animatable[];
  32293. /**
  32294. * Resets the last animation time frame.
  32295. * Useful to override when animations start running when loading a scene for the first time.
  32296. */
  32297. resetLastAnimationTimeFrame(): void;
  32298. /**
  32299. * Gets the current view matrix
  32300. * @returns a Matrix
  32301. */
  32302. getViewMatrix(): Matrix;
  32303. /**
  32304. * Gets the current projection matrix
  32305. * @returns a Matrix
  32306. */
  32307. getProjectionMatrix(): Matrix;
  32308. /**
  32309. * Gets the current transform matrix
  32310. * @returns a Matrix made of View * Projection
  32311. */
  32312. getTransformMatrix(): Matrix;
  32313. /**
  32314. * Sets the current transform matrix
  32315. * @param viewL defines the View matrix to use
  32316. * @param projectionL defines the Projection matrix to use
  32317. * @param viewR defines the right View matrix to use (if provided)
  32318. * @param projectionR defines the right Projection matrix to use (if provided)
  32319. */
  32320. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32321. /**
  32322. * Gets the uniform buffer used to store scene data
  32323. * @returns a UniformBuffer
  32324. */
  32325. getSceneUniformBuffer(): UniformBuffer;
  32326. /**
  32327. * Gets an unique (relatively to the current scene) Id
  32328. * @returns an unique number for the scene
  32329. */
  32330. getUniqueId(): number;
  32331. /**
  32332. * Add a mesh to the list of scene's meshes
  32333. * @param newMesh defines the mesh to add
  32334. * @param recursive if all child meshes should also be added to the scene
  32335. */
  32336. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32337. /**
  32338. * Remove a mesh for the list of scene's meshes
  32339. * @param toRemove defines the mesh to remove
  32340. * @param recursive if all child meshes should also be removed from the scene
  32341. * @returns the index where the mesh was in the mesh list
  32342. */
  32343. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32344. /**
  32345. * Add a transform node to the list of scene's transform nodes
  32346. * @param newTransformNode defines the transform node to add
  32347. */
  32348. addTransformNode(newTransformNode: TransformNode): void;
  32349. /**
  32350. * Remove a transform node for the list of scene's transform nodes
  32351. * @param toRemove defines the transform node to remove
  32352. * @returns the index where the transform node was in the transform node list
  32353. */
  32354. removeTransformNode(toRemove: TransformNode): number;
  32355. /**
  32356. * Remove a skeleton for the list of scene's skeletons
  32357. * @param toRemove defines the skeleton to remove
  32358. * @returns the index where the skeleton was in the skeleton list
  32359. */
  32360. removeSkeleton(toRemove: Skeleton): number;
  32361. /**
  32362. * Remove a morph target for the list of scene's morph targets
  32363. * @param toRemove defines the morph target to remove
  32364. * @returns the index where the morph target was in the morph target list
  32365. */
  32366. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32367. /**
  32368. * Remove a light for the list of scene's lights
  32369. * @param toRemove defines the light to remove
  32370. * @returns the index where the light was in the light list
  32371. */
  32372. removeLight(toRemove: Light): number;
  32373. /**
  32374. * Remove a camera for the list of scene's cameras
  32375. * @param toRemove defines the camera to remove
  32376. * @returns the index where the camera was in the camera list
  32377. */
  32378. removeCamera(toRemove: Camera): number;
  32379. /**
  32380. * Remove a particle system for the list of scene's particle systems
  32381. * @param toRemove defines the particle system to remove
  32382. * @returns the index where the particle system was in the particle system list
  32383. */
  32384. removeParticleSystem(toRemove: IParticleSystem): number;
  32385. /**
  32386. * Remove a animation for the list of scene's animations
  32387. * @param toRemove defines the animation to remove
  32388. * @returns the index where the animation was in the animation list
  32389. */
  32390. removeAnimation(toRemove: Animation): number;
  32391. /**
  32392. * Will stop the animation of the given target
  32393. * @param target - the target
  32394. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32395. * @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)
  32396. */
  32397. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32398. /**
  32399. * Removes the given animation group from this scene.
  32400. * @param toRemove The animation group to remove
  32401. * @returns The index of the removed animation group
  32402. */
  32403. removeAnimationGroup(toRemove: AnimationGroup): number;
  32404. /**
  32405. * Removes the given multi-material from this scene.
  32406. * @param toRemove The multi-material to remove
  32407. * @returns The index of the removed multi-material
  32408. */
  32409. removeMultiMaterial(toRemove: MultiMaterial): number;
  32410. /**
  32411. * Removes the given material from this scene.
  32412. * @param toRemove The material to remove
  32413. * @returns The index of the removed material
  32414. */
  32415. removeMaterial(toRemove: Material): number;
  32416. /**
  32417. * Removes the given action manager from this scene.
  32418. * @param toRemove The action manager to remove
  32419. * @returns The index of the removed action manager
  32420. */
  32421. removeActionManager(toRemove: AbstractActionManager): number;
  32422. /**
  32423. * Removes the given texture from this scene.
  32424. * @param toRemove The texture to remove
  32425. * @returns The index of the removed texture
  32426. */
  32427. removeTexture(toRemove: BaseTexture): number;
  32428. /**
  32429. * Adds the given light to this scene
  32430. * @param newLight The light to add
  32431. */
  32432. addLight(newLight: Light): void;
  32433. /**
  32434. * Sorts the list list based on light priorities
  32435. */
  32436. sortLightsByPriority(): void;
  32437. /**
  32438. * Adds the given camera to this scene
  32439. * @param newCamera The camera to add
  32440. */
  32441. addCamera(newCamera: Camera): void;
  32442. /**
  32443. * Adds the given skeleton to this scene
  32444. * @param newSkeleton The skeleton to add
  32445. */
  32446. addSkeleton(newSkeleton: Skeleton): void;
  32447. /**
  32448. * Adds the given particle system to this scene
  32449. * @param newParticleSystem The particle system to add
  32450. */
  32451. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32452. /**
  32453. * Adds the given animation to this scene
  32454. * @param newAnimation The animation to add
  32455. */
  32456. addAnimation(newAnimation: Animation): void;
  32457. /**
  32458. * Adds the given animation group to this scene.
  32459. * @param newAnimationGroup The animation group to add
  32460. */
  32461. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32462. /**
  32463. * Adds the given multi-material to this scene
  32464. * @param newMultiMaterial The multi-material to add
  32465. */
  32466. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32467. /**
  32468. * Adds the given material to this scene
  32469. * @param newMaterial The material to add
  32470. */
  32471. addMaterial(newMaterial: Material): void;
  32472. /**
  32473. * Adds the given morph target to this scene
  32474. * @param newMorphTargetManager The morph target to add
  32475. */
  32476. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32477. /**
  32478. * Adds the given geometry to this scene
  32479. * @param newGeometry The geometry to add
  32480. */
  32481. addGeometry(newGeometry: Geometry): void;
  32482. /**
  32483. * Adds the given action manager to this scene
  32484. * @param newActionManager The action manager to add
  32485. */
  32486. addActionManager(newActionManager: AbstractActionManager): void;
  32487. /**
  32488. * Adds the given texture to this scene.
  32489. * @param newTexture The texture to add
  32490. */
  32491. addTexture(newTexture: BaseTexture): void;
  32492. /**
  32493. * Switch active camera
  32494. * @param newCamera defines the new active camera
  32495. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32496. */
  32497. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32498. /**
  32499. * sets the active camera of the scene using its ID
  32500. * @param id defines the camera's ID
  32501. * @return the new active camera or null if none found.
  32502. */
  32503. setActiveCameraByID(id: string): Nullable<Camera>;
  32504. /**
  32505. * sets the active camera of the scene using its name
  32506. * @param name defines the camera's name
  32507. * @returns the new active camera or null if none found.
  32508. */
  32509. setActiveCameraByName(name: string): Nullable<Camera>;
  32510. /**
  32511. * get an animation group using its name
  32512. * @param name defines the material's name
  32513. * @return the animation group or null if none found.
  32514. */
  32515. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32516. /**
  32517. * Get a material using its unique id
  32518. * @param uniqueId defines the material's unique id
  32519. * @return the material or null if none found.
  32520. */
  32521. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32522. /**
  32523. * get a material using its id
  32524. * @param id defines the material's ID
  32525. * @return the material or null if none found.
  32526. */
  32527. getMaterialByID(id: string): Nullable<Material>;
  32528. /**
  32529. * Gets a material using its name
  32530. * @param name defines the material's name
  32531. * @return the material or null if none found.
  32532. */
  32533. getMaterialByName(name: string): Nullable<Material>;
  32534. /**
  32535. * Gets a camera using its id
  32536. * @param id defines the id to look for
  32537. * @returns the camera or null if not found
  32538. */
  32539. getCameraByID(id: string): Nullable<Camera>;
  32540. /**
  32541. * Gets a camera using its unique id
  32542. * @param uniqueId defines the unique id to look for
  32543. * @returns the camera or null if not found
  32544. */
  32545. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32546. /**
  32547. * Gets a camera using its name
  32548. * @param name defines the camera's name
  32549. * @return the camera or null if none found.
  32550. */
  32551. getCameraByName(name: string): Nullable<Camera>;
  32552. /**
  32553. * Gets a bone using its id
  32554. * @param id defines the bone's id
  32555. * @return the bone or null if not found
  32556. */
  32557. getBoneByID(id: string): Nullable<Bone>;
  32558. /**
  32559. * Gets a bone using its id
  32560. * @param name defines the bone's name
  32561. * @return the bone or null if not found
  32562. */
  32563. getBoneByName(name: string): Nullable<Bone>;
  32564. /**
  32565. * Gets a light node using its name
  32566. * @param name defines the the light's name
  32567. * @return the light or null if none found.
  32568. */
  32569. getLightByName(name: string): Nullable<Light>;
  32570. /**
  32571. * Gets a light node using its id
  32572. * @param id defines the light's id
  32573. * @return the light or null if none found.
  32574. */
  32575. getLightByID(id: string): Nullable<Light>;
  32576. /**
  32577. * Gets a light node using its scene-generated unique ID
  32578. * @param uniqueId defines the light's unique id
  32579. * @return the light or null if none found.
  32580. */
  32581. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32582. /**
  32583. * Gets a particle system by id
  32584. * @param id defines the particle system id
  32585. * @return the corresponding system or null if none found
  32586. */
  32587. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32588. /**
  32589. * Gets a geometry using its ID
  32590. * @param id defines the geometry's id
  32591. * @return the geometry or null if none found.
  32592. */
  32593. getGeometryByID(id: string): Nullable<Geometry>;
  32594. private _getGeometryByUniqueID;
  32595. /**
  32596. * Add a new geometry to this scene
  32597. * @param geometry defines the geometry to be added to the scene.
  32598. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32599. * @return a boolean defining if the geometry was added or not
  32600. */
  32601. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32602. /**
  32603. * Removes an existing geometry
  32604. * @param geometry defines the geometry to be removed from the scene
  32605. * @return a boolean defining if the geometry was removed or not
  32606. */
  32607. removeGeometry(geometry: Geometry): boolean;
  32608. /**
  32609. * Gets the list of geometries attached to the scene
  32610. * @returns an array of Geometry
  32611. */
  32612. getGeometries(): Geometry[];
  32613. /**
  32614. * Gets the first added mesh found of a given ID
  32615. * @param id defines the id to search for
  32616. * @return the mesh found or null if not found at all
  32617. */
  32618. getMeshByID(id: string): Nullable<AbstractMesh>;
  32619. /**
  32620. * Gets a list of meshes using their id
  32621. * @param id defines the id to search for
  32622. * @returns a list of meshes
  32623. */
  32624. getMeshesByID(id: string): Array<AbstractMesh>;
  32625. /**
  32626. * Gets the first added transform node found of a given ID
  32627. * @param id defines the id to search for
  32628. * @return the found transform node or null if not found at all.
  32629. */
  32630. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32631. /**
  32632. * Gets a transform node with its auto-generated unique id
  32633. * @param uniqueId efines the unique id to search for
  32634. * @return the found transform node or null if not found at all.
  32635. */
  32636. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32637. /**
  32638. * Gets a list of transform nodes using their id
  32639. * @param id defines the id to search for
  32640. * @returns a list of transform nodes
  32641. */
  32642. getTransformNodesByID(id: string): Array<TransformNode>;
  32643. /**
  32644. * Gets a mesh with its auto-generated unique id
  32645. * @param uniqueId defines the unique id to search for
  32646. * @return the found mesh or null if not found at all.
  32647. */
  32648. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32649. /**
  32650. * Gets a the last added mesh using a given id
  32651. * @param id defines the id to search for
  32652. * @return the found mesh or null if not found at all.
  32653. */
  32654. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32655. /**
  32656. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32657. * @param id defines the id to search for
  32658. * @return the found node or null if not found at all
  32659. */
  32660. getLastEntryByID(id: string): Nullable<Node>;
  32661. /**
  32662. * Gets a node (Mesh, Camera, Light) using a given id
  32663. * @param id defines the id to search for
  32664. * @return the found node or null if not found at all
  32665. */
  32666. getNodeByID(id: string): Nullable<Node>;
  32667. /**
  32668. * Gets a node (Mesh, Camera, Light) using a given name
  32669. * @param name defines the name to search for
  32670. * @return the found node or null if not found at all.
  32671. */
  32672. getNodeByName(name: string): Nullable<Node>;
  32673. /**
  32674. * Gets a mesh using a given name
  32675. * @param name defines the name to search for
  32676. * @return the found mesh or null if not found at all.
  32677. */
  32678. getMeshByName(name: string): Nullable<AbstractMesh>;
  32679. /**
  32680. * Gets a transform node using a given name
  32681. * @param name defines the name to search for
  32682. * @return the found transform node or null if not found at all.
  32683. */
  32684. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32685. /**
  32686. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32687. * @param id defines the id to search for
  32688. * @return the found skeleton or null if not found at all.
  32689. */
  32690. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32691. /**
  32692. * Gets a skeleton using a given auto generated unique id
  32693. * @param uniqueId defines the unique id to search for
  32694. * @return the found skeleton or null if not found at all.
  32695. */
  32696. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32697. /**
  32698. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32699. * @param id defines the id to search for
  32700. * @return the found skeleton or null if not found at all.
  32701. */
  32702. getSkeletonById(id: string): Nullable<Skeleton>;
  32703. /**
  32704. * Gets a skeleton using a given name
  32705. * @param name defines the name to search for
  32706. * @return the found skeleton or null if not found at all.
  32707. */
  32708. getSkeletonByName(name: string): Nullable<Skeleton>;
  32709. /**
  32710. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32711. * @param id defines the id to search for
  32712. * @return the found morph target manager or null if not found at all.
  32713. */
  32714. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32715. /**
  32716. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32717. * @param id defines the id to search for
  32718. * @return the found morph target or null if not found at all.
  32719. */
  32720. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32721. /**
  32722. * Gets a boolean indicating if the given mesh is active
  32723. * @param mesh defines the mesh to look for
  32724. * @returns true if the mesh is in the active list
  32725. */
  32726. isActiveMesh(mesh: AbstractMesh): boolean;
  32727. /**
  32728. * Return a unique id as a string which can serve as an identifier for the scene
  32729. */
  32730. readonly uid: string;
  32731. /**
  32732. * Add an externaly attached data from its key.
  32733. * This method call will fail and return false, if such key already exists.
  32734. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32735. * @param key the unique key that identifies the data
  32736. * @param data the data object to associate to the key for this Engine instance
  32737. * @return true if no such key were already present and the data was added successfully, false otherwise
  32738. */
  32739. addExternalData<T>(key: string, data: T): boolean;
  32740. /**
  32741. * Get an externaly attached data from its key
  32742. * @param key the unique key that identifies the data
  32743. * @return the associated data, if present (can be null), or undefined if not present
  32744. */
  32745. getExternalData<T>(key: string): Nullable<T>;
  32746. /**
  32747. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32748. * @param key the unique key that identifies the data
  32749. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32750. * @return the associated data, can be null if the factory returned null.
  32751. */
  32752. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32753. /**
  32754. * Remove an externaly attached data from the Engine instance
  32755. * @param key the unique key that identifies the data
  32756. * @return true if the data was successfully removed, false if it doesn't exist
  32757. */
  32758. removeExternalData(key: string): boolean;
  32759. private _evaluateSubMesh;
  32760. /**
  32761. * Clear the processed materials smart array preventing retention point in material dispose.
  32762. */
  32763. freeProcessedMaterials(): void;
  32764. private _preventFreeActiveMeshesAndRenderingGroups;
  32765. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32766. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32767. * when disposing several meshes in a row or a hierarchy of meshes.
  32768. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32769. */
  32770. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32771. /**
  32772. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32773. */
  32774. freeActiveMeshes(): void;
  32775. /**
  32776. * Clear the info related to rendering groups preventing retention points during dispose.
  32777. */
  32778. freeRenderingGroups(): void;
  32779. /** @hidden */ isInIntermediateRendering(): boolean;
  32780. /**
  32781. * Lambda returning the list of potentially active meshes.
  32782. */
  32783. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32784. /**
  32785. * Lambda returning the list of potentially active sub meshes.
  32786. */
  32787. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32788. /**
  32789. * Lambda returning the list of potentially intersecting sub meshes.
  32790. */
  32791. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32792. /**
  32793. * Lambda returning the list of potentially colliding sub meshes.
  32794. */
  32795. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32796. private _activeMeshesFrozen;
  32797. /**
  32798. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32799. * @returns the current scene
  32800. */
  32801. freezeActiveMeshes(): Scene;
  32802. /**
  32803. * Use this function to restart evaluating active meshes on every frame
  32804. * @returns the current scene
  32805. */
  32806. unfreezeActiveMeshes(): Scene;
  32807. private _evaluateActiveMeshes;
  32808. private _activeMesh;
  32809. /**
  32810. * Update the transform matrix to update from the current active camera
  32811. * @param force defines a boolean used to force the update even if cache is up to date
  32812. */
  32813. updateTransformMatrix(force?: boolean): void;
  32814. private _bindFrameBuffer;
  32815. /** @hidden */ allowPostProcessClearColor: boolean;
  32816. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32817. private _processSubCameras;
  32818. private _checkIntersections;
  32819. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32820. /**
  32821. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32822. */
  32823. getDeterministicFrameTime: () => number;
  32824. /** @hidden */ animate(): void;
  32825. /** Execute all animations (for a frame) */
  32826. animate(): void;
  32827. /**
  32828. * Render the scene
  32829. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32830. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32831. */
  32832. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32833. /**
  32834. * Freeze all materials
  32835. * A frozen material will not be updatable but should be faster to render
  32836. */
  32837. freezeMaterials(): void;
  32838. /**
  32839. * Unfreeze all materials
  32840. * A frozen material will not be updatable but should be faster to render
  32841. */
  32842. unfreezeMaterials(): void;
  32843. /**
  32844. * Releases all held ressources
  32845. */
  32846. dispose(): void;
  32847. /**
  32848. * Gets if the scene is already disposed
  32849. */
  32850. readonly isDisposed: boolean;
  32851. /**
  32852. * Call this function to reduce memory footprint of the scene.
  32853. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32854. */
  32855. clearCachedVertexData(): void;
  32856. /**
  32857. * This function will remove the local cached buffer data from texture.
  32858. * It will save memory but will prevent the texture from being rebuilt
  32859. */
  32860. cleanCachedTextureBuffer(): void;
  32861. /**
  32862. * Get the world extend vectors with an optional filter
  32863. *
  32864. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32865. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32866. */
  32867. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32868. min: Vector3;
  32869. max: Vector3;
  32870. };
  32871. /**
  32872. * Creates a ray that can be used to pick in the scene
  32873. * @param x defines the x coordinate of the origin (on-screen)
  32874. * @param y defines the y coordinate of the origin (on-screen)
  32875. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32876. * @param camera defines the camera to use for the picking
  32877. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32878. * @returns a Ray
  32879. */
  32880. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32881. /**
  32882. * Creates a ray that can be used to pick in the scene
  32883. * @param x defines the x coordinate of the origin (on-screen)
  32884. * @param y defines the y coordinate of the origin (on-screen)
  32885. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32886. * @param result defines the ray where to store the picking ray
  32887. * @param camera defines the camera to use for the picking
  32888. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32889. * @returns the current scene
  32890. */
  32891. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32892. /**
  32893. * Creates a ray that can be used to pick in the scene
  32894. * @param x defines the x coordinate of the origin (on-screen)
  32895. * @param y defines the y coordinate of the origin (on-screen)
  32896. * @param camera defines the camera to use for the picking
  32897. * @returns a Ray
  32898. */
  32899. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32900. /**
  32901. * Creates a ray that can be used to pick in the scene
  32902. * @param x defines the x coordinate of the origin (on-screen)
  32903. * @param y defines the y coordinate of the origin (on-screen)
  32904. * @param result defines the ray where to store the picking ray
  32905. * @param camera defines the camera to use for the picking
  32906. * @returns the current scene
  32907. */
  32908. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32909. /** Launch a ray to try to pick a mesh in the scene
  32910. * @param x position on screen
  32911. * @param y position on screen
  32912. * @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
  32913. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32914. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32915. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32916. * @returns a PickingInfo
  32917. */
  32918. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32919. /** Use the given ray to pick a mesh in the scene
  32920. * @param ray The ray to use to pick meshes
  32921. * @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
  32922. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32923. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32924. * @returns a PickingInfo
  32925. */
  32926. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32927. /**
  32928. * Launch a ray to try to pick a mesh in the scene
  32929. * @param x X position on screen
  32930. * @param y Y position on screen
  32931. * @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
  32932. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32933. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32934. * @returns an array of PickingInfo
  32935. */
  32936. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32937. /**
  32938. * Launch a ray to try to pick a mesh in the scene
  32939. * @param ray Ray to use
  32940. * @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
  32941. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32942. * @returns an array of PickingInfo
  32943. */
  32944. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32945. /**
  32946. * Force the value of meshUnderPointer
  32947. * @param mesh defines the mesh to use
  32948. */
  32949. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32950. /**
  32951. * Gets the mesh under the pointer
  32952. * @returns a Mesh or null if no mesh is under the pointer
  32953. */
  32954. getPointerOverMesh(): Nullable<AbstractMesh>;
  32955. /** @hidden */ rebuildGeometries(): void;
  32956. /** @hidden */ rebuildTextures(): void;
  32957. private _getByTags;
  32958. /**
  32959. * Get a list of meshes by tags
  32960. * @param tagsQuery defines the tags query to use
  32961. * @param forEach defines a predicate used to filter results
  32962. * @returns an array of Mesh
  32963. */
  32964. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32965. /**
  32966. * Get a list of cameras by tags
  32967. * @param tagsQuery defines the tags query to use
  32968. * @param forEach defines a predicate used to filter results
  32969. * @returns an array of Camera
  32970. */
  32971. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32972. /**
  32973. * Get a list of lights by tags
  32974. * @param tagsQuery defines the tags query to use
  32975. * @param forEach defines a predicate used to filter results
  32976. * @returns an array of Light
  32977. */
  32978. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32979. /**
  32980. * Get a list of materials by tags
  32981. * @param tagsQuery defines the tags query to use
  32982. * @param forEach defines a predicate used to filter results
  32983. * @returns an array of Material
  32984. */
  32985. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32986. /**
  32987. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32988. * This allowed control for front to back rendering or reversly depending of the special needs.
  32989. *
  32990. * @param renderingGroupId The rendering group id corresponding to its index
  32991. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32992. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32993. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32994. */
  32995. 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;
  32996. /**
  32997. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32998. *
  32999. * @param renderingGroupId The rendering group id corresponding to its index
  33000. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33001. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33002. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33003. */
  33004. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33005. /**
  33006. * Gets the current auto clear configuration for one rendering group of the rendering
  33007. * manager.
  33008. * @param index the rendering group index to get the information for
  33009. * @returns The auto clear setup for the requested rendering group
  33010. */
  33011. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33012. private _blockMaterialDirtyMechanism;
  33013. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33014. blockMaterialDirtyMechanism: boolean;
  33015. /**
  33016. * Will flag all materials as dirty to trigger new shader compilation
  33017. * @param flag defines the flag used to specify which material part must be marked as dirty
  33018. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33019. */
  33020. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33021. /** @hidden */ 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;
  33022. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33023. }
  33024. }
  33025. declare module BABYLON {
  33026. /**
  33027. * Set of assets to keep when moving a scene into an asset container.
  33028. */
  33029. export class KeepAssets extends AbstractScene {
  33030. }
  33031. /**
  33032. * Container with a set of assets that can be added or removed from a scene.
  33033. */
  33034. export class AssetContainer extends AbstractScene {
  33035. /**
  33036. * The scene the AssetContainer belongs to.
  33037. */
  33038. scene: Scene;
  33039. /**
  33040. * Instantiates an AssetContainer.
  33041. * @param scene The scene the AssetContainer belongs to.
  33042. */
  33043. constructor(scene: Scene);
  33044. /**
  33045. * Adds all the assets from the container to the scene.
  33046. */
  33047. addAllToScene(): void;
  33048. /**
  33049. * Removes all the assets in the container from the scene
  33050. */
  33051. removeAllFromScene(): void;
  33052. /**
  33053. * Disposes all the assets in the container
  33054. */
  33055. dispose(): void;
  33056. private _moveAssets;
  33057. /**
  33058. * Removes all the assets contained in the scene and adds them to the container.
  33059. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33060. */
  33061. moveAllFromScene(keepAssets?: KeepAssets): void;
  33062. /**
  33063. * 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.
  33064. * @returns the root mesh
  33065. */
  33066. createRootMesh(): Mesh;
  33067. }
  33068. }
  33069. declare module BABYLON {
  33070. /**
  33071. * Defines how the parser contract is defined.
  33072. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33073. */
  33074. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33075. /**
  33076. * Defines how the individual parser contract is defined.
  33077. * These parser can parse an individual asset
  33078. */
  33079. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33080. /**
  33081. * Base class of the scene acting as a container for the different elements composing a scene.
  33082. * This class is dynamically extended by the different components of the scene increasing
  33083. * flexibility and reducing coupling
  33084. */
  33085. export abstract class AbstractScene {
  33086. /**
  33087. * Stores the list of available parsers in the application.
  33088. */
  33089. private static _BabylonFileParsers;
  33090. /**
  33091. * Stores the list of available individual parsers in the application.
  33092. */
  33093. private static _IndividualBabylonFileParsers;
  33094. /**
  33095. * Adds a parser in the list of available ones
  33096. * @param name Defines the name of the parser
  33097. * @param parser Defines the parser to add
  33098. */
  33099. static AddParser(name: string, parser: BabylonFileParser): void;
  33100. /**
  33101. * Gets a general parser from the list of avaialble ones
  33102. * @param name Defines the name of the parser
  33103. * @returns the requested parser or null
  33104. */
  33105. static GetParser(name: string): Nullable<BabylonFileParser>;
  33106. /**
  33107. * Adds n individual parser in the list of available ones
  33108. * @param name Defines the name of the parser
  33109. * @param parser Defines the parser to add
  33110. */
  33111. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33112. /**
  33113. * Gets an individual parser from the list of avaialble ones
  33114. * @param name Defines the name of the parser
  33115. * @returns the requested parser or null
  33116. */
  33117. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33118. /**
  33119. * Parser json data and populate both a scene and its associated container object
  33120. * @param jsonData Defines the data to parse
  33121. * @param scene Defines the scene to parse the data for
  33122. * @param container Defines the container attached to the parsing sequence
  33123. * @param rootUrl Defines the root url of the data
  33124. */
  33125. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33126. /**
  33127. * Gets the list of root nodes (ie. nodes with no parent)
  33128. */
  33129. rootNodes: Node[];
  33130. /** All of the cameras added to this scene
  33131. * @see http://doc.babylonjs.com/babylon101/cameras
  33132. */
  33133. cameras: Camera[];
  33134. /**
  33135. * All of the lights added to this scene
  33136. * @see http://doc.babylonjs.com/babylon101/lights
  33137. */
  33138. lights: Light[];
  33139. /**
  33140. * All of the (abstract) meshes added to this scene
  33141. */
  33142. meshes: AbstractMesh[];
  33143. /**
  33144. * The list of skeletons added to the scene
  33145. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33146. */
  33147. skeletons: Skeleton[];
  33148. /**
  33149. * All of the particle systems added to this scene
  33150. * @see http://doc.babylonjs.com/babylon101/particles
  33151. */
  33152. particleSystems: IParticleSystem[];
  33153. /**
  33154. * Gets a list of Animations associated with the scene
  33155. */
  33156. animations: Animation[];
  33157. /**
  33158. * All of the animation groups added to this scene
  33159. * @see http://doc.babylonjs.com/how_to/group
  33160. */
  33161. animationGroups: AnimationGroup[];
  33162. /**
  33163. * All of the multi-materials added to this scene
  33164. * @see http://doc.babylonjs.com/how_to/multi_materials
  33165. */
  33166. multiMaterials: MultiMaterial[];
  33167. /**
  33168. * All of the materials added to this scene
  33169. * In the context of a Scene, it is not supposed to be modified manually.
  33170. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33171. * Note also that the order of the Material wihin the array is not significant and might change.
  33172. * @see http://doc.babylonjs.com/babylon101/materials
  33173. */
  33174. materials: Material[];
  33175. /**
  33176. * The list of morph target managers added to the scene
  33177. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33178. */
  33179. morphTargetManagers: MorphTargetManager[];
  33180. /**
  33181. * The list of geometries used in the scene.
  33182. */
  33183. geometries: Geometry[];
  33184. /**
  33185. * All of the tranform nodes added to this scene
  33186. * In the context of a Scene, it is not supposed to be modified manually.
  33187. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33188. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33189. * @see http://doc.babylonjs.com/how_to/transformnode
  33190. */
  33191. transformNodes: TransformNode[];
  33192. /**
  33193. * ActionManagers available on the scene.
  33194. */
  33195. actionManagers: AbstractActionManager[];
  33196. /**
  33197. * Textures to keep.
  33198. */
  33199. textures: BaseTexture[];
  33200. /**
  33201. * Environment texture for the scene
  33202. */
  33203. environmentTexture: Nullable<BaseTexture>;
  33204. }
  33205. }
  33206. declare module BABYLON {
  33207. /**
  33208. * Defines a sound that can be played in the application.
  33209. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33211. */
  33212. export class Sound {
  33213. /**
  33214. * The name of the sound in the scene.
  33215. */
  33216. name: string;
  33217. /**
  33218. * Does the sound autoplay once loaded.
  33219. */
  33220. autoplay: boolean;
  33221. /**
  33222. * Does the sound loop after it finishes playing once.
  33223. */
  33224. loop: boolean;
  33225. /**
  33226. * Does the sound use a custom attenuation curve to simulate the falloff
  33227. * happening when the source gets further away from the camera.
  33228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33229. */
  33230. useCustomAttenuation: boolean;
  33231. /**
  33232. * The sound track id this sound belongs to.
  33233. */
  33234. soundTrackId: number;
  33235. /**
  33236. * Is this sound currently played.
  33237. */
  33238. isPlaying: boolean;
  33239. /**
  33240. * Is this sound currently paused.
  33241. */
  33242. isPaused: boolean;
  33243. /**
  33244. * Does this sound enables spatial sound.
  33245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33246. */
  33247. spatialSound: boolean;
  33248. /**
  33249. * Define the reference distance the sound should be heard perfectly.
  33250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33251. */
  33252. refDistance: number;
  33253. /**
  33254. * Define the roll off factor of spatial sounds.
  33255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33256. */
  33257. rolloffFactor: number;
  33258. /**
  33259. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33261. */
  33262. maxDistance: number;
  33263. /**
  33264. * Define the distance attenuation model the sound will follow.
  33265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33266. */
  33267. distanceModel: string;
  33268. /**
  33269. * @hidden
  33270. * Back Compat
  33271. **/
  33272. onended: () => any;
  33273. /**
  33274. * Observable event when the current playing sound finishes.
  33275. */
  33276. onEndedObservable: Observable<Sound>;
  33277. private _panningModel;
  33278. private _playbackRate;
  33279. private _streaming;
  33280. private _startTime;
  33281. private _startOffset;
  33282. private _position;
  33283. /** @hidden */ positionInEmitterSpace: boolean;
  33284. private _localDirection;
  33285. private _volume;
  33286. private _isReadyToPlay;
  33287. private _isDirectional;
  33288. private _readyToPlayCallback;
  33289. private _audioBuffer;
  33290. private _soundSource;
  33291. private _streamingSource;
  33292. private _soundPanner;
  33293. private _soundGain;
  33294. private _inputAudioNode;
  33295. private _outputAudioNode;
  33296. private _coneInnerAngle;
  33297. private _coneOuterAngle;
  33298. private _coneOuterGain;
  33299. private _scene;
  33300. private _connectedTransformNode;
  33301. private _customAttenuationFunction;
  33302. private _registerFunc;
  33303. private _isOutputConnected;
  33304. private _htmlAudioElement;
  33305. private _urlType;
  33306. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33307. /**
  33308. * Create a sound and attach it to a scene
  33309. * @param name Name of your sound
  33310. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33311. * @param scene defines the scene the sound belongs to
  33312. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33313. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33314. */
  33315. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33316. /**
  33317. * Release the sound and its associated resources
  33318. */
  33319. dispose(): void;
  33320. /**
  33321. * Gets if the sounds is ready to be played or not.
  33322. * @returns true if ready, otherwise false
  33323. */
  33324. isReady(): boolean;
  33325. private _soundLoaded;
  33326. /**
  33327. * Sets the data of the sound from an audiobuffer
  33328. * @param audioBuffer The audioBuffer containing the data
  33329. */
  33330. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33331. /**
  33332. * Updates the current sounds options such as maxdistance, loop...
  33333. * @param options A JSON object containing values named as the object properties
  33334. */
  33335. updateOptions(options: any): void;
  33336. private _createSpatialParameters;
  33337. private _updateSpatialParameters;
  33338. /**
  33339. * Switch the panning model to HRTF:
  33340. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33342. */
  33343. switchPanningModelToHRTF(): void;
  33344. /**
  33345. * Switch the panning model to Equal Power:
  33346. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33348. */
  33349. switchPanningModelToEqualPower(): void;
  33350. private _switchPanningModel;
  33351. /**
  33352. * Connect this sound to a sound track audio node like gain...
  33353. * @param soundTrackAudioNode the sound track audio node to connect to
  33354. */
  33355. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33356. /**
  33357. * Transform this sound into a directional source
  33358. * @param coneInnerAngle Size of the inner cone in degree
  33359. * @param coneOuterAngle Size of the outer cone in degree
  33360. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33361. */
  33362. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33363. /**
  33364. * Gets or sets the inner angle for the directional cone.
  33365. */
  33366. /**
  33367. * Gets or sets the inner angle for the directional cone.
  33368. */
  33369. directionalConeInnerAngle: number;
  33370. /**
  33371. * Gets or sets the outer angle for the directional cone.
  33372. */
  33373. /**
  33374. * Gets or sets the outer angle for the directional cone.
  33375. */
  33376. directionalConeOuterAngle: number;
  33377. /**
  33378. * Sets the position of the emitter if spatial sound is enabled
  33379. * @param newPosition Defines the new posisiton
  33380. */
  33381. setPosition(newPosition: Vector3): void;
  33382. /**
  33383. * Sets the local direction of the emitter if spatial sound is enabled
  33384. * @param newLocalDirection Defines the new local direction
  33385. */
  33386. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33387. private _updateDirection;
  33388. /** @hidden */
  33389. updateDistanceFromListener(): void;
  33390. /**
  33391. * Sets a new custom attenuation function for the sound.
  33392. * @param callback Defines the function used for the attenuation
  33393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33394. */
  33395. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33396. /**
  33397. * Play the sound
  33398. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33399. * @param offset (optional) Start the sound setting it at a specific time
  33400. */
  33401. play(time?: number, offset?: number): void;
  33402. private _onended;
  33403. /**
  33404. * Stop the sound
  33405. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33406. */
  33407. stop(time?: number): void;
  33408. /**
  33409. * Put the sound in pause
  33410. */
  33411. pause(): void;
  33412. /**
  33413. * Sets a dedicated volume for this sounds
  33414. * @param newVolume Define the new volume of the sound
  33415. * @param time Define in how long the sound should be at this value
  33416. */
  33417. setVolume(newVolume: number, time?: number): void;
  33418. /**
  33419. * Set the sound play back rate
  33420. * @param newPlaybackRate Define the playback rate the sound should be played at
  33421. */
  33422. setPlaybackRate(newPlaybackRate: number): void;
  33423. /**
  33424. * Gets the volume of the sound.
  33425. * @returns the volume of the sound
  33426. */
  33427. getVolume(): number;
  33428. /**
  33429. * Attach the sound to a dedicated mesh
  33430. * @param transformNode The transform node to connect the sound with
  33431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33432. */
  33433. attachToMesh(transformNode: TransformNode): void;
  33434. /**
  33435. * Detach the sound from the previously attached mesh
  33436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33437. */
  33438. detachFromMesh(): void;
  33439. private _onRegisterAfterWorldMatrixUpdate;
  33440. /**
  33441. * Clone the current sound in the scene.
  33442. * @returns the new sound clone
  33443. */
  33444. clone(): Nullable<Sound>;
  33445. /**
  33446. * Gets the current underlying audio buffer containing the data
  33447. * @returns the audio buffer
  33448. */
  33449. getAudioBuffer(): Nullable<AudioBuffer>;
  33450. /**
  33451. * Serializes the Sound in a JSON representation
  33452. * @returns the JSON representation of the sound
  33453. */
  33454. serialize(): any;
  33455. /**
  33456. * Parse a JSON representation of a sound to innstantiate in a given scene
  33457. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33458. * @param scene Define the scene the new parsed sound should be created in
  33459. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33460. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33461. * @returns the newly parsed sound
  33462. */
  33463. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33464. }
  33465. }
  33466. declare module BABYLON {
  33467. /**
  33468. * This defines an action helpful to play a defined sound on a triggered action.
  33469. */
  33470. export class PlaySoundAction extends Action {
  33471. private _sound;
  33472. /**
  33473. * Instantiate the action
  33474. * @param triggerOptions defines the trigger options
  33475. * @param sound defines the sound to play
  33476. * @param condition defines the trigger related conditions
  33477. */
  33478. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33479. /** @hidden */ prepare(): void;
  33480. /**
  33481. * Execute the action and play the sound.
  33482. */
  33483. execute(): void;
  33484. /**
  33485. * Serializes the actions and its related information.
  33486. * @param parent defines the object to serialize in
  33487. * @returns the serialized object
  33488. */
  33489. serialize(parent: any): any;
  33490. }
  33491. /**
  33492. * This defines an action helpful to stop a defined sound on a triggered action.
  33493. */
  33494. export class StopSoundAction extends Action {
  33495. private _sound;
  33496. /**
  33497. * Instantiate the action
  33498. * @param triggerOptions defines the trigger options
  33499. * @param sound defines the sound to stop
  33500. * @param condition defines the trigger related conditions
  33501. */
  33502. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33503. /** @hidden */ prepare(): void;
  33504. /**
  33505. * Execute the action and stop the sound.
  33506. */
  33507. execute(): void;
  33508. /**
  33509. * Serializes the actions and its related information.
  33510. * @param parent defines the object to serialize in
  33511. * @returns the serialized object
  33512. */
  33513. serialize(parent: any): any;
  33514. }
  33515. }
  33516. declare module BABYLON {
  33517. /**
  33518. * This defines an action responsible to change the value of a property
  33519. * by interpolating between its current value and the newly set one once triggered.
  33520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33521. */
  33522. export class InterpolateValueAction extends Action {
  33523. /**
  33524. * Defines the path of the property where the value should be interpolated
  33525. */
  33526. propertyPath: string;
  33527. /**
  33528. * Defines the target value at the end of the interpolation.
  33529. */
  33530. value: any;
  33531. /**
  33532. * Defines the time it will take for the property to interpolate to the value.
  33533. */
  33534. duration: number;
  33535. /**
  33536. * Defines if the other scene animations should be stopped when the action has been triggered
  33537. */
  33538. stopOtherAnimations?: boolean;
  33539. /**
  33540. * Defines a callback raised once the interpolation animation has been done.
  33541. */
  33542. onInterpolationDone?: () => void;
  33543. /**
  33544. * Observable triggered once the interpolation animation has been done.
  33545. */
  33546. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33547. private _target;
  33548. private _effectiveTarget;
  33549. private _property;
  33550. /**
  33551. * Instantiate the action
  33552. * @param triggerOptions defines the trigger options
  33553. * @param target defines the object containing the value to interpolate
  33554. * @param propertyPath defines the path to the property in the target object
  33555. * @param value defines the target value at the end of the interpolation
  33556. * @param duration deines the time it will take for the property to interpolate to the value.
  33557. * @param condition defines the trigger related conditions
  33558. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33559. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33560. */
  33561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33562. /** @hidden */ prepare(): void;
  33563. /**
  33564. * Execute the action starts the value interpolation.
  33565. */
  33566. execute(): void;
  33567. /**
  33568. * Serializes the actions and its related information.
  33569. * @param parent defines the object to serialize in
  33570. * @returns the serialized object
  33571. */
  33572. serialize(parent: any): any;
  33573. }
  33574. }
  33575. declare module BABYLON {
  33576. /**
  33577. * Options allowed during the creation of a sound track.
  33578. */
  33579. export interface ISoundTrackOptions {
  33580. /**
  33581. * The volume the sound track should take during creation
  33582. */
  33583. volume?: number;
  33584. /**
  33585. * Define if the sound track is the main sound track of the scene
  33586. */
  33587. mainTrack?: boolean;
  33588. }
  33589. /**
  33590. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33591. * It will be also used in a future release to apply effects on a specific track.
  33592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33593. */
  33594. export class SoundTrack {
  33595. /**
  33596. * The unique identifier of the sound track in the scene.
  33597. */
  33598. id: number;
  33599. /**
  33600. * The list of sounds included in the sound track.
  33601. */
  33602. soundCollection: Array<Sound>;
  33603. private _outputAudioNode;
  33604. private _scene;
  33605. private _isMainTrack;
  33606. private _connectedAnalyser;
  33607. private _options;
  33608. private _isInitialized;
  33609. /**
  33610. * Creates a new sound track.
  33611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33612. * @param scene Define the scene the sound track belongs to
  33613. * @param options
  33614. */
  33615. constructor(scene: Scene, options?: ISoundTrackOptions);
  33616. private _initializeSoundTrackAudioGraph;
  33617. /**
  33618. * Release the sound track and its associated resources
  33619. */
  33620. dispose(): void;
  33621. /**
  33622. * Adds a sound to this sound track
  33623. * @param sound define the cound to add
  33624. * @ignoreNaming
  33625. */
  33626. AddSound(sound: Sound): void;
  33627. /**
  33628. * Removes a sound to this sound track
  33629. * @param sound define the cound to remove
  33630. * @ignoreNaming
  33631. */
  33632. RemoveSound(sound: Sound): void;
  33633. /**
  33634. * Set a global volume for the full sound track.
  33635. * @param newVolume Define the new volume of the sound track
  33636. */
  33637. setVolume(newVolume: number): void;
  33638. /**
  33639. * Switch the panning model to HRTF:
  33640. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33642. */
  33643. switchPanningModelToHRTF(): void;
  33644. /**
  33645. * Switch the panning model to Equal Power:
  33646. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33648. */
  33649. switchPanningModelToEqualPower(): void;
  33650. /**
  33651. * Connect the sound track to an audio analyser allowing some amazing
  33652. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33654. * @param analyser The analyser to connect to the engine
  33655. */
  33656. connectToAnalyser(analyser: Analyser): void;
  33657. }
  33658. }
  33659. declare module BABYLON {
  33660. interface AbstractScene {
  33661. /**
  33662. * The list of sounds used in the scene.
  33663. */
  33664. sounds: Nullable<Array<Sound>>;
  33665. }
  33666. interface Scene {
  33667. /**
  33668. * @hidden
  33669. * Backing field
  33670. */ mainSoundTrack: SoundTrack;
  33671. /**
  33672. * The main sound track played by the scene.
  33673. * It cotains your primary collection of sounds.
  33674. */
  33675. mainSoundTrack: SoundTrack;
  33676. /**
  33677. * The list of sound tracks added to the scene
  33678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33679. */
  33680. soundTracks: Nullable<Array<SoundTrack>>;
  33681. /**
  33682. * Gets a sound using a given name
  33683. * @param name defines the name to search for
  33684. * @return the found sound or null if not found at all.
  33685. */
  33686. getSoundByName(name: string): Nullable<Sound>;
  33687. /**
  33688. * Gets or sets if audio support is enabled
  33689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33690. */
  33691. audioEnabled: boolean;
  33692. /**
  33693. * Gets or sets if audio will be output to headphones
  33694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33695. */
  33696. headphone: boolean;
  33697. }
  33698. /**
  33699. * Defines the sound scene component responsible to manage any sounds
  33700. * in a given scene.
  33701. */
  33702. export class AudioSceneComponent implements ISceneSerializableComponent {
  33703. /**
  33704. * The component name helpfull to identify the component in the list of scene components.
  33705. */
  33706. readonly name: string;
  33707. /**
  33708. * The scene the component belongs to.
  33709. */
  33710. scene: Scene;
  33711. private _audioEnabled;
  33712. /**
  33713. * Gets whether audio is enabled or not.
  33714. * Please use related enable/disable method to switch state.
  33715. */
  33716. readonly audioEnabled: boolean;
  33717. private _headphone;
  33718. /**
  33719. * Gets whether audio is outputing to headphone or not.
  33720. * Please use the according Switch methods to change output.
  33721. */
  33722. readonly headphone: boolean;
  33723. /**
  33724. * Creates a new instance of the component for the given scene
  33725. * @param scene Defines the scene to register the component in
  33726. */
  33727. constructor(scene: Scene);
  33728. /**
  33729. * Registers the component in a given scene
  33730. */
  33731. register(): void;
  33732. /**
  33733. * Rebuilds the elements related to this component in case of
  33734. * context lost for instance.
  33735. */
  33736. rebuild(): void;
  33737. /**
  33738. * Serializes the component data to the specified json object
  33739. * @param serializationObject The object to serialize to
  33740. */
  33741. serialize(serializationObject: any): void;
  33742. /**
  33743. * Adds all the element from the container to the scene
  33744. * @param container the container holding the elements
  33745. */
  33746. addFromContainer(container: AbstractScene): void;
  33747. /**
  33748. * Removes all the elements in the container from the scene
  33749. * @param container contains the elements to remove
  33750. * @param dispose if the removed element should be disposed (default: false)
  33751. */
  33752. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33753. /**
  33754. * Disposes the component and the associated ressources.
  33755. */
  33756. dispose(): void;
  33757. /**
  33758. * Disables audio in the associated scene.
  33759. */
  33760. disableAudio(): void;
  33761. /**
  33762. * Enables audio in the associated scene.
  33763. */
  33764. enableAudio(): void;
  33765. /**
  33766. * Switch audio to headphone output.
  33767. */
  33768. switchAudioModeForHeadphones(): void;
  33769. /**
  33770. * Switch audio to normal speakers.
  33771. */
  33772. switchAudioModeForNormalSpeakers(): void;
  33773. private _afterRender;
  33774. }
  33775. }
  33776. declare module BABYLON {
  33777. /**
  33778. * Wraps one or more Sound objects and selects one with random weight for playback.
  33779. */
  33780. export class WeightedSound {
  33781. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33782. loop: boolean;
  33783. private _coneInnerAngle;
  33784. private _coneOuterAngle;
  33785. private _volume;
  33786. /** A Sound is currently playing. */
  33787. isPlaying: boolean;
  33788. /** A Sound is currently paused. */
  33789. isPaused: boolean;
  33790. private _sounds;
  33791. private _weights;
  33792. private _currentIndex?;
  33793. /**
  33794. * Creates a new WeightedSound from the list of sounds given.
  33795. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33796. * @param sounds Array of Sounds that will be selected from.
  33797. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33798. */
  33799. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33800. /**
  33801. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33802. */
  33803. /**
  33804. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33805. */
  33806. directionalConeInnerAngle: number;
  33807. /**
  33808. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33809. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33810. */
  33811. /**
  33812. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33813. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33814. */
  33815. directionalConeOuterAngle: number;
  33816. /**
  33817. * Playback volume.
  33818. */
  33819. /**
  33820. * Playback volume.
  33821. */
  33822. volume: number;
  33823. private _onended;
  33824. /**
  33825. * Suspend playback
  33826. */
  33827. pause(): void;
  33828. /**
  33829. * Stop playback
  33830. */
  33831. stop(): void;
  33832. /**
  33833. * Start playback.
  33834. * @param startOffset Position the clip head at a specific time in seconds.
  33835. */
  33836. play(startOffset?: number): void;
  33837. }
  33838. }
  33839. declare module BABYLON {
  33840. /**
  33841. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33842. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33843. */
  33844. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33845. /**
  33846. * Gets the name of the behavior.
  33847. */
  33848. readonly name: string;
  33849. /**
  33850. * The easing function used by animations
  33851. */
  33852. static EasingFunction: BackEase;
  33853. /**
  33854. * The easing mode used by animations
  33855. */
  33856. static EasingMode: number;
  33857. /**
  33858. * The duration of the animation, in milliseconds
  33859. */
  33860. transitionDuration: number;
  33861. /**
  33862. * Length of the distance animated by the transition when lower radius is reached
  33863. */
  33864. lowerRadiusTransitionRange: number;
  33865. /**
  33866. * Length of the distance animated by the transition when upper radius is reached
  33867. */
  33868. upperRadiusTransitionRange: number;
  33869. private _autoTransitionRange;
  33870. /**
  33871. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33872. */
  33873. /**
  33874. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33875. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33876. */
  33877. autoTransitionRange: boolean;
  33878. private _attachedCamera;
  33879. private _onAfterCheckInputsObserver;
  33880. private _onMeshTargetChangedObserver;
  33881. /**
  33882. * Initializes the behavior.
  33883. */
  33884. init(): void;
  33885. /**
  33886. * Attaches the behavior to its arc rotate camera.
  33887. * @param camera Defines the camera to attach the behavior to
  33888. */
  33889. attach(camera: ArcRotateCamera): void;
  33890. /**
  33891. * Detaches the behavior from its current arc rotate camera.
  33892. */
  33893. detach(): void;
  33894. private _radiusIsAnimating;
  33895. private _radiusBounceTransition;
  33896. private _animatables;
  33897. private _cachedWheelPrecision;
  33898. /**
  33899. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33900. * @param radiusLimit The limit to check against.
  33901. * @return Bool to indicate if at limit.
  33902. */
  33903. private _isRadiusAtLimit;
  33904. /**
  33905. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33906. * @param radiusDelta The delta by which to animate to. Can be negative.
  33907. */
  33908. private _applyBoundRadiusAnimation;
  33909. /**
  33910. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33911. */
  33912. protected _clearAnimationLocks(): void;
  33913. /**
  33914. * Stops and removes all animations that have been applied to the camera
  33915. */
  33916. stopAllAnimations(): void;
  33917. }
  33918. }
  33919. declare module BABYLON {
  33920. /**
  33921. * 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.
  33922. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33923. */
  33924. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33925. /**
  33926. * Gets the name of the behavior.
  33927. */
  33928. readonly name: string;
  33929. private _mode;
  33930. private _radiusScale;
  33931. private _positionScale;
  33932. private _defaultElevation;
  33933. private _elevationReturnTime;
  33934. private _elevationReturnWaitTime;
  33935. private _zoomStopsAnimation;
  33936. private _framingTime;
  33937. /**
  33938. * The easing function used by animations
  33939. */
  33940. static EasingFunction: ExponentialEase;
  33941. /**
  33942. * The easing mode used by animations
  33943. */
  33944. static EasingMode: number;
  33945. /**
  33946. * Sets the current mode used by the behavior
  33947. */
  33948. /**
  33949. * Gets current mode used by the behavior.
  33950. */
  33951. mode: number;
  33952. /**
  33953. * Sets the scale applied to the radius (1 by default)
  33954. */
  33955. /**
  33956. * Gets the scale applied to the radius
  33957. */
  33958. radiusScale: number;
  33959. /**
  33960. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33961. */
  33962. /**
  33963. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33964. */
  33965. positionScale: number;
  33966. /**
  33967. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33968. * behaviour is triggered, in radians.
  33969. */
  33970. /**
  33971. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33972. * behaviour is triggered, in radians.
  33973. */
  33974. defaultElevation: number;
  33975. /**
  33976. * Sets the time (in milliseconds) taken to return to the default beta position.
  33977. * Negative value indicates camera should not return to default.
  33978. */
  33979. /**
  33980. * Gets the time (in milliseconds) taken to return to the default beta position.
  33981. * Negative value indicates camera should not return to default.
  33982. */
  33983. elevationReturnTime: number;
  33984. /**
  33985. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33986. */
  33987. /**
  33988. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33989. */
  33990. elevationReturnWaitTime: number;
  33991. /**
  33992. * Sets the flag that indicates if user zooming should stop animation.
  33993. */
  33994. /**
  33995. * Gets the flag that indicates if user zooming should stop animation.
  33996. */
  33997. zoomStopsAnimation: boolean;
  33998. /**
  33999. * Sets the transition time when framing the mesh, in milliseconds
  34000. */
  34001. /**
  34002. * Gets the transition time when framing the mesh, in milliseconds
  34003. */
  34004. framingTime: number;
  34005. /**
  34006. * Define if the behavior should automatically change the configured
  34007. * camera limits and sensibilities.
  34008. */
  34009. autoCorrectCameraLimitsAndSensibility: boolean;
  34010. private _onPrePointerObservableObserver;
  34011. private _onAfterCheckInputsObserver;
  34012. private _onMeshTargetChangedObserver;
  34013. private _attachedCamera;
  34014. private _isPointerDown;
  34015. private _lastInteractionTime;
  34016. /**
  34017. * Initializes the behavior.
  34018. */
  34019. init(): void;
  34020. /**
  34021. * Attaches the behavior to its arc rotate camera.
  34022. * @param camera Defines the camera to attach the behavior to
  34023. */
  34024. attach(camera: ArcRotateCamera): void;
  34025. /**
  34026. * Detaches the behavior from its current arc rotate camera.
  34027. */
  34028. detach(): void;
  34029. private _animatables;
  34030. private _betaIsAnimating;
  34031. private _betaTransition;
  34032. private _radiusTransition;
  34033. private _vectorTransition;
  34034. /**
  34035. * Targets the given mesh and updates zoom level accordingly.
  34036. * @param mesh The mesh to target.
  34037. * @param radius Optional. If a cached radius position already exists, overrides default.
  34038. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34039. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34040. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34041. */
  34042. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34043. /**
  34044. * Targets the given mesh with its children and updates zoom level accordingly.
  34045. * @param mesh The mesh to target.
  34046. * @param radius Optional. If a cached radius position already exists, overrides default.
  34047. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34048. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34049. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34050. */
  34051. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34052. /**
  34053. * Targets the given meshes with their children and updates zoom level accordingly.
  34054. * @param meshes The mesh to target.
  34055. * @param radius Optional. If a cached radius position already exists, overrides default.
  34056. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34057. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34058. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34059. */
  34060. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34061. /**
  34062. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34063. * @param minimumWorld Determines the smaller position of the bounding box extend
  34064. * @param maximumWorld Determines the bigger position of the bounding box extend
  34065. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34066. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34067. */
  34068. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34069. /**
  34070. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34071. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34072. * frustum width.
  34073. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34074. * to fully enclose the mesh in the viewing frustum.
  34075. */
  34076. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34077. /**
  34078. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34079. * is automatically returned to its default position (expected to be above ground plane).
  34080. */
  34081. private _maintainCameraAboveGround;
  34082. /**
  34083. * Returns the frustum slope based on the canvas ratio and camera FOV
  34084. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34085. */
  34086. private _getFrustumSlope;
  34087. /**
  34088. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34089. */
  34090. private _clearAnimationLocks;
  34091. /**
  34092. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34093. */
  34094. private _applyUserInteraction;
  34095. /**
  34096. * Stops and removes all animations that have been applied to the camera
  34097. */
  34098. stopAllAnimations(): void;
  34099. /**
  34100. * Gets a value indicating if the user is moving the camera
  34101. */
  34102. readonly isUserIsMoving: boolean;
  34103. /**
  34104. * The camera can move all the way towards the mesh.
  34105. */
  34106. static IgnoreBoundsSizeMode: number;
  34107. /**
  34108. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34109. */
  34110. static FitFrustumSidesMode: number;
  34111. }
  34112. }
  34113. declare module BABYLON {
  34114. /**
  34115. * Base class for Camera Pointer Inputs.
  34116. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34117. * for example usage.
  34118. */
  34119. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34120. /**
  34121. * Defines the camera the input is attached to.
  34122. */
  34123. abstract camera: Camera;
  34124. /**
  34125. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34126. */
  34127. protected _altKey: boolean;
  34128. protected _ctrlKey: boolean;
  34129. protected _metaKey: boolean;
  34130. protected _shiftKey: boolean;
  34131. /**
  34132. * Which mouse buttons were pressed at time of last mouse event.
  34133. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34134. */
  34135. protected _buttonsPressed: number;
  34136. /**
  34137. * Defines the buttons associated with the input to handle camera move.
  34138. */
  34139. buttons: number[];
  34140. /**
  34141. * Attach the input controls to a specific dom element to get the input from.
  34142. * @param element Defines the element the controls should be listened from
  34143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34144. */
  34145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34146. /**
  34147. * Detach the current controls from the specified dom element.
  34148. * @param element Defines the element to stop listening the inputs from
  34149. */
  34150. detachControl(element: Nullable<HTMLElement>): void;
  34151. /**
  34152. * Gets the class name of the current input.
  34153. * @returns the class name
  34154. */
  34155. getClassName(): string;
  34156. /**
  34157. * Get the friendly name associated with the input class.
  34158. * @returns the input friendly name
  34159. */
  34160. getSimpleName(): string;
  34161. /**
  34162. * Called on pointer POINTERDOUBLETAP event.
  34163. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34164. */
  34165. protected onDoubleTap(type: string): void;
  34166. /**
  34167. * Called on pointer POINTERMOVE event if only a single touch is active.
  34168. * Override this method to provide functionality.
  34169. */
  34170. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34171. /**
  34172. * Called on pointer POINTERMOVE event if multiple touches are active.
  34173. * Override this method to provide functionality.
  34174. */
  34175. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34176. /**
  34177. * Called on JS contextmenu event.
  34178. * Override this method to provide functionality.
  34179. */
  34180. protected onContextMenu(evt: PointerEvent): void;
  34181. /**
  34182. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34183. * press.
  34184. * Override this method to provide functionality.
  34185. */
  34186. protected onButtonDown(evt: PointerEvent): void;
  34187. /**
  34188. * Called each time a new POINTERUP event occurs. Ie, for each button
  34189. * release.
  34190. * Override this method to provide functionality.
  34191. */
  34192. protected onButtonUp(evt: PointerEvent): void;
  34193. /**
  34194. * Called when window becomes inactive.
  34195. * Override this method to provide functionality.
  34196. */
  34197. protected onLostFocus(): void;
  34198. private _pointerInput;
  34199. private _observer;
  34200. private _onLostFocus;
  34201. private pointA;
  34202. private pointB;
  34203. }
  34204. }
  34205. declare module BABYLON {
  34206. /**
  34207. * Manage the pointers inputs to control an arc rotate camera.
  34208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34209. */
  34210. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34211. /**
  34212. * Defines the camera the input is attached to.
  34213. */
  34214. camera: ArcRotateCamera;
  34215. /**
  34216. * Gets the class name of the current input.
  34217. * @returns the class name
  34218. */
  34219. getClassName(): string;
  34220. /**
  34221. * Defines the buttons associated with the input to handle camera move.
  34222. */
  34223. buttons: number[];
  34224. /**
  34225. * Defines the pointer angular sensibility along the X axis or how fast is
  34226. * the camera rotating.
  34227. */
  34228. angularSensibilityX: number;
  34229. /**
  34230. * Defines the pointer angular sensibility along the Y axis or how fast is
  34231. * the camera rotating.
  34232. */
  34233. angularSensibilityY: number;
  34234. /**
  34235. * Defines the pointer pinch precision or how fast is the camera zooming.
  34236. */
  34237. pinchPrecision: number;
  34238. /**
  34239. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34240. * from 0.
  34241. * It defines the percentage of current camera.radius to use as delta when
  34242. * pinch zoom is used.
  34243. */
  34244. pinchDeltaPercentage: number;
  34245. /**
  34246. * Defines the pointer panning sensibility or how fast is the camera moving.
  34247. */
  34248. panningSensibility: number;
  34249. /**
  34250. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34251. */
  34252. multiTouchPanning: boolean;
  34253. /**
  34254. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34255. * zoom (pinch) through multitouch.
  34256. */
  34257. multiTouchPanAndZoom: boolean;
  34258. /**
  34259. * Revers pinch action direction.
  34260. */
  34261. pinchInwards: boolean;
  34262. private _isPanClick;
  34263. private _twoFingerActivityCount;
  34264. private _isPinching;
  34265. /**
  34266. * Called on pointer POINTERMOVE event if only a single touch is active.
  34267. */
  34268. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34269. /**
  34270. * Called on pointer POINTERDOUBLETAP event.
  34271. */
  34272. protected onDoubleTap(type: string): void;
  34273. /**
  34274. * Called on pointer POINTERMOVE event if multiple touches are active.
  34275. */
  34276. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34277. /**
  34278. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34279. * press.
  34280. */
  34281. protected onButtonDown(evt: PointerEvent): void;
  34282. /**
  34283. * Called each time a new POINTERUP event occurs. Ie, for each button
  34284. * release.
  34285. */
  34286. protected onButtonUp(evt: PointerEvent): void;
  34287. /**
  34288. * Called when window becomes inactive.
  34289. */
  34290. protected onLostFocus(): void;
  34291. }
  34292. }
  34293. declare module BABYLON {
  34294. /**
  34295. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34297. */
  34298. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34299. /**
  34300. * Defines the camera the input is attached to.
  34301. */
  34302. camera: ArcRotateCamera;
  34303. /**
  34304. * Defines the list of key codes associated with the up action (increase alpha)
  34305. */
  34306. keysUp: number[];
  34307. /**
  34308. * Defines the list of key codes associated with the down action (decrease alpha)
  34309. */
  34310. keysDown: number[];
  34311. /**
  34312. * Defines the list of key codes associated with the left action (increase beta)
  34313. */
  34314. keysLeft: number[];
  34315. /**
  34316. * Defines the list of key codes associated with the right action (decrease beta)
  34317. */
  34318. keysRight: number[];
  34319. /**
  34320. * Defines the list of key codes associated with the reset action.
  34321. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34322. */
  34323. keysReset: number[];
  34324. /**
  34325. * Defines the panning sensibility of the inputs.
  34326. * (How fast is the camera paning)
  34327. */
  34328. panningSensibility: number;
  34329. /**
  34330. * Defines the zooming sensibility of the inputs.
  34331. * (How fast is the camera zooming)
  34332. */
  34333. zoomingSensibility: number;
  34334. /**
  34335. * Defines wether maintaining the alt key down switch the movement mode from
  34336. * orientation to zoom.
  34337. */
  34338. useAltToZoom: boolean;
  34339. /**
  34340. * Rotation speed of the camera
  34341. */
  34342. angularSpeed: number;
  34343. private _keys;
  34344. private _ctrlPressed;
  34345. private _altPressed;
  34346. private _onCanvasBlurObserver;
  34347. private _onKeyboardObserver;
  34348. private _engine;
  34349. private _scene;
  34350. /**
  34351. * Attach the input controls to a specific dom element to get the input from.
  34352. * @param element Defines the element the controls should be listened from
  34353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34354. */
  34355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34356. /**
  34357. * Detach the current controls from the specified dom element.
  34358. * @param element Defines the element to stop listening the inputs from
  34359. */
  34360. detachControl(element: Nullable<HTMLElement>): void;
  34361. /**
  34362. * Update the current camera state depending on the inputs that have been used this frame.
  34363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34364. */
  34365. checkInputs(): void;
  34366. /**
  34367. * Gets the class name of the current intput.
  34368. * @returns the class name
  34369. */
  34370. getClassName(): string;
  34371. /**
  34372. * Get the friendly name associated with the input class.
  34373. * @returns the input friendly name
  34374. */
  34375. getSimpleName(): string;
  34376. }
  34377. }
  34378. declare module BABYLON {
  34379. /**
  34380. * Manage the mouse wheel inputs to control an arc rotate camera.
  34381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34382. */
  34383. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34384. /**
  34385. * Defines the camera the input is attached to.
  34386. */
  34387. camera: ArcRotateCamera;
  34388. /**
  34389. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34390. */
  34391. wheelPrecision: number;
  34392. /**
  34393. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34394. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34395. */
  34396. wheelDeltaPercentage: number;
  34397. private _wheel;
  34398. private _observer;
  34399. private computeDeltaFromMouseWheelLegacyEvent;
  34400. /**
  34401. * Attach the input controls to a specific dom element to get the input from.
  34402. * @param element Defines the element the controls should be listened from
  34403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34404. */
  34405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34406. /**
  34407. * Detach the current controls from the specified dom element.
  34408. * @param element Defines the element to stop listening the inputs from
  34409. */
  34410. detachControl(element: Nullable<HTMLElement>): void;
  34411. /**
  34412. * Gets the class name of the current intput.
  34413. * @returns the class name
  34414. */
  34415. getClassName(): string;
  34416. /**
  34417. * Get the friendly name associated with the input class.
  34418. * @returns the input friendly name
  34419. */
  34420. getSimpleName(): string;
  34421. }
  34422. }
  34423. declare module BABYLON {
  34424. /**
  34425. * Default Inputs manager for the ArcRotateCamera.
  34426. * It groups all the default supported inputs for ease of use.
  34427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34428. */
  34429. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34430. /**
  34431. * Instantiates a new ArcRotateCameraInputsManager.
  34432. * @param camera Defines the camera the inputs belong to
  34433. */
  34434. constructor(camera: ArcRotateCamera);
  34435. /**
  34436. * Add mouse wheel input support to the input manager.
  34437. * @returns the current input manager
  34438. */
  34439. addMouseWheel(): ArcRotateCameraInputsManager;
  34440. /**
  34441. * Add pointers input support to the input manager.
  34442. * @returns the current input manager
  34443. */
  34444. addPointers(): ArcRotateCameraInputsManager;
  34445. /**
  34446. * Add keyboard input support to the input manager.
  34447. * @returns the current input manager
  34448. */
  34449. addKeyboard(): ArcRotateCameraInputsManager;
  34450. }
  34451. }
  34452. declare module BABYLON {
  34453. /**
  34454. * This represents an orbital type of camera.
  34455. *
  34456. * 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.
  34457. * 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.
  34458. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34459. */
  34460. export class ArcRotateCamera extends TargetCamera {
  34461. /**
  34462. * Defines the rotation angle of the camera along the longitudinal axis.
  34463. */
  34464. alpha: number;
  34465. /**
  34466. * Defines the rotation angle of the camera along the latitudinal axis.
  34467. */
  34468. beta: number;
  34469. /**
  34470. * Defines the radius of the camera from it s target point.
  34471. */
  34472. radius: number;
  34473. protected _target: Vector3;
  34474. protected _targetHost: Nullable<AbstractMesh>;
  34475. /**
  34476. * Defines the target point of the camera.
  34477. * The camera looks towards it form the radius distance.
  34478. */
  34479. target: Vector3;
  34480. /**
  34481. * Define the current local position of the camera in the scene
  34482. */
  34483. position: Vector3;
  34484. protected _upVector: Vector3;
  34485. protected _upToYMatrix: Matrix;
  34486. protected _YToUpMatrix: Matrix;
  34487. /**
  34488. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34489. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34490. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34491. */
  34492. upVector: Vector3;
  34493. /**
  34494. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34495. */
  34496. setMatUp(): void;
  34497. /**
  34498. * Current inertia value on the longitudinal axis.
  34499. * The bigger this number the longer it will take for the camera to stop.
  34500. */
  34501. inertialAlphaOffset: number;
  34502. /**
  34503. * Current inertia value on the latitudinal axis.
  34504. * The bigger this number the longer it will take for the camera to stop.
  34505. */
  34506. inertialBetaOffset: number;
  34507. /**
  34508. * Current inertia value on the radius axis.
  34509. * The bigger this number the longer it will take for the camera to stop.
  34510. */
  34511. inertialRadiusOffset: number;
  34512. /**
  34513. * Minimum allowed angle on the longitudinal axis.
  34514. * This can help limiting how the Camera is able to move in the scene.
  34515. */
  34516. lowerAlphaLimit: Nullable<number>;
  34517. /**
  34518. * Maximum allowed angle on the longitudinal axis.
  34519. * This can help limiting how the Camera is able to move in the scene.
  34520. */
  34521. upperAlphaLimit: Nullable<number>;
  34522. /**
  34523. * Minimum allowed angle on the latitudinal axis.
  34524. * This can help limiting how the Camera is able to move in the scene.
  34525. */
  34526. lowerBetaLimit: number;
  34527. /**
  34528. * Maximum allowed angle on the latitudinal axis.
  34529. * This can help limiting how the Camera is able to move in the scene.
  34530. */
  34531. upperBetaLimit: number;
  34532. /**
  34533. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34534. * This can help limiting how the Camera is able to move in the scene.
  34535. */
  34536. lowerRadiusLimit: Nullable<number>;
  34537. /**
  34538. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34539. * This can help limiting how the Camera is able to move in the scene.
  34540. */
  34541. upperRadiusLimit: Nullable<number>;
  34542. /**
  34543. * Defines the current inertia value used during panning of the camera along the X axis.
  34544. */
  34545. inertialPanningX: number;
  34546. /**
  34547. * Defines the current inertia value used during panning of the camera along the Y axis.
  34548. */
  34549. inertialPanningY: number;
  34550. /**
  34551. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34552. * Basically if your fingers moves away from more than this distance you will be considered
  34553. * in pinch mode.
  34554. */
  34555. pinchToPanMaxDistance: number;
  34556. /**
  34557. * Defines the maximum distance the camera can pan.
  34558. * This could help keeping the cammera always in your scene.
  34559. */
  34560. panningDistanceLimit: Nullable<number>;
  34561. /**
  34562. * Defines the target of the camera before paning.
  34563. */
  34564. panningOriginTarget: Vector3;
  34565. /**
  34566. * Defines the value of the inertia used during panning.
  34567. * 0 would mean stop inertia and one would mean no decelleration at all.
  34568. */
  34569. panningInertia: number;
  34570. /**
  34571. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34572. */
  34573. angularSensibilityX: number;
  34574. /**
  34575. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34576. */
  34577. angularSensibilityY: number;
  34578. /**
  34579. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34580. */
  34581. pinchPrecision: number;
  34582. /**
  34583. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34584. * It will be used instead of pinchDeltaPrecision if different from 0.
  34585. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34586. */
  34587. pinchDeltaPercentage: number;
  34588. /**
  34589. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34590. */
  34591. panningSensibility: number;
  34592. /**
  34593. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34594. */
  34595. keysUp: number[];
  34596. /**
  34597. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34598. */
  34599. keysDown: number[];
  34600. /**
  34601. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34602. */
  34603. keysLeft: number[];
  34604. /**
  34605. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34606. */
  34607. keysRight: number[];
  34608. /**
  34609. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34610. */
  34611. wheelPrecision: number;
  34612. /**
  34613. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34614. * It will be used instead of pinchDeltaPrecision if different from 0.
  34615. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34616. */
  34617. wheelDeltaPercentage: number;
  34618. /**
  34619. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34620. */
  34621. zoomOnFactor: number;
  34622. /**
  34623. * Defines a screen offset for the camera position.
  34624. */
  34625. targetScreenOffset: Vector2;
  34626. /**
  34627. * Allows the camera to be completely reversed.
  34628. * If false the camera can not arrive upside down.
  34629. */
  34630. allowUpsideDown: boolean;
  34631. /**
  34632. * Define if double tap/click is used to restore the previously saved state of the camera.
  34633. */
  34634. useInputToRestoreState: boolean;
  34635. /** @hidden */ viewMatrix: Matrix;
  34636. /** @hidden */ useCtrlForPanning: boolean;
  34637. /** @hidden */ panningMouseButton: number;
  34638. /**
  34639. * Defines the input associated to the camera.
  34640. */
  34641. inputs: ArcRotateCameraInputsManager;
  34642. /** @hidden */ reset: () => void;
  34643. /**
  34644. * Defines the allowed panning axis.
  34645. */
  34646. panningAxis: Vector3;
  34647. protected _localDirection: Vector3;
  34648. protected _transformedDirection: Vector3;
  34649. private _bouncingBehavior;
  34650. /**
  34651. * Gets the bouncing behavior of the camera if it has been enabled.
  34652. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34653. */
  34654. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34655. /**
  34656. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34657. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34658. */
  34659. useBouncingBehavior: boolean;
  34660. private _framingBehavior;
  34661. /**
  34662. * Gets the framing behavior of the camera if it has been enabled.
  34663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34664. */
  34665. readonly framingBehavior: Nullable<FramingBehavior>;
  34666. /**
  34667. * Defines if the framing behavior of the camera is enabled on the camera.
  34668. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34669. */
  34670. useFramingBehavior: boolean;
  34671. private _autoRotationBehavior;
  34672. /**
  34673. * Gets the auto rotation behavior of the camera if it has been enabled.
  34674. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34675. */
  34676. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34677. /**
  34678. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34680. */
  34681. useAutoRotationBehavior: boolean;
  34682. /**
  34683. * Observable triggered when the mesh target has been changed on the camera.
  34684. */
  34685. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34686. /**
  34687. * Event raised when the camera is colliding with a mesh.
  34688. */
  34689. onCollide: (collidedMesh: AbstractMesh) => void;
  34690. /**
  34691. * Defines whether the camera should check collision with the objects oh the scene.
  34692. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34693. */
  34694. checkCollisions: boolean;
  34695. /**
  34696. * Defines the collision radius of the camera.
  34697. * This simulates a sphere around the camera.
  34698. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34699. */
  34700. collisionRadius: Vector3;
  34701. protected _collider: Collider;
  34702. protected _previousPosition: Vector3;
  34703. protected _collisionVelocity: Vector3;
  34704. protected _newPosition: Vector3;
  34705. protected _previousAlpha: number;
  34706. protected _previousBeta: number;
  34707. protected _previousRadius: number;
  34708. protected _collisionTriggered: boolean;
  34709. protected _targetBoundingCenter: Nullable<Vector3>;
  34710. private _computationVector;
  34711. /**
  34712. * Instantiates a new ArcRotateCamera in a given scene
  34713. * @param name Defines the name of the camera
  34714. * @param alpha Defines the camera rotation along the logitudinal axis
  34715. * @param beta Defines the camera rotation along the latitudinal axis
  34716. * @param radius Defines the camera distance from its target
  34717. * @param target Defines the camera target
  34718. * @param scene Defines the scene the camera belongs to
  34719. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34720. */
  34721. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34722. /** @hidden */ initCache(): void;
  34723. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34724. protected _getTargetPosition(): Vector3;
  34725. private _storedAlpha;
  34726. private _storedBeta;
  34727. private _storedRadius;
  34728. private _storedTarget;
  34729. /**
  34730. * Stores the current state of the camera (alpha, beta, radius and target)
  34731. * @returns the camera itself
  34732. */
  34733. storeState(): Camera;
  34734. /**
  34735. * @hidden
  34736. * Restored camera state. You must call storeState() first
  34737. */ restoreStateValues(): boolean;
  34738. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34739. /**
  34740. * Attached controls to the current camera.
  34741. * @param element Defines the element the controls should be listened from
  34742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34743. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34744. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34745. */
  34746. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34747. /**
  34748. * Detach the current controls from the camera.
  34749. * The camera will stop reacting to inputs.
  34750. * @param element Defines the element to stop listening the inputs from
  34751. */
  34752. detachControl(element: HTMLElement): void;
  34753. /** @hidden */ checkInputs(): void;
  34754. protected _checkLimits(): void;
  34755. /**
  34756. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34757. */
  34758. rebuildAnglesAndRadius(): void;
  34759. /**
  34760. * Use a position to define the current camera related information like aplha, beta and radius
  34761. * @param position Defines the position to set the camera at
  34762. */
  34763. setPosition(position: Vector3): void;
  34764. /**
  34765. * Defines the target the camera should look at.
  34766. * This will automatically adapt alpha beta and radius to fit within the new target.
  34767. * @param target Defines the new target as a Vector or a mesh
  34768. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34769. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34770. */
  34771. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34772. /** @hidden */ getViewMatrix(): Matrix;
  34773. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34774. /**
  34775. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34776. * @param meshes Defines the mesh to zoom on
  34777. * @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)
  34778. */
  34779. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34780. /**
  34781. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34782. * The target will be changed but the radius
  34783. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34784. * @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)
  34785. */
  34786. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34787. min: Vector3;
  34788. max: Vector3;
  34789. distance: number;
  34790. }, doNotUpdateMaxZ?: boolean): void;
  34791. /**
  34792. * @override
  34793. * Override Camera.createRigCamera
  34794. */
  34795. createRigCamera(name: string, cameraIndex: number): Camera;
  34796. /**
  34797. * @hidden
  34798. * @override
  34799. * Override Camera._updateRigCameras
  34800. */ updateRigCameras(): void;
  34801. /**
  34802. * Destroy the camera and release the current resources hold by it.
  34803. */
  34804. dispose(): void;
  34805. /**
  34806. * Gets the current object class name.
  34807. * @return the class name
  34808. */
  34809. getClassName(): string;
  34810. }
  34811. }
  34812. declare module BABYLON {
  34813. /**
  34814. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34815. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34816. */
  34817. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34818. /**
  34819. * Gets the name of the behavior.
  34820. */
  34821. readonly name: string;
  34822. private _zoomStopsAnimation;
  34823. private _idleRotationSpeed;
  34824. private _idleRotationWaitTime;
  34825. private _idleRotationSpinupTime;
  34826. /**
  34827. * Sets the flag that indicates if user zooming should stop animation.
  34828. */
  34829. /**
  34830. * Gets the flag that indicates if user zooming should stop animation.
  34831. */
  34832. zoomStopsAnimation: boolean;
  34833. /**
  34834. * Sets the default speed at which the camera rotates around the model.
  34835. */
  34836. /**
  34837. * Gets the default speed at which the camera rotates around the model.
  34838. */
  34839. idleRotationSpeed: number;
  34840. /**
  34841. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34842. */
  34843. /**
  34844. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34845. */
  34846. idleRotationWaitTime: number;
  34847. /**
  34848. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34849. */
  34850. /**
  34851. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34852. */
  34853. idleRotationSpinupTime: number;
  34854. /**
  34855. * Gets a value indicating if the camera is currently rotating because of this behavior
  34856. */
  34857. readonly rotationInProgress: boolean;
  34858. private _onPrePointerObservableObserver;
  34859. private _onAfterCheckInputsObserver;
  34860. private _attachedCamera;
  34861. private _isPointerDown;
  34862. private _lastFrameTime;
  34863. private _lastInteractionTime;
  34864. private _cameraRotationSpeed;
  34865. /**
  34866. * Initializes the behavior.
  34867. */
  34868. init(): void;
  34869. /**
  34870. * Attaches the behavior to its arc rotate camera.
  34871. * @param camera Defines the camera to attach the behavior to
  34872. */
  34873. attach(camera: ArcRotateCamera): void;
  34874. /**
  34875. * Detaches the behavior from its current arc rotate camera.
  34876. */
  34877. detach(): void;
  34878. /**
  34879. * Returns true if user is scrolling.
  34880. * @return true if user is scrolling.
  34881. */
  34882. private _userIsZooming;
  34883. private _lastFrameRadius;
  34884. private _shouldAnimationStopForInteraction;
  34885. /**
  34886. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34887. */
  34888. private _applyUserInteraction;
  34889. private _userIsMoving;
  34890. }
  34891. }
  34892. declare module BABYLON {
  34893. /**
  34894. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34895. */
  34896. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34897. private ui;
  34898. /**
  34899. * The name of the behavior
  34900. */
  34901. name: string;
  34902. /**
  34903. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34904. */
  34905. distanceAwayFromFace: number;
  34906. /**
  34907. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34908. */
  34909. distanceAwayFromBottomOfFace: number;
  34910. private _faceVectors;
  34911. private _target;
  34912. private _scene;
  34913. private _onRenderObserver;
  34914. private _tmpMatrix;
  34915. private _tmpVector;
  34916. /**
  34917. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34918. * @param ui The transform node that should be attched to the mesh
  34919. */
  34920. constructor(ui: TransformNode);
  34921. /**
  34922. * Initializes the behavior
  34923. */
  34924. init(): void;
  34925. private _closestFace;
  34926. private _zeroVector;
  34927. private _lookAtTmpMatrix;
  34928. private _lookAtToRef;
  34929. /**
  34930. * Attaches the AttachToBoxBehavior to the passed in mesh
  34931. * @param target The mesh that the specified node will be attached to
  34932. */
  34933. attach(target: Mesh): void;
  34934. /**
  34935. * Detaches the behavior from the mesh
  34936. */
  34937. detach(): void;
  34938. }
  34939. }
  34940. declare module BABYLON {
  34941. /**
  34942. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34943. */
  34944. export class FadeInOutBehavior implements Behavior<Mesh> {
  34945. /**
  34946. * Time in milliseconds to delay before fading in (Default: 0)
  34947. */
  34948. delay: number;
  34949. /**
  34950. * Time in milliseconds for the mesh to fade in (Default: 300)
  34951. */
  34952. fadeInTime: number;
  34953. private _millisecondsPerFrame;
  34954. private _hovered;
  34955. private _hoverValue;
  34956. private _ownerNode;
  34957. /**
  34958. * Instatiates the FadeInOutBehavior
  34959. */
  34960. constructor();
  34961. /**
  34962. * The name of the behavior
  34963. */
  34964. readonly name: string;
  34965. /**
  34966. * Initializes the behavior
  34967. */
  34968. init(): void;
  34969. /**
  34970. * Attaches the fade behavior on the passed in mesh
  34971. * @param ownerNode The mesh that will be faded in/out once attached
  34972. */
  34973. attach(ownerNode: Mesh): void;
  34974. /**
  34975. * Detaches the behavior from the mesh
  34976. */
  34977. detach(): void;
  34978. /**
  34979. * Triggers the mesh to begin fading in or out
  34980. * @param value if the object should fade in or out (true to fade in)
  34981. */
  34982. fadeIn(value: boolean): void;
  34983. private _update;
  34984. private _setAllVisibility;
  34985. }
  34986. }
  34987. declare module BABYLON {
  34988. /**
  34989. * Class containing a set of static utilities functions for managing Pivots
  34990. * @hidden
  34991. */
  34992. export class PivotTools {
  34993. private static _PivotCached;
  34994. private static _OldPivotPoint;
  34995. private static _PivotTranslation;
  34996. private static _PivotTmpVector;
  34997. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34998. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34999. }
  35000. }
  35001. declare module BABYLON {
  35002. /**
  35003. * Class containing static functions to help procedurally build meshes
  35004. */
  35005. export class PlaneBuilder {
  35006. /**
  35007. * Creates a plane mesh
  35008. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35009. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35010. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35012. * * 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
  35013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35014. * @param name defines the name of the mesh
  35015. * @param options defines the options used to create the mesh
  35016. * @param scene defines the hosting scene
  35017. * @returns the plane mesh
  35018. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35019. */
  35020. static CreatePlane(name: string, options: {
  35021. size?: number;
  35022. width?: number;
  35023. height?: number;
  35024. sideOrientation?: number;
  35025. frontUVs?: Vector4;
  35026. backUVs?: Vector4;
  35027. updatable?: boolean;
  35028. sourcePlane?: Plane;
  35029. }, scene?: Nullable<Scene>): Mesh;
  35030. }
  35031. }
  35032. declare module BABYLON {
  35033. /**
  35034. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35035. */
  35036. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35037. private static _AnyMouseID;
  35038. private _attachedNode;
  35039. private _dragPlane;
  35040. private _scene;
  35041. private _pointerObserver;
  35042. private _beforeRenderObserver;
  35043. private static _planeScene;
  35044. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35045. /**
  35046. * 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)
  35047. */
  35048. maxDragAngle: number;
  35049. /**
  35050. * @hidden
  35051. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  35052. /**
  35053. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35054. */
  35055. currentDraggingPointerID: number;
  35056. /**
  35057. * The last position where the pointer hit the drag plane in world space
  35058. */
  35059. lastDragPosition: Vector3;
  35060. /**
  35061. * If the behavior is currently in a dragging state
  35062. */
  35063. dragging: boolean;
  35064. /**
  35065. * 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)
  35066. */
  35067. dragDeltaRatio: number;
  35068. /**
  35069. * If the drag plane orientation should be updated during the dragging (Default: true)
  35070. */
  35071. updateDragPlane: boolean;
  35072. private _debugMode;
  35073. private _moving;
  35074. /**
  35075. * Fires each time the attached mesh is dragged with the pointer
  35076. * * delta between last drag position and current drag position in world space
  35077. * * dragDistance along the drag axis
  35078. * * dragPlaneNormal normal of the current drag plane used during the drag
  35079. * * dragPlanePoint in world space where the drag intersects the drag plane
  35080. */
  35081. onDragObservable: Observable<{
  35082. delta: Vector3;
  35083. dragPlanePoint: Vector3;
  35084. dragPlaneNormal: Vector3;
  35085. dragDistance: number;
  35086. pointerId: number;
  35087. }>;
  35088. /**
  35089. * Fires each time a drag begins (eg. mouse down on mesh)
  35090. */
  35091. onDragStartObservable: Observable<{
  35092. dragPlanePoint: Vector3;
  35093. pointerId: number;
  35094. }>;
  35095. /**
  35096. * Fires each time a drag ends (eg. mouse release after drag)
  35097. */
  35098. onDragEndObservable: Observable<{
  35099. dragPlanePoint: Vector3;
  35100. pointerId: number;
  35101. }>;
  35102. /**
  35103. * If the attached mesh should be moved when dragged
  35104. */
  35105. moveAttached: boolean;
  35106. /**
  35107. * If the drag behavior will react to drag events (Default: true)
  35108. */
  35109. enabled: boolean;
  35110. /**
  35111. * If camera controls should be detached during the drag
  35112. */
  35113. detachCameraControls: boolean;
  35114. /**
  35115. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35116. */
  35117. useObjectOrienationForDragging: boolean;
  35118. private _options;
  35119. /**
  35120. * Creates a pointer drag behavior that can be attached to a mesh
  35121. * @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)
  35122. */
  35123. constructor(options?: {
  35124. dragAxis?: Vector3;
  35125. dragPlaneNormal?: Vector3;
  35126. });
  35127. /**
  35128. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35129. */
  35130. validateDrag: (targetPosition: Vector3) => boolean;
  35131. /**
  35132. * The name of the behavior
  35133. */
  35134. readonly name: string;
  35135. /**
  35136. * Initializes the behavior
  35137. */
  35138. init(): void;
  35139. private _tmpVector;
  35140. private _alternatePickedPoint;
  35141. private _worldDragAxis;
  35142. private _targetPosition;
  35143. private _attachedElement;
  35144. /**
  35145. * Attaches the drag behavior the passed in mesh
  35146. * @param ownerNode The mesh that will be dragged around once attached
  35147. */
  35148. attach(ownerNode: AbstractMesh): void;
  35149. /**
  35150. * Force relase the drag action by code.
  35151. */
  35152. releaseDrag(): void;
  35153. private _startDragRay;
  35154. private _lastPointerRay;
  35155. /**
  35156. * Simulates the start of a pointer drag event on the behavior
  35157. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35158. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35159. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35160. */
  35161. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35162. private _startDrag;
  35163. private _dragDelta;
  35164. private _moveDrag;
  35165. private _pickWithRayOnDragPlane;
  35166. private _pointA;
  35167. private _pointB;
  35168. private _pointC;
  35169. private _lineA;
  35170. private _lineB;
  35171. private _localAxis;
  35172. private _lookAt;
  35173. private _updateDragPlanePosition;
  35174. /**
  35175. * Detaches the behavior from the mesh
  35176. */
  35177. detach(): void;
  35178. }
  35179. }
  35180. declare module BABYLON {
  35181. /**
  35182. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35183. */
  35184. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35185. private _dragBehaviorA;
  35186. private _dragBehaviorB;
  35187. private _startDistance;
  35188. private _initialScale;
  35189. private _targetScale;
  35190. private _ownerNode;
  35191. private _sceneRenderObserver;
  35192. /**
  35193. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35194. */
  35195. constructor();
  35196. /**
  35197. * The name of the behavior
  35198. */
  35199. readonly name: string;
  35200. /**
  35201. * Initializes the behavior
  35202. */
  35203. init(): void;
  35204. private _getCurrentDistance;
  35205. /**
  35206. * Attaches the scale behavior the passed in mesh
  35207. * @param ownerNode The mesh that will be scaled around once attached
  35208. */
  35209. attach(ownerNode: Mesh): void;
  35210. /**
  35211. * Detaches the behavior from the mesh
  35212. */
  35213. detach(): void;
  35214. }
  35215. }
  35216. declare module BABYLON {
  35217. /**
  35218. * 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
  35219. */
  35220. export class SixDofDragBehavior implements Behavior<Mesh> {
  35221. private static _virtualScene;
  35222. private _ownerNode;
  35223. private _sceneRenderObserver;
  35224. private _scene;
  35225. private _targetPosition;
  35226. private _virtualOriginMesh;
  35227. private _virtualDragMesh;
  35228. private _pointerObserver;
  35229. private _moving;
  35230. private _startingOrientation;
  35231. /**
  35232. * 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)
  35233. */
  35234. private zDragFactor;
  35235. /**
  35236. * If the object should rotate to face the drag origin
  35237. */
  35238. rotateDraggedObject: boolean;
  35239. /**
  35240. * If the behavior is currently in a dragging state
  35241. */
  35242. dragging: boolean;
  35243. /**
  35244. * 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)
  35245. */
  35246. dragDeltaRatio: number;
  35247. /**
  35248. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35249. */
  35250. currentDraggingPointerID: number;
  35251. /**
  35252. * If camera controls should be detached during the drag
  35253. */
  35254. detachCameraControls: boolean;
  35255. /**
  35256. * Fires each time a drag starts
  35257. */
  35258. onDragStartObservable: Observable<{}>;
  35259. /**
  35260. * Fires each time a drag ends (eg. mouse release after drag)
  35261. */
  35262. onDragEndObservable: Observable<{}>;
  35263. /**
  35264. * 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
  35265. */
  35266. constructor();
  35267. /**
  35268. * The name of the behavior
  35269. */
  35270. readonly name: string;
  35271. /**
  35272. * Initializes the behavior
  35273. */
  35274. init(): void;
  35275. /**
  35276. * Attaches the scale behavior the passed in mesh
  35277. * @param ownerNode The mesh that will be scaled around once attached
  35278. */
  35279. attach(ownerNode: Mesh): void;
  35280. /**
  35281. * Detaches the behavior from the mesh
  35282. */
  35283. detach(): void;
  35284. }
  35285. }
  35286. declare module BABYLON {
  35287. /**
  35288. * Class used to apply inverse kinematics to bones
  35289. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35290. */
  35291. export class BoneIKController {
  35292. private static _tmpVecs;
  35293. private static _tmpQuat;
  35294. private static _tmpMats;
  35295. /**
  35296. * Gets or sets the target mesh
  35297. */
  35298. targetMesh: AbstractMesh;
  35299. /** Gets or sets the mesh used as pole */
  35300. poleTargetMesh: AbstractMesh;
  35301. /**
  35302. * Gets or sets the bone used as pole
  35303. */
  35304. poleTargetBone: Nullable<Bone>;
  35305. /**
  35306. * Gets or sets the target position
  35307. */
  35308. targetPosition: Vector3;
  35309. /**
  35310. * Gets or sets the pole target position
  35311. */
  35312. poleTargetPosition: Vector3;
  35313. /**
  35314. * Gets or sets the pole target local offset
  35315. */
  35316. poleTargetLocalOffset: Vector3;
  35317. /**
  35318. * Gets or sets the pole angle
  35319. */
  35320. poleAngle: number;
  35321. /**
  35322. * Gets or sets the mesh associated with the controller
  35323. */
  35324. mesh: AbstractMesh;
  35325. /**
  35326. * 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)
  35327. */
  35328. slerpAmount: number;
  35329. private _bone1Quat;
  35330. private _bone1Mat;
  35331. private _bone2Ang;
  35332. private _bone1;
  35333. private _bone2;
  35334. private _bone1Length;
  35335. private _bone2Length;
  35336. private _maxAngle;
  35337. private _maxReach;
  35338. private _rightHandedSystem;
  35339. private _bendAxis;
  35340. private _slerping;
  35341. private _adjustRoll;
  35342. /**
  35343. * Gets or sets maximum allowed angle
  35344. */
  35345. maxAngle: number;
  35346. /**
  35347. * Creates a new BoneIKController
  35348. * @param mesh defines the mesh to control
  35349. * @param bone defines the bone to control
  35350. * @param options defines options to set up the controller
  35351. */
  35352. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35353. targetMesh?: AbstractMesh;
  35354. poleTargetMesh?: AbstractMesh;
  35355. poleTargetBone?: Bone;
  35356. poleTargetLocalOffset?: Vector3;
  35357. poleAngle?: number;
  35358. bendAxis?: Vector3;
  35359. maxAngle?: number;
  35360. slerpAmount?: number;
  35361. });
  35362. private _setMaxAngle;
  35363. /**
  35364. * Force the controller to update the bones
  35365. */
  35366. update(): void;
  35367. }
  35368. }
  35369. declare module BABYLON {
  35370. /**
  35371. * Class used to make a bone look toward a point in space
  35372. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35373. */
  35374. export class BoneLookController {
  35375. private static _tmpVecs;
  35376. private static _tmpQuat;
  35377. private static _tmpMats;
  35378. /**
  35379. * The target Vector3 that the bone will look at
  35380. */
  35381. target: Vector3;
  35382. /**
  35383. * The mesh that the bone is attached to
  35384. */
  35385. mesh: AbstractMesh;
  35386. /**
  35387. * The bone that will be looking to the target
  35388. */
  35389. bone: Bone;
  35390. /**
  35391. * The up axis of the coordinate system that is used when the bone is rotated
  35392. */
  35393. upAxis: Vector3;
  35394. /**
  35395. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35396. */
  35397. upAxisSpace: Space;
  35398. /**
  35399. * Used to make an adjustment to the yaw of the bone
  35400. */
  35401. adjustYaw: number;
  35402. /**
  35403. * Used to make an adjustment to the pitch of the bone
  35404. */
  35405. adjustPitch: number;
  35406. /**
  35407. * Used to make an adjustment to the roll of the bone
  35408. */
  35409. adjustRoll: number;
  35410. /**
  35411. * 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)
  35412. */
  35413. slerpAmount: number;
  35414. private _minYaw;
  35415. private _maxYaw;
  35416. private _minPitch;
  35417. private _maxPitch;
  35418. private _minYawSin;
  35419. private _minYawCos;
  35420. private _maxYawSin;
  35421. private _maxYawCos;
  35422. private _midYawConstraint;
  35423. private _minPitchTan;
  35424. private _maxPitchTan;
  35425. private _boneQuat;
  35426. private _slerping;
  35427. private _transformYawPitch;
  35428. private _transformYawPitchInv;
  35429. private _firstFrameSkipped;
  35430. private _yawRange;
  35431. private _fowardAxis;
  35432. /**
  35433. * Gets or sets the minimum yaw angle that the bone can look to
  35434. */
  35435. minYaw: number;
  35436. /**
  35437. * Gets or sets the maximum yaw angle that the bone can look to
  35438. */
  35439. maxYaw: number;
  35440. /**
  35441. * Gets or sets the minimum pitch angle that the bone can look to
  35442. */
  35443. minPitch: number;
  35444. /**
  35445. * Gets or sets the maximum pitch angle that the bone can look to
  35446. */
  35447. maxPitch: number;
  35448. /**
  35449. * Create a BoneLookController
  35450. * @param mesh the mesh that the bone belongs to
  35451. * @param bone the bone that will be looking to the target
  35452. * @param target the target Vector3 to look at
  35453. * @param options optional settings:
  35454. * * maxYaw: the maximum angle the bone will yaw to
  35455. * * minYaw: the minimum angle the bone will yaw to
  35456. * * maxPitch: the maximum angle the bone will pitch to
  35457. * * minPitch: the minimum angle the bone will yaw to
  35458. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35459. * * upAxis: the up axis of the coordinate system
  35460. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35461. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35462. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35463. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35464. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35465. * * adjustRoll: used to make an adjustment to the roll of the bone
  35466. **/
  35467. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35468. maxYaw?: number;
  35469. minYaw?: number;
  35470. maxPitch?: number;
  35471. minPitch?: number;
  35472. slerpAmount?: number;
  35473. upAxis?: Vector3;
  35474. upAxisSpace?: Space;
  35475. yawAxis?: Vector3;
  35476. pitchAxis?: Vector3;
  35477. adjustYaw?: number;
  35478. adjustPitch?: number;
  35479. adjustRoll?: number;
  35480. });
  35481. /**
  35482. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35483. */
  35484. update(): void;
  35485. private _getAngleDiff;
  35486. private _getAngleBetween;
  35487. private _isAngleBetween;
  35488. }
  35489. }
  35490. declare module BABYLON {
  35491. /**
  35492. * Manage the gamepad inputs to control an arc rotate camera.
  35493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35494. */
  35495. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35496. /**
  35497. * Defines the camera the input is attached to.
  35498. */
  35499. camera: ArcRotateCamera;
  35500. /**
  35501. * Defines the gamepad the input is gathering event from.
  35502. */
  35503. gamepad: Nullable<Gamepad>;
  35504. /**
  35505. * Defines the gamepad rotation sensiblity.
  35506. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35507. */
  35508. gamepadRotationSensibility: number;
  35509. /**
  35510. * Defines the gamepad move sensiblity.
  35511. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35512. */
  35513. gamepadMoveSensibility: number;
  35514. private _onGamepadConnectedObserver;
  35515. private _onGamepadDisconnectedObserver;
  35516. /**
  35517. * Attach the input controls to a specific dom element to get the input from.
  35518. * @param element Defines the element the controls should be listened from
  35519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35520. */
  35521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35522. /**
  35523. * Detach the current controls from the specified dom element.
  35524. * @param element Defines the element to stop listening the inputs from
  35525. */
  35526. detachControl(element: Nullable<HTMLElement>): void;
  35527. /**
  35528. * Update the current camera state depending on the inputs that have been used this frame.
  35529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35530. */
  35531. checkInputs(): void;
  35532. /**
  35533. * Gets the class name of the current intput.
  35534. * @returns the class name
  35535. */
  35536. getClassName(): string;
  35537. /**
  35538. * Get the friendly name associated with the input class.
  35539. * @returns the input friendly name
  35540. */
  35541. getSimpleName(): string;
  35542. }
  35543. }
  35544. declare module BABYLON {
  35545. interface ArcRotateCameraInputsManager {
  35546. /**
  35547. * Add orientation input support to the input manager.
  35548. * @returns the current input manager
  35549. */
  35550. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35551. }
  35552. /**
  35553. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35555. */
  35556. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35557. /**
  35558. * Defines the camera the input is attached to.
  35559. */
  35560. camera: ArcRotateCamera;
  35561. /**
  35562. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35563. */
  35564. alphaCorrection: number;
  35565. /**
  35566. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35567. */
  35568. gammaCorrection: number;
  35569. private _alpha;
  35570. private _gamma;
  35571. private _dirty;
  35572. private _deviceOrientationHandler;
  35573. /**
  35574. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35575. */
  35576. constructor();
  35577. /**
  35578. * Attach the input controls to a specific dom element to get the input from.
  35579. * @param element Defines the element the controls should be listened from
  35580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35581. */
  35582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35583. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35584. /**
  35585. * Update the current camera state depending on the inputs that have been used this frame.
  35586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35587. */
  35588. checkInputs(): void;
  35589. /**
  35590. * Detach the current controls from the specified dom element.
  35591. * @param element Defines the element to stop listening the inputs from
  35592. */
  35593. detachControl(element: Nullable<HTMLElement>): void;
  35594. /**
  35595. * Gets the class name of the current intput.
  35596. * @returns the class name
  35597. */
  35598. getClassName(): string;
  35599. /**
  35600. * Get the friendly name associated with the input class.
  35601. * @returns the input friendly name
  35602. */
  35603. getSimpleName(): string;
  35604. }
  35605. }
  35606. declare module BABYLON {
  35607. /**
  35608. * Listen to mouse events to control the camera.
  35609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35610. */
  35611. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35612. /**
  35613. * Defines the camera the input is attached to.
  35614. */
  35615. camera: FlyCamera;
  35616. /**
  35617. * Defines if touch is enabled. (Default is true.)
  35618. */
  35619. touchEnabled: boolean;
  35620. /**
  35621. * Defines the buttons associated with the input to handle camera rotation.
  35622. */
  35623. buttons: number[];
  35624. /**
  35625. * Assign buttons for Yaw control.
  35626. */
  35627. buttonsYaw: number[];
  35628. /**
  35629. * Assign buttons for Pitch control.
  35630. */
  35631. buttonsPitch: number[];
  35632. /**
  35633. * Assign buttons for Roll control.
  35634. */
  35635. buttonsRoll: number[];
  35636. /**
  35637. * Detect if any button is being pressed while mouse is moved.
  35638. * -1 = Mouse locked.
  35639. * 0 = Left button.
  35640. * 1 = Middle Button.
  35641. * 2 = Right Button.
  35642. */
  35643. activeButton: number;
  35644. /**
  35645. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35646. * Higher values reduce its sensitivity.
  35647. */
  35648. angularSensibility: number;
  35649. private _mousemoveCallback;
  35650. private _observer;
  35651. private _rollObserver;
  35652. private previousPosition;
  35653. private noPreventDefault;
  35654. private element;
  35655. /**
  35656. * Listen to mouse events to control the camera.
  35657. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35659. */
  35660. constructor(touchEnabled?: boolean);
  35661. /**
  35662. * Attach the mouse control to the HTML DOM element.
  35663. * @param element Defines the element that listens to the input events.
  35664. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35665. */
  35666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35667. /**
  35668. * Detach the current controls from the specified dom element.
  35669. * @param element Defines the element to stop listening the inputs from
  35670. */
  35671. detachControl(element: Nullable<HTMLElement>): void;
  35672. /**
  35673. * Gets the class name of the current input.
  35674. * @returns the class name.
  35675. */
  35676. getClassName(): string;
  35677. /**
  35678. * Get the friendly name associated with the input class.
  35679. * @returns the input's friendly name.
  35680. */
  35681. getSimpleName(): string;
  35682. private _pointerInput;
  35683. private _onMouseMove;
  35684. /**
  35685. * Rotate camera by mouse offset.
  35686. */
  35687. private rotateCamera;
  35688. }
  35689. }
  35690. declare module BABYLON {
  35691. /**
  35692. * Default Inputs manager for the FlyCamera.
  35693. * It groups all the default supported inputs for ease of use.
  35694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35695. */
  35696. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35697. /**
  35698. * Instantiates a new FlyCameraInputsManager.
  35699. * @param camera Defines the camera the inputs belong to.
  35700. */
  35701. constructor(camera: FlyCamera);
  35702. /**
  35703. * Add keyboard input support to the input manager.
  35704. * @returns the new FlyCameraKeyboardMoveInput().
  35705. */
  35706. addKeyboard(): FlyCameraInputsManager;
  35707. /**
  35708. * Add mouse input support to the input manager.
  35709. * @param touchEnabled Enable touch screen support.
  35710. * @returns the new FlyCameraMouseInput().
  35711. */
  35712. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35713. }
  35714. }
  35715. declare module BABYLON {
  35716. /**
  35717. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35718. * such as in a 3D Space Shooter or a Flight Simulator.
  35719. */
  35720. export class FlyCamera extends TargetCamera {
  35721. /**
  35722. * Define the collision ellipsoid of the camera.
  35723. * This is helpful for simulating a camera body, like a player's body.
  35724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35725. */
  35726. ellipsoid: Vector3;
  35727. /**
  35728. * Define an offset for the position of the ellipsoid around the camera.
  35729. * This can be helpful if the camera is attached away from the player's body center,
  35730. * such as at its head.
  35731. */
  35732. ellipsoidOffset: Vector3;
  35733. /**
  35734. * Enable or disable collisions of the camera with the rest of the scene objects.
  35735. */
  35736. checkCollisions: boolean;
  35737. /**
  35738. * Enable or disable gravity on the camera.
  35739. */
  35740. applyGravity: boolean;
  35741. /**
  35742. * Define the current direction the camera is moving to.
  35743. */
  35744. cameraDirection: Vector3;
  35745. /**
  35746. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35747. * This overrides and empties cameraRotation.
  35748. */
  35749. rotationQuaternion: Quaternion;
  35750. /**
  35751. * Track Roll to maintain the wanted Rolling when looking around.
  35752. */ trackRoll: number;
  35753. /**
  35754. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35755. */
  35756. rollCorrect: number;
  35757. /**
  35758. * Mimic a banked turn, Rolling the camera when Yawing.
  35759. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35760. */
  35761. bankedTurn: boolean;
  35762. /**
  35763. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35764. */
  35765. bankedTurnLimit: number;
  35766. /**
  35767. * Value of 0 disables the banked Roll.
  35768. * Value of 1 is equal to the Yaw angle in radians.
  35769. */
  35770. bankedTurnMultiplier: number;
  35771. /**
  35772. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35773. */
  35774. inputs: FlyCameraInputsManager;
  35775. /**
  35776. * Gets the input sensibility for mouse input.
  35777. * Higher values reduce sensitivity.
  35778. */
  35779. /**
  35780. * Sets the input sensibility for a mouse input.
  35781. * Higher values reduce sensitivity.
  35782. */
  35783. angularSensibility: number;
  35784. /**
  35785. * Get the keys for camera movement forward.
  35786. */
  35787. /**
  35788. * Set the keys for camera movement forward.
  35789. */
  35790. keysForward: number[];
  35791. /**
  35792. * Get the keys for camera movement backward.
  35793. */
  35794. keysBackward: number[];
  35795. /**
  35796. * Get the keys for camera movement up.
  35797. */
  35798. /**
  35799. * Set the keys for camera movement up.
  35800. */
  35801. keysUp: number[];
  35802. /**
  35803. * Get the keys for camera movement down.
  35804. */
  35805. /**
  35806. * Set the keys for camera movement down.
  35807. */
  35808. keysDown: number[];
  35809. /**
  35810. * Get the keys for camera movement left.
  35811. */
  35812. /**
  35813. * Set the keys for camera movement left.
  35814. */
  35815. keysLeft: number[];
  35816. /**
  35817. * Set the keys for camera movement right.
  35818. */
  35819. /**
  35820. * Set the keys for camera movement right.
  35821. */
  35822. keysRight: number[];
  35823. /**
  35824. * Event raised when the camera collides with a mesh in the scene.
  35825. */
  35826. onCollide: (collidedMesh: AbstractMesh) => void;
  35827. private _collider;
  35828. private _needMoveForGravity;
  35829. private _oldPosition;
  35830. private _diffPosition;
  35831. private _newPosition;
  35832. /** @hidden */ localDirection: Vector3;
  35833. /** @hidden */ transformedDirection: Vector3;
  35834. /**
  35835. * Instantiates a FlyCamera.
  35836. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35837. * such as in a 3D Space Shooter or a Flight Simulator.
  35838. * @param name Define the name of the camera in the scene.
  35839. * @param position Define the starting position of the camera in the scene.
  35840. * @param scene Define the scene the camera belongs to.
  35841. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35842. */
  35843. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35844. /**
  35845. * Attach a control to the HTML DOM element.
  35846. * @param element Defines the element that listens to the input events.
  35847. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35848. */
  35849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35850. /**
  35851. * Detach a control from the HTML DOM element.
  35852. * The camera will stop reacting to that input.
  35853. * @param element Defines the element that listens to the input events.
  35854. */
  35855. detachControl(element: HTMLElement): void;
  35856. private _collisionMask;
  35857. /**
  35858. * Get the mask that the camera ignores in collision events.
  35859. */
  35860. /**
  35861. * Set the mask that the camera ignores in collision events.
  35862. */
  35863. collisionMask: number;
  35864. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35865. /** @hidden */
  35866. private _onCollisionPositionChange;
  35867. /** @hidden */ checkInputs(): void;
  35868. /** @hidden */ decideIfNeedsToMove(): boolean;
  35869. /** @hidden */ updatePosition(): void;
  35870. /**
  35871. * Restore the Roll to its target value at the rate specified.
  35872. * @param rate - Higher means slower restoring.
  35873. * @hidden
  35874. */
  35875. restoreRoll(rate: number): void;
  35876. /**
  35877. * Destroy the camera and release the current resources held by it.
  35878. */
  35879. dispose(): void;
  35880. /**
  35881. * Get the current object class name.
  35882. * @returns the class name.
  35883. */
  35884. getClassName(): string;
  35885. }
  35886. }
  35887. declare module BABYLON {
  35888. /**
  35889. * Listen to keyboard events to control the camera.
  35890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35891. */
  35892. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35893. /**
  35894. * Defines the camera the input is attached to.
  35895. */
  35896. camera: FlyCamera;
  35897. /**
  35898. * The list of keyboard keys used to control the forward move of the camera.
  35899. */
  35900. keysForward: number[];
  35901. /**
  35902. * The list of keyboard keys used to control the backward move of the camera.
  35903. */
  35904. keysBackward: number[];
  35905. /**
  35906. * The list of keyboard keys used to control the forward move of the camera.
  35907. */
  35908. keysUp: number[];
  35909. /**
  35910. * The list of keyboard keys used to control the backward move of the camera.
  35911. */
  35912. keysDown: number[];
  35913. /**
  35914. * The list of keyboard keys used to control the right strafe move of the camera.
  35915. */
  35916. keysRight: number[];
  35917. /**
  35918. * The list of keyboard keys used to control the left strafe move of the camera.
  35919. */
  35920. keysLeft: number[];
  35921. private _keys;
  35922. private _onCanvasBlurObserver;
  35923. private _onKeyboardObserver;
  35924. private _engine;
  35925. private _scene;
  35926. /**
  35927. * Attach the input controls to a specific dom element to get the input from.
  35928. * @param element Defines the element the controls should be listened from
  35929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35930. */
  35931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35932. /**
  35933. * Detach the current controls from the specified dom element.
  35934. * @param element Defines the element to stop listening the inputs from
  35935. */
  35936. detachControl(element: Nullable<HTMLElement>): void;
  35937. /**
  35938. * Gets the class name of the current intput.
  35939. * @returns the class name
  35940. */
  35941. getClassName(): string;
  35942. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35943. /**
  35944. * Get the friendly name associated with the input class.
  35945. * @returns the input friendly name
  35946. */
  35947. getSimpleName(): string;
  35948. /**
  35949. * Update the current camera state depending on the inputs that have been used this frame.
  35950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35951. */
  35952. checkInputs(): void;
  35953. }
  35954. }
  35955. declare module BABYLON {
  35956. /**
  35957. * Manage the mouse wheel inputs to control a follow camera.
  35958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35959. */
  35960. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35961. /**
  35962. * Defines the camera the input is attached to.
  35963. */
  35964. camera: FollowCamera;
  35965. /**
  35966. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35967. */
  35968. axisControlRadius: boolean;
  35969. /**
  35970. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35971. */
  35972. axisControlHeight: boolean;
  35973. /**
  35974. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35975. */
  35976. axisControlRotation: boolean;
  35977. /**
  35978. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35979. * relation to mouseWheel events.
  35980. */
  35981. wheelPrecision: number;
  35982. /**
  35983. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35984. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35985. */
  35986. wheelDeltaPercentage: number;
  35987. private _wheel;
  35988. private _observer;
  35989. /**
  35990. * Attach the input controls to a specific dom element to get the input from.
  35991. * @param element Defines the element the controls should be listened from
  35992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35993. */
  35994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35995. /**
  35996. * Detach the current controls from the specified dom element.
  35997. * @param element Defines the element to stop listening the inputs from
  35998. */
  35999. detachControl(element: Nullable<HTMLElement>): void;
  36000. /**
  36001. * Gets the class name of the current intput.
  36002. * @returns the class name
  36003. */
  36004. getClassName(): string;
  36005. /**
  36006. * Get the friendly name associated with the input class.
  36007. * @returns the input friendly name
  36008. */
  36009. getSimpleName(): string;
  36010. }
  36011. }
  36012. declare module BABYLON {
  36013. /**
  36014. * Manage the pointers inputs to control an follow camera.
  36015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36016. */
  36017. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36018. /**
  36019. * Defines the camera the input is attached to.
  36020. */
  36021. camera: FollowCamera;
  36022. /**
  36023. * Gets the class name of the current input.
  36024. * @returns the class name
  36025. */
  36026. getClassName(): string;
  36027. /**
  36028. * Defines the pointer angular sensibility along the X axis or how fast is
  36029. * the camera rotating.
  36030. * A negative number will reverse the axis direction.
  36031. */
  36032. angularSensibilityX: number;
  36033. /**
  36034. * Defines the pointer angular sensibility along the Y axis or how fast is
  36035. * the camera rotating.
  36036. * A negative number will reverse the axis direction.
  36037. */
  36038. angularSensibilityY: number;
  36039. /**
  36040. * Defines the pointer pinch precision or how fast is the camera zooming.
  36041. * A negative number will reverse the axis direction.
  36042. */
  36043. pinchPrecision: number;
  36044. /**
  36045. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36046. * from 0.
  36047. * It defines the percentage of current camera.radius to use as delta when
  36048. * pinch zoom is used.
  36049. */
  36050. pinchDeltaPercentage: number;
  36051. /**
  36052. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36053. */
  36054. axisXControlRadius: boolean;
  36055. /**
  36056. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36057. */
  36058. axisXControlHeight: boolean;
  36059. /**
  36060. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36061. */
  36062. axisXControlRotation: boolean;
  36063. /**
  36064. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36065. */
  36066. axisYControlRadius: boolean;
  36067. /**
  36068. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36069. */
  36070. axisYControlHeight: boolean;
  36071. /**
  36072. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36073. */
  36074. axisYControlRotation: boolean;
  36075. /**
  36076. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36077. */
  36078. axisPinchControlRadius: boolean;
  36079. /**
  36080. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36081. */
  36082. axisPinchControlHeight: boolean;
  36083. /**
  36084. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36085. */
  36086. axisPinchControlRotation: boolean;
  36087. /**
  36088. * Log error messages if basic misconfiguration has occurred.
  36089. */
  36090. warningEnable: boolean;
  36091. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36092. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36093. private _warningCounter;
  36094. private _warning;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Default Inputs manager for the FollowCamera.
  36100. * It groups all the default supported inputs for ease of use.
  36101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36102. */
  36103. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36104. /**
  36105. * Instantiates a new FollowCameraInputsManager.
  36106. * @param camera Defines the camera the inputs belong to
  36107. */
  36108. constructor(camera: FollowCamera);
  36109. /**
  36110. * Add keyboard input support to the input manager.
  36111. * @returns the current input manager
  36112. */
  36113. addKeyboard(): FollowCameraInputsManager;
  36114. /**
  36115. * Add mouse wheel input support to the input manager.
  36116. * @returns the current input manager
  36117. */
  36118. addMouseWheel(): FollowCameraInputsManager;
  36119. /**
  36120. * Add pointers input support to the input manager.
  36121. * @returns the current input manager
  36122. */
  36123. addPointers(): FollowCameraInputsManager;
  36124. /**
  36125. * Add orientation input support to the input manager.
  36126. * @returns the current input manager
  36127. */
  36128. addVRDeviceOrientation(): FollowCameraInputsManager;
  36129. }
  36130. }
  36131. declare module BABYLON {
  36132. /**
  36133. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36134. * an arc rotate version arcFollowCamera are available.
  36135. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36136. */
  36137. export class FollowCamera extends TargetCamera {
  36138. /**
  36139. * Distance the follow camera should follow an object at
  36140. */
  36141. radius: number;
  36142. /**
  36143. * Minimum allowed distance of the camera to the axis of rotation
  36144. * (The camera can not get closer).
  36145. * This can help limiting how the Camera is able to move in the scene.
  36146. */
  36147. lowerRadiusLimit: Nullable<number>;
  36148. /**
  36149. * Maximum allowed distance of the camera to the axis of rotation
  36150. * (The camera can not get further).
  36151. * This can help limiting how the Camera is able to move in the scene.
  36152. */
  36153. upperRadiusLimit: Nullable<number>;
  36154. /**
  36155. * Define a rotation offset between the camera and the object it follows
  36156. */
  36157. rotationOffset: number;
  36158. /**
  36159. * Minimum allowed angle to camera position relative to target object.
  36160. * This can help limiting how the Camera is able to move in the scene.
  36161. */
  36162. lowerRotationOffsetLimit: Nullable<number>;
  36163. /**
  36164. * Maximum allowed angle to camera position relative to target object.
  36165. * This can help limiting how the Camera is able to move in the scene.
  36166. */
  36167. upperRotationOffsetLimit: Nullable<number>;
  36168. /**
  36169. * Define a height offset between the camera and the object it follows.
  36170. * It can help following an object from the top (like a car chaing a plane)
  36171. */
  36172. heightOffset: number;
  36173. /**
  36174. * Minimum allowed height of camera position relative to target object.
  36175. * This can help limiting how the Camera is able to move in the scene.
  36176. */
  36177. lowerHeightOffsetLimit: Nullable<number>;
  36178. /**
  36179. * Maximum allowed height of camera position relative to target object.
  36180. * This can help limiting how the Camera is able to move in the scene.
  36181. */
  36182. upperHeightOffsetLimit: Nullable<number>;
  36183. /**
  36184. * Define how fast the camera can accelerate to follow it s target.
  36185. */
  36186. cameraAcceleration: number;
  36187. /**
  36188. * Define the speed limit of the camera following an object.
  36189. */
  36190. maxCameraSpeed: number;
  36191. /**
  36192. * Define the target of the camera.
  36193. */
  36194. lockedTarget: Nullable<AbstractMesh>;
  36195. /**
  36196. * Defines the input associated with the camera.
  36197. */
  36198. inputs: FollowCameraInputsManager;
  36199. /**
  36200. * Instantiates the follow camera.
  36201. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36202. * @param name Define the name of the camera in the scene
  36203. * @param position Define the position of the camera
  36204. * @param scene Define the scene the camera belong to
  36205. * @param lockedTarget Define the target of the camera
  36206. */
  36207. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36208. private _follow;
  36209. /**
  36210. * Attached controls to the current camera.
  36211. * @param element Defines the element the controls should be listened from
  36212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36213. */
  36214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36215. /**
  36216. * Detach the current controls from the camera.
  36217. * The camera will stop reacting to inputs.
  36218. * @param element Defines the element to stop listening the inputs from
  36219. */
  36220. detachControl(element: HTMLElement): void;
  36221. /** @hidden */ checkInputs(): void;
  36222. private _checkLimits;
  36223. /**
  36224. * Gets the camera class name.
  36225. * @returns the class name
  36226. */
  36227. getClassName(): string;
  36228. }
  36229. /**
  36230. * Arc Rotate version of the follow camera.
  36231. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36232. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36233. */
  36234. export class ArcFollowCamera extends TargetCamera {
  36235. /** The longitudinal angle of the camera */
  36236. alpha: number;
  36237. /** The latitudinal angle of the camera */
  36238. beta: number;
  36239. /** The radius of the camera from its target */
  36240. radius: number;
  36241. /** Define the camera target (the messh it should follow) */
  36242. target: Nullable<AbstractMesh>;
  36243. private _cartesianCoordinates;
  36244. /**
  36245. * Instantiates a new ArcFollowCamera
  36246. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36247. * @param name Define the name of the camera
  36248. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36249. * @param beta Define the rotation angle of the camera around the elevation axis
  36250. * @param radius Define the radius of the camera from its target point
  36251. * @param target Define the target of the camera
  36252. * @param scene Define the scene the camera belongs to
  36253. */
  36254. constructor(name: string,
  36255. /** The longitudinal angle of the camera */
  36256. alpha: number,
  36257. /** The latitudinal angle of the camera */
  36258. beta: number,
  36259. /** The radius of the camera from its target */
  36260. radius: number,
  36261. /** Define the camera target (the messh it should follow) */
  36262. target: Nullable<AbstractMesh>, scene: Scene);
  36263. private _follow;
  36264. /** @hidden */ checkInputs(): void;
  36265. /**
  36266. * Returns the class name of the object.
  36267. * It is mostly used internally for serialization purposes.
  36268. */
  36269. getClassName(): string;
  36270. }
  36271. }
  36272. declare module BABYLON {
  36273. /**
  36274. * Manage the keyboard inputs to control the movement of a follow camera.
  36275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36276. */
  36277. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36278. /**
  36279. * Defines the camera the input is attached to.
  36280. */
  36281. camera: FollowCamera;
  36282. /**
  36283. * Defines the list of key codes associated with the up action (increase heightOffset)
  36284. */
  36285. keysHeightOffsetIncr: number[];
  36286. /**
  36287. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36288. */
  36289. keysHeightOffsetDecr: number[];
  36290. /**
  36291. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36292. */
  36293. keysHeightOffsetModifierAlt: boolean;
  36294. /**
  36295. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36296. */
  36297. keysHeightOffsetModifierCtrl: boolean;
  36298. /**
  36299. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36300. */
  36301. keysHeightOffsetModifierShift: boolean;
  36302. /**
  36303. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36304. */
  36305. keysRotationOffsetIncr: number[];
  36306. /**
  36307. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36308. */
  36309. keysRotationOffsetDecr: number[];
  36310. /**
  36311. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36312. */
  36313. keysRotationOffsetModifierAlt: boolean;
  36314. /**
  36315. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36316. */
  36317. keysRotationOffsetModifierCtrl: boolean;
  36318. /**
  36319. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36320. */
  36321. keysRotationOffsetModifierShift: boolean;
  36322. /**
  36323. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36324. */
  36325. keysRadiusIncr: number[];
  36326. /**
  36327. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36328. */
  36329. keysRadiusDecr: number[];
  36330. /**
  36331. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36332. */
  36333. keysRadiusModifierAlt: boolean;
  36334. /**
  36335. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36336. */
  36337. keysRadiusModifierCtrl: boolean;
  36338. /**
  36339. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36340. */
  36341. keysRadiusModifierShift: boolean;
  36342. /**
  36343. * Defines the rate of change of heightOffset.
  36344. */
  36345. heightSensibility: number;
  36346. /**
  36347. * Defines the rate of change of rotationOffset.
  36348. */
  36349. rotationSensibility: number;
  36350. /**
  36351. * Defines the rate of change of radius.
  36352. */
  36353. radiusSensibility: number;
  36354. private _keys;
  36355. private _ctrlPressed;
  36356. private _altPressed;
  36357. private _shiftPressed;
  36358. private _onCanvasBlurObserver;
  36359. private _onKeyboardObserver;
  36360. private _engine;
  36361. private _scene;
  36362. /**
  36363. * Attach the input controls to a specific dom element to get the input from.
  36364. * @param element Defines the element the controls should be listened from
  36365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36366. */
  36367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36368. /**
  36369. * Detach the current controls from the specified dom element.
  36370. * @param element Defines the element to stop listening the inputs from
  36371. */
  36372. detachControl(element: Nullable<HTMLElement>): void;
  36373. /**
  36374. * Update the current camera state depending on the inputs that have been used this frame.
  36375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36376. */
  36377. checkInputs(): void;
  36378. /**
  36379. * Gets the class name of the current input.
  36380. * @returns the class name
  36381. */
  36382. getClassName(): string;
  36383. /**
  36384. * Get the friendly name associated with the input class.
  36385. * @returns the input friendly name
  36386. */
  36387. getSimpleName(): string;
  36388. /**
  36389. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36390. * allow modification of the heightOffset value.
  36391. */
  36392. private _modifierHeightOffset;
  36393. /**
  36394. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36395. * allow modification of the rotationOffset value.
  36396. */
  36397. private _modifierRotationOffset;
  36398. /**
  36399. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36400. * allow modification of the radius value.
  36401. */
  36402. private _modifierRadius;
  36403. }
  36404. }
  36405. declare module BABYLON {
  36406. interface FreeCameraInputsManager {
  36407. /**
  36408. * @hidden
  36409. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36410. /**
  36411. * Add orientation input support to the input manager.
  36412. * @returns the current input manager
  36413. */
  36414. addDeviceOrientation(): FreeCameraInputsManager;
  36415. }
  36416. /**
  36417. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36418. * Screen rotation is taken into account.
  36419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36420. */
  36421. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36422. private _camera;
  36423. private _screenOrientationAngle;
  36424. private _constantTranform;
  36425. private _screenQuaternion;
  36426. private _alpha;
  36427. private _beta;
  36428. private _gamma;
  36429. /**
  36430. * @hidden
  36431. */ onDeviceOrientationChangedObservable: Observable<void>;
  36432. /**
  36433. * Instantiates a new input
  36434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36435. */
  36436. constructor();
  36437. /**
  36438. * Define the camera controlled by the input.
  36439. */
  36440. camera: FreeCamera;
  36441. /**
  36442. * Attach the input controls to a specific dom element to get the input from.
  36443. * @param element Defines the element the controls should be listened from
  36444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36445. */
  36446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36447. private _orientationChanged;
  36448. private _deviceOrientation;
  36449. /**
  36450. * Detach the current controls from the specified dom element.
  36451. * @param element Defines the element to stop listening the inputs from
  36452. */
  36453. detachControl(element: Nullable<HTMLElement>): void;
  36454. /**
  36455. * Update the current camera state depending on the inputs that have been used this frame.
  36456. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36457. */
  36458. checkInputs(): void;
  36459. /**
  36460. * Gets the class name of the current intput.
  36461. * @returns the class name
  36462. */
  36463. getClassName(): string;
  36464. /**
  36465. * Get the friendly name associated with the input class.
  36466. * @returns the input friendly name
  36467. */
  36468. getSimpleName(): string;
  36469. }
  36470. }
  36471. declare module BABYLON {
  36472. /**
  36473. * Manage the gamepad inputs to control a free camera.
  36474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36475. */
  36476. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36477. /**
  36478. * Define the camera the input is attached to.
  36479. */
  36480. camera: FreeCamera;
  36481. /**
  36482. * Define the Gamepad controlling the input
  36483. */
  36484. gamepad: Nullable<Gamepad>;
  36485. /**
  36486. * Defines the gamepad rotation sensiblity.
  36487. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36488. */
  36489. gamepadAngularSensibility: number;
  36490. /**
  36491. * Defines the gamepad move sensiblity.
  36492. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36493. */
  36494. gamepadMoveSensibility: number;
  36495. private _onGamepadConnectedObserver;
  36496. private _onGamepadDisconnectedObserver;
  36497. private _cameraTransform;
  36498. private _deltaTransform;
  36499. private _vector3;
  36500. private _vector2;
  36501. /**
  36502. * Attach the input controls to a specific dom element to get the input from.
  36503. * @param element Defines the element the controls should be listened from
  36504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36505. */
  36506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36507. /**
  36508. * Detach the current controls from the specified dom element.
  36509. * @param element Defines the element to stop listening the inputs from
  36510. */
  36511. detachControl(element: Nullable<HTMLElement>): void;
  36512. /**
  36513. * Update the current camera state depending on the inputs that have been used this frame.
  36514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36515. */
  36516. checkInputs(): void;
  36517. /**
  36518. * Gets the class name of the current intput.
  36519. * @returns the class name
  36520. */
  36521. getClassName(): string;
  36522. /**
  36523. * Get the friendly name associated with the input class.
  36524. * @returns the input friendly name
  36525. */
  36526. getSimpleName(): string;
  36527. }
  36528. }
  36529. declare module BABYLON {
  36530. /**
  36531. * Defines the potential axis of a Joystick
  36532. */
  36533. export enum JoystickAxis {
  36534. /** X axis */
  36535. X = 0,
  36536. /** Y axis */
  36537. Y = 1,
  36538. /** Z axis */
  36539. Z = 2
  36540. }
  36541. /**
  36542. * Class used to define virtual joystick (used in touch mode)
  36543. */
  36544. export class VirtualJoystick {
  36545. /**
  36546. * Gets or sets a boolean indicating that left and right values must be inverted
  36547. */
  36548. reverseLeftRight: boolean;
  36549. /**
  36550. * Gets or sets a boolean indicating that up and down values must be inverted
  36551. */
  36552. reverseUpDown: boolean;
  36553. /**
  36554. * Gets the offset value for the position (ie. the change of the position value)
  36555. */
  36556. deltaPosition: Vector3;
  36557. /**
  36558. * Gets a boolean indicating if the virtual joystick was pressed
  36559. */
  36560. pressed: boolean;
  36561. /**
  36562. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36563. */
  36564. static Canvas: Nullable<HTMLCanvasElement>;
  36565. private static _globalJoystickIndex;
  36566. private static vjCanvasContext;
  36567. private static vjCanvasWidth;
  36568. private static vjCanvasHeight;
  36569. private static halfWidth;
  36570. private _action;
  36571. private _axisTargetedByLeftAndRight;
  36572. private _axisTargetedByUpAndDown;
  36573. private _joystickSensibility;
  36574. private _inversedSensibility;
  36575. private _joystickPointerID;
  36576. private _joystickColor;
  36577. private _joystickPointerPos;
  36578. private _joystickPreviousPointerPos;
  36579. private _joystickPointerStartPos;
  36580. private _deltaJoystickVector;
  36581. private _leftJoystick;
  36582. private _touches;
  36583. private _onPointerDownHandlerRef;
  36584. private _onPointerMoveHandlerRef;
  36585. private _onPointerUpHandlerRef;
  36586. private _onResize;
  36587. /**
  36588. * Creates a new virtual joystick
  36589. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36590. */
  36591. constructor(leftJoystick?: boolean);
  36592. /**
  36593. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36594. * @param newJoystickSensibility defines the new sensibility
  36595. */
  36596. setJoystickSensibility(newJoystickSensibility: number): void;
  36597. private _onPointerDown;
  36598. private _onPointerMove;
  36599. private _onPointerUp;
  36600. /**
  36601. * Change the color of the virtual joystick
  36602. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36603. */
  36604. setJoystickColor(newColor: string): void;
  36605. /**
  36606. * Defines a callback to call when the joystick is touched
  36607. * @param action defines the callback
  36608. */
  36609. setActionOnTouch(action: () => any): void;
  36610. /**
  36611. * Defines which axis you'd like to control for left & right
  36612. * @param axis defines the axis to use
  36613. */
  36614. setAxisForLeftRight(axis: JoystickAxis): void;
  36615. /**
  36616. * Defines which axis you'd like to control for up & down
  36617. * @param axis defines the axis to use
  36618. */
  36619. setAxisForUpDown(axis: JoystickAxis): void;
  36620. private _drawVirtualJoystick;
  36621. /**
  36622. * Release internal HTML canvas
  36623. */
  36624. releaseCanvas(): void;
  36625. }
  36626. }
  36627. declare module BABYLON {
  36628. interface FreeCameraInputsManager {
  36629. /**
  36630. * Add virtual joystick input support to the input manager.
  36631. * @returns the current input manager
  36632. */
  36633. addVirtualJoystick(): FreeCameraInputsManager;
  36634. }
  36635. /**
  36636. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36638. */
  36639. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36640. /**
  36641. * Defines the camera the input is attached to.
  36642. */
  36643. camera: FreeCamera;
  36644. private _leftjoystick;
  36645. private _rightjoystick;
  36646. /**
  36647. * Gets the left stick of the virtual joystick.
  36648. * @returns The virtual Joystick
  36649. */
  36650. getLeftJoystick(): VirtualJoystick;
  36651. /**
  36652. * Gets the right stick of the virtual joystick.
  36653. * @returns The virtual Joystick
  36654. */
  36655. getRightJoystick(): VirtualJoystick;
  36656. /**
  36657. * Update the current camera state depending on the inputs that have been used this frame.
  36658. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36659. */
  36660. checkInputs(): void;
  36661. /**
  36662. * Attach the input controls to a specific dom element to get the input from.
  36663. * @param element Defines the element the controls should be listened from
  36664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36665. */
  36666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36667. /**
  36668. * Detach the current controls from the specified dom element.
  36669. * @param element Defines the element to stop listening the inputs from
  36670. */
  36671. detachControl(element: Nullable<HTMLElement>): void;
  36672. /**
  36673. * Gets the class name of the current intput.
  36674. * @returns the class name
  36675. */
  36676. getClassName(): string;
  36677. /**
  36678. * Get the friendly name associated with the input class.
  36679. * @returns the input friendly name
  36680. */
  36681. getSimpleName(): string;
  36682. }
  36683. }
  36684. declare module BABYLON {
  36685. /**
  36686. * This represents a FPS type of camera controlled by touch.
  36687. * This is like a universal camera minus the Gamepad controls.
  36688. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36689. */
  36690. export class TouchCamera extends FreeCamera {
  36691. /**
  36692. * Defines the touch sensibility for rotation.
  36693. * The higher the faster.
  36694. */
  36695. touchAngularSensibility: number;
  36696. /**
  36697. * Defines the touch sensibility for move.
  36698. * The higher the faster.
  36699. */
  36700. touchMoveSensibility: number;
  36701. /**
  36702. * Instantiates a new touch camera.
  36703. * This represents a FPS type of camera controlled by touch.
  36704. * This is like a universal camera minus the Gamepad controls.
  36705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36706. * @param name Define the name of the camera in the scene
  36707. * @param position Define the start position of the camera in the scene
  36708. * @param scene Define the scene the camera belongs to
  36709. */
  36710. constructor(name: string, position: Vector3, scene: Scene);
  36711. /**
  36712. * Gets the current object class name.
  36713. * @return the class name
  36714. */
  36715. getClassName(): string;
  36716. /** @hidden */ setupInputs(): void;
  36717. }
  36718. }
  36719. declare module BABYLON {
  36720. /**
  36721. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36722. * being tilted forward or back and left or right.
  36723. */
  36724. export class DeviceOrientationCamera extends FreeCamera {
  36725. private _initialQuaternion;
  36726. private _quaternionCache;
  36727. private _tmpDragQuaternion;
  36728. /**
  36729. * Creates a new device orientation camera
  36730. * @param name The name of the camera
  36731. * @param position The start position camera
  36732. * @param scene The scene the camera belongs to
  36733. */
  36734. constructor(name: string, position: Vector3, scene: Scene);
  36735. /**
  36736. * @hidden
  36737. * Disabled pointer input on first orientation sensor update (Default: true)
  36738. */ disablePointerInputWhenUsingDeviceOrientation: boolean;
  36739. private _dragFactor;
  36740. /**
  36741. * Enabled turning on the y axis when the orientation sensor is active
  36742. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36743. */
  36744. enableHorizontalDragging(dragFactor?: number): void;
  36745. /**
  36746. * Gets the current instance class name ("DeviceOrientationCamera").
  36747. * This helps avoiding instanceof at run time.
  36748. * @returns the class name
  36749. */
  36750. getClassName(): string;
  36751. /**
  36752. * @hidden
  36753. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36754. */ checkInputs(): void;
  36755. /**
  36756. * Reset the camera to its default orientation on the specified axis only.
  36757. * @param axis The axis to reset
  36758. */
  36759. resetToCurrentRotation(axis?: Axis): void;
  36760. }
  36761. }
  36762. declare module BABYLON {
  36763. /**
  36764. * 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,
  36765. * which still works and will still be found in many Playgrounds.
  36766. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36767. */
  36768. export class UniversalCamera extends TouchCamera {
  36769. /**
  36770. * Defines the gamepad rotation sensiblity.
  36771. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36772. */
  36773. gamepadAngularSensibility: number;
  36774. /**
  36775. * Defines the gamepad move sensiblity.
  36776. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36777. */
  36778. gamepadMoveSensibility: number;
  36779. /**
  36780. * 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,
  36781. * which still works and will still be found in many Playgrounds.
  36782. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36783. * @param name Define the name of the camera in the scene
  36784. * @param position Define the start position of the camera in the scene
  36785. * @param scene Define the scene the camera belongs to
  36786. */
  36787. constructor(name: string, position: Vector3, scene: Scene);
  36788. /**
  36789. * Gets the current object class name.
  36790. * @return the class name
  36791. */
  36792. getClassName(): string;
  36793. }
  36794. }
  36795. declare module BABYLON {
  36796. /**
  36797. * This represents a FPS type of camera. This is only here for back compat purpose.
  36798. * Please use the UniversalCamera instead as both are identical.
  36799. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36800. */
  36801. export class GamepadCamera extends UniversalCamera {
  36802. /**
  36803. * Instantiates a new Gamepad Camera
  36804. * This represents a FPS type of camera. This is only here for back compat purpose.
  36805. * Please use the UniversalCamera instead as both are identical.
  36806. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36807. * @param name Define the name of the camera in the scene
  36808. * @param position Define the start position of the camera in the scene
  36809. * @param scene Define the scene the camera belongs to
  36810. */
  36811. constructor(name: string, position: Vector3, scene: Scene);
  36812. /**
  36813. * Gets the current object class name.
  36814. * @return the class name
  36815. */
  36816. getClassName(): string;
  36817. }
  36818. }
  36819. declare module BABYLON {
  36820. /** @hidden */
  36821. export var passPixelShader: {
  36822. name: string;
  36823. shader: string;
  36824. };
  36825. }
  36826. declare module BABYLON {
  36827. /** @hidden */
  36828. export var passCubePixelShader: {
  36829. name: string;
  36830. shader: string;
  36831. };
  36832. }
  36833. declare module BABYLON {
  36834. /**
  36835. * PassPostProcess which produces an output the same as it's input
  36836. */
  36837. export class PassPostProcess extends PostProcess {
  36838. /**
  36839. * Creates the PassPostProcess
  36840. * @param name The name of the effect.
  36841. * @param options The required width/height ratio to downsize to before computing the render pass.
  36842. * @param camera The camera to apply the render pass to.
  36843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36844. * @param engine The engine which the post process will be applied. (default: current engine)
  36845. * @param reusable If the post process can be reused on the same frame. (default: false)
  36846. * @param textureType The type of texture to be used when performing the post processing.
  36847. * @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)
  36848. */
  36849. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36850. }
  36851. /**
  36852. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36853. */
  36854. export class PassCubePostProcess extends PostProcess {
  36855. private _face;
  36856. /**
  36857. * Gets or sets the cube face to display.
  36858. * * 0 is +X
  36859. * * 1 is -X
  36860. * * 2 is +Y
  36861. * * 3 is -Y
  36862. * * 4 is +Z
  36863. * * 5 is -Z
  36864. */
  36865. face: number;
  36866. /**
  36867. * Creates the PassCubePostProcess
  36868. * @param name The name of the effect.
  36869. * @param options The required width/height ratio to downsize to before computing the render pass.
  36870. * @param camera The camera to apply the render pass to.
  36871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36872. * @param engine The engine which the post process will be applied. (default: current engine)
  36873. * @param reusable If the post process can be reused on the same frame. (default: false)
  36874. * @param textureType The type of texture to be used when performing the post processing.
  36875. * @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)
  36876. */
  36877. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36878. }
  36879. }
  36880. declare module BABYLON {
  36881. /** @hidden */
  36882. export var anaglyphPixelShader: {
  36883. name: string;
  36884. shader: string;
  36885. };
  36886. }
  36887. declare module BABYLON {
  36888. /**
  36889. * Postprocess used to generate anaglyphic rendering
  36890. */
  36891. export class AnaglyphPostProcess extends PostProcess {
  36892. private _passedProcess;
  36893. /**
  36894. * Creates a new AnaglyphPostProcess
  36895. * @param name defines postprocess name
  36896. * @param options defines creation options or target ratio scale
  36897. * @param rigCameras defines cameras using this postprocess
  36898. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36899. * @param engine defines hosting engine
  36900. * @param reusable defines if the postprocess will be reused multiple times per frame
  36901. */
  36902. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36903. }
  36904. }
  36905. declare module BABYLON {
  36906. /**
  36907. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36908. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36909. */
  36910. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36911. /**
  36912. * Creates a new AnaglyphArcRotateCamera
  36913. * @param name defines camera name
  36914. * @param alpha defines alpha angle (in radians)
  36915. * @param beta defines beta angle (in radians)
  36916. * @param radius defines radius
  36917. * @param target defines camera target
  36918. * @param interaxialDistance defines distance between each color axis
  36919. * @param scene defines the hosting scene
  36920. */
  36921. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36922. /**
  36923. * Gets camera class name
  36924. * @returns AnaglyphArcRotateCamera
  36925. */
  36926. getClassName(): string;
  36927. }
  36928. }
  36929. declare module BABYLON {
  36930. /**
  36931. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36932. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36933. */
  36934. export class AnaglyphFreeCamera extends FreeCamera {
  36935. /**
  36936. * Creates a new AnaglyphFreeCamera
  36937. * @param name defines camera name
  36938. * @param position defines initial position
  36939. * @param interaxialDistance defines distance between each color axis
  36940. * @param scene defines the hosting scene
  36941. */
  36942. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36943. /**
  36944. * Gets camera class name
  36945. * @returns AnaglyphFreeCamera
  36946. */
  36947. getClassName(): string;
  36948. }
  36949. }
  36950. declare module BABYLON {
  36951. /**
  36952. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36953. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36954. */
  36955. export class AnaglyphGamepadCamera extends GamepadCamera {
  36956. /**
  36957. * Creates a new AnaglyphGamepadCamera
  36958. * @param name defines camera name
  36959. * @param position defines initial position
  36960. * @param interaxialDistance defines distance between each color axis
  36961. * @param scene defines the hosting scene
  36962. */
  36963. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36964. /**
  36965. * Gets camera class name
  36966. * @returns AnaglyphGamepadCamera
  36967. */
  36968. getClassName(): string;
  36969. }
  36970. }
  36971. declare module BABYLON {
  36972. /**
  36973. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36974. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36975. */
  36976. export class AnaglyphUniversalCamera extends UniversalCamera {
  36977. /**
  36978. * Creates a new AnaglyphUniversalCamera
  36979. * @param name defines camera name
  36980. * @param position defines initial position
  36981. * @param interaxialDistance defines distance between each color axis
  36982. * @param scene defines the hosting scene
  36983. */
  36984. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36985. /**
  36986. * Gets camera class name
  36987. * @returns AnaglyphUniversalCamera
  36988. */
  36989. getClassName(): string;
  36990. }
  36991. }
  36992. declare module BABYLON {
  36993. /** @hidden */
  36994. export var stereoscopicInterlacePixelShader: {
  36995. name: string;
  36996. shader: string;
  36997. };
  36998. }
  36999. declare module BABYLON {
  37000. /**
  37001. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37002. */
  37003. export class StereoscopicInterlacePostProcess extends PostProcess {
  37004. private _stepSize;
  37005. private _passedProcess;
  37006. /**
  37007. * Initializes a StereoscopicInterlacePostProcess
  37008. * @param name The name of the effect.
  37009. * @param rigCameras The rig cameras to be appled to the post process
  37010. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37012. * @param engine The engine which the post process will be applied. (default: current engine)
  37013. * @param reusable If the post process can be reused on the same frame. (default: false)
  37014. */
  37015. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37016. }
  37017. }
  37018. declare module BABYLON {
  37019. /**
  37020. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37021. * @see http://doc.babylonjs.com/features/cameras
  37022. */
  37023. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37024. /**
  37025. * Creates a new StereoscopicArcRotateCamera
  37026. * @param name defines camera name
  37027. * @param alpha defines alpha angle (in radians)
  37028. * @param beta defines beta angle (in radians)
  37029. * @param radius defines radius
  37030. * @param target defines camera target
  37031. * @param interaxialDistance defines distance between each color axis
  37032. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37033. * @param scene defines the hosting scene
  37034. */
  37035. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37036. /**
  37037. * Gets camera class name
  37038. * @returns StereoscopicArcRotateCamera
  37039. */
  37040. getClassName(): string;
  37041. }
  37042. }
  37043. declare module BABYLON {
  37044. /**
  37045. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37046. * @see http://doc.babylonjs.com/features/cameras
  37047. */
  37048. export class StereoscopicFreeCamera extends FreeCamera {
  37049. /**
  37050. * Creates a new StereoscopicFreeCamera
  37051. * @param name defines camera name
  37052. * @param position defines initial position
  37053. * @param interaxialDistance defines distance between each color axis
  37054. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37055. * @param scene defines the hosting scene
  37056. */
  37057. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37058. /**
  37059. * Gets camera class name
  37060. * @returns StereoscopicFreeCamera
  37061. */
  37062. getClassName(): string;
  37063. }
  37064. }
  37065. declare module BABYLON {
  37066. /**
  37067. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37068. * @see http://doc.babylonjs.com/features/cameras
  37069. */
  37070. export class StereoscopicGamepadCamera extends GamepadCamera {
  37071. /**
  37072. * Creates a new StereoscopicGamepadCamera
  37073. * @param name defines camera name
  37074. * @param position defines initial position
  37075. * @param interaxialDistance defines distance between each color axis
  37076. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37077. * @param scene defines the hosting scene
  37078. */
  37079. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37080. /**
  37081. * Gets camera class name
  37082. * @returns StereoscopicGamepadCamera
  37083. */
  37084. getClassName(): string;
  37085. }
  37086. }
  37087. declare module BABYLON {
  37088. /**
  37089. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37090. * @see http://doc.babylonjs.com/features/cameras
  37091. */
  37092. export class StereoscopicUniversalCamera extends UniversalCamera {
  37093. /**
  37094. * Creates a new StereoscopicUniversalCamera
  37095. * @param name defines camera name
  37096. * @param position defines initial position
  37097. * @param interaxialDistance defines distance between each color axis
  37098. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37099. * @param scene defines the hosting scene
  37100. */
  37101. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37102. /**
  37103. * Gets camera class name
  37104. * @returns StereoscopicUniversalCamera
  37105. */
  37106. getClassName(): string;
  37107. }
  37108. }
  37109. declare module BABYLON {
  37110. /**
  37111. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37112. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37113. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37114. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37115. */
  37116. export class VirtualJoysticksCamera extends FreeCamera {
  37117. /**
  37118. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37119. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37120. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37121. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37122. * @param name Define the name of the camera in the scene
  37123. * @param position Define the start position of the camera in the scene
  37124. * @param scene Define the scene the camera belongs to
  37125. */
  37126. constructor(name: string, position: Vector3, scene: Scene);
  37127. /**
  37128. * Gets the current object class name.
  37129. * @return the class name
  37130. */
  37131. getClassName(): string;
  37132. }
  37133. }
  37134. declare module BABYLON {
  37135. /**
  37136. * This represents all the required metrics to create a VR camera.
  37137. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37138. */
  37139. export class VRCameraMetrics {
  37140. /**
  37141. * Define the horizontal resolution off the screen.
  37142. */
  37143. hResolution: number;
  37144. /**
  37145. * Define the vertical resolution off the screen.
  37146. */
  37147. vResolution: number;
  37148. /**
  37149. * Define the horizontal screen size.
  37150. */
  37151. hScreenSize: number;
  37152. /**
  37153. * Define the vertical screen size.
  37154. */
  37155. vScreenSize: number;
  37156. /**
  37157. * Define the vertical screen center position.
  37158. */
  37159. vScreenCenter: number;
  37160. /**
  37161. * Define the distance of the eyes to the screen.
  37162. */
  37163. eyeToScreenDistance: number;
  37164. /**
  37165. * Define the distance between both lenses
  37166. */
  37167. lensSeparationDistance: number;
  37168. /**
  37169. * Define the distance between both viewer's eyes.
  37170. */
  37171. interpupillaryDistance: number;
  37172. /**
  37173. * Define the distortion factor of the VR postprocess.
  37174. * Please, touch with care.
  37175. */
  37176. distortionK: number[];
  37177. /**
  37178. * Define the chromatic aberration correction factors for the VR post process.
  37179. */
  37180. chromaAbCorrection: number[];
  37181. /**
  37182. * Define the scale factor of the post process.
  37183. * The smaller the better but the slower.
  37184. */
  37185. postProcessScaleFactor: number;
  37186. /**
  37187. * Define an offset for the lens center.
  37188. */
  37189. lensCenterOffset: number;
  37190. /**
  37191. * Define if the current vr camera should compensate the distortion of the lense or not.
  37192. */
  37193. compensateDistortion: boolean;
  37194. /**
  37195. * Defines if multiview should be enabled when rendering (Default: false)
  37196. */
  37197. multiviewEnabled: boolean;
  37198. /**
  37199. * Gets the rendering aspect ratio based on the provided resolutions.
  37200. */
  37201. readonly aspectRatio: number;
  37202. /**
  37203. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37204. */
  37205. readonly aspectRatioFov: number;
  37206. /**
  37207. * @hidden
  37208. */
  37209. readonly leftHMatrix: Matrix;
  37210. /**
  37211. * @hidden
  37212. */
  37213. readonly rightHMatrix: Matrix;
  37214. /**
  37215. * @hidden
  37216. */
  37217. readonly leftPreViewMatrix: Matrix;
  37218. /**
  37219. * @hidden
  37220. */
  37221. readonly rightPreViewMatrix: Matrix;
  37222. /**
  37223. * Get the default VRMetrics based on the most generic setup.
  37224. * @returns the default vr metrics
  37225. */
  37226. static GetDefault(): VRCameraMetrics;
  37227. }
  37228. }
  37229. declare module BABYLON {
  37230. /** @hidden */
  37231. export var vrDistortionCorrectionPixelShader: {
  37232. name: string;
  37233. shader: string;
  37234. };
  37235. }
  37236. declare module BABYLON {
  37237. /**
  37238. * VRDistortionCorrectionPostProcess used for mobile VR
  37239. */
  37240. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37241. private _isRightEye;
  37242. private _distortionFactors;
  37243. private _postProcessScaleFactor;
  37244. private _lensCenterOffset;
  37245. private _scaleIn;
  37246. private _scaleFactor;
  37247. private _lensCenter;
  37248. /**
  37249. * Initializes the VRDistortionCorrectionPostProcess
  37250. * @param name The name of the effect.
  37251. * @param camera The camera to apply the render pass to.
  37252. * @param isRightEye If this is for the right eye distortion
  37253. * @param vrMetrics All the required metrics for the VR camera
  37254. */
  37255. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37256. }
  37257. }
  37258. declare module BABYLON {
  37259. /**
  37260. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37261. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37262. */
  37263. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37264. /**
  37265. * Creates a new VRDeviceOrientationArcRotateCamera
  37266. * @param name defines camera name
  37267. * @param alpha defines the camera rotation along the logitudinal axis
  37268. * @param beta defines the camera rotation along the latitudinal axis
  37269. * @param radius defines the camera distance from its target
  37270. * @param target defines the camera target
  37271. * @param scene defines the scene the camera belongs to
  37272. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37273. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37274. */
  37275. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37276. /**
  37277. * Gets camera class name
  37278. * @returns VRDeviceOrientationArcRotateCamera
  37279. */
  37280. getClassName(): string;
  37281. }
  37282. }
  37283. declare module BABYLON {
  37284. /**
  37285. * Camera used to simulate VR rendering (based on FreeCamera)
  37286. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37287. */
  37288. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37289. /**
  37290. * Creates a new VRDeviceOrientationFreeCamera
  37291. * @param name defines camera name
  37292. * @param position defines the start position of the camera
  37293. * @param scene defines the scene the camera belongs to
  37294. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37295. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37296. */
  37297. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37298. /**
  37299. * Gets camera class name
  37300. * @returns VRDeviceOrientationFreeCamera
  37301. */
  37302. getClassName(): string;
  37303. }
  37304. }
  37305. declare module BABYLON {
  37306. /**
  37307. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37308. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37309. */
  37310. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37311. /**
  37312. * Creates a new VRDeviceOrientationGamepadCamera
  37313. * @param name defines camera name
  37314. * @param position defines the start position of the camera
  37315. * @param scene defines the scene the camera belongs to
  37316. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37317. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37318. */
  37319. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37320. /**
  37321. * Gets camera class name
  37322. * @returns VRDeviceOrientationGamepadCamera
  37323. */
  37324. getClassName(): string;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. /**
  37329. * Defines supported buttons for XBox360 compatible gamepads
  37330. */
  37331. export enum Xbox360Button {
  37332. /** A */
  37333. A = 0,
  37334. /** B */
  37335. B = 1,
  37336. /** X */
  37337. X = 2,
  37338. /** Y */
  37339. Y = 3,
  37340. /** Start */
  37341. Start = 4,
  37342. /** Back */
  37343. Back = 5,
  37344. /** Left button */
  37345. LB = 6,
  37346. /** Right button */
  37347. RB = 7,
  37348. /** Left stick */
  37349. LeftStick = 8,
  37350. /** Right stick */
  37351. RightStick = 9
  37352. }
  37353. /** Defines values for XBox360 DPad */
  37354. export enum Xbox360Dpad {
  37355. /** Up */
  37356. Up = 0,
  37357. /** Down */
  37358. Down = 1,
  37359. /** Left */
  37360. Left = 2,
  37361. /** Right */
  37362. Right = 3
  37363. }
  37364. /**
  37365. * Defines a XBox360 gamepad
  37366. */
  37367. export class Xbox360Pad extends Gamepad {
  37368. private _leftTrigger;
  37369. private _rightTrigger;
  37370. private _onlefttriggerchanged;
  37371. private _onrighttriggerchanged;
  37372. private _onbuttondown;
  37373. private _onbuttonup;
  37374. private _ondpaddown;
  37375. private _ondpadup;
  37376. /** Observable raised when a button is pressed */
  37377. onButtonDownObservable: Observable<Xbox360Button>;
  37378. /** Observable raised when a button is released */
  37379. onButtonUpObservable: Observable<Xbox360Button>;
  37380. /** Observable raised when a pad is pressed */
  37381. onPadDownObservable: Observable<Xbox360Dpad>;
  37382. /** Observable raised when a pad is released */
  37383. onPadUpObservable: Observable<Xbox360Dpad>;
  37384. private _buttonA;
  37385. private _buttonB;
  37386. private _buttonX;
  37387. private _buttonY;
  37388. private _buttonBack;
  37389. private _buttonStart;
  37390. private _buttonLB;
  37391. private _buttonRB;
  37392. private _buttonLeftStick;
  37393. private _buttonRightStick;
  37394. private _dPadUp;
  37395. private _dPadDown;
  37396. private _dPadLeft;
  37397. private _dPadRight;
  37398. private _isXboxOnePad;
  37399. /**
  37400. * Creates a new XBox360 gamepad object
  37401. * @param id defines the id of this gamepad
  37402. * @param index defines its index
  37403. * @param gamepad defines the internal HTML gamepad object
  37404. * @param xboxOne defines if it is a XBox One gamepad
  37405. */
  37406. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37407. /**
  37408. * Defines the callback to call when left trigger is pressed
  37409. * @param callback defines the callback to use
  37410. */
  37411. onlefttriggerchanged(callback: (value: number) => void): void;
  37412. /**
  37413. * Defines the callback to call when right trigger is pressed
  37414. * @param callback defines the callback to use
  37415. */
  37416. onrighttriggerchanged(callback: (value: number) => void): void;
  37417. /**
  37418. * Gets the left trigger value
  37419. */
  37420. /**
  37421. * Sets the left trigger value
  37422. */
  37423. leftTrigger: number;
  37424. /**
  37425. * Gets the right trigger value
  37426. */
  37427. /**
  37428. * Sets the right trigger value
  37429. */
  37430. rightTrigger: number;
  37431. /**
  37432. * Defines the callback to call when a button is pressed
  37433. * @param callback defines the callback to use
  37434. */
  37435. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37436. /**
  37437. * Defines the callback to call when a button is released
  37438. * @param callback defines the callback to use
  37439. */
  37440. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37441. /**
  37442. * Defines the callback to call when a pad is pressed
  37443. * @param callback defines the callback to use
  37444. */
  37445. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37446. /**
  37447. * Defines the callback to call when a pad is released
  37448. * @param callback defines the callback to use
  37449. */
  37450. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37451. private _setButtonValue;
  37452. private _setDPadValue;
  37453. /**
  37454. * Gets the value of the `A` button
  37455. */
  37456. /**
  37457. * Sets the value of the `A` button
  37458. */
  37459. buttonA: number;
  37460. /**
  37461. * Gets the value of the `B` button
  37462. */
  37463. /**
  37464. * Sets the value of the `B` button
  37465. */
  37466. buttonB: number;
  37467. /**
  37468. * Gets the value of the `X` button
  37469. */
  37470. /**
  37471. * Sets the value of the `X` button
  37472. */
  37473. buttonX: number;
  37474. /**
  37475. * Gets the value of the `Y` button
  37476. */
  37477. /**
  37478. * Sets the value of the `Y` button
  37479. */
  37480. buttonY: number;
  37481. /**
  37482. * Gets the value of the `Start` button
  37483. */
  37484. /**
  37485. * Sets the value of the `Start` button
  37486. */
  37487. buttonStart: number;
  37488. /**
  37489. * Gets the value of the `Back` button
  37490. */
  37491. /**
  37492. * Sets the value of the `Back` button
  37493. */
  37494. buttonBack: number;
  37495. /**
  37496. * Gets the value of the `Left` button
  37497. */
  37498. /**
  37499. * Sets the value of the `Left` button
  37500. */
  37501. buttonLB: number;
  37502. /**
  37503. * Gets the value of the `Right` button
  37504. */
  37505. /**
  37506. * Sets the value of the `Right` button
  37507. */
  37508. buttonRB: number;
  37509. /**
  37510. * Gets the value of the Left joystick
  37511. */
  37512. /**
  37513. * Sets the value of the Left joystick
  37514. */
  37515. buttonLeftStick: number;
  37516. /**
  37517. * Gets the value of the Right joystick
  37518. */
  37519. /**
  37520. * Sets the value of the Right joystick
  37521. */
  37522. buttonRightStick: number;
  37523. /**
  37524. * Gets the value of D-pad up
  37525. */
  37526. /**
  37527. * Sets the value of D-pad up
  37528. */
  37529. dPadUp: number;
  37530. /**
  37531. * Gets the value of D-pad down
  37532. */
  37533. /**
  37534. * Sets the value of D-pad down
  37535. */
  37536. dPadDown: number;
  37537. /**
  37538. * Gets the value of D-pad left
  37539. */
  37540. /**
  37541. * Sets the value of D-pad left
  37542. */
  37543. dPadLeft: number;
  37544. /**
  37545. * Gets the value of D-pad right
  37546. */
  37547. /**
  37548. * Sets the value of D-pad right
  37549. */
  37550. dPadRight: number;
  37551. /**
  37552. * Force the gamepad to synchronize with device values
  37553. */
  37554. update(): void;
  37555. /**
  37556. * Disposes the gamepad
  37557. */
  37558. dispose(): void;
  37559. }
  37560. }
  37561. declare module BABYLON {
  37562. /**
  37563. * Base class of materials working in push mode in babylon JS
  37564. * @hidden
  37565. */
  37566. export class PushMaterial extends Material {
  37567. protected _activeEffect: Effect;
  37568. protected _normalMatrix: Matrix;
  37569. /**
  37570. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37571. * This means that the material can keep using a previous shader while a new one is being compiled.
  37572. * This is mostly used when shader parallel compilation is supported (true by default)
  37573. */
  37574. allowShaderHotSwapping: boolean;
  37575. constructor(name: string, scene: Scene);
  37576. getEffect(): Effect;
  37577. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37578. /**
  37579. * Binds the given world matrix to the active effect
  37580. *
  37581. * @param world the matrix to bind
  37582. */
  37583. bindOnlyWorldMatrix(world: Matrix): void;
  37584. /**
  37585. * Binds the given normal matrix to the active effect
  37586. *
  37587. * @param normalMatrix the matrix to bind
  37588. */
  37589. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37590. bind(world: Matrix, mesh?: Mesh): void;
  37591. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37592. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37593. }
  37594. }
  37595. declare module BABYLON {
  37596. /**
  37597. * This groups all the flags used to control the materials channel.
  37598. */
  37599. export class MaterialFlags {
  37600. private static _DiffuseTextureEnabled;
  37601. /**
  37602. * Are diffuse textures enabled in the application.
  37603. */
  37604. static DiffuseTextureEnabled: boolean;
  37605. private static _AmbientTextureEnabled;
  37606. /**
  37607. * Are ambient textures enabled in the application.
  37608. */
  37609. static AmbientTextureEnabled: boolean;
  37610. private static _OpacityTextureEnabled;
  37611. /**
  37612. * Are opacity textures enabled in the application.
  37613. */
  37614. static OpacityTextureEnabled: boolean;
  37615. private static _ReflectionTextureEnabled;
  37616. /**
  37617. * Are reflection textures enabled in the application.
  37618. */
  37619. static ReflectionTextureEnabled: boolean;
  37620. private static _EmissiveTextureEnabled;
  37621. /**
  37622. * Are emissive textures enabled in the application.
  37623. */
  37624. static EmissiveTextureEnabled: boolean;
  37625. private static _SpecularTextureEnabled;
  37626. /**
  37627. * Are specular textures enabled in the application.
  37628. */
  37629. static SpecularTextureEnabled: boolean;
  37630. private static _BumpTextureEnabled;
  37631. /**
  37632. * Are bump textures enabled in the application.
  37633. */
  37634. static BumpTextureEnabled: boolean;
  37635. private static _LightmapTextureEnabled;
  37636. /**
  37637. * Are lightmap textures enabled in the application.
  37638. */
  37639. static LightmapTextureEnabled: boolean;
  37640. private static _RefractionTextureEnabled;
  37641. /**
  37642. * Are refraction textures enabled in the application.
  37643. */
  37644. static RefractionTextureEnabled: boolean;
  37645. private static _ColorGradingTextureEnabled;
  37646. /**
  37647. * Are color grading textures enabled in the application.
  37648. */
  37649. static ColorGradingTextureEnabled: boolean;
  37650. private static _FresnelEnabled;
  37651. /**
  37652. * Are fresnels enabled in the application.
  37653. */
  37654. static FresnelEnabled: boolean;
  37655. private static _ClearCoatTextureEnabled;
  37656. /**
  37657. * Are clear coat textures enabled in the application.
  37658. */
  37659. static ClearCoatTextureEnabled: boolean;
  37660. private static _ClearCoatBumpTextureEnabled;
  37661. /**
  37662. * Are clear coat bump textures enabled in the application.
  37663. */
  37664. static ClearCoatBumpTextureEnabled: boolean;
  37665. private static _ClearCoatTintTextureEnabled;
  37666. /**
  37667. * Are clear coat tint textures enabled in the application.
  37668. */
  37669. static ClearCoatTintTextureEnabled: boolean;
  37670. private static _SheenTextureEnabled;
  37671. /**
  37672. * Are sheen textures enabled in the application.
  37673. */
  37674. static SheenTextureEnabled: boolean;
  37675. private static _AnisotropicTextureEnabled;
  37676. /**
  37677. * Are anisotropic textures enabled in the application.
  37678. */
  37679. static AnisotropicTextureEnabled: boolean;
  37680. private static _ThicknessTextureEnabled;
  37681. /**
  37682. * Are thickness textures enabled in the application.
  37683. */
  37684. static ThicknessTextureEnabled: boolean;
  37685. }
  37686. }
  37687. declare module BABYLON {
  37688. /** @hidden */
  37689. export var defaultFragmentDeclaration: {
  37690. name: string;
  37691. shader: string;
  37692. };
  37693. }
  37694. declare module BABYLON {
  37695. /** @hidden */
  37696. export var defaultUboDeclaration: {
  37697. name: string;
  37698. shader: string;
  37699. };
  37700. }
  37701. declare module BABYLON {
  37702. /** @hidden */
  37703. export var lightFragmentDeclaration: {
  37704. name: string;
  37705. shader: string;
  37706. };
  37707. }
  37708. declare module BABYLON {
  37709. /** @hidden */
  37710. export var lightUboDeclaration: {
  37711. name: string;
  37712. shader: string;
  37713. };
  37714. }
  37715. declare module BABYLON {
  37716. /** @hidden */
  37717. export var lightsFragmentFunctions: {
  37718. name: string;
  37719. shader: string;
  37720. };
  37721. }
  37722. declare module BABYLON {
  37723. /** @hidden */
  37724. export var shadowsFragmentFunctions: {
  37725. name: string;
  37726. shader: string;
  37727. };
  37728. }
  37729. declare module BABYLON {
  37730. /** @hidden */
  37731. export var fresnelFunction: {
  37732. name: string;
  37733. shader: string;
  37734. };
  37735. }
  37736. declare module BABYLON {
  37737. /** @hidden */
  37738. export var reflectionFunction: {
  37739. name: string;
  37740. shader: string;
  37741. };
  37742. }
  37743. declare module BABYLON {
  37744. /** @hidden */
  37745. export var bumpFragmentFunctions: {
  37746. name: string;
  37747. shader: string;
  37748. };
  37749. }
  37750. declare module BABYLON {
  37751. /** @hidden */
  37752. export var logDepthDeclaration: {
  37753. name: string;
  37754. shader: string;
  37755. };
  37756. }
  37757. declare module BABYLON {
  37758. /** @hidden */
  37759. export var bumpFragment: {
  37760. name: string;
  37761. shader: string;
  37762. };
  37763. }
  37764. declare module BABYLON {
  37765. /** @hidden */
  37766. export var depthPrePass: {
  37767. name: string;
  37768. shader: string;
  37769. };
  37770. }
  37771. declare module BABYLON {
  37772. /** @hidden */
  37773. export var lightFragment: {
  37774. name: string;
  37775. shader: string;
  37776. };
  37777. }
  37778. declare module BABYLON {
  37779. /** @hidden */
  37780. export var logDepthFragment: {
  37781. name: string;
  37782. shader: string;
  37783. };
  37784. }
  37785. declare module BABYLON {
  37786. /** @hidden */
  37787. export var defaultPixelShader: {
  37788. name: string;
  37789. shader: string;
  37790. };
  37791. }
  37792. declare module BABYLON {
  37793. /** @hidden */
  37794. export var defaultVertexDeclaration: {
  37795. name: string;
  37796. shader: string;
  37797. };
  37798. }
  37799. declare module BABYLON {
  37800. /** @hidden */
  37801. export var bumpVertexDeclaration: {
  37802. name: string;
  37803. shader: string;
  37804. };
  37805. }
  37806. declare module BABYLON {
  37807. /** @hidden */
  37808. export var bumpVertex: {
  37809. name: string;
  37810. shader: string;
  37811. };
  37812. }
  37813. declare module BABYLON {
  37814. /** @hidden */
  37815. export var fogVertex: {
  37816. name: string;
  37817. shader: string;
  37818. };
  37819. }
  37820. declare module BABYLON {
  37821. /** @hidden */
  37822. export var shadowsVertex: {
  37823. name: string;
  37824. shader: string;
  37825. };
  37826. }
  37827. declare module BABYLON {
  37828. /** @hidden */
  37829. export var pointCloudVertex: {
  37830. name: string;
  37831. shader: string;
  37832. };
  37833. }
  37834. declare module BABYLON {
  37835. /** @hidden */
  37836. export var logDepthVertex: {
  37837. name: string;
  37838. shader: string;
  37839. };
  37840. }
  37841. declare module BABYLON {
  37842. /** @hidden */
  37843. export var defaultVertexShader: {
  37844. name: string;
  37845. shader: string;
  37846. };
  37847. }
  37848. declare module BABYLON {
  37849. /** @hidden */
  37850. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37851. MAINUV1: boolean;
  37852. MAINUV2: boolean;
  37853. DIFFUSE: boolean;
  37854. DIFFUSEDIRECTUV: number;
  37855. AMBIENT: boolean;
  37856. AMBIENTDIRECTUV: number;
  37857. OPACITY: boolean;
  37858. OPACITYDIRECTUV: number;
  37859. OPACITYRGB: boolean;
  37860. REFLECTION: boolean;
  37861. EMISSIVE: boolean;
  37862. EMISSIVEDIRECTUV: number;
  37863. SPECULAR: boolean;
  37864. SPECULARDIRECTUV: number;
  37865. BUMP: boolean;
  37866. BUMPDIRECTUV: number;
  37867. PARALLAX: boolean;
  37868. PARALLAXOCCLUSION: boolean;
  37869. SPECULAROVERALPHA: boolean;
  37870. CLIPPLANE: boolean;
  37871. CLIPPLANE2: boolean;
  37872. CLIPPLANE3: boolean;
  37873. CLIPPLANE4: boolean;
  37874. ALPHATEST: boolean;
  37875. DEPTHPREPASS: boolean;
  37876. ALPHAFROMDIFFUSE: boolean;
  37877. POINTSIZE: boolean;
  37878. FOG: boolean;
  37879. SPECULARTERM: boolean;
  37880. DIFFUSEFRESNEL: boolean;
  37881. OPACITYFRESNEL: boolean;
  37882. REFLECTIONFRESNEL: boolean;
  37883. REFRACTIONFRESNEL: boolean;
  37884. EMISSIVEFRESNEL: boolean;
  37885. FRESNEL: boolean;
  37886. NORMAL: boolean;
  37887. UV1: boolean;
  37888. UV2: boolean;
  37889. VERTEXCOLOR: boolean;
  37890. VERTEXALPHA: boolean;
  37891. NUM_BONE_INFLUENCERS: number;
  37892. BonesPerMesh: number;
  37893. BONETEXTURE: boolean;
  37894. INSTANCES: boolean;
  37895. GLOSSINESS: boolean;
  37896. ROUGHNESS: boolean;
  37897. EMISSIVEASILLUMINATION: boolean;
  37898. LINKEMISSIVEWITHDIFFUSE: boolean;
  37899. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37900. LIGHTMAP: boolean;
  37901. LIGHTMAPDIRECTUV: number;
  37902. OBJECTSPACE_NORMALMAP: boolean;
  37903. USELIGHTMAPASSHADOWMAP: boolean;
  37904. REFLECTIONMAP_3D: boolean;
  37905. REFLECTIONMAP_SPHERICAL: boolean;
  37906. REFLECTIONMAP_PLANAR: boolean;
  37907. REFLECTIONMAP_CUBIC: boolean;
  37908. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37909. REFLECTIONMAP_PROJECTION: boolean;
  37910. REFLECTIONMAP_SKYBOX: boolean;
  37911. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37912. REFLECTIONMAP_EXPLICIT: boolean;
  37913. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37914. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37915. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37916. INVERTCUBICMAP: boolean;
  37917. LOGARITHMICDEPTH: boolean;
  37918. REFRACTION: boolean;
  37919. REFRACTIONMAP_3D: boolean;
  37920. REFLECTIONOVERALPHA: boolean;
  37921. TWOSIDEDLIGHTING: boolean;
  37922. SHADOWFLOAT: boolean;
  37923. MORPHTARGETS: boolean;
  37924. MORPHTARGETS_NORMAL: boolean;
  37925. MORPHTARGETS_TANGENT: boolean;
  37926. NUM_MORPH_INFLUENCERS: number;
  37927. NONUNIFORMSCALING: boolean;
  37928. PREMULTIPLYALPHA: boolean;
  37929. IMAGEPROCESSING: boolean;
  37930. VIGNETTE: boolean;
  37931. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37932. VIGNETTEBLENDMODEOPAQUE: boolean;
  37933. TONEMAPPING: boolean;
  37934. TONEMAPPING_ACES: boolean;
  37935. CONTRAST: boolean;
  37936. COLORCURVES: boolean;
  37937. COLORGRADING: boolean;
  37938. COLORGRADING3D: boolean;
  37939. SAMPLER3DGREENDEPTH: boolean;
  37940. SAMPLER3DBGRMAP: boolean;
  37941. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37942. MULTIVIEW: boolean;
  37943. /**
  37944. * If the reflection texture on this material is in linear color space
  37945. * @hidden
  37946. */
  37947. IS_REFLECTION_LINEAR: boolean;
  37948. /**
  37949. * If the refraction texture on this material is in linear color space
  37950. * @hidden
  37951. */
  37952. IS_REFRACTION_LINEAR: boolean;
  37953. EXPOSURE: boolean;
  37954. constructor();
  37955. setReflectionMode(modeToEnable: string): void;
  37956. }
  37957. /**
  37958. * This is the default material used in Babylon. It is the best trade off between quality
  37959. * and performances.
  37960. * @see http://doc.babylonjs.com/babylon101/materials
  37961. */
  37962. export class StandardMaterial extends PushMaterial {
  37963. private _diffuseTexture;
  37964. /**
  37965. * The basic texture of the material as viewed under a light.
  37966. */
  37967. diffuseTexture: Nullable<BaseTexture>;
  37968. private _ambientTexture;
  37969. /**
  37970. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37971. */
  37972. ambientTexture: Nullable<BaseTexture>;
  37973. private _opacityTexture;
  37974. /**
  37975. * Define the transparency of the material from a texture.
  37976. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37977. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37978. */
  37979. opacityTexture: Nullable<BaseTexture>;
  37980. private _reflectionTexture;
  37981. /**
  37982. * Define the texture used to display the reflection.
  37983. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37984. */
  37985. reflectionTexture: Nullable<BaseTexture>;
  37986. private _emissiveTexture;
  37987. /**
  37988. * Define texture of the material as if self lit.
  37989. * This will be mixed in the final result even in the absence of light.
  37990. */
  37991. emissiveTexture: Nullable<BaseTexture>;
  37992. private _specularTexture;
  37993. /**
  37994. * Define how the color and intensity of the highlight given by the light in the material.
  37995. */
  37996. specularTexture: Nullable<BaseTexture>;
  37997. private _bumpTexture;
  37998. /**
  37999. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38000. * 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.
  38001. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38002. */
  38003. bumpTexture: Nullable<BaseTexture>;
  38004. private _lightmapTexture;
  38005. /**
  38006. * Complex lighting can be computationally expensive to compute at runtime.
  38007. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38008. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38009. */
  38010. lightmapTexture: Nullable<BaseTexture>;
  38011. private _refractionTexture;
  38012. /**
  38013. * Define the texture used to display the refraction.
  38014. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38015. */
  38016. refractionTexture: Nullable<BaseTexture>;
  38017. /**
  38018. * The color of the material lit by the environmental background lighting.
  38019. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38020. */
  38021. ambientColor: Color3;
  38022. /**
  38023. * The basic color of the material as viewed under a light.
  38024. */
  38025. diffuseColor: Color3;
  38026. /**
  38027. * Define how the color and intensity of the highlight given by the light in the material.
  38028. */
  38029. specularColor: Color3;
  38030. /**
  38031. * Define the color of the material as if self lit.
  38032. * This will be mixed in the final result even in the absence of light.
  38033. */
  38034. emissiveColor: Color3;
  38035. /**
  38036. * Defines how sharp are the highlights in the material.
  38037. * The bigger the value the sharper giving a more glossy feeling to the result.
  38038. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38039. */
  38040. specularPower: number;
  38041. private _useAlphaFromDiffuseTexture;
  38042. /**
  38043. * Does the transparency come from the diffuse texture alpha channel.
  38044. */
  38045. useAlphaFromDiffuseTexture: boolean;
  38046. private _useEmissiveAsIllumination;
  38047. /**
  38048. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38049. */
  38050. useEmissiveAsIllumination: boolean;
  38051. private _linkEmissiveWithDiffuse;
  38052. /**
  38053. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38054. * the emissive level when the final color is close to one.
  38055. */
  38056. linkEmissiveWithDiffuse: boolean;
  38057. private _useSpecularOverAlpha;
  38058. /**
  38059. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38060. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38061. */
  38062. useSpecularOverAlpha: boolean;
  38063. private _useReflectionOverAlpha;
  38064. /**
  38065. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38066. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38067. */
  38068. useReflectionOverAlpha: boolean;
  38069. private _disableLighting;
  38070. /**
  38071. * Does lights from the scene impacts this material.
  38072. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38073. */
  38074. disableLighting: boolean;
  38075. private _useObjectSpaceNormalMap;
  38076. /**
  38077. * Allows using an object space normal map (instead of tangent space).
  38078. */
  38079. useObjectSpaceNormalMap: boolean;
  38080. private _useParallax;
  38081. /**
  38082. * Is parallax enabled or not.
  38083. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38084. */
  38085. useParallax: boolean;
  38086. private _useParallaxOcclusion;
  38087. /**
  38088. * Is parallax occlusion enabled or not.
  38089. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38090. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38091. */
  38092. useParallaxOcclusion: boolean;
  38093. /**
  38094. * 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.
  38095. */
  38096. parallaxScaleBias: number;
  38097. private _roughness;
  38098. /**
  38099. * Helps to define how blurry the reflections should appears in the material.
  38100. */
  38101. roughness: number;
  38102. /**
  38103. * In case of refraction, define the value of the indice of refraction.
  38104. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38105. */
  38106. indexOfRefraction: number;
  38107. /**
  38108. * Invert the refraction texture alongside the y axis.
  38109. * It can be useful with procedural textures or probe for instance.
  38110. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38111. */
  38112. invertRefractionY: boolean;
  38113. /**
  38114. * Defines the alpha limits in alpha test mode.
  38115. */
  38116. alphaCutOff: number;
  38117. private _useLightmapAsShadowmap;
  38118. /**
  38119. * In case of light mapping, define whether the map contains light or shadow informations.
  38120. */
  38121. useLightmapAsShadowmap: boolean;
  38122. private _diffuseFresnelParameters;
  38123. /**
  38124. * Define the diffuse fresnel parameters of the material.
  38125. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38126. */
  38127. diffuseFresnelParameters: FresnelParameters;
  38128. private _opacityFresnelParameters;
  38129. /**
  38130. * Define the opacity fresnel parameters of the material.
  38131. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38132. */
  38133. opacityFresnelParameters: FresnelParameters;
  38134. private _reflectionFresnelParameters;
  38135. /**
  38136. * Define the reflection fresnel parameters of the material.
  38137. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38138. */
  38139. reflectionFresnelParameters: FresnelParameters;
  38140. private _refractionFresnelParameters;
  38141. /**
  38142. * Define the refraction fresnel parameters of the material.
  38143. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38144. */
  38145. refractionFresnelParameters: FresnelParameters;
  38146. private _emissiveFresnelParameters;
  38147. /**
  38148. * Define the emissive fresnel parameters of the material.
  38149. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38150. */
  38151. emissiveFresnelParameters: FresnelParameters;
  38152. private _useReflectionFresnelFromSpecular;
  38153. /**
  38154. * If true automatically deducts the fresnels values from the material specularity.
  38155. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38156. */
  38157. useReflectionFresnelFromSpecular: boolean;
  38158. private _useGlossinessFromSpecularMapAlpha;
  38159. /**
  38160. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38161. */
  38162. useGlossinessFromSpecularMapAlpha: boolean;
  38163. private _maxSimultaneousLights;
  38164. /**
  38165. * Defines the maximum number of lights that can be used in the material
  38166. */
  38167. maxSimultaneousLights: number;
  38168. private _invertNormalMapX;
  38169. /**
  38170. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38171. */
  38172. invertNormalMapX: boolean;
  38173. private _invertNormalMapY;
  38174. /**
  38175. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38176. */
  38177. invertNormalMapY: boolean;
  38178. private _twoSidedLighting;
  38179. /**
  38180. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38181. */
  38182. twoSidedLighting: boolean;
  38183. /**
  38184. * Default configuration related to image processing available in the standard Material.
  38185. */
  38186. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38187. /**
  38188. * Gets the image processing configuration used either in this material.
  38189. */
  38190. /**
  38191. * Sets the Default image processing configuration used either in the this material.
  38192. *
  38193. * If sets to null, the scene one is in use.
  38194. */
  38195. imageProcessingConfiguration: ImageProcessingConfiguration;
  38196. /**
  38197. * Keep track of the image processing observer to allow dispose and replace.
  38198. */
  38199. private _imageProcessingObserver;
  38200. /**
  38201. * Attaches a new image processing configuration to the Standard Material.
  38202. * @param configuration
  38203. */
  38204. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38205. /**
  38206. * Gets wether the color curves effect is enabled.
  38207. */
  38208. /**
  38209. * Sets wether the color curves effect is enabled.
  38210. */
  38211. cameraColorCurvesEnabled: boolean;
  38212. /**
  38213. * Gets wether the color grading effect is enabled.
  38214. */
  38215. /**
  38216. * Gets wether the color grading effect is enabled.
  38217. */
  38218. cameraColorGradingEnabled: boolean;
  38219. /**
  38220. * Gets wether tonemapping is enabled or not.
  38221. */
  38222. /**
  38223. * Sets wether tonemapping is enabled or not
  38224. */
  38225. cameraToneMappingEnabled: boolean;
  38226. /**
  38227. * The camera exposure used on this material.
  38228. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38229. * This corresponds to a photographic exposure.
  38230. */
  38231. /**
  38232. * The camera exposure used on this material.
  38233. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38234. * This corresponds to a photographic exposure.
  38235. */
  38236. cameraExposure: number;
  38237. /**
  38238. * Gets The camera contrast used on this material.
  38239. */
  38240. /**
  38241. * Sets The camera contrast used on this material.
  38242. */
  38243. cameraContrast: number;
  38244. /**
  38245. * Gets the Color Grading 2D Lookup Texture.
  38246. */
  38247. /**
  38248. * Sets the Color Grading 2D Lookup Texture.
  38249. */
  38250. cameraColorGradingTexture: Nullable<BaseTexture>;
  38251. /**
  38252. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38253. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38254. * 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;
  38255. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38256. */
  38257. /**
  38258. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38259. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38260. * 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;
  38261. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38262. */
  38263. cameraColorCurves: Nullable<ColorCurves>;
  38264. /**
  38265. * Custom callback helping to override the default shader used in the material.
  38266. */
  38267. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38268. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38269. protected _worldViewProjectionMatrix: Matrix;
  38270. protected _globalAmbientColor: Color3;
  38271. protected _useLogarithmicDepth: boolean;
  38272. /**
  38273. * Instantiates a new standard material.
  38274. * This is the default material used in Babylon. It is the best trade off between quality
  38275. * and performances.
  38276. * @see http://doc.babylonjs.com/babylon101/materials
  38277. * @param name Define the name of the material in the scene
  38278. * @param scene Define the scene the material belong to
  38279. */
  38280. constructor(name: string, scene: Scene);
  38281. /**
  38282. * Gets a boolean indicating that current material needs to register RTT
  38283. */
  38284. readonly hasRenderTargetTextures: boolean;
  38285. /**
  38286. * Gets the current class name of the material e.g. "StandardMaterial"
  38287. * Mainly use in serialization.
  38288. * @returns the class name
  38289. */
  38290. getClassName(): string;
  38291. /**
  38292. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38293. * You can try switching to logarithmic depth.
  38294. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38295. */
  38296. useLogarithmicDepth: boolean;
  38297. /**
  38298. * Specifies if the material will require alpha blending
  38299. * @returns a boolean specifying if alpha blending is needed
  38300. */
  38301. needAlphaBlending(): boolean;
  38302. /**
  38303. * Specifies if this material should be rendered in alpha test mode
  38304. * @returns a boolean specifying if an alpha test is needed.
  38305. */
  38306. needAlphaTesting(): boolean;
  38307. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38308. /**
  38309. * Get the texture used for alpha test purpose.
  38310. * @returns the diffuse texture in case of the standard material.
  38311. */
  38312. getAlphaTestTexture(): Nullable<BaseTexture>;
  38313. /**
  38314. * Get if the submesh is ready to be used and all its information available.
  38315. * Child classes can use it to update shaders
  38316. * @param mesh defines the mesh to check
  38317. * @param subMesh defines which submesh to check
  38318. * @param useInstances specifies that instances should be used
  38319. * @returns a boolean indicating that the submesh is ready or not
  38320. */
  38321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38322. /**
  38323. * Builds the material UBO layouts.
  38324. * Used internally during the effect preparation.
  38325. */
  38326. buildUniformLayout(): void;
  38327. /**
  38328. * Unbinds the material from the mesh
  38329. */
  38330. unbind(): void;
  38331. /**
  38332. * Binds the submesh to this material by preparing the effect and shader to draw
  38333. * @param world defines the world transformation matrix
  38334. * @param mesh defines the mesh containing the submesh
  38335. * @param subMesh defines the submesh to bind the material to
  38336. */
  38337. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38338. /**
  38339. * Get the list of animatables in the material.
  38340. * @returns the list of animatables object used in the material
  38341. */
  38342. getAnimatables(): IAnimatable[];
  38343. /**
  38344. * Gets the active textures from the material
  38345. * @returns an array of textures
  38346. */
  38347. getActiveTextures(): BaseTexture[];
  38348. /**
  38349. * Specifies if the material uses a texture
  38350. * @param texture defines the texture to check against the material
  38351. * @returns a boolean specifying if the material uses the texture
  38352. */
  38353. hasTexture(texture: BaseTexture): boolean;
  38354. /**
  38355. * Disposes the material
  38356. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38357. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38358. */
  38359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38360. /**
  38361. * Makes a duplicate of the material, and gives it a new name
  38362. * @param name defines the new name for the duplicated material
  38363. * @returns the cloned material
  38364. */
  38365. clone(name: string): StandardMaterial;
  38366. /**
  38367. * Serializes this material in a JSON representation
  38368. * @returns the serialized material object
  38369. */
  38370. serialize(): any;
  38371. /**
  38372. * Creates a standard material from parsed material data
  38373. * @param source defines the JSON representation of the material
  38374. * @param scene defines the hosting scene
  38375. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38376. * @returns a new standard material
  38377. */
  38378. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38379. /**
  38380. * Are diffuse textures enabled in the application.
  38381. */
  38382. static DiffuseTextureEnabled: boolean;
  38383. /**
  38384. * Are ambient textures enabled in the application.
  38385. */
  38386. static AmbientTextureEnabled: boolean;
  38387. /**
  38388. * Are opacity textures enabled in the application.
  38389. */
  38390. static OpacityTextureEnabled: boolean;
  38391. /**
  38392. * Are reflection textures enabled in the application.
  38393. */
  38394. static ReflectionTextureEnabled: boolean;
  38395. /**
  38396. * Are emissive textures enabled in the application.
  38397. */
  38398. static EmissiveTextureEnabled: boolean;
  38399. /**
  38400. * Are specular textures enabled in the application.
  38401. */
  38402. static SpecularTextureEnabled: boolean;
  38403. /**
  38404. * Are bump textures enabled in the application.
  38405. */
  38406. static BumpTextureEnabled: boolean;
  38407. /**
  38408. * Are lightmap textures enabled in the application.
  38409. */
  38410. static LightmapTextureEnabled: boolean;
  38411. /**
  38412. * Are refraction textures enabled in the application.
  38413. */
  38414. static RefractionTextureEnabled: boolean;
  38415. /**
  38416. * Are color grading textures enabled in the application.
  38417. */
  38418. static ColorGradingTextureEnabled: boolean;
  38419. /**
  38420. * Are fresnels enabled in the application.
  38421. */
  38422. static FresnelEnabled: boolean;
  38423. }
  38424. }
  38425. declare module BABYLON {
  38426. /**
  38427. * A class extending Texture allowing drawing on a texture
  38428. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38429. */
  38430. export class DynamicTexture extends Texture {
  38431. private _generateMipMaps;
  38432. private _canvas;
  38433. private _context;
  38434. private _engine;
  38435. /**
  38436. * Creates a DynamicTexture
  38437. * @param name defines the name of the texture
  38438. * @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
  38439. * @param scene defines the scene where you want the texture
  38440. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38441. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38442. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38443. */
  38444. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38445. /**
  38446. * Get the current class name of the texture useful for serialization or dynamic coding.
  38447. * @returns "DynamicTexture"
  38448. */
  38449. getClassName(): string;
  38450. /**
  38451. * Gets the current state of canRescale
  38452. */
  38453. readonly canRescale: boolean;
  38454. private _recreate;
  38455. /**
  38456. * Scales the texture
  38457. * @param ratio the scale factor to apply to both width and height
  38458. */
  38459. scale(ratio: number): void;
  38460. /**
  38461. * Resizes the texture
  38462. * @param width the new width
  38463. * @param height the new height
  38464. */
  38465. scaleTo(width: number, height: number): void;
  38466. /**
  38467. * Gets the context of the canvas used by the texture
  38468. * @returns the canvas context of the dynamic texture
  38469. */
  38470. getContext(): CanvasRenderingContext2D;
  38471. /**
  38472. * Clears the texture
  38473. */
  38474. clear(): void;
  38475. /**
  38476. * Updates the texture
  38477. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38478. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38479. */
  38480. update(invertY?: boolean, premulAlpha?: boolean): void;
  38481. /**
  38482. * Draws text onto the texture
  38483. * @param text defines the text to be drawn
  38484. * @param x defines the placement of the text from the left
  38485. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38486. * @param font defines the font to be used with font-style, font-size, font-name
  38487. * @param color defines the color used for the text
  38488. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38489. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38490. * @param update defines whether texture is immediately update (default is true)
  38491. */
  38492. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38493. /**
  38494. * Clones the texture
  38495. * @returns the clone of the texture.
  38496. */
  38497. clone(): DynamicTexture;
  38498. /**
  38499. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38500. * @returns a serialized dynamic texture object
  38501. */
  38502. serialize(): any;
  38503. /** @hidden */ rebuild(): void;
  38504. }
  38505. }
  38506. declare module BABYLON {
  38507. /** @hidden */
  38508. export var imageProcessingPixelShader: {
  38509. name: string;
  38510. shader: string;
  38511. };
  38512. }
  38513. declare module BABYLON {
  38514. /**
  38515. * ImageProcessingPostProcess
  38516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38517. */
  38518. export class ImageProcessingPostProcess extends PostProcess {
  38519. /**
  38520. * Default configuration related to image processing available in the PBR Material.
  38521. */
  38522. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38523. /**
  38524. * Gets the image processing configuration used either in this material.
  38525. */
  38526. /**
  38527. * Sets the Default image processing configuration used either in the this material.
  38528. *
  38529. * If sets to null, the scene one is in use.
  38530. */
  38531. imageProcessingConfiguration: ImageProcessingConfiguration;
  38532. /**
  38533. * Keep track of the image processing observer to allow dispose and replace.
  38534. */
  38535. private _imageProcessingObserver;
  38536. /**
  38537. * Attaches a new image processing configuration to the PBR Material.
  38538. * @param configuration
  38539. */
  38540. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38541. /**
  38542. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38543. */
  38544. /**
  38545. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38546. */
  38547. colorCurves: Nullable<ColorCurves>;
  38548. /**
  38549. * Gets wether the color curves effect is enabled.
  38550. */
  38551. /**
  38552. * Sets wether the color curves effect is enabled.
  38553. */
  38554. colorCurvesEnabled: boolean;
  38555. /**
  38556. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38557. */
  38558. /**
  38559. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38560. */
  38561. colorGradingTexture: Nullable<BaseTexture>;
  38562. /**
  38563. * Gets wether the color grading effect is enabled.
  38564. */
  38565. /**
  38566. * Gets wether the color grading effect is enabled.
  38567. */
  38568. colorGradingEnabled: boolean;
  38569. /**
  38570. * Gets exposure used in the effect.
  38571. */
  38572. /**
  38573. * Sets exposure used in the effect.
  38574. */
  38575. exposure: number;
  38576. /**
  38577. * Gets wether tonemapping is enabled or not.
  38578. */
  38579. /**
  38580. * Sets wether tonemapping is enabled or not
  38581. */
  38582. toneMappingEnabled: boolean;
  38583. /**
  38584. * Gets the type of tone mapping effect.
  38585. */
  38586. /**
  38587. * Sets the type of tone mapping effect.
  38588. */
  38589. toneMappingType: number;
  38590. /**
  38591. * Gets contrast used in the effect.
  38592. */
  38593. /**
  38594. * Sets contrast used in the effect.
  38595. */
  38596. contrast: number;
  38597. /**
  38598. * Gets Vignette stretch size.
  38599. */
  38600. /**
  38601. * Sets Vignette stretch size.
  38602. */
  38603. vignetteStretch: number;
  38604. /**
  38605. * Gets Vignette centre X Offset.
  38606. */
  38607. /**
  38608. * Sets Vignette centre X Offset.
  38609. */
  38610. vignetteCentreX: number;
  38611. /**
  38612. * Gets Vignette centre Y Offset.
  38613. */
  38614. /**
  38615. * Sets Vignette centre Y Offset.
  38616. */
  38617. vignetteCentreY: number;
  38618. /**
  38619. * Gets Vignette weight or intensity of the vignette effect.
  38620. */
  38621. /**
  38622. * Sets Vignette weight or intensity of the vignette effect.
  38623. */
  38624. vignetteWeight: number;
  38625. /**
  38626. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38627. * if vignetteEnabled is set to true.
  38628. */
  38629. /**
  38630. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38631. * if vignetteEnabled is set to true.
  38632. */
  38633. vignetteColor: Color4;
  38634. /**
  38635. * Gets Camera field of view used by the Vignette effect.
  38636. */
  38637. /**
  38638. * Sets Camera field of view used by the Vignette effect.
  38639. */
  38640. vignetteCameraFov: number;
  38641. /**
  38642. * Gets the vignette blend mode allowing different kind of effect.
  38643. */
  38644. /**
  38645. * Sets the vignette blend mode allowing different kind of effect.
  38646. */
  38647. vignetteBlendMode: number;
  38648. /**
  38649. * Gets wether the vignette effect is enabled.
  38650. */
  38651. /**
  38652. * Sets wether the vignette effect is enabled.
  38653. */
  38654. vignetteEnabled: boolean;
  38655. private _fromLinearSpace;
  38656. /**
  38657. * Gets wether the input of the processing is in Gamma or Linear Space.
  38658. */
  38659. /**
  38660. * Sets wether the input of the processing is in Gamma or Linear Space.
  38661. */
  38662. fromLinearSpace: boolean;
  38663. /**
  38664. * Defines cache preventing GC.
  38665. */
  38666. private _defines;
  38667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38668. /**
  38669. * "ImageProcessingPostProcess"
  38670. * @returns "ImageProcessingPostProcess"
  38671. */
  38672. getClassName(): string;
  38673. protected _updateParameters(): void;
  38674. dispose(camera?: Camera): void;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * Class containing static functions to help procedurally build meshes
  38680. */
  38681. export class GroundBuilder {
  38682. /**
  38683. * Creates a ground mesh
  38684. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38685. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38687. * @param name defines the name of the mesh
  38688. * @param options defines the options used to create the mesh
  38689. * @param scene defines the hosting scene
  38690. * @returns the ground mesh
  38691. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38692. */
  38693. static CreateGround(name: string, options: {
  38694. width?: number;
  38695. height?: number;
  38696. subdivisions?: number;
  38697. subdivisionsX?: number;
  38698. subdivisionsY?: number;
  38699. updatable?: boolean;
  38700. }, scene: any): Mesh;
  38701. /**
  38702. * Creates a tiled ground mesh
  38703. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38704. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38705. * * 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
  38706. * * 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
  38707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38708. * @param name defines the name of the mesh
  38709. * @param options defines the options used to create the mesh
  38710. * @param scene defines the hosting scene
  38711. * @returns the tiled ground mesh
  38712. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38713. */
  38714. static CreateTiledGround(name: string, options: {
  38715. xmin: number;
  38716. zmin: number;
  38717. xmax: number;
  38718. zmax: number;
  38719. subdivisions?: {
  38720. w: number;
  38721. h: number;
  38722. };
  38723. precision?: {
  38724. w: number;
  38725. h: number;
  38726. };
  38727. updatable?: boolean;
  38728. }, scene?: Nullable<Scene>): Mesh;
  38729. /**
  38730. * Creates a ground mesh from a height map
  38731. * * The parameter `url` sets the URL of the height map image resource.
  38732. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38733. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38734. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38735. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38736. * * 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.
  38737. * * 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).
  38738. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38740. * @param name defines the name of the mesh
  38741. * @param url defines the url to the height map
  38742. * @param options defines the options used to create the mesh
  38743. * @param scene defines the hosting scene
  38744. * @returns the ground mesh
  38745. * @see https://doc.babylonjs.com/babylon101/height_map
  38746. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38747. */
  38748. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38749. width?: number;
  38750. height?: number;
  38751. subdivisions?: number;
  38752. minHeight?: number;
  38753. maxHeight?: number;
  38754. colorFilter?: Color3;
  38755. alphaFilter?: number;
  38756. updatable?: boolean;
  38757. onReady?: (mesh: GroundMesh) => void;
  38758. }, scene?: Nullable<Scene>): GroundMesh;
  38759. }
  38760. }
  38761. declare module BABYLON {
  38762. /**
  38763. * Class containing static functions to help procedurally build meshes
  38764. */
  38765. export class TorusBuilder {
  38766. /**
  38767. * Creates a torus mesh
  38768. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38769. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38770. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38772. * * 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
  38773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38774. * @param name defines the name of the mesh
  38775. * @param options defines the options used to create the mesh
  38776. * @param scene defines the hosting scene
  38777. * @returns the torus mesh
  38778. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38779. */
  38780. static CreateTorus(name: string, options: {
  38781. diameter?: number;
  38782. thickness?: number;
  38783. tessellation?: number;
  38784. updatable?: boolean;
  38785. sideOrientation?: number;
  38786. frontUVs?: Vector4;
  38787. backUVs?: Vector4;
  38788. }, scene: any): Mesh;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * Class containing static functions to help procedurally build meshes
  38794. */
  38795. export class CylinderBuilder {
  38796. /**
  38797. * Creates a cylinder or a cone mesh
  38798. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38799. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38800. * * 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.
  38801. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38802. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38803. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38804. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38805. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38806. * * 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).
  38807. * * 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
  38808. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38809. * * 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
  38810. * * 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.
  38811. * * If `enclose` is false, a ring surface is one element.
  38812. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38813. * * 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
  38814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38815. * * 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
  38816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38817. * @param name defines the name of the mesh
  38818. * @param options defines the options used to create the mesh
  38819. * @param scene defines the hosting scene
  38820. * @returns the cylinder mesh
  38821. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38822. */
  38823. static CreateCylinder(name: string, options: {
  38824. height?: number;
  38825. diameterTop?: number;
  38826. diameterBottom?: number;
  38827. diameter?: number;
  38828. tessellation?: number;
  38829. subdivisions?: number;
  38830. arc?: number;
  38831. faceColors?: Color4[];
  38832. faceUV?: Vector4[];
  38833. updatable?: boolean;
  38834. hasRings?: boolean;
  38835. enclose?: boolean;
  38836. sideOrientation?: number;
  38837. frontUVs?: Vector4;
  38838. backUVs?: Vector4;
  38839. }, scene: any): Mesh;
  38840. }
  38841. }
  38842. declare module BABYLON {
  38843. /**
  38844. * Manager for handling gamepads
  38845. */
  38846. export class GamepadManager {
  38847. private _scene?;
  38848. private _babylonGamepads;
  38849. private _oneGamepadConnected;
  38850. /** @hidden */ isMonitoring: boolean;
  38851. private _gamepadEventSupported;
  38852. private _gamepadSupport;
  38853. /**
  38854. * observable to be triggered when the gamepad controller has been connected
  38855. */
  38856. onGamepadConnectedObservable: Observable<Gamepad>;
  38857. /**
  38858. * observable to be triggered when the gamepad controller has been disconnected
  38859. */
  38860. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38861. private _onGamepadConnectedEvent;
  38862. private _onGamepadDisconnectedEvent;
  38863. /**
  38864. * Initializes the gamepad manager
  38865. * @param _scene BabylonJS scene
  38866. */
  38867. constructor(_scene?: Scene | undefined);
  38868. /**
  38869. * The gamepads in the game pad manager
  38870. */
  38871. readonly gamepads: Gamepad[];
  38872. /**
  38873. * Get the gamepad controllers based on type
  38874. * @param type The type of gamepad controller
  38875. * @returns Nullable gamepad
  38876. */
  38877. getGamepadByType(type?: number): Nullable<Gamepad>;
  38878. /**
  38879. * Disposes the gamepad manager
  38880. */
  38881. dispose(): void;
  38882. private _addNewGamepad;
  38883. private _startMonitoringGamepads;
  38884. private _stopMonitoringGamepads;
  38885. /** @hidden */ checkGamepadsStatus(): void;
  38886. private _updateGamepadObjects;
  38887. }
  38888. }
  38889. declare module BABYLON {
  38890. interface Scene {
  38891. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38892. /**
  38893. * Gets the gamepad manager associated with the scene
  38894. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38895. */
  38896. gamepadManager: GamepadManager;
  38897. }
  38898. /**
  38899. * Interface representing a free camera inputs manager
  38900. */
  38901. interface FreeCameraInputsManager {
  38902. /**
  38903. * Adds gamepad input support to the FreeCameraInputsManager.
  38904. * @returns the FreeCameraInputsManager
  38905. */
  38906. addGamepad(): FreeCameraInputsManager;
  38907. }
  38908. /**
  38909. * Interface representing an arc rotate camera inputs manager
  38910. */
  38911. interface ArcRotateCameraInputsManager {
  38912. /**
  38913. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38914. * @returns the camera inputs manager
  38915. */
  38916. addGamepad(): ArcRotateCameraInputsManager;
  38917. }
  38918. /**
  38919. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38920. */
  38921. export class GamepadSystemSceneComponent implements ISceneComponent {
  38922. /**
  38923. * The component name helpfull to identify the component in the list of scene components.
  38924. */
  38925. readonly name: string;
  38926. /**
  38927. * The scene the component belongs to.
  38928. */
  38929. scene: Scene;
  38930. /**
  38931. * Creates a new instance of the component for the given scene
  38932. * @param scene Defines the scene to register the component in
  38933. */
  38934. constructor(scene: Scene);
  38935. /**
  38936. * Registers the component in a given scene
  38937. */
  38938. register(): void;
  38939. /**
  38940. * Rebuilds the elements related to this component in case of
  38941. * context lost for instance.
  38942. */
  38943. rebuild(): void;
  38944. /**
  38945. * Disposes the component and the associated ressources
  38946. */
  38947. dispose(): void;
  38948. private _beforeCameraUpdate;
  38949. }
  38950. }
  38951. declare module BABYLON {
  38952. /**
  38953. * Options to modify the vr teleportation behavior.
  38954. */
  38955. export interface VRTeleportationOptions {
  38956. /**
  38957. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38958. */
  38959. floorMeshName?: string;
  38960. /**
  38961. * A list of meshes to be used as the teleportation floor. (default: empty)
  38962. */
  38963. floorMeshes?: Mesh[];
  38964. }
  38965. /**
  38966. * Options to modify the vr experience helper's behavior.
  38967. */
  38968. export interface VRExperienceHelperOptions extends WebVROptions {
  38969. /**
  38970. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38971. */
  38972. createDeviceOrientationCamera?: boolean;
  38973. /**
  38974. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38975. */
  38976. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38977. /**
  38978. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38979. */
  38980. laserToggle?: boolean;
  38981. /**
  38982. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38983. */
  38984. floorMeshes?: Mesh[];
  38985. /**
  38986. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38987. */
  38988. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38989. }
  38990. /**
  38991. * Event containing information after VR has been entered
  38992. */
  38993. export class OnAfterEnteringVRObservableEvent {
  38994. /**
  38995. * If entering vr was successful
  38996. */
  38997. success: boolean;
  38998. }
  38999. /**
  39000. * Helps to quickly add VR support to an existing scene.
  39001. * See http://doc.babylonjs.com/how_to/webvr_helper
  39002. */
  39003. export class VRExperienceHelper {
  39004. /** Options to modify the vr experience helper's behavior. */
  39005. webVROptions: VRExperienceHelperOptions;
  39006. private _scene;
  39007. private _position;
  39008. private _btnVR;
  39009. private _btnVRDisplayed;
  39010. private _webVRsupported;
  39011. private _webVRready;
  39012. private _webVRrequesting;
  39013. private _webVRpresenting;
  39014. private _hasEnteredVR;
  39015. private _fullscreenVRpresenting;
  39016. private _canvas;
  39017. private _webVRCamera;
  39018. private _vrDeviceOrientationCamera;
  39019. private _deviceOrientationCamera;
  39020. private _existingCamera;
  39021. private _onKeyDown;
  39022. private _onVrDisplayPresentChange;
  39023. private _onVRDisplayChanged;
  39024. private _onVRRequestPresentStart;
  39025. private _onVRRequestPresentComplete;
  39026. /**
  39027. * Observable raised right before entering VR.
  39028. */
  39029. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39030. /**
  39031. * Observable raised when entering VR has completed.
  39032. */
  39033. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39034. /**
  39035. * Observable raised when exiting VR.
  39036. */
  39037. onExitingVRObservable: Observable<VRExperienceHelper>;
  39038. /**
  39039. * Observable raised when controller mesh is loaded.
  39040. */
  39041. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39042. /** Return this.onEnteringVRObservable
  39043. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39044. */
  39045. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39046. /** Return this.onExitingVRObservable
  39047. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39048. */
  39049. readonly onExitingVR: Observable<VRExperienceHelper>;
  39050. /** Return this.onControllerMeshLoadedObservable
  39051. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39052. */
  39053. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39054. private _rayLength;
  39055. private _useCustomVRButton;
  39056. private _teleportationRequested;
  39057. private _teleportActive;
  39058. private _floorMeshName;
  39059. private _floorMeshesCollection;
  39060. private _rotationAllowed;
  39061. private _teleportBackwardsVector;
  39062. private _teleportationTarget;
  39063. private _isDefaultTeleportationTarget;
  39064. private _postProcessMove;
  39065. private _teleportationFillColor;
  39066. private _teleportationBorderColor;
  39067. private _rotationAngle;
  39068. private _haloCenter;
  39069. private _cameraGazer;
  39070. private _padSensibilityUp;
  39071. private _padSensibilityDown;
  39072. private _leftController;
  39073. private _rightController;
  39074. /**
  39075. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39076. */
  39077. onNewMeshSelected: Observable<AbstractMesh>;
  39078. /**
  39079. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39080. */
  39081. onNewMeshPicked: Observable<PickingInfo>;
  39082. private _circleEase;
  39083. /**
  39084. * Observable raised before camera teleportation
  39085. */
  39086. onBeforeCameraTeleport: Observable<Vector3>;
  39087. /**
  39088. * Observable raised after camera teleportation
  39089. */
  39090. onAfterCameraTeleport: Observable<Vector3>;
  39091. /**
  39092. * Observable raised when current selected mesh gets unselected
  39093. */
  39094. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39095. private _raySelectionPredicate;
  39096. /**
  39097. * To be optionaly changed by user to define custom ray selection
  39098. */
  39099. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39100. /**
  39101. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39102. */
  39103. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39104. /**
  39105. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39106. */
  39107. teleportationEnabled: boolean;
  39108. private _defaultHeight;
  39109. private _teleportationInitialized;
  39110. private _interactionsEnabled;
  39111. private _interactionsRequested;
  39112. private _displayGaze;
  39113. private _displayLaserPointer;
  39114. /**
  39115. * The mesh used to display where the user is going to teleport.
  39116. */
  39117. /**
  39118. * Sets the mesh to be used to display where the user is going to teleport.
  39119. */
  39120. teleportationTarget: Mesh;
  39121. /**
  39122. * 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
  39123. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39124. * See http://doc.babylonjs.com/resources/baking_transformations
  39125. */
  39126. gazeTrackerMesh: Mesh;
  39127. /**
  39128. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39129. */
  39130. updateGazeTrackerScale: boolean;
  39131. /**
  39132. * If the gaze trackers color should be updated when selecting meshes
  39133. */
  39134. updateGazeTrackerColor: boolean;
  39135. /**
  39136. * The gaze tracking mesh corresponding to the left controller
  39137. */
  39138. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39139. /**
  39140. * The gaze tracking mesh corresponding to the right controller
  39141. */
  39142. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39143. /**
  39144. * If the ray of the gaze should be displayed.
  39145. */
  39146. /**
  39147. * Sets if the ray of the gaze should be displayed.
  39148. */
  39149. displayGaze: boolean;
  39150. /**
  39151. * If the ray of the LaserPointer should be displayed.
  39152. */
  39153. /**
  39154. * Sets if the ray of the LaserPointer should be displayed.
  39155. */
  39156. displayLaserPointer: boolean;
  39157. /**
  39158. * The deviceOrientationCamera used as the camera when not in VR.
  39159. */
  39160. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39161. /**
  39162. * Based on the current WebVR support, returns the current VR camera used.
  39163. */
  39164. readonly currentVRCamera: Nullable<Camera>;
  39165. /**
  39166. * The webVRCamera which is used when in VR.
  39167. */
  39168. readonly webVRCamera: WebVRFreeCamera;
  39169. /**
  39170. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39171. */
  39172. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39173. private readonly _teleportationRequestInitiated;
  39174. /**
  39175. * Defines wether or not Pointer lock should be requested when switching to
  39176. * full screen.
  39177. */
  39178. requestPointerLockOnFullScreen: boolean;
  39179. /**
  39180. * Instantiates a VRExperienceHelper.
  39181. * Helps to quickly add VR support to an existing scene.
  39182. * @param scene The scene the VRExperienceHelper belongs to.
  39183. * @param webVROptions Options to modify the vr experience helper's behavior.
  39184. */
  39185. constructor(scene: Scene,
  39186. /** Options to modify the vr experience helper's behavior. */
  39187. webVROptions?: VRExperienceHelperOptions);
  39188. private _onDefaultMeshLoaded;
  39189. private _onResize;
  39190. private _onFullscreenChange;
  39191. /**
  39192. * Gets a value indicating if we are currently in VR mode.
  39193. */
  39194. readonly isInVRMode: boolean;
  39195. private onVrDisplayPresentChange;
  39196. private onVRDisplayChanged;
  39197. private moveButtonToBottomRight;
  39198. private displayVRButton;
  39199. private updateButtonVisibility;
  39200. private _cachedAngularSensibility;
  39201. /**
  39202. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39203. * Otherwise, will use the fullscreen API.
  39204. */
  39205. enterVR(): void;
  39206. /**
  39207. * Attempt to exit VR, or fullscreen.
  39208. */
  39209. exitVR(): void;
  39210. /**
  39211. * The position of the vr experience helper.
  39212. */
  39213. /**
  39214. * Sets the position of the vr experience helper.
  39215. */
  39216. position: Vector3;
  39217. /**
  39218. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39219. */
  39220. enableInteractions(): void;
  39221. private readonly _noControllerIsActive;
  39222. private beforeRender;
  39223. private _isTeleportationFloor;
  39224. /**
  39225. * Adds a floor mesh to be used for teleportation.
  39226. * @param floorMesh the mesh to be used for teleportation.
  39227. */
  39228. addFloorMesh(floorMesh: Mesh): void;
  39229. /**
  39230. * Removes a floor mesh from being used for teleportation.
  39231. * @param floorMesh the mesh to be removed.
  39232. */
  39233. removeFloorMesh(floorMesh: Mesh): void;
  39234. /**
  39235. * Enables interactions and teleportation using the VR controllers and gaze.
  39236. * @param vrTeleportationOptions options to modify teleportation behavior.
  39237. */
  39238. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39239. private _onNewGamepadConnected;
  39240. private _tryEnableInteractionOnController;
  39241. private _onNewGamepadDisconnected;
  39242. private _enableInteractionOnController;
  39243. private _checkTeleportWithRay;
  39244. private _checkRotate;
  39245. private _checkTeleportBackwards;
  39246. private _enableTeleportationOnController;
  39247. private _createTeleportationCircles;
  39248. private _displayTeleportationTarget;
  39249. private _hideTeleportationTarget;
  39250. private _rotateCamera;
  39251. private _moveTeleportationSelectorTo;
  39252. private _workingVector;
  39253. private _workingQuaternion;
  39254. private _workingMatrix;
  39255. /**
  39256. * Teleports the users feet to the desired location
  39257. * @param location The location where the user's feet should be placed
  39258. */
  39259. teleportCamera(location: Vector3): void;
  39260. private _convertNormalToDirectionOfRay;
  39261. private _castRayAndSelectObject;
  39262. private _notifySelectedMeshUnselected;
  39263. /**
  39264. * Sets the color of the laser ray from the vr controllers.
  39265. * @param color new color for the ray.
  39266. */
  39267. changeLaserColor(color: Color3): void;
  39268. /**
  39269. * Sets the color of the ray from the vr headsets gaze.
  39270. * @param color new color for the ray.
  39271. */
  39272. changeGazeColor(color: Color3): void;
  39273. /**
  39274. * Exits VR and disposes of the vr experience helper
  39275. */
  39276. dispose(): void;
  39277. /**
  39278. * Gets the name of the VRExperienceHelper class
  39279. * @returns "VRExperienceHelper"
  39280. */
  39281. getClassName(): string;
  39282. }
  39283. }
  39284. declare module BABYLON {
  39285. /**
  39286. * Manages an XRSession
  39287. * @see https://doc.babylonjs.com/how_to/webxr
  39288. */
  39289. export class WebXRSessionManager implements IDisposable {
  39290. private scene;
  39291. /**
  39292. * Fires every time a new xrFrame arrives which can be used to update the camera
  39293. */
  39294. onXRFrameObservable: Observable<any>;
  39295. /**
  39296. * Fires when the xr session is ended either by the device or manually done
  39297. */
  39298. onXRSessionEnded: Observable<any>;
  39299. /** @hidden */ xrSession: XRSession;
  39300. /** @hidden */ frameOfReference: XRFrameOfReference;
  39301. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39302. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39303. private _xrNavigator;
  39304. private _xrDevice;
  39305. private _tmpMatrix;
  39306. /**
  39307. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39308. * @param scene The scene which the session should be created for
  39309. */
  39310. constructor(scene: Scene);
  39311. /**
  39312. * Initializes the manager
  39313. * After initialization enterXR can be called to start an XR session
  39314. * @returns Promise which resolves after it is initialized
  39315. */
  39316. initializeAsync(): Promise<void>;
  39317. /**
  39318. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39319. * @param sessionCreationOptions xr options to create the session with
  39320. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39321. * @returns Promise which resolves after it enters XR
  39322. */
  39323. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39324. /**
  39325. * Stops the xrSession and restores the renderloop
  39326. * @returns Promise which resolves after it exits XR
  39327. */
  39328. exitXRAsync(): Promise<void>;
  39329. /**
  39330. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39331. * @param ray ray to cast into the environment
  39332. * @returns Promise which resolves with a collision point in the environment if it exists
  39333. */
  39334. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39335. /**
  39336. * Checks if a session would be supported for the creation options specified
  39337. * @param options creation options to check if they are supported
  39338. * @returns true if supported
  39339. */
  39340. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39341. /**
  39342. * @hidden
  39343. * Converts the render layer of xrSession to a render target
  39344. * @param session session to create render target for
  39345. * @param scene scene the new render target should be created for
  39346. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39347. /**
  39348. * Disposes of the session manager
  39349. */
  39350. dispose(): void;
  39351. }
  39352. }
  39353. declare module BABYLON {
  39354. /**
  39355. * WebXR Camera which holds the views for the xrSession
  39356. * @see https://doc.babylonjs.com/how_to/webxr
  39357. */
  39358. export class WebXRCamera extends FreeCamera {
  39359. private static _TmpMatrix;
  39360. /**
  39361. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39362. * @param name the name of the camera
  39363. * @param scene the scene to add the camera to
  39364. */
  39365. constructor(name: string, scene: Scene);
  39366. private _updateNumberOfRigCameras;
  39367. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39368. /**
  39369. * Updates the cameras position from the current pose information of the XR session
  39370. * @param xrSessionManager the session containing pose information
  39371. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39372. */
  39373. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39374. }
  39375. }
  39376. declare module BABYLON {
  39377. /**
  39378. * States of the webXR experience
  39379. */
  39380. export enum WebXRState {
  39381. /**
  39382. * Transitioning to being in XR mode
  39383. */
  39384. ENTERING_XR = 0,
  39385. /**
  39386. * Transitioning to non XR mode
  39387. */
  39388. EXITING_XR = 1,
  39389. /**
  39390. * In XR mode and presenting
  39391. */
  39392. IN_XR = 2,
  39393. /**
  39394. * Not entered XR mode
  39395. */
  39396. NOT_IN_XR = 3
  39397. }
  39398. /**
  39399. * Helper class used to enable XR
  39400. * @see https://doc.babylonjs.com/how_to/webxr
  39401. */
  39402. export class WebXRExperienceHelper implements IDisposable {
  39403. private scene;
  39404. /**
  39405. * 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
  39406. */
  39407. container: AbstractMesh;
  39408. /**
  39409. * Camera used to render xr content
  39410. */
  39411. camera: WebXRCamera;
  39412. /**
  39413. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39414. */
  39415. state: WebXRState;
  39416. private _setState;
  39417. private static _TmpVector;
  39418. /**
  39419. * Fires when the state of the experience helper has changed
  39420. */
  39421. onStateChangedObservable: Observable<WebXRState>;
  39422. /** @hidden */ sessionManager: WebXRSessionManager;
  39423. private _nonVRCamera;
  39424. private _originalSceneAutoClear;
  39425. private _supported;
  39426. /**
  39427. * Creates the experience helper
  39428. * @param scene the scene to attach the experience helper to
  39429. * @returns a promise for the experience helper
  39430. */
  39431. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39432. /**
  39433. * Creates a WebXRExperienceHelper
  39434. * @param scene The scene the helper should be created in
  39435. */
  39436. private constructor();
  39437. /**
  39438. * Exits XR mode and returns the scene to its original state
  39439. * @returns promise that resolves after xr mode has exited
  39440. */
  39441. exitXRAsync(): Promise<void>;
  39442. /**
  39443. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39444. * @param sessionCreationOptions options for the XR session
  39445. * @param frameOfReference frame of reference of the XR session
  39446. * @returns promise that resolves after xr mode has entered
  39447. */
  39448. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39449. /**
  39450. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39451. * @param ray ray to cast into the environment
  39452. * @returns Promise which resolves with a collision point in the environment if it exists
  39453. */
  39454. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39455. /**
  39456. * Updates the global position of the camera by moving the camera's container
  39457. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39458. * @param position The desired global position of the camera
  39459. */
  39460. setPositionOfCameraUsingContainer(position: Vector3): void;
  39461. /**
  39462. * Rotates the xr camera by rotating the camera's container around the camera's position
  39463. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39464. * @param rotation the desired quaternion rotation to apply to the camera
  39465. */
  39466. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39467. /**
  39468. * Checks if the creation options are supported by the xr session
  39469. * @param options creation options
  39470. * @returns true if supported
  39471. */
  39472. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39473. /**
  39474. * Disposes of the experience helper
  39475. */
  39476. dispose(): void;
  39477. }
  39478. }
  39479. declare module BABYLON {
  39480. /**
  39481. * Button which can be used to enter a different mode of XR
  39482. */
  39483. export class WebXREnterExitUIButton {
  39484. /** button element */
  39485. element: HTMLElement;
  39486. /** XR initialization options for the button */
  39487. initializationOptions: XRSessionCreationOptions;
  39488. /**
  39489. * Creates a WebXREnterExitUIButton
  39490. * @param element button element
  39491. * @param initializationOptions XR initialization options for the button
  39492. */
  39493. constructor(
  39494. /** button element */
  39495. element: HTMLElement,
  39496. /** XR initialization options for the button */
  39497. initializationOptions: XRSessionCreationOptions);
  39498. /**
  39499. * Overwritable function which can be used to update the button's visuals when the state changes
  39500. * @param activeButton the current active button in the UI
  39501. */
  39502. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39503. }
  39504. /**
  39505. * Options to create the webXR UI
  39506. */
  39507. export class WebXREnterExitUIOptions {
  39508. /**
  39509. * Context to enter xr with
  39510. */
  39511. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39512. /**
  39513. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39514. */
  39515. customButtons?: Array<WebXREnterExitUIButton>;
  39516. }
  39517. /**
  39518. * UI to allow the user to enter/exit XR mode
  39519. */
  39520. export class WebXREnterExitUI implements IDisposable {
  39521. private scene;
  39522. private _overlay;
  39523. private _buttons;
  39524. private _activeButton;
  39525. /**
  39526. * Fired every time the active button is changed.
  39527. *
  39528. * When xr is entered via a button that launches xr that button will be the callback parameter
  39529. *
  39530. * When exiting xr the callback parameter will be null)
  39531. */
  39532. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39533. /**
  39534. * Creates UI to allow the user to enter/exit XR mode
  39535. * @param scene the scene to add the ui to
  39536. * @param helper the xr experience helper to enter/exit xr with
  39537. * @param options options to configure the UI
  39538. * @returns the created ui
  39539. */
  39540. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39541. private constructor();
  39542. private _updateButtons;
  39543. /**
  39544. * Disposes of the object
  39545. */
  39546. dispose(): void;
  39547. }
  39548. }
  39549. declare module BABYLON {
  39550. /**
  39551. * Represents an XR input
  39552. */
  39553. export class WebXRController {
  39554. /**
  39555. * 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
  39556. */
  39557. grip?: AbstractMesh;
  39558. /**
  39559. * Pointer which can be used to select objects or attach a visible laser to
  39560. */
  39561. pointer: AbstractMesh;
  39562. /**
  39563. * Creates the controller
  39564. * @see https://doc.babylonjs.com/how_to/webxr
  39565. * @param scene the scene which the controller should be associated to
  39566. */
  39567. constructor(scene: Scene);
  39568. /**
  39569. * Disposes of the object
  39570. */
  39571. dispose(): void;
  39572. }
  39573. /**
  39574. * XR input used to track XR inputs such as controllers/rays
  39575. */
  39576. export class WebXRInput implements IDisposable {
  39577. private helper;
  39578. /**
  39579. * XR controllers being tracked
  39580. */
  39581. controllers: Array<WebXRController>;
  39582. private _tmpMatrix;
  39583. private _frameObserver;
  39584. /**
  39585. * Initializes the WebXRInput
  39586. * @param helper experience helper which the input should be created for
  39587. */
  39588. constructor(helper: WebXRExperienceHelper);
  39589. /**
  39590. * Disposes of the object
  39591. */
  39592. dispose(): void;
  39593. }
  39594. }
  39595. declare module BABYLON {
  39596. /**
  39597. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39598. */
  39599. export class WebXRManagedOutputCanvas implements IDisposable {
  39600. private _canvas;
  39601. /**
  39602. * xrpresent context of the canvas which can be used to display/mirror xr content
  39603. */
  39604. canvasContext: Nullable<WebGLRenderingContext>;
  39605. /**
  39606. * Initializes the canvas to be added/removed upon entering/exiting xr
  39607. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39608. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39609. */
  39610. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39611. /**
  39612. * Disposes of the object
  39613. */
  39614. dispose(): void;
  39615. private _setManagedOutputCanvas;
  39616. private _addCanvas;
  39617. private _removeCanvas;
  39618. }
  39619. }
  39620. declare module BABYLON {
  39621. /**
  39622. * Contains an array of blocks representing the octree
  39623. */
  39624. export interface IOctreeContainer<T> {
  39625. /**
  39626. * Blocks within the octree
  39627. */
  39628. blocks: Array<OctreeBlock<T>>;
  39629. }
  39630. /**
  39631. * Class used to store a cell in an octree
  39632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39633. */
  39634. export class OctreeBlock<T> {
  39635. /**
  39636. * Gets the content of the current block
  39637. */
  39638. entries: T[];
  39639. /**
  39640. * Gets the list of block children
  39641. */
  39642. blocks: Array<OctreeBlock<T>>;
  39643. private _depth;
  39644. private _maxDepth;
  39645. private _capacity;
  39646. private _minPoint;
  39647. private _maxPoint;
  39648. private _boundingVectors;
  39649. private _creationFunc;
  39650. /**
  39651. * Creates a new block
  39652. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39653. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39654. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39655. * @param depth defines the current depth of this block in the octree
  39656. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39657. * @param creationFunc defines a callback to call when an element is added to the block
  39658. */
  39659. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39660. /**
  39661. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39662. */
  39663. readonly capacity: number;
  39664. /**
  39665. * Gets the minimum vector (in world space) of the block's bounding box
  39666. */
  39667. readonly minPoint: Vector3;
  39668. /**
  39669. * Gets the maximum vector (in world space) of the block's bounding box
  39670. */
  39671. readonly maxPoint: Vector3;
  39672. /**
  39673. * Add a new element to this block
  39674. * @param entry defines the element to add
  39675. */
  39676. addEntry(entry: T): void;
  39677. /**
  39678. * Remove an element from this block
  39679. * @param entry defines the element to remove
  39680. */
  39681. removeEntry(entry: T): void;
  39682. /**
  39683. * Add an array of elements to this block
  39684. * @param entries defines the array of elements to add
  39685. */
  39686. addEntries(entries: T[]): void;
  39687. /**
  39688. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39689. * @param frustumPlanes defines the frustum planes to test
  39690. * @param selection defines the array to store current content if selection is positive
  39691. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39692. */
  39693. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39694. /**
  39695. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39696. * @param sphereCenter defines the bounding sphere center
  39697. * @param sphereRadius defines the bounding sphere radius
  39698. * @param selection defines the array to store current content if selection is positive
  39699. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39700. */
  39701. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39702. /**
  39703. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39704. * @param ray defines the ray to test with
  39705. * @param selection defines the array to store current content if selection is positive
  39706. */
  39707. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39708. /**
  39709. * Subdivide the content into child blocks (this block will then be empty)
  39710. */
  39711. createInnerBlocks(): void;
  39712. /**
  39713. * @hidden
  39714. */ 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;
  39715. }
  39716. }
  39717. declare module BABYLON {
  39718. /**
  39719. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39720. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39721. */
  39722. export class Octree<T> {
  39723. /** 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.) */
  39724. maxDepth: number;
  39725. /**
  39726. * Blocks within the octree containing objects
  39727. */
  39728. blocks: Array<OctreeBlock<T>>;
  39729. /**
  39730. * Content stored in the octree
  39731. */
  39732. dynamicContent: T[];
  39733. private _maxBlockCapacity;
  39734. private _selectionContent;
  39735. private _creationFunc;
  39736. /**
  39737. * Creates a octree
  39738. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39739. * @param creationFunc function to be used to instatiate the octree
  39740. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39741. * @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.)
  39742. */
  39743. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39744. /** 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.) */
  39745. maxDepth?: number);
  39746. /**
  39747. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39748. * @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);
  39749. * @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);
  39750. * @param entries meshes to be added to the octree blocks
  39751. */
  39752. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39753. /**
  39754. * Adds a mesh to the octree
  39755. * @param entry Mesh to add to the octree
  39756. */
  39757. addMesh(entry: T): void;
  39758. /**
  39759. * Remove an element from the octree
  39760. * @param entry defines the element to remove
  39761. */
  39762. removeMesh(entry: T): void;
  39763. /**
  39764. * Selects an array of meshes within the frustum
  39765. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39766. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39767. * @returns array of meshes within the frustum
  39768. */
  39769. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39770. /**
  39771. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39772. * @param sphereCenter defines the bounding sphere center
  39773. * @param sphereRadius defines the bounding sphere radius
  39774. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39775. * @returns an array of objects that intersect the sphere
  39776. */
  39777. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39778. /**
  39779. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39780. * @param ray defines the ray to test with
  39781. * @returns array of intersected objects
  39782. */
  39783. intersectsRay(ray: Ray): SmartArray<T>;
  39784. /**
  39785. * Adds a mesh into the octree block if it intersects the block
  39786. */
  39787. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39788. /**
  39789. * Adds a submesh into the octree block if it intersects the block
  39790. */
  39791. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39792. }
  39793. }
  39794. declare module BABYLON {
  39795. interface Scene {
  39796. /**
  39797. * @hidden
  39798. * Backing Filed
  39799. */ selectionOctree: Octree<AbstractMesh>;
  39800. /**
  39801. * Gets the octree used to boost mesh selection (picking)
  39802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39803. */
  39804. selectionOctree: Octree<AbstractMesh>;
  39805. /**
  39806. * Creates or updates the octree used to boost selection (picking)
  39807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39808. * @param maxCapacity defines the maximum capacity per leaf
  39809. * @param maxDepth defines the maximum depth of the octree
  39810. * @returns an octree of AbstractMesh
  39811. */
  39812. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39813. }
  39814. interface AbstractMesh {
  39815. /**
  39816. * @hidden
  39817. * Backing Field
  39818. */ submeshesOctree: Octree<SubMesh>;
  39819. /**
  39820. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39821. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39822. * @param maxCapacity defines the maximum size of each block (64 by default)
  39823. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39824. * @returns the new octree
  39825. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39827. */
  39828. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39829. }
  39830. /**
  39831. * Defines the octree scene component responsible to manage any octrees
  39832. * in a given scene.
  39833. */
  39834. export class OctreeSceneComponent {
  39835. /**
  39836. * The component name help to identify the component in the list of scene components.
  39837. */
  39838. readonly name: string;
  39839. /**
  39840. * The scene the component belongs to.
  39841. */
  39842. scene: Scene;
  39843. /**
  39844. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39845. */
  39846. readonly checksIsEnabled: boolean;
  39847. /**
  39848. * Creates a new instance of the component for the given scene
  39849. * @param scene Defines the scene to register the component in
  39850. */
  39851. constructor(scene: Scene);
  39852. /**
  39853. * Registers the component in a given scene
  39854. */
  39855. register(): void;
  39856. /**
  39857. * Return the list of active meshes
  39858. * @returns the list of active meshes
  39859. */
  39860. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39861. /**
  39862. * Return the list of active sub meshes
  39863. * @param mesh The mesh to get the candidates sub meshes from
  39864. * @returns the list of active sub meshes
  39865. */
  39866. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39867. private _tempRay;
  39868. /**
  39869. * Return the list of sub meshes intersecting with a given local ray
  39870. * @param mesh defines the mesh to find the submesh for
  39871. * @param localRay defines the ray in local space
  39872. * @returns the list of intersecting sub meshes
  39873. */
  39874. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39875. /**
  39876. * Return the list of sub meshes colliding with a collider
  39877. * @param mesh defines the mesh to find the submesh for
  39878. * @param collider defines the collider to evaluate the collision against
  39879. * @returns the list of colliding sub meshes
  39880. */
  39881. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39882. /**
  39883. * Rebuilds the elements related to this component in case of
  39884. * context lost for instance.
  39885. */
  39886. rebuild(): void;
  39887. /**
  39888. * Disposes the component and the associated ressources.
  39889. */
  39890. dispose(): void;
  39891. }
  39892. }
  39893. declare module BABYLON {
  39894. /**
  39895. * Renders a layer on top of an existing scene
  39896. */
  39897. export class UtilityLayerRenderer implements IDisposable {
  39898. /** the original scene that will be rendered on top of */
  39899. originalScene: Scene;
  39900. private _pointerCaptures;
  39901. private _lastPointerEvents;
  39902. private static _DefaultUtilityLayer;
  39903. private static _DefaultKeepDepthUtilityLayer;
  39904. private _sharedGizmoLight;
  39905. /**
  39906. * @hidden
  39907. * Light which used by gizmos to get light shading
  39908. */ getSharedGizmoLight(): HemisphericLight;
  39909. /**
  39910. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39911. */
  39912. pickUtilitySceneFirst: boolean;
  39913. /**
  39914. * 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)
  39915. */
  39916. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39917. /**
  39918. * 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)
  39919. */
  39920. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39921. /**
  39922. * The scene that is rendered on top of the original scene
  39923. */
  39924. utilityLayerScene: Scene;
  39925. /**
  39926. * If the utility layer should automatically be rendered on top of existing scene
  39927. */
  39928. shouldRender: boolean;
  39929. /**
  39930. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39931. */
  39932. onlyCheckPointerDownEvents: boolean;
  39933. /**
  39934. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39935. */
  39936. processAllEvents: boolean;
  39937. /**
  39938. * Observable raised when the pointer move from the utility layer scene to the main scene
  39939. */
  39940. onPointerOutObservable: Observable<number>;
  39941. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39942. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39943. private _afterRenderObserver;
  39944. private _sceneDisposeObserver;
  39945. private _originalPointerObserver;
  39946. /**
  39947. * Instantiates a UtilityLayerRenderer
  39948. * @param originalScene the original scene that will be rendered on top of
  39949. * @param handleEvents boolean indicating if the utility layer should handle events
  39950. */
  39951. constructor(
  39952. /** the original scene that will be rendered on top of */
  39953. originalScene: Scene, handleEvents?: boolean);
  39954. private _notifyObservers;
  39955. /**
  39956. * Renders the utility layers scene on top of the original scene
  39957. */
  39958. render(): void;
  39959. /**
  39960. * Disposes of the renderer
  39961. */
  39962. dispose(): void;
  39963. private _updateCamera;
  39964. }
  39965. }
  39966. declare module BABYLON {
  39967. /**
  39968. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39969. */
  39970. export class Gizmo implements IDisposable {
  39971. /** The utility layer the gizmo will be added to */
  39972. gizmoLayer: UtilityLayerRenderer;
  39973. /**
  39974. * The root mesh of the gizmo
  39975. */ rootMesh: Mesh;
  39976. private _attachedMesh;
  39977. /**
  39978. * Ratio for the scale of the gizmo (Default: 1)
  39979. */
  39980. scaleRatio: number;
  39981. /**
  39982. * If a custom mesh has been set (Default: false)
  39983. */
  39984. protected _customMeshSet: boolean;
  39985. /**
  39986. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39987. * * When set, interactions will be enabled
  39988. */
  39989. attachedMesh: Nullable<AbstractMesh>;
  39990. /**
  39991. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39992. * @param mesh The mesh to replace the default mesh of the gizmo
  39993. */
  39994. setCustomMesh(mesh: Mesh): void;
  39995. /**
  39996. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39997. */
  39998. updateGizmoRotationToMatchAttachedMesh: boolean;
  39999. /**
  40000. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40001. */
  40002. updateGizmoPositionToMatchAttachedMesh: boolean;
  40003. /**
  40004. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40005. */
  40006. protected _updateScale: boolean;
  40007. protected _interactionsEnabled: boolean;
  40008. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40009. private _beforeRenderObserver;
  40010. private _tempVector;
  40011. /**
  40012. * Creates a gizmo
  40013. * @param gizmoLayer The utility layer the gizmo will be added to
  40014. */
  40015. constructor(
  40016. /** The utility layer the gizmo will be added to */
  40017. gizmoLayer?: UtilityLayerRenderer);
  40018. /**
  40019. * Updates the gizmo to match the attached mesh's position/rotation
  40020. */
  40021. protected _update(): void;
  40022. /**
  40023. * Disposes of the gizmo
  40024. */
  40025. dispose(): void;
  40026. }
  40027. }
  40028. declare module BABYLON {
  40029. /**
  40030. * Single axis drag gizmo
  40031. */
  40032. export class AxisDragGizmo extends Gizmo {
  40033. /**
  40034. * Drag behavior responsible for the gizmos dragging interactions
  40035. */
  40036. dragBehavior: PointerDragBehavior;
  40037. private _pointerObserver;
  40038. /**
  40039. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40040. */
  40041. snapDistance: number;
  40042. /**
  40043. * Event that fires each time the gizmo snaps to a new location.
  40044. * * snapDistance is the the change in distance
  40045. */
  40046. onSnapObservable: Observable<{
  40047. snapDistance: number;
  40048. }>;
  40049. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40050. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40051. /**
  40052. * Creates an AxisDragGizmo
  40053. * @param gizmoLayer The utility layer the gizmo will be added to
  40054. * @param dragAxis The axis which the gizmo will be able to drag on
  40055. * @param color The color of the gizmo
  40056. */
  40057. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40058. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40059. /**
  40060. * Disposes of the gizmo
  40061. */
  40062. dispose(): void;
  40063. }
  40064. }
  40065. declare module BABYLON.Debug {
  40066. /**
  40067. * The Axes viewer will show 3 axes in a specific point in space
  40068. */
  40069. export class AxesViewer {
  40070. private _xAxis;
  40071. private _yAxis;
  40072. private _zAxis;
  40073. private _scaleLinesFactor;
  40074. private _instanced;
  40075. /**
  40076. * Gets the hosting scene
  40077. */
  40078. scene: Scene;
  40079. /**
  40080. * Gets or sets a number used to scale line length
  40081. */
  40082. scaleLines: number;
  40083. /** Gets the node hierarchy used to render x-axis */
  40084. readonly xAxis: TransformNode;
  40085. /** Gets the node hierarchy used to render y-axis */
  40086. readonly yAxis: TransformNode;
  40087. /** Gets the node hierarchy used to render z-axis */
  40088. readonly zAxis: TransformNode;
  40089. /**
  40090. * Creates a new AxesViewer
  40091. * @param scene defines the hosting scene
  40092. * @param scaleLines defines a number used to scale line length (1 by default)
  40093. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40094. * @param xAxis defines the node hierarchy used to render the x-axis
  40095. * @param yAxis defines the node hierarchy used to render the y-axis
  40096. * @param zAxis defines the node hierarchy used to render the z-axis
  40097. */
  40098. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40099. /**
  40100. * Force the viewer to update
  40101. * @param position defines the position of the viewer
  40102. * @param xaxis defines the x axis of the viewer
  40103. * @param yaxis defines the y axis of the viewer
  40104. * @param zaxis defines the z axis of the viewer
  40105. */
  40106. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40107. /**
  40108. * Creates an instance of this axes viewer.
  40109. * @returns a new axes viewer with instanced meshes
  40110. */
  40111. createInstance(): AxesViewer;
  40112. /** Releases resources */
  40113. dispose(): void;
  40114. private static _SetRenderingGroupId;
  40115. }
  40116. }
  40117. declare module BABYLON.Debug {
  40118. /**
  40119. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40120. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40121. */
  40122. export class BoneAxesViewer extends AxesViewer {
  40123. /**
  40124. * Gets or sets the target mesh where to display the axes viewer
  40125. */
  40126. mesh: Nullable<Mesh>;
  40127. /**
  40128. * Gets or sets the target bone where to display the axes viewer
  40129. */
  40130. bone: Nullable<Bone>;
  40131. /** Gets current position */
  40132. pos: Vector3;
  40133. /** Gets direction of X axis */
  40134. xaxis: Vector3;
  40135. /** Gets direction of Y axis */
  40136. yaxis: Vector3;
  40137. /** Gets direction of Z axis */
  40138. zaxis: Vector3;
  40139. /**
  40140. * Creates a new BoneAxesViewer
  40141. * @param scene defines the hosting scene
  40142. * @param bone defines the target bone
  40143. * @param mesh defines the target mesh
  40144. * @param scaleLines defines a scaling factor for line length (1 by default)
  40145. */
  40146. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40147. /**
  40148. * Force the viewer to update
  40149. */
  40150. update(): void;
  40151. /** Releases resources */
  40152. dispose(): void;
  40153. }
  40154. }
  40155. declare module BABYLON {
  40156. /**
  40157. * Interface used to define scene explorer extensibility option
  40158. */
  40159. export interface IExplorerExtensibilityOption {
  40160. /**
  40161. * Define the option label
  40162. */
  40163. label: string;
  40164. /**
  40165. * Defines the action to execute on click
  40166. */
  40167. action: (entity: any) => void;
  40168. }
  40169. /**
  40170. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40171. */
  40172. export interface IExplorerExtensibilityGroup {
  40173. /**
  40174. * Defines a predicate to test if a given type mut be extended
  40175. */
  40176. predicate: (entity: any) => boolean;
  40177. /**
  40178. * Gets the list of options added to a type
  40179. */
  40180. entries: IExplorerExtensibilityOption[];
  40181. }
  40182. /**
  40183. * Interface used to define the options to use to create the Inspector
  40184. */
  40185. export interface IInspectorOptions {
  40186. /**
  40187. * Display in overlay mode (default: false)
  40188. */
  40189. overlay?: boolean;
  40190. /**
  40191. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40192. */
  40193. globalRoot?: HTMLElement;
  40194. /**
  40195. * Display the Scene explorer
  40196. */
  40197. showExplorer?: boolean;
  40198. /**
  40199. * Display the property inspector
  40200. */
  40201. showInspector?: boolean;
  40202. /**
  40203. * Display in embed mode (both panes on the right)
  40204. */
  40205. embedMode?: boolean;
  40206. /**
  40207. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40208. */
  40209. handleResize?: boolean;
  40210. /**
  40211. * Allow the panes to popup (default: true)
  40212. */
  40213. enablePopup?: boolean;
  40214. /**
  40215. * Allow the panes to be closed by users (default: true)
  40216. */
  40217. enableClose?: boolean;
  40218. /**
  40219. * Optional list of extensibility entries
  40220. */
  40221. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40222. /**
  40223. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40224. */
  40225. inspectorURL?: string;
  40226. }
  40227. interface Scene {
  40228. /**
  40229. * @hidden
  40230. * Backing field
  40231. */ debugLayer: DebugLayer;
  40232. /**
  40233. * Gets the debug layer (aka Inspector) associated with the scene
  40234. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40235. */
  40236. debugLayer: DebugLayer;
  40237. }
  40238. /**
  40239. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40240. * what is happening in your scene
  40241. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40242. */
  40243. export class DebugLayer {
  40244. /**
  40245. * Define the url to get the inspector script from.
  40246. * By default it uses the babylonjs CDN.
  40247. * @ignoreNaming
  40248. */
  40249. static InspectorURL: string;
  40250. private _scene;
  40251. private BJSINSPECTOR;
  40252. /**
  40253. * Observable triggered when a property is changed through the inspector.
  40254. */
  40255. onPropertyChangedObservable: Observable<{
  40256. object: any;
  40257. property: string;
  40258. value: any;
  40259. initialValue: any;
  40260. }>;
  40261. /**
  40262. * Instantiates a new debug layer.
  40263. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40264. * what is happening in your scene
  40265. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40266. * @param scene Defines the scene to inspect
  40267. */
  40268. constructor(scene: Scene);
  40269. /** Creates the inspector window. */
  40270. private _createInspector;
  40271. /**
  40272. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40273. * @param entity defines the entity to select
  40274. * @param lineContainerTitle defines the specific block to highlight
  40275. */
  40276. select(entity: any, lineContainerTitle?: string): void;
  40277. /** Get the inspector from bundle or global */
  40278. private _getGlobalInspector;
  40279. /**
  40280. * Get if the inspector is visible or not.
  40281. * @returns true if visible otherwise, false
  40282. */
  40283. isVisible(): boolean;
  40284. /**
  40285. * Hide the inspector and close its window.
  40286. */
  40287. hide(): void;
  40288. /**
  40289. * Launch the debugLayer.
  40290. * @param config Define the configuration of the inspector
  40291. * @return a promise fulfilled when the debug layer is visible
  40292. */
  40293. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40294. }
  40295. }
  40296. declare module BABYLON {
  40297. /**
  40298. * Class containing static functions to help procedurally build meshes
  40299. */
  40300. export class BoxBuilder {
  40301. /**
  40302. * Creates a box mesh
  40303. * * The parameter `size` sets the size (float) of each box side (default 1)
  40304. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40305. * * 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)
  40306. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40308. * * 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
  40309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40310. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40311. * @param name defines the name of the mesh
  40312. * @param options defines the options used to create the mesh
  40313. * @param scene defines the hosting scene
  40314. * @returns the box mesh
  40315. */
  40316. static CreateBox(name: string, options: {
  40317. size?: number;
  40318. width?: number;
  40319. height?: number;
  40320. depth?: number;
  40321. faceUV?: Vector4[];
  40322. faceColors?: Color4[];
  40323. sideOrientation?: number;
  40324. frontUVs?: Vector4;
  40325. backUVs?: Vector4;
  40326. wrap?: boolean;
  40327. topBaseAt?: number;
  40328. bottomBaseAt?: number;
  40329. updatable?: boolean;
  40330. }, scene?: Nullable<Scene>): Mesh;
  40331. }
  40332. }
  40333. declare module BABYLON {
  40334. /**
  40335. * Class containing static functions to help procedurally build meshes
  40336. */
  40337. export class SphereBuilder {
  40338. /**
  40339. * Creates a sphere mesh
  40340. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40341. * * 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`)
  40342. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40343. * * 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
  40344. * * 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)
  40345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40346. * * 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
  40347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40348. * @param name defines the name of the mesh
  40349. * @param options defines the options used to create the mesh
  40350. * @param scene defines the hosting scene
  40351. * @returns the sphere mesh
  40352. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40353. */
  40354. static CreateSphere(name: string, options: {
  40355. segments?: number;
  40356. diameter?: number;
  40357. diameterX?: number;
  40358. diameterY?: number;
  40359. diameterZ?: number;
  40360. arc?: number;
  40361. slice?: number;
  40362. sideOrientation?: number;
  40363. frontUVs?: Vector4;
  40364. backUVs?: Vector4;
  40365. updatable?: boolean;
  40366. }, scene: any): Mesh;
  40367. }
  40368. }
  40369. declare module BABYLON.Debug {
  40370. /**
  40371. * Used to show the physics impostor around the specific mesh
  40372. */
  40373. export class PhysicsViewer {
  40374. /** @hidden */
  40375. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40376. /** @hidden */
  40377. protected _meshes: Array<Nullable<AbstractMesh>>;
  40378. /** @hidden */
  40379. protected _scene: Nullable<Scene>;
  40380. /** @hidden */
  40381. protected _numMeshes: number;
  40382. /** @hidden */
  40383. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40384. private _renderFunction;
  40385. private _utilityLayer;
  40386. private _debugBoxMesh;
  40387. private _debugSphereMesh;
  40388. private _debugCylinderMesh;
  40389. private _debugMaterial;
  40390. private _debugMeshMeshes;
  40391. /**
  40392. * Creates a new PhysicsViewer
  40393. * @param scene defines the hosting scene
  40394. */
  40395. constructor(scene: Scene);
  40396. /** @hidden */
  40397. protected _updateDebugMeshes(): void;
  40398. /**
  40399. * Renders a specified physic impostor
  40400. * @param impostor defines the impostor to render
  40401. * @param targetMesh defines the mesh represented by the impostor
  40402. * @returns the new debug mesh used to render the impostor
  40403. */
  40404. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40405. /**
  40406. * Hides a specified physic impostor
  40407. * @param impostor defines the impostor to hide
  40408. */
  40409. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40410. private _getDebugMaterial;
  40411. private _getDebugBoxMesh;
  40412. private _getDebugSphereMesh;
  40413. private _getDebugCylinderMesh;
  40414. private _getDebugMeshMesh;
  40415. private _getDebugMesh;
  40416. /** Releases all resources */
  40417. dispose(): void;
  40418. }
  40419. }
  40420. declare module BABYLON {
  40421. /**
  40422. * Class containing static functions to help procedurally build meshes
  40423. */
  40424. export class LinesBuilder {
  40425. /**
  40426. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40427. * * 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
  40428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40429. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40430. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40431. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40432. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40433. * * 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
  40434. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40437. * @param name defines the name of the new line system
  40438. * @param options defines the options used to create the line system
  40439. * @param scene defines the hosting scene
  40440. * @returns a new line system mesh
  40441. */
  40442. static CreateLineSystem(name: string, options: {
  40443. lines: Vector3[][];
  40444. updatable?: boolean;
  40445. instance?: Nullable<LinesMesh>;
  40446. colors?: Nullable<Color4[][]>;
  40447. useVertexAlpha?: boolean;
  40448. }, scene: Nullable<Scene>): LinesMesh;
  40449. /**
  40450. * Creates a line mesh
  40451. * 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
  40452. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40453. * * The parameter `points` is an array successive Vector3
  40454. * * 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
  40455. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40456. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40457. * * When updating an instance, remember that only point positions can change, not the number of points
  40458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40460. * @param name defines the name of the new line system
  40461. * @param options defines the options used to create the line system
  40462. * @param scene defines the hosting scene
  40463. * @returns a new line mesh
  40464. */
  40465. static CreateLines(name: string, options: {
  40466. points: Vector3[];
  40467. updatable?: boolean;
  40468. instance?: Nullable<LinesMesh>;
  40469. colors?: Color4[];
  40470. useVertexAlpha?: boolean;
  40471. }, scene?: Nullable<Scene>): LinesMesh;
  40472. /**
  40473. * Creates a dashed line mesh
  40474. * * 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
  40475. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40476. * * The parameter `points` is an array successive Vector3
  40477. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40478. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40479. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40480. * * 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
  40481. * * When updating an instance, remember that only point positions can change, not the number of points
  40482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40483. * @param name defines the name of the mesh
  40484. * @param options defines the options used to create the mesh
  40485. * @param scene defines the hosting scene
  40486. * @returns the dashed line mesh
  40487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40488. */
  40489. static CreateDashedLines(name: string, options: {
  40490. points: Vector3[];
  40491. dashSize?: number;
  40492. gapSize?: number;
  40493. dashNb?: number;
  40494. updatable?: boolean;
  40495. instance?: LinesMesh;
  40496. }, scene?: Nullable<Scene>): LinesMesh;
  40497. }
  40498. }
  40499. declare module BABYLON {
  40500. /**
  40501. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40502. * in order to better appreciate the issue one might have.
  40503. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40504. */
  40505. export class RayHelper {
  40506. /**
  40507. * Defines the ray we are currently tryin to visualize.
  40508. */
  40509. ray: Nullable<Ray>;
  40510. private _renderPoints;
  40511. private _renderLine;
  40512. private _renderFunction;
  40513. private _scene;
  40514. private _updateToMeshFunction;
  40515. private _attachedToMesh;
  40516. private _meshSpaceDirection;
  40517. private _meshSpaceOrigin;
  40518. /**
  40519. * Helper function to create a colored helper in a scene in one line.
  40520. * @param ray Defines the ray we are currently tryin to visualize
  40521. * @param scene Defines the scene the ray is used in
  40522. * @param color Defines the color we want to see the ray in
  40523. * @returns The newly created ray helper.
  40524. */
  40525. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40526. /**
  40527. * Instantiate a new ray helper.
  40528. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40529. * in order to better appreciate the issue one might have.
  40530. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40531. * @param ray Defines the ray we are currently tryin to visualize
  40532. */
  40533. constructor(ray: Ray);
  40534. /**
  40535. * Shows the ray we are willing to debug.
  40536. * @param scene Defines the scene the ray needs to be rendered in
  40537. * @param color Defines the color the ray needs to be rendered in
  40538. */
  40539. show(scene: Scene, color?: Color3): void;
  40540. /**
  40541. * Hides the ray we are debugging.
  40542. */
  40543. hide(): void;
  40544. private _render;
  40545. /**
  40546. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40547. * @param mesh Defines the mesh we want the helper attached to
  40548. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40549. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40550. * @param length Defines the length of the ray
  40551. */
  40552. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40553. /**
  40554. * Detach the ray helper from the mesh it has previously been attached to.
  40555. */
  40556. detachFromMesh(): void;
  40557. private _updateToMesh;
  40558. /**
  40559. * Dispose the helper and release its associated resources.
  40560. */
  40561. dispose(): void;
  40562. }
  40563. }
  40564. declare module BABYLON.Debug {
  40565. /**
  40566. * Class used to render a debug view of a given skeleton
  40567. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40568. */
  40569. export class SkeletonViewer {
  40570. /** defines the skeleton to render */
  40571. skeleton: Skeleton;
  40572. /** defines the mesh attached to the skeleton */
  40573. mesh: AbstractMesh;
  40574. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40575. autoUpdateBonesMatrices: boolean;
  40576. /** defines the rendering group id to use with the viewer */
  40577. renderingGroupId: number;
  40578. /** Gets or sets the color used to render the skeleton */
  40579. color: Color3;
  40580. private _scene;
  40581. private _debugLines;
  40582. private _debugMesh;
  40583. private _isEnabled;
  40584. private _renderFunction;
  40585. private _utilityLayer;
  40586. /**
  40587. * Returns the mesh used to render the bones
  40588. */
  40589. readonly debugMesh: Nullable<LinesMesh>;
  40590. /**
  40591. * Creates a new SkeletonViewer
  40592. * @param skeleton defines the skeleton to render
  40593. * @param mesh defines the mesh attached to the skeleton
  40594. * @param scene defines the hosting scene
  40595. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40596. * @param renderingGroupId defines the rendering group id to use with the viewer
  40597. */
  40598. constructor(
  40599. /** defines the skeleton to render */
  40600. skeleton: Skeleton,
  40601. /** defines the mesh attached to the skeleton */
  40602. mesh: AbstractMesh, scene: Scene,
  40603. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40604. autoUpdateBonesMatrices?: boolean,
  40605. /** defines the rendering group id to use with the viewer */
  40606. renderingGroupId?: number);
  40607. /** Gets or sets a boolean indicating if the viewer is enabled */
  40608. isEnabled: boolean;
  40609. private _getBonePosition;
  40610. private _getLinesForBonesWithLength;
  40611. private _getLinesForBonesNoLength;
  40612. /** Update the viewer to sync with current skeleton state */
  40613. update(): void;
  40614. /** Release associated resources */
  40615. dispose(): void;
  40616. }
  40617. }
  40618. declare module BABYLON {
  40619. /**
  40620. * Options to create the null engine
  40621. */
  40622. export class NullEngineOptions {
  40623. /**
  40624. * Render width (Default: 512)
  40625. */
  40626. renderWidth: number;
  40627. /**
  40628. * Render height (Default: 256)
  40629. */
  40630. renderHeight: number;
  40631. /**
  40632. * Texture size (Default: 512)
  40633. */
  40634. textureSize: number;
  40635. /**
  40636. * If delta time between frames should be constant
  40637. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40638. */
  40639. deterministicLockstep: boolean;
  40640. /**
  40641. * Maximum about of steps between frames (Default: 4)
  40642. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40643. */
  40644. lockstepMaxSteps: number;
  40645. }
  40646. /**
  40647. * The null engine class provides support for headless version of babylon.js.
  40648. * This can be used in server side scenario or for testing purposes
  40649. */
  40650. export class NullEngine extends Engine {
  40651. private _options;
  40652. /**
  40653. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40654. */
  40655. isDeterministicLockStep(): boolean;
  40656. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40657. getLockstepMaxSteps(): number;
  40658. /**
  40659. * Sets hardware scaling, used to save performance if needed
  40660. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40661. */
  40662. getHardwareScalingLevel(): number;
  40663. constructor(options?: NullEngineOptions);
  40664. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40665. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40666. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40667. getRenderWidth(useScreen?: boolean): number;
  40668. getRenderHeight(useScreen?: boolean): number;
  40669. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40670. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40671. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40672. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40673. bindSamplers(effect: Effect): void;
  40674. enableEffect(effect: Effect): void;
  40675. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40676. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40677. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40678. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40679. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40680. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40681. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40682. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40683. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40684. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40685. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40686. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40687. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40688. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40689. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40690. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40691. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40692. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40693. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40694. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40695. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40696. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40697. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40698. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40699. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40700. bindBuffers(vertexBuffers: {
  40701. [key: string]: VertexBuffer;
  40702. }, indexBuffer: DataBuffer, effect: Effect): void;
  40703. wipeCaches(bruteForce?: boolean): void;
  40704. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40705. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40706. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40707. /** @hidden */ createTexture(): WebGLTexture;
  40708. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40709. 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;
  40710. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40711. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40712. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40713. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40714. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40715. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40716. areAllEffectsReady(): boolean;
  40717. /**
  40718. * @hidden
  40719. * Get the current error code of the webGL context
  40720. * @returns the error code
  40721. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40722. */
  40723. getError(): number;
  40724. /** @hidden */ getUnpackAlignement(): number;
  40725. /** @hidden */ unpackFlipY(value: boolean): void;
  40726. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40727. /**
  40728. * Updates a dynamic vertex buffer.
  40729. * @param vertexBuffer the vertex buffer to update
  40730. * @param data the data used to update the vertex buffer
  40731. * @param byteOffset the byte offset of the data (optional)
  40732. * @param byteLength the byte length of the data (optional)
  40733. */
  40734. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40735. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40736. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  40737. releaseEffects(): void;
  40738. displayLoadingUI(): void;
  40739. hideLoadingUI(): void;
  40740. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40741. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40742. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40743. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40744. }
  40745. }
  40746. declare module BABYLON {
  40747. /** @hidden */
  40748. export class _OcclusionDataStorage {
  40749. /** @hidden */
  40750. occlusionInternalRetryCounter: number;
  40751. /** @hidden */
  40752. isOcclusionQueryInProgress: boolean;
  40753. /** @hidden */
  40754. isOccluded: boolean;
  40755. /** @hidden */
  40756. occlusionRetryCount: number;
  40757. /** @hidden */
  40758. occlusionType: number;
  40759. /** @hidden */
  40760. occlusionQueryAlgorithmType: number;
  40761. }
  40762. interface Engine {
  40763. /**
  40764. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40765. * @return the new query
  40766. */
  40767. createQuery(): WebGLQuery;
  40768. /**
  40769. * Delete and release a webGL query
  40770. * @param query defines the query to delete
  40771. * @return the current engine
  40772. */
  40773. deleteQuery(query: WebGLQuery): Engine;
  40774. /**
  40775. * Check if a given query has resolved and got its value
  40776. * @param query defines the query to check
  40777. * @returns true if the query got its value
  40778. */
  40779. isQueryResultAvailable(query: WebGLQuery): boolean;
  40780. /**
  40781. * Gets the value of a given query
  40782. * @param query defines the query to check
  40783. * @returns the value of the query
  40784. */
  40785. getQueryResult(query: WebGLQuery): number;
  40786. /**
  40787. * Initiates an occlusion query
  40788. * @param algorithmType defines the algorithm to use
  40789. * @param query defines the query to use
  40790. * @returns the current engine
  40791. * @see http://doc.babylonjs.com/features/occlusionquery
  40792. */
  40793. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40794. /**
  40795. * Ends an occlusion query
  40796. * @see http://doc.babylonjs.com/features/occlusionquery
  40797. * @param algorithmType defines the algorithm to use
  40798. * @returns the current engine
  40799. */
  40800. endOcclusionQuery(algorithmType: number): Engine;
  40801. /**
  40802. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40803. * Please note that only one query can be issued at a time
  40804. * @returns a time token used to track the time span
  40805. */
  40806. startTimeQuery(): Nullable<_TimeToken>;
  40807. /**
  40808. * Ends a time query
  40809. * @param token defines the token used to measure the time span
  40810. * @returns the time spent (in ns)
  40811. */
  40812. endTimeQuery(token: _TimeToken): int;
  40813. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40814. /** @hidden */ createTimeQuery(): WebGLQuery;
  40815. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40816. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40817. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40818. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40819. }
  40820. interface AbstractMesh {
  40821. /**
  40822. * Backing filed
  40823. * @hidden
  40824. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40825. /**
  40826. * Access property
  40827. * @hidden
  40828. */ occlusionDataStorage: _OcclusionDataStorage;
  40829. /**
  40830. * 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.
  40831. * The default value is -1 which means don't break the query and wait till the result
  40832. * @see http://doc.babylonjs.com/features/occlusionquery
  40833. */
  40834. occlusionRetryCount: number;
  40835. /**
  40836. * 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:
  40837. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40838. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40839. * * 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.
  40840. * @see http://doc.babylonjs.com/features/occlusionquery
  40841. */
  40842. occlusionType: number;
  40843. /**
  40844. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40845. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40846. * * 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.
  40847. * @see http://doc.babylonjs.com/features/occlusionquery
  40848. */
  40849. occlusionQueryAlgorithmType: number;
  40850. /**
  40851. * 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
  40852. * @see http://doc.babylonjs.com/features/occlusionquery
  40853. */
  40854. isOccluded: boolean;
  40855. /**
  40856. * Flag to check the progress status of the query
  40857. * @see http://doc.babylonjs.com/features/occlusionquery
  40858. */
  40859. isOcclusionQueryInProgress: boolean;
  40860. }
  40861. }
  40862. declare module BABYLON {
  40863. /** @hidden */
  40864. export var _forceTransformFeedbackToBundle: boolean;
  40865. interface Engine {
  40866. /**
  40867. * Creates a webGL transform feedback object
  40868. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40869. * @returns the webGL transform feedback object
  40870. */
  40871. createTransformFeedback(): WebGLTransformFeedback;
  40872. /**
  40873. * Delete a webGL transform feedback object
  40874. * @param value defines the webGL transform feedback object to delete
  40875. */
  40876. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40877. /**
  40878. * Bind a webGL transform feedback object to the webgl context
  40879. * @param value defines the webGL transform feedback object to bind
  40880. */
  40881. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40882. /**
  40883. * Begins a transform feedback operation
  40884. * @param usePoints defines if points or triangles must be used
  40885. */
  40886. beginTransformFeedback(usePoints: boolean): void;
  40887. /**
  40888. * Ends a transform feedback operation
  40889. */
  40890. endTransformFeedback(): void;
  40891. /**
  40892. * Specify the varyings to use with transform feedback
  40893. * @param program defines the associated webGL program
  40894. * @param value defines the list of strings representing the varying names
  40895. */
  40896. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40897. /**
  40898. * Bind a webGL buffer for a transform feedback operation
  40899. * @param value defines the webGL buffer to bind
  40900. */
  40901. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  40902. }
  40903. }
  40904. declare module BABYLON {
  40905. /**
  40906. * Creation options of the multi render target texture.
  40907. */
  40908. export interface IMultiRenderTargetOptions {
  40909. /**
  40910. * Define if the texture needs to create mip maps after render.
  40911. */
  40912. generateMipMaps?: boolean;
  40913. /**
  40914. * Define the types of all the draw buffers we want to create
  40915. */
  40916. types?: number[];
  40917. /**
  40918. * Define the sampling modes of all the draw buffers we want to create
  40919. */
  40920. samplingModes?: number[];
  40921. /**
  40922. * Define if a depth buffer is required
  40923. */
  40924. generateDepthBuffer?: boolean;
  40925. /**
  40926. * Define if a stencil buffer is required
  40927. */
  40928. generateStencilBuffer?: boolean;
  40929. /**
  40930. * Define if a depth texture is required instead of a depth buffer
  40931. */
  40932. generateDepthTexture?: boolean;
  40933. /**
  40934. * Define the number of desired draw buffers
  40935. */
  40936. textureCount?: number;
  40937. /**
  40938. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40939. */
  40940. doNotChangeAspectRatio?: boolean;
  40941. /**
  40942. * Define the default type of the buffers we are creating
  40943. */
  40944. defaultType?: number;
  40945. }
  40946. /**
  40947. * A multi render target, like a render target provides the ability to render to a texture.
  40948. * Unlike the render target, it can render to several draw buffers in one draw.
  40949. * This is specially interesting in deferred rendering or for any effects requiring more than
  40950. * just one color from a single pass.
  40951. */
  40952. export class MultiRenderTarget extends RenderTargetTexture {
  40953. private _internalTextures;
  40954. private _textures;
  40955. private _multiRenderTargetOptions;
  40956. /**
  40957. * Get if draw buffers are currently supported by the used hardware and browser.
  40958. */
  40959. readonly isSupported: boolean;
  40960. /**
  40961. * Get the list of textures generated by the multi render target.
  40962. */
  40963. readonly textures: Texture[];
  40964. /**
  40965. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  40966. */
  40967. readonly depthTexture: Texture;
  40968. /**
  40969. * Set the wrapping mode on U of all the textures we are rendering to.
  40970. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40971. */
  40972. wrapU: number;
  40973. /**
  40974. * Set the wrapping mode on V of all the textures we are rendering to.
  40975. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40976. */
  40977. wrapV: number;
  40978. /**
  40979. * Instantiate a new multi render target texture.
  40980. * A multi render target, like a render target provides the ability to render to a texture.
  40981. * Unlike the render target, it can render to several draw buffers in one draw.
  40982. * This is specially interesting in deferred rendering or for any effects requiring more than
  40983. * just one color from a single pass.
  40984. * @param name Define the name of the texture
  40985. * @param size Define the size of the buffers to render to
  40986. * @param count Define the number of target we are rendering into
  40987. * @param scene Define the scene the texture belongs to
  40988. * @param options Define the options used to create the multi render target
  40989. */
  40990. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  40991. /** @hidden */ rebuild(): void;
  40992. private _createInternalTextures;
  40993. private _createTextures;
  40994. /**
  40995. * Define the number of samples used if MSAA is enabled.
  40996. */
  40997. samples: number;
  40998. /**
  40999. * Resize all the textures in the multi render target.
  41000. * Be carrefull as it will recreate all the data in the new texture.
  41001. * @param size Define the new size
  41002. */
  41003. resize(size: any): void;
  41004. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41005. /**
  41006. * Dispose the render targets and their associated resources
  41007. */
  41008. dispose(): void;
  41009. /**
  41010. * Release all the underlying texture used as draw buffers.
  41011. */
  41012. releaseInternalTextures(): void;
  41013. }
  41014. }
  41015. declare module BABYLON {
  41016. interface Engine {
  41017. /**
  41018. * Unbind a list of render target textures from the webGL context
  41019. * This is used only when drawBuffer extension or webGL2 are active
  41020. * @param textures defines the render target textures to unbind
  41021. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41022. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41023. */
  41024. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41025. /**
  41026. * Create a multi render target texture
  41027. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41028. * @param size defines the size of the texture
  41029. * @param options defines the creation options
  41030. * @returns the cube texture as an InternalTexture
  41031. */
  41032. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41033. /**
  41034. * Update the sample count for a given multiple render target texture
  41035. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41036. * @param textures defines the textures to update
  41037. * @param samples defines the sample count to set
  41038. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41039. */
  41040. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41041. }
  41042. }
  41043. declare module BABYLON {
  41044. /**
  41045. * Gather the list of clipboard event types as constants.
  41046. */
  41047. export class ClipboardEventTypes {
  41048. /**
  41049. * The clipboard event is fired when a copy command is active (pressed).
  41050. */
  41051. static readonly COPY: number;
  41052. /**
  41053. * The clipboard event is fired when a cut command is active (pressed).
  41054. */
  41055. static readonly CUT: number;
  41056. /**
  41057. * The clipboard event is fired when a paste command is active (pressed).
  41058. */
  41059. static readonly PASTE: number;
  41060. }
  41061. /**
  41062. * This class is used to store clipboard related info for the onClipboardObservable event.
  41063. */
  41064. export class ClipboardInfo {
  41065. /**
  41066. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41067. */
  41068. type: number;
  41069. /**
  41070. * Defines the related dom event
  41071. */
  41072. event: ClipboardEvent;
  41073. /**
  41074. *Creates an instance of ClipboardInfo.
  41075. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41076. * @param event Defines the related dom event
  41077. */
  41078. constructor(
  41079. /**
  41080. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41081. */
  41082. type: number,
  41083. /**
  41084. * Defines the related dom event
  41085. */
  41086. event: ClipboardEvent);
  41087. /**
  41088. * Get the clipboard event's type from the keycode.
  41089. * @param keyCode Defines the keyCode for the current keyboard event.
  41090. * @return {number}
  41091. */
  41092. static GetTypeFromCharacter(keyCode: number): number;
  41093. }
  41094. }
  41095. declare module BABYLON {
  41096. /**
  41097. * Class used to represent data loading progression
  41098. */
  41099. export class SceneLoaderProgressEvent {
  41100. /** defines if data length to load can be evaluated */
  41101. readonly lengthComputable: boolean;
  41102. /** defines the loaded data length */
  41103. readonly loaded: number;
  41104. /** defines the data length to load */
  41105. readonly total: number;
  41106. /**
  41107. * Create a new progress event
  41108. * @param lengthComputable defines if data length to load can be evaluated
  41109. * @param loaded defines the loaded data length
  41110. * @param total defines the data length to load
  41111. */
  41112. constructor(
  41113. /** defines if data length to load can be evaluated */
  41114. lengthComputable: boolean,
  41115. /** defines the loaded data length */
  41116. loaded: number,
  41117. /** defines the data length to load */
  41118. total: number);
  41119. /**
  41120. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41121. * @param event defines the source event
  41122. * @returns a new SceneLoaderProgressEvent
  41123. */
  41124. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41125. }
  41126. /**
  41127. * Interface used by SceneLoader plugins to define supported file extensions
  41128. */
  41129. export interface ISceneLoaderPluginExtensions {
  41130. /**
  41131. * Defines the list of supported extensions
  41132. */
  41133. [extension: string]: {
  41134. isBinary: boolean;
  41135. };
  41136. }
  41137. /**
  41138. * Interface used by SceneLoader plugin factory
  41139. */
  41140. export interface ISceneLoaderPluginFactory {
  41141. /**
  41142. * Defines the name of the factory
  41143. */
  41144. name: string;
  41145. /**
  41146. * Function called to create a new plugin
  41147. * @return the new plugin
  41148. */
  41149. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41150. /**
  41151. * Boolean indicating if the plugin can direct load specific data
  41152. */
  41153. canDirectLoad?: (data: string) => boolean;
  41154. }
  41155. /**
  41156. * Interface used to define a SceneLoader plugin
  41157. */
  41158. export interface ISceneLoaderPlugin {
  41159. /**
  41160. * The friendly name of this plugin.
  41161. */
  41162. name: string;
  41163. /**
  41164. * The file extensions supported by this plugin.
  41165. */
  41166. extensions: string | ISceneLoaderPluginExtensions;
  41167. /**
  41168. * Import meshes into a scene.
  41169. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41170. * @param scene The scene to import into
  41171. * @param data The data to import
  41172. * @param rootUrl The root url for scene and resources
  41173. * @param meshes The meshes array to import into
  41174. * @param particleSystems The particle systems array to import into
  41175. * @param skeletons The skeletons array to import into
  41176. * @param onError The callback when import fails
  41177. * @returns True if successful or false otherwise
  41178. */
  41179. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41180. /**
  41181. * Load into a scene.
  41182. * @param scene The scene to load into
  41183. * @param data The data to import
  41184. * @param rootUrl The root url for scene and resources
  41185. * @param onError The callback when import fails
  41186. * @returns true if successful or false otherwise
  41187. */
  41188. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41189. /**
  41190. * The callback that returns true if the data can be directly loaded.
  41191. */
  41192. canDirectLoad?: (data: string) => boolean;
  41193. /**
  41194. * The callback that allows custom handling of the root url based on the response url.
  41195. */
  41196. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41197. /**
  41198. * Load into an asset container.
  41199. * @param scene The scene to load into
  41200. * @param data The data to import
  41201. * @param rootUrl The root url for scene and resources
  41202. * @param onError The callback when import fails
  41203. * @returns The loaded asset container
  41204. */
  41205. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41206. }
  41207. /**
  41208. * Interface used to define an async SceneLoader plugin
  41209. */
  41210. export interface ISceneLoaderPluginAsync {
  41211. /**
  41212. * The friendly name of this plugin.
  41213. */
  41214. name: string;
  41215. /**
  41216. * The file extensions supported by this plugin.
  41217. */
  41218. extensions: string | ISceneLoaderPluginExtensions;
  41219. /**
  41220. * Import meshes into a scene.
  41221. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41222. * @param scene The scene to import into
  41223. * @param data The data to import
  41224. * @param rootUrl The root url for scene and resources
  41225. * @param onProgress The callback when the load progresses
  41226. * @param fileName Defines the name of the file to load
  41227. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41228. */
  41229. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41230. meshes: AbstractMesh[];
  41231. particleSystems: IParticleSystem[];
  41232. skeletons: Skeleton[];
  41233. animationGroups: AnimationGroup[];
  41234. }>;
  41235. /**
  41236. * Load into a scene.
  41237. * @param scene The scene to load into
  41238. * @param data The data to import
  41239. * @param rootUrl The root url for scene and resources
  41240. * @param onProgress The callback when the load progresses
  41241. * @param fileName Defines the name of the file to load
  41242. * @returns Nothing
  41243. */
  41244. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41245. /**
  41246. * The callback that returns true if the data can be directly loaded.
  41247. */
  41248. canDirectLoad?: (data: string) => boolean;
  41249. /**
  41250. * The callback that allows custom handling of the root url based on the response url.
  41251. */
  41252. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41253. /**
  41254. * Load into an asset container.
  41255. * @param scene The scene to load into
  41256. * @param data The data to import
  41257. * @param rootUrl The root url for scene and resources
  41258. * @param onProgress The callback when the load progresses
  41259. * @param fileName Defines the name of the file to load
  41260. * @returns The loaded asset container
  41261. */
  41262. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41263. }
  41264. /**
  41265. * Class used to load scene from various file formats using registered plugins
  41266. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41267. */
  41268. export class SceneLoader {
  41269. /**
  41270. * No logging while loading
  41271. */
  41272. static readonly NO_LOGGING: number;
  41273. /**
  41274. * Minimal logging while loading
  41275. */
  41276. static readonly MINIMAL_LOGGING: number;
  41277. /**
  41278. * Summary logging while loading
  41279. */
  41280. static readonly SUMMARY_LOGGING: number;
  41281. /**
  41282. * Detailled logging while loading
  41283. */
  41284. static readonly DETAILED_LOGGING: number;
  41285. /**
  41286. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41287. */
  41288. static ForceFullSceneLoadingForIncremental: boolean;
  41289. /**
  41290. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41291. */
  41292. static ShowLoadingScreen: boolean;
  41293. /**
  41294. * Defines the current logging level (while loading the scene)
  41295. * @ignorenaming
  41296. */
  41297. static loggingLevel: number;
  41298. /**
  41299. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41300. */
  41301. static CleanBoneMatrixWeights: boolean;
  41302. /**
  41303. * Event raised when a plugin is used to load a scene
  41304. */
  41305. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41306. private static _registeredPlugins;
  41307. private static _getDefaultPlugin;
  41308. private static _getPluginForExtension;
  41309. private static _getPluginForDirectLoad;
  41310. private static _getPluginForFilename;
  41311. private static _getDirectLoad;
  41312. private static _loadData;
  41313. private static _getFileInfo;
  41314. /**
  41315. * Gets a plugin that can load the given extension
  41316. * @param extension defines the extension to load
  41317. * @returns a plugin or null if none works
  41318. */
  41319. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41320. /**
  41321. * Gets a boolean indicating that the given extension can be loaded
  41322. * @param extension defines the extension to load
  41323. * @returns true if the extension is supported
  41324. */
  41325. static IsPluginForExtensionAvailable(extension: string): boolean;
  41326. /**
  41327. * Adds a new plugin to the list of registered plugins
  41328. * @param plugin defines the plugin to add
  41329. */
  41330. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41331. /**
  41332. * Import meshes into a scene
  41333. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41334. * @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)
  41335. * @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)
  41336. * @param scene the instance of BABYLON.Scene to append to
  41337. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41338. * @param onProgress a callback with a progress event for each file being loaded
  41339. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41340. * @param pluginExtension the extension used to determine the plugin
  41341. * @returns The loaded plugin
  41342. */
  41343. 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>;
  41344. /**
  41345. * Import meshes into a scene
  41346. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41347. * @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)
  41348. * @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)
  41349. * @param scene the instance of BABYLON.Scene to append to
  41350. * @param onProgress a callback with a progress event for each file being loaded
  41351. * @param pluginExtension the extension used to determine the plugin
  41352. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41353. */
  41354. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41355. meshes: AbstractMesh[];
  41356. particleSystems: IParticleSystem[];
  41357. skeletons: Skeleton[];
  41358. animationGroups: AnimationGroup[];
  41359. }>;
  41360. /**
  41361. * Load a scene
  41362. * @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)
  41363. * @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)
  41364. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41365. * @param onSuccess a callback with the scene when import succeeds
  41366. * @param onProgress a callback with a progress event for each file being loaded
  41367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41368. * @param pluginExtension the extension used to determine the plugin
  41369. * @returns The loaded plugin
  41370. */
  41371. 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>;
  41372. /**
  41373. * Load a scene
  41374. * @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)
  41375. * @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)
  41376. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41377. * @param onProgress a callback with a progress event for each file being loaded
  41378. * @param pluginExtension the extension used to determine the plugin
  41379. * @returns The loaded scene
  41380. */
  41381. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41382. /**
  41383. * Append a scene
  41384. * @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)
  41385. * @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)
  41386. * @param scene is the instance of BABYLON.Scene to append to
  41387. * @param onSuccess a callback with the scene when import succeeds
  41388. * @param onProgress a callback with a progress event for each file being loaded
  41389. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41390. * @param pluginExtension the extension used to determine the plugin
  41391. * @returns The loaded plugin
  41392. */
  41393. 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>;
  41394. /**
  41395. * Append a scene
  41396. * @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)
  41397. * @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)
  41398. * @param scene is the instance of BABYLON.Scene to append to
  41399. * @param onProgress a callback with a progress event for each file being loaded
  41400. * @param pluginExtension the extension used to determine the plugin
  41401. * @returns The given scene
  41402. */
  41403. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41404. /**
  41405. * Load a scene into an asset container
  41406. * @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)
  41407. * @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)
  41408. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41409. * @param onSuccess a callback with the scene when import succeeds
  41410. * @param onProgress a callback with a progress event for each file being loaded
  41411. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41412. * @param pluginExtension the extension used to determine the plugin
  41413. * @returns The loaded plugin
  41414. */
  41415. 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>;
  41416. /**
  41417. * Load a scene into an asset container
  41418. * @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)
  41419. * @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)
  41420. * @param scene is the instance of Scene to append to
  41421. * @param onProgress a callback with a progress event for each file being loaded
  41422. * @param pluginExtension the extension used to determine the plugin
  41423. * @returns The loaded asset container
  41424. */
  41425. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41426. }
  41427. }
  41428. declare module BABYLON {
  41429. /**
  41430. * Google Daydream controller
  41431. */
  41432. export class DaydreamController extends WebVRController {
  41433. /**
  41434. * Base Url for the controller model.
  41435. */
  41436. static MODEL_BASE_URL: string;
  41437. /**
  41438. * File name for the controller model.
  41439. */
  41440. static MODEL_FILENAME: string;
  41441. /**
  41442. * Gamepad Id prefix used to identify Daydream Controller.
  41443. */
  41444. static readonly GAMEPAD_ID_PREFIX: string;
  41445. /**
  41446. * Creates a new DaydreamController from a gamepad
  41447. * @param vrGamepad the gamepad that the controller should be created from
  41448. */
  41449. constructor(vrGamepad: any);
  41450. /**
  41451. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41452. * @param scene scene in which to add meshes
  41453. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41454. */
  41455. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41456. /**
  41457. * Called once for each button that changed state since the last frame
  41458. * @param buttonIdx Which button index changed
  41459. * @param state New state of the button
  41460. * @param changes Which properties on the state changed since last frame
  41461. */
  41462. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41463. }
  41464. }
  41465. declare module BABYLON {
  41466. /**
  41467. * Gear VR Controller
  41468. */
  41469. export class GearVRController extends WebVRController {
  41470. /**
  41471. * Base Url for the controller model.
  41472. */
  41473. static MODEL_BASE_URL: string;
  41474. /**
  41475. * File name for the controller model.
  41476. */
  41477. static MODEL_FILENAME: string;
  41478. /**
  41479. * Gamepad Id prefix used to identify this controller.
  41480. */
  41481. static readonly GAMEPAD_ID_PREFIX: string;
  41482. private readonly _buttonIndexToObservableNameMap;
  41483. /**
  41484. * Creates a new GearVRController from a gamepad
  41485. * @param vrGamepad the gamepad that the controller should be created from
  41486. */
  41487. constructor(vrGamepad: any);
  41488. /**
  41489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41490. * @param scene scene in which to add meshes
  41491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41492. */
  41493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41494. /**
  41495. * Called once for each button that changed state since the last frame
  41496. * @param buttonIdx Which button index changed
  41497. * @param state New state of the button
  41498. * @param changes Which properties on the state changed since last frame
  41499. */
  41500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41501. }
  41502. }
  41503. declare module BABYLON {
  41504. /**
  41505. * Generic Controller
  41506. */
  41507. export class GenericController extends WebVRController {
  41508. /**
  41509. * Base Url for the controller model.
  41510. */
  41511. static readonly MODEL_BASE_URL: string;
  41512. /**
  41513. * File name for the controller model.
  41514. */
  41515. static readonly MODEL_FILENAME: string;
  41516. /**
  41517. * Creates a new GenericController from a gamepad
  41518. * @param vrGamepad the gamepad that the controller should be created from
  41519. */
  41520. constructor(vrGamepad: any);
  41521. /**
  41522. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41523. * @param scene scene in which to add meshes
  41524. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41525. */
  41526. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41527. /**
  41528. * Called once for each button that changed state since the last frame
  41529. * @param buttonIdx Which button index changed
  41530. * @param state New state of the button
  41531. * @param changes Which properties on the state changed since last frame
  41532. */
  41533. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Oculus Touch Controller
  41539. */
  41540. export class OculusTouchController extends WebVRController {
  41541. /**
  41542. * Base Url for the controller model.
  41543. */
  41544. static MODEL_BASE_URL: string;
  41545. /**
  41546. * File name for the left controller model.
  41547. */
  41548. static MODEL_LEFT_FILENAME: string;
  41549. /**
  41550. * File name for the right controller model.
  41551. */
  41552. static MODEL_RIGHT_FILENAME: string;
  41553. /**
  41554. * Fired when the secondary trigger on this controller is modified
  41555. */
  41556. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41557. /**
  41558. * Fired when the thumb rest on this controller is modified
  41559. */
  41560. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41561. /**
  41562. * Creates a new OculusTouchController from a gamepad
  41563. * @param vrGamepad the gamepad that the controller should be created from
  41564. */
  41565. constructor(vrGamepad: any);
  41566. /**
  41567. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41568. * @param scene scene in which to add meshes
  41569. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41570. */
  41571. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41572. /**
  41573. * Fired when the A button on this controller is modified
  41574. */
  41575. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41576. /**
  41577. * Fired when the B button on this controller is modified
  41578. */
  41579. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41580. /**
  41581. * Fired when the X button on this controller is modified
  41582. */
  41583. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41584. /**
  41585. * Fired when the Y button on this controller is modified
  41586. */
  41587. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41588. /**
  41589. * Called once for each button that changed state since the last frame
  41590. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41591. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41592. * 2) secondary trigger (same)
  41593. * 3) A (right) X (left), touch, pressed = value
  41594. * 4) B / Y
  41595. * 5) thumb rest
  41596. * @param buttonIdx Which button index changed
  41597. * @param state New state of the button
  41598. * @param changes Which properties on the state changed since last frame
  41599. */
  41600. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41601. }
  41602. }
  41603. declare module BABYLON {
  41604. /**
  41605. * Vive Controller
  41606. */
  41607. export class ViveController extends WebVRController {
  41608. /**
  41609. * Base Url for the controller model.
  41610. */
  41611. static MODEL_BASE_URL: string;
  41612. /**
  41613. * File name for the controller model.
  41614. */
  41615. static MODEL_FILENAME: string;
  41616. /**
  41617. * Creates a new ViveController from a gamepad
  41618. * @param vrGamepad the gamepad that the controller should be created from
  41619. */
  41620. constructor(vrGamepad: any);
  41621. /**
  41622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41623. * @param scene scene in which to add meshes
  41624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41625. */
  41626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41627. /**
  41628. * Fired when the left button on this controller is modified
  41629. */
  41630. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41631. /**
  41632. * Fired when the right button on this controller is modified
  41633. */
  41634. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41635. /**
  41636. * Fired when the menu button on this controller is modified
  41637. */
  41638. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41639. /**
  41640. * Called once for each button that changed state since the last frame
  41641. * Vive mapping:
  41642. * 0: touchpad
  41643. * 1: trigger
  41644. * 2: left AND right buttons
  41645. * 3: menu button
  41646. * @param buttonIdx Which button index changed
  41647. * @param state New state of the button
  41648. * @param changes Which properties on the state changed since last frame
  41649. */
  41650. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41651. }
  41652. }
  41653. declare module BABYLON {
  41654. /**
  41655. * Defines the WindowsMotionController object that the state of the windows motion controller
  41656. */
  41657. export class WindowsMotionController extends WebVRController {
  41658. /**
  41659. * The base url used to load the left and right controller models
  41660. */
  41661. static MODEL_BASE_URL: string;
  41662. /**
  41663. * The name of the left controller model file
  41664. */
  41665. static MODEL_LEFT_FILENAME: string;
  41666. /**
  41667. * The name of the right controller model file
  41668. */
  41669. static MODEL_RIGHT_FILENAME: string;
  41670. /**
  41671. * The controller name prefix for this controller type
  41672. */
  41673. static readonly GAMEPAD_ID_PREFIX: string;
  41674. /**
  41675. * The controller id pattern for this controller type
  41676. */
  41677. private static readonly GAMEPAD_ID_PATTERN;
  41678. private _loadedMeshInfo;
  41679. private readonly _mapping;
  41680. /**
  41681. * Fired when the trackpad on this controller is clicked
  41682. */
  41683. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41684. /**
  41685. * Fired when the trackpad on this controller is modified
  41686. */
  41687. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41688. /**
  41689. * The current x and y values of this controller's trackpad
  41690. */
  41691. trackpad: StickValues;
  41692. /**
  41693. * Creates a new WindowsMotionController from a gamepad
  41694. * @param vrGamepad the gamepad that the controller should be created from
  41695. */
  41696. constructor(vrGamepad: any);
  41697. /**
  41698. * Fired when the trigger on this controller is modified
  41699. */
  41700. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41701. /**
  41702. * Fired when the menu button on this controller is modified
  41703. */
  41704. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41705. /**
  41706. * Fired when the grip button on this controller is modified
  41707. */
  41708. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41709. /**
  41710. * Fired when the thumbstick button on this controller is modified
  41711. */
  41712. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41713. /**
  41714. * Fired when the touchpad button on this controller is modified
  41715. */
  41716. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41717. /**
  41718. * Fired when the touchpad values on this controller are modified
  41719. */
  41720. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41721. private _updateTrackpad;
  41722. /**
  41723. * Called once per frame by the engine.
  41724. */
  41725. update(): void;
  41726. /**
  41727. * Called once for each button that changed state since the last frame
  41728. * @param buttonIdx Which button index changed
  41729. * @param state New state of the button
  41730. * @param changes Which properties on the state changed since last frame
  41731. */
  41732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41733. /**
  41734. * Moves the buttons on the controller mesh based on their current state
  41735. * @param buttonName the name of the button to move
  41736. * @param buttonValue the value of the button which determines the buttons new position
  41737. */
  41738. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41739. /**
  41740. * Moves the axis on the controller mesh based on its current state
  41741. * @param axis the index of the axis
  41742. * @param axisValue the value of the axis which determines the meshes new position
  41743. * @hidden
  41744. */
  41745. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41746. /**
  41747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41748. * @param scene scene in which to add meshes
  41749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41750. */
  41751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41752. /**
  41753. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41754. * can be transformed by button presses and axes values, based on this._mapping.
  41755. *
  41756. * @param scene scene in which the meshes exist
  41757. * @param meshes list of meshes that make up the controller model to process
  41758. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41759. */
  41760. private processModel;
  41761. private createMeshInfo;
  41762. /**
  41763. * Gets the ray of the controller in the direction the controller is pointing
  41764. * @param length the length the resulting ray should be
  41765. * @returns a ray in the direction the controller is pointing
  41766. */
  41767. getForwardRay(length?: number): Ray;
  41768. /**
  41769. * Disposes of the controller
  41770. */
  41771. dispose(): void;
  41772. }
  41773. }
  41774. declare module BABYLON {
  41775. /**
  41776. * Single axis scale gizmo
  41777. */
  41778. export class AxisScaleGizmo extends Gizmo {
  41779. private _coloredMaterial;
  41780. /**
  41781. * Drag behavior responsible for the gizmos dragging interactions
  41782. */
  41783. dragBehavior: PointerDragBehavior;
  41784. private _pointerObserver;
  41785. /**
  41786. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41787. */
  41788. snapDistance: number;
  41789. /**
  41790. * Event that fires each time the gizmo snaps to a new location.
  41791. * * snapDistance is the the change in distance
  41792. */
  41793. onSnapObservable: Observable<{
  41794. snapDistance: number;
  41795. }>;
  41796. /**
  41797. * If the scaling operation should be done on all axis (default: false)
  41798. */
  41799. uniformScaling: boolean;
  41800. /**
  41801. * Creates an AxisScaleGizmo
  41802. * @param gizmoLayer The utility layer the gizmo will be added to
  41803. * @param dragAxis The axis which the gizmo will be able to scale on
  41804. * @param color The color of the gizmo
  41805. */
  41806. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41807. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41808. /**
  41809. * Disposes of the gizmo
  41810. */
  41811. dispose(): void;
  41812. /**
  41813. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41814. * @param mesh The mesh to replace the default mesh of the gizmo
  41815. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41816. */
  41817. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41818. }
  41819. }
  41820. declare module BABYLON {
  41821. /**
  41822. * Bounding box gizmo
  41823. */
  41824. export class BoundingBoxGizmo extends Gizmo {
  41825. private _lineBoundingBox;
  41826. private _rotateSpheresParent;
  41827. private _scaleBoxesParent;
  41828. private _boundingDimensions;
  41829. private _renderObserver;
  41830. private _pointerObserver;
  41831. private _scaleDragSpeed;
  41832. private _tmpQuaternion;
  41833. private _tmpVector;
  41834. private _tmpRotationMatrix;
  41835. /**
  41836. * 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)
  41837. */
  41838. ignoreChildren: boolean;
  41839. /**
  41840. * 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)
  41841. */
  41842. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41843. /**
  41844. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41845. */
  41846. rotationSphereSize: number;
  41847. /**
  41848. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41849. */
  41850. scaleBoxSize: number;
  41851. /**
  41852. * 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)
  41853. */
  41854. fixedDragMeshScreenSize: boolean;
  41855. /**
  41856. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41857. */
  41858. fixedDragMeshScreenSizeDistanceFactor: number;
  41859. /**
  41860. * Fired when a rotation sphere or scale box is dragged
  41861. */
  41862. onDragStartObservable: Observable<{}>;
  41863. /**
  41864. * Fired when a scale box is dragged
  41865. */
  41866. onScaleBoxDragObservable: Observable<{}>;
  41867. /**
  41868. * Fired when a scale box drag is ended
  41869. */
  41870. onScaleBoxDragEndObservable: Observable<{}>;
  41871. /**
  41872. * Fired when a rotation sphere is dragged
  41873. */
  41874. onRotationSphereDragObservable: Observable<{}>;
  41875. /**
  41876. * Fired when a rotation sphere drag is ended
  41877. */
  41878. onRotationSphereDragEndObservable: Observable<{}>;
  41879. /**
  41880. * 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)
  41881. */
  41882. scalePivot: Nullable<Vector3>;
  41883. /**
  41884. * Mesh used as a pivot to rotate the attached mesh
  41885. */
  41886. private _anchorMesh;
  41887. private _existingMeshScale;
  41888. private _dragMesh;
  41889. private pointerDragBehavior;
  41890. private coloredMaterial;
  41891. private hoverColoredMaterial;
  41892. /**
  41893. * Sets the color of the bounding box gizmo
  41894. * @param color the color to set
  41895. */
  41896. setColor(color: Color3): void;
  41897. /**
  41898. * Creates an BoundingBoxGizmo
  41899. * @param gizmoLayer The utility layer the gizmo will be added to
  41900. * @param color The color of the gizmo
  41901. */
  41902. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41903. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41904. private _selectNode;
  41905. /**
  41906. * Updates the bounding box information for the Gizmo
  41907. */
  41908. updateBoundingBox(): void;
  41909. private _updateRotationSpheres;
  41910. private _updateScaleBoxes;
  41911. /**
  41912. * Enables rotation on the specified axis and disables rotation on the others
  41913. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41914. */
  41915. setEnabledRotationAxis(axis: string): void;
  41916. /**
  41917. * Enables/disables scaling
  41918. * @param enable if scaling should be enabled
  41919. */
  41920. setEnabledScaling(enable: boolean): void;
  41921. private _updateDummy;
  41922. /**
  41923. * Enables a pointer drag behavior on the bounding box of the gizmo
  41924. */
  41925. enableDragBehavior(): void;
  41926. /**
  41927. * Disposes of the gizmo
  41928. */
  41929. dispose(): void;
  41930. /**
  41931. * 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)
  41932. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41933. * @returns the bounding box mesh with the passed in mesh as a child
  41934. */
  41935. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41936. /**
  41937. * CustomMeshes are not supported by this gizmo
  41938. * @param mesh The mesh to replace the default mesh of the gizmo
  41939. */
  41940. setCustomMesh(mesh: Mesh): void;
  41941. }
  41942. }
  41943. declare module BABYLON {
  41944. /**
  41945. * Single plane rotation gizmo
  41946. */
  41947. export class PlaneRotationGizmo extends Gizmo {
  41948. /**
  41949. * Drag behavior responsible for the gizmos dragging interactions
  41950. */
  41951. dragBehavior: PointerDragBehavior;
  41952. private _pointerObserver;
  41953. /**
  41954. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41955. */
  41956. snapDistance: number;
  41957. /**
  41958. * Event that fires each time the gizmo snaps to a new location.
  41959. * * snapDistance is the the change in distance
  41960. */
  41961. onSnapObservable: Observable<{
  41962. snapDistance: number;
  41963. }>;
  41964. /**
  41965. * Creates a PlaneRotationGizmo
  41966. * @param gizmoLayer The utility layer the gizmo will be added to
  41967. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41968. * @param color The color of the gizmo
  41969. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41970. */
  41971. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41972. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41973. /**
  41974. * Disposes of the gizmo
  41975. */
  41976. dispose(): void;
  41977. }
  41978. }
  41979. declare module BABYLON {
  41980. /**
  41981. * Gizmo that enables rotating a mesh along 3 axis
  41982. */
  41983. export class RotationGizmo extends Gizmo {
  41984. /**
  41985. * Internal gizmo used for interactions on the x axis
  41986. */
  41987. xGizmo: PlaneRotationGizmo;
  41988. /**
  41989. * Internal gizmo used for interactions on the y axis
  41990. */
  41991. yGizmo: PlaneRotationGizmo;
  41992. /**
  41993. * Internal gizmo used for interactions on the z axis
  41994. */
  41995. zGizmo: PlaneRotationGizmo;
  41996. /** Fires an event when any of it's sub gizmos are dragged */
  41997. onDragStartObservable: Observable<{}>;
  41998. /** Fires an event when any of it's sub gizmos are released from dragging */
  41999. onDragEndObservable: Observable<{}>;
  42000. attachedMesh: Nullable<AbstractMesh>;
  42001. /**
  42002. * Creates a RotationGizmo
  42003. * @param gizmoLayer The utility layer the gizmo will be added to
  42004. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42005. */
  42006. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42007. updateGizmoRotationToMatchAttachedMesh: boolean;
  42008. /**
  42009. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42010. */
  42011. snapDistance: number;
  42012. /**
  42013. * Ratio for the scale of the gizmo (Default: 1)
  42014. */
  42015. scaleRatio: number;
  42016. /**
  42017. * Disposes of the gizmo
  42018. */
  42019. dispose(): void;
  42020. /**
  42021. * CustomMeshes are not supported by this gizmo
  42022. * @param mesh The mesh to replace the default mesh of the gizmo
  42023. */
  42024. setCustomMesh(mesh: Mesh): void;
  42025. }
  42026. }
  42027. declare module BABYLON {
  42028. /**
  42029. * Gizmo that enables dragging a mesh along 3 axis
  42030. */
  42031. export class PositionGizmo extends Gizmo {
  42032. /**
  42033. * Internal gizmo used for interactions on the x axis
  42034. */
  42035. xGizmo: AxisDragGizmo;
  42036. /**
  42037. * Internal gizmo used for interactions on the y axis
  42038. */
  42039. yGizmo: AxisDragGizmo;
  42040. /**
  42041. * Internal gizmo used for interactions on the z axis
  42042. */
  42043. zGizmo: AxisDragGizmo;
  42044. /** Fires an event when any of it's sub gizmos are dragged */
  42045. onDragStartObservable: Observable<{}>;
  42046. /** Fires an event when any of it's sub gizmos are released from dragging */
  42047. onDragEndObservable: Observable<{}>;
  42048. attachedMesh: Nullable<AbstractMesh>;
  42049. /**
  42050. * Creates a PositionGizmo
  42051. * @param gizmoLayer The utility layer the gizmo will be added to
  42052. */
  42053. constructor(gizmoLayer?: UtilityLayerRenderer);
  42054. updateGizmoRotationToMatchAttachedMesh: boolean;
  42055. /**
  42056. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42057. */
  42058. snapDistance: number;
  42059. /**
  42060. * Ratio for the scale of the gizmo (Default: 1)
  42061. */
  42062. scaleRatio: number;
  42063. /**
  42064. * Disposes of the gizmo
  42065. */
  42066. dispose(): void;
  42067. /**
  42068. * CustomMeshes are not supported by this gizmo
  42069. * @param mesh The mesh to replace the default mesh of the gizmo
  42070. */
  42071. setCustomMesh(mesh: Mesh): void;
  42072. }
  42073. }
  42074. declare module BABYLON {
  42075. /**
  42076. * Class containing static functions to help procedurally build meshes
  42077. */
  42078. export class PolyhedronBuilder {
  42079. /**
  42080. * Creates a polyhedron mesh
  42081. * * 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
  42082. * * The parameter `size` (positive float, default 1) sets the polygon size
  42083. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42084. * * 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`
  42085. * * 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
  42086. * * 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)`)
  42087. * * 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
  42088. * * 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
  42089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42090. * * 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
  42091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42092. * @param name defines the name of the mesh
  42093. * @param options defines the options used to create the mesh
  42094. * @param scene defines the hosting scene
  42095. * @returns the polyhedron mesh
  42096. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42097. */
  42098. static CreatePolyhedron(name: string, options: {
  42099. type?: number;
  42100. size?: number;
  42101. sizeX?: number;
  42102. sizeY?: number;
  42103. sizeZ?: number;
  42104. custom?: any;
  42105. faceUV?: Vector4[];
  42106. faceColors?: Color4[];
  42107. flat?: boolean;
  42108. updatable?: boolean;
  42109. sideOrientation?: number;
  42110. frontUVs?: Vector4;
  42111. backUVs?: Vector4;
  42112. }, scene?: Nullable<Scene>): Mesh;
  42113. }
  42114. }
  42115. declare module BABYLON {
  42116. /**
  42117. * Gizmo that enables scaling a mesh along 3 axis
  42118. */
  42119. export class ScaleGizmo extends Gizmo {
  42120. /**
  42121. * Internal gizmo used for interactions on the x axis
  42122. */
  42123. xGizmo: AxisScaleGizmo;
  42124. /**
  42125. * Internal gizmo used for interactions on the y axis
  42126. */
  42127. yGizmo: AxisScaleGizmo;
  42128. /**
  42129. * Internal gizmo used for interactions on the z axis
  42130. */
  42131. zGizmo: AxisScaleGizmo;
  42132. /**
  42133. * Internal gizmo used to scale all axis equally
  42134. */
  42135. uniformScaleGizmo: AxisScaleGizmo;
  42136. /** Fires an event when any of it's sub gizmos are dragged */
  42137. onDragStartObservable: Observable<{}>;
  42138. /** Fires an event when any of it's sub gizmos are released from dragging */
  42139. onDragEndObservable: Observable<{}>;
  42140. attachedMesh: Nullable<AbstractMesh>;
  42141. /**
  42142. * Creates a ScaleGizmo
  42143. * @param gizmoLayer The utility layer the gizmo will be added to
  42144. */
  42145. constructor(gizmoLayer?: UtilityLayerRenderer);
  42146. updateGizmoRotationToMatchAttachedMesh: boolean;
  42147. /**
  42148. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42149. */
  42150. snapDistance: number;
  42151. /**
  42152. * Ratio for the scale of the gizmo (Default: 1)
  42153. */
  42154. scaleRatio: number;
  42155. /**
  42156. * Disposes of the gizmo
  42157. */
  42158. dispose(): void;
  42159. }
  42160. }
  42161. declare module BABYLON {
  42162. /**
  42163. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42164. */
  42165. export class GizmoManager implements IDisposable {
  42166. private scene;
  42167. /**
  42168. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42169. */
  42170. gizmos: {
  42171. positionGizmo: Nullable<PositionGizmo>;
  42172. rotationGizmo: Nullable<RotationGizmo>;
  42173. scaleGizmo: Nullable<ScaleGizmo>;
  42174. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42175. };
  42176. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42177. clearGizmoOnEmptyPointerEvent: boolean;
  42178. /** Fires an event when the manager is attached to a mesh */
  42179. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42180. private _gizmosEnabled;
  42181. private _pointerObserver;
  42182. private _attachedMesh;
  42183. private _boundingBoxColor;
  42184. private _defaultUtilityLayer;
  42185. private _defaultKeepDepthUtilityLayer;
  42186. /**
  42187. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42188. */
  42189. boundingBoxDragBehavior: SixDofDragBehavior;
  42190. /**
  42191. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42192. */
  42193. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42194. /**
  42195. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42196. */
  42197. usePointerToAttachGizmos: boolean;
  42198. /**
  42199. * Instatiates a gizmo manager
  42200. * @param scene the scene to overlay the gizmos on top of
  42201. */
  42202. constructor(scene: Scene);
  42203. /**
  42204. * Attaches a set of gizmos to the specified mesh
  42205. * @param mesh The mesh the gizmo's should be attached to
  42206. */
  42207. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42208. /**
  42209. * If the position gizmo is enabled
  42210. */
  42211. positionGizmoEnabled: boolean;
  42212. /**
  42213. * If the rotation gizmo is enabled
  42214. */
  42215. rotationGizmoEnabled: boolean;
  42216. /**
  42217. * If the scale gizmo is enabled
  42218. */
  42219. scaleGizmoEnabled: boolean;
  42220. /**
  42221. * If the boundingBox gizmo is enabled
  42222. */
  42223. boundingBoxGizmoEnabled: boolean;
  42224. /**
  42225. * Disposes of the gizmo manager
  42226. */
  42227. dispose(): void;
  42228. }
  42229. }
  42230. declare module BABYLON {
  42231. /**
  42232. * A directional light is defined by a direction (what a surprise!).
  42233. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42234. * 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.
  42235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42236. */
  42237. export class DirectionalLight extends ShadowLight {
  42238. private _shadowFrustumSize;
  42239. /**
  42240. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42241. */
  42242. /**
  42243. * Specifies a fix frustum size for the shadow generation.
  42244. */
  42245. shadowFrustumSize: number;
  42246. private _shadowOrthoScale;
  42247. /**
  42248. * Gets the shadow projection scale against the optimal computed one.
  42249. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42250. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42251. */
  42252. /**
  42253. * Sets the shadow projection scale against the optimal computed one.
  42254. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42255. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42256. */
  42257. shadowOrthoScale: number;
  42258. /**
  42259. * Automatically compute the projection matrix to best fit (including all the casters)
  42260. * on each frame.
  42261. */
  42262. autoUpdateExtends: boolean;
  42263. private _orthoLeft;
  42264. private _orthoRight;
  42265. private _orthoTop;
  42266. private _orthoBottom;
  42267. /**
  42268. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42269. * The directional light is emitted from everywhere in the given direction.
  42270. * It can cast shadows.
  42271. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42272. * @param name The friendly name of the light
  42273. * @param direction The direction of the light
  42274. * @param scene The scene the light belongs to
  42275. */
  42276. constructor(name: string, direction: Vector3, scene: Scene);
  42277. /**
  42278. * Returns the string "DirectionalLight".
  42279. * @return The class name
  42280. */
  42281. getClassName(): string;
  42282. /**
  42283. * Returns the integer 1.
  42284. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42285. */
  42286. getTypeID(): number;
  42287. /**
  42288. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42289. * Returns the DirectionalLight Shadow projection matrix.
  42290. */
  42291. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42292. /**
  42293. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42294. * Returns the DirectionalLight Shadow projection matrix.
  42295. */
  42296. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42297. /**
  42298. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42299. * Returns the DirectionalLight Shadow projection matrix.
  42300. */
  42301. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42302. protected _buildUniformLayout(): void;
  42303. /**
  42304. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42305. * @param effect The effect to update
  42306. * @param lightIndex The index of the light in the effect to update
  42307. * @returns The directional light
  42308. */
  42309. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42310. /**
  42311. * Gets the minZ used for shadow according to both the scene and the light.
  42312. *
  42313. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42314. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42315. * @param activeCamera The camera we are returning the min for
  42316. * @returns the depth min z
  42317. */
  42318. getDepthMinZ(activeCamera: Camera): number;
  42319. /**
  42320. * Gets the maxZ used for shadow according to both the scene and the light.
  42321. *
  42322. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42323. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42324. * @param activeCamera The camera we are returning the max for
  42325. * @returns the depth max z
  42326. */
  42327. getDepthMaxZ(activeCamera: Camera): number;
  42328. /**
  42329. * Prepares the list of defines specific to the light type.
  42330. * @param defines the list of defines
  42331. * @param lightIndex defines the index of the light for the effect
  42332. */
  42333. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42334. }
  42335. }
  42336. declare module BABYLON {
  42337. /**
  42338. * Class containing static functions to help procedurally build meshes
  42339. */
  42340. export class HemisphereBuilder {
  42341. /**
  42342. * Creates a hemisphere mesh
  42343. * @param name defines the name of the mesh
  42344. * @param options defines the options used to create the mesh
  42345. * @param scene defines the hosting scene
  42346. * @returns the hemisphere mesh
  42347. */
  42348. static CreateHemisphere(name: string, options: {
  42349. segments?: number;
  42350. diameter?: number;
  42351. sideOrientation?: number;
  42352. }, scene: any): Mesh;
  42353. }
  42354. }
  42355. declare module BABYLON {
  42356. /**
  42357. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42358. * These values define a cone of light starting from the position, emitting toward the direction.
  42359. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42360. * and the exponent defines the speed of the decay of the light with distance (reach).
  42361. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42362. */
  42363. export class SpotLight extends ShadowLight {
  42364. private _angle;
  42365. private _innerAngle;
  42366. private _cosHalfAngle;
  42367. private _lightAngleScale;
  42368. private _lightAngleOffset;
  42369. /**
  42370. * Gets the cone angle of the spot light in Radians.
  42371. */
  42372. /**
  42373. * Sets the cone angle of the spot light in Radians.
  42374. */
  42375. angle: number;
  42376. /**
  42377. * Only used in gltf falloff mode, this defines the angle where
  42378. * the directional falloff will start before cutting at angle which could be seen
  42379. * as outer angle.
  42380. */
  42381. /**
  42382. * Only used in gltf falloff mode, this defines the angle where
  42383. * the directional falloff will start before cutting at angle which could be seen
  42384. * as outer angle.
  42385. */
  42386. innerAngle: number;
  42387. private _shadowAngleScale;
  42388. /**
  42389. * Allows scaling the angle of the light for shadow generation only.
  42390. */
  42391. /**
  42392. * Allows scaling the angle of the light for shadow generation only.
  42393. */
  42394. shadowAngleScale: number;
  42395. /**
  42396. * The light decay speed with the distance from the emission spot.
  42397. */
  42398. exponent: number;
  42399. private _projectionTextureMatrix;
  42400. /**
  42401. * Allows reading the projecton texture
  42402. */
  42403. readonly projectionTextureMatrix: Matrix;
  42404. protected _projectionTextureLightNear: number;
  42405. /**
  42406. * Gets the near clip of the Spotlight for texture projection.
  42407. */
  42408. /**
  42409. * Sets the near clip of the Spotlight for texture projection.
  42410. */
  42411. projectionTextureLightNear: number;
  42412. protected _projectionTextureLightFar: number;
  42413. /**
  42414. * Gets the far clip of the Spotlight for texture projection.
  42415. */
  42416. /**
  42417. * Sets the far clip of the Spotlight for texture projection.
  42418. */
  42419. projectionTextureLightFar: number;
  42420. protected _projectionTextureUpDirection: Vector3;
  42421. /**
  42422. * Gets the Up vector of the Spotlight for texture projection.
  42423. */
  42424. /**
  42425. * Sets the Up vector of the Spotlight for texture projection.
  42426. */
  42427. projectionTextureUpDirection: Vector3;
  42428. private _projectionTexture;
  42429. /**
  42430. * Gets the projection texture of the light.
  42431. */
  42432. /**
  42433. * Sets the projection texture of the light.
  42434. */
  42435. projectionTexture: Nullable<BaseTexture>;
  42436. private _projectionTextureViewLightDirty;
  42437. private _projectionTextureProjectionLightDirty;
  42438. private _projectionTextureDirty;
  42439. private _projectionTextureViewTargetVector;
  42440. private _projectionTextureViewLightMatrix;
  42441. private _projectionTextureProjectionLightMatrix;
  42442. private _projectionTextureScalingMatrix;
  42443. /**
  42444. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42445. * It can cast shadows.
  42446. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42447. * @param name The light friendly name
  42448. * @param position The position of the spot light in the scene
  42449. * @param direction The direction of the light in the scene
  42450. * @param angle The cone angle of the light in Radians
  42451. * @param exponent The light decay speed with the distance from the emission spot
  42452. * @param scene The scene the lights belongs to
  42453. */
  42454. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42455. /**
  42456. * Returns the string "SpotLight".
  42457. * @returns the class name
  42458. */
  42459. getClassName(): string;
  42460. /**
  42461. * Returns the integer 2.
  42462. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42463. */
  42464. getTypeID(): number;
  42465. /**
  42466. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42467. */
  42468. protected _setDirection(value: Vector3): void;
  42469. /**
  42470. * Overrides the position setter to recompute the projection texture view light Matrix.
  42471. */
  42472. protected _setPosition(value: Vector3): void;
  42473. /**
  42474. * 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.
  42475. * Returns the SpotLight.
  42476. */
  42477. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42478. protected _computeProjectionTextureViewLightMatrix(): void;
  42479. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42480. /**
  42481. * Main function for light texture projection matrix computing.
  42482. */
  42483. protected _computeProjectionTextureMatrix(): void;
  42484. protected _buildUniformLayout(): void;
  42485. private _computeAngleValues;
  42486. /**
  42487. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42488. * @param effect The effect to update
  42489. * @param lightIndex The index of the light in the effect to update
  42490. * @returns The spot light
  42491. */
  42492. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42493. /**
  42494. * Disposes the light and the associated resources.
  42495. */
  42496. dispose(): void;
  42497. /**
  42498. * Prepares the list of defines specific to the light type.
  42499. * @param defines the list of defines
  42500. * @param lightIndex defines the index of the light for the effect
  42501. */
  42502. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42503. }
  42504. }
  42505. declare module BABYLON {
  42506. /**
  42507. * Gizmo that enables viewing a light
  42508. */
  42509. export class LightGizmo extends Gizmo {
  42510. private _lightMesh;
  42511. private _material;
  42512. /**
  42513. * Creates a LightGizmo
  42514. * @param gizmoLayer The utility layer the gizmo will be added to
  42515. */
  42516. constructor(gizmoLayer?: UtilityLayerRenderer);
  42517. private _light;
  42518. /**
  42519. * The light that the gizmo is attached to
  42520. */
  42521. light: Nullable<Light>;
  42522. /**
  42523. * @hidden
  42524. * Updates the gizmo to match the attached mesh's position/rotation
  42525. */
  42526. protected _update(): void;
  42527. private static _Scale;
  42528. /**
  42529. * Creates the lines for a light mesh
  42530. */
  42531. private static _createLightLines;
  42532. private static _CreateHemisphericLightMesh;
  42533. private static _CreatePointLightMesh;
  42534. private static _CreateSpotLightMesh;
  42535. private static _CreateDirectionalLightMesh;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /** @hidden */
  42540. export var backgroundFragmentDeclaration: {
  42541. name: string;
  42542. shader: string;
  42543. };
  42544. }
  42545. declare module BABYLON {
  42546. /** @hidden */
  42547. export var backgroundUboDeclaration: {
  42548. name: string;
  42549. shader: string;
  42550. };
  42551. }
  42552. declare module BABYLON {
  42553. /** @hidden */
  42554. export var backgroundPixelShader: {
  42555. name: string;
  42556. shader: string;
  42557. };
  42558. }
  42559. declare module BABYLON {
  42560. /** @hidden */
  42561. export var backgroundVertexDeclaration: {
  42562. name: string;
  42563. shader: string;
  42564. };
  42565. }
  42566. declare module BABYLON {
  42567. /** @hidden */
  42568. export var backgroundVertexShader: {
  42569. name: string;
  42570. shader: string;
  42571. };
  42572. }
  42573. declare module BABYLON {
  42574. /**
  42575. * Background material used to create an efficient environement around your scene.
  42576. */
  42577. export class BackgroundMaterial extends PushMaterial {
  42578. /**
  42579. * Standard reflectance value at parallel view angle.
  42580. */
  42581. static StandardReflectance0: number;
  42582. /**
  42583. * Standard reflectance value at grazing angle.
  42584. */
  42585. static StandardReflectance90: number;
  42586. protected _primaryColor: Color3;
  42587. /**
  42588. * Key light Color (multiply against the environement texture)
  42589. */
  42590. primaryColor: Color3;
  42591. protected __perceptualColor: Nullable<Color3>;
  42592. /**
  42593. * Experimental Internal Use Only.
  42594. *
  42595. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42596. * This acts as a helper to set the primary color to a more "human friendly" value.
  42597. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42598. * output color as close as possible from the chosen value.
  42599. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42600. * part of lighting setup.)
  42601. */ perceptualColor: Nullable<Color3>;
  42602. protected _primaryColorShadowLevel: float;
  42603. /**
  42604. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42605. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42606. */
  42607. primaryColorShadowLevel: float;
  42608. protected _primaryColorHighlightLevel: float;
  42609. /**
  42610. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42611. * The primary color is used at the level chosen to define what the white area would look.
  42612. */
  42613. primaryColorHighlightLevel: float;
  42614. protected _reflectionTexture: Nullable<BaseTexture>;
  42615. /**
  42616. * Reflection Texture used in the material.
  42617. * Should be author in a specific way for the best result (refer to the documentation).
  42618. */
  42619. reflectionTexture: Nullable<BaseTexture>;
  42620. protected _reflectionBlur: float;
  42621. /**
  42622. * Reflection Texture level of blur.
  42623. *
  42624. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42625. * texture twice.
  42626. */
  42627. reflectionBlur: float;
  42628. protected _diffuseTexture: Nullable<BaseTexture>;
  42629. /**
  42630. * Diffuse Texture used in the material.
  42631. * Should be author in a specific way for the best result (refer to the documentation).
  42632. */
  42633. diffuseTexture: Nullable<BaseTexture>;
  42634. protected _shadowLights: Nullable<IShadowLight[]>;
  42635. /**
  42636. * Specify the list of lights casting shadow on the material.
  42637. * All scene shadow lights will be included if null.
  42638. */
  42639. shadowLights: Nullable<IShadowLight[]>;
  42640. protected _shadowLevel: float;
  42641. /**
  42642. * Helps adjusting the shadow to a softer level if required.
  42643. * 0 means black shadows and 1 means no shadows.
  42644. */
  42645. shadowLevel: float;
  42646. protected _sceneCenter: Vector3;
  42647. /**
  42648. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42649. * It is usually zero but might be interesting to modify according to your setup.
  42650. */
  42651. sceneCenter: Vector3;
  42652. protected _opacityFresnel: boolean;
  42653. /**
  42654. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42655. * This helps ensuring a nice transition when the camera goes under the ground.
  42656. */
  42657. opacityFresnel: boolean;
  42658. protected _reflectionFresnel: boolean;
  42659. /**
  42660. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42661. * This helps adding a mirror texture on the ground.
  42662. */
  42663. reflectionFresnel: boolean;
  42664. protected _reflectionFalloffDistance: number;
  42665. /**
  42666. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42667. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42668. */
  42669. reflectionFalloffDistance: number;
  42670. protected _reflectionAmount: number;
  42671. /**
  42672. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42673. */
  42674. reflectionAmount: number;
  42675. protected _reflectionReflectance0: number;
  42676. /**
  42677. * This specifies the weight of the reflection at grazing angle.
  42678. */
  42679. reflectionReflectance0: number;
  42680. protected _reflectionReflectance90: number;
  42681. /**
  42682. * This specifies the weight of the reflection at a perpendicular point of view.
  42683. */
  42684. reflectionReflectance90: number;
  42685. /**
  42686. * Sets the reflection reflectance fresnel values according to the default standard
  42687. * empirically know to work well :-)
  42688. */
  42689. reflectionStandardFresnelWeight: number;
  42690. protected _useRGBColor: boolean;
  42691. /**
  42692. * Helps to directly use the maps channels instead of their level.
  42693. */
  42694. useRGBColor: boolean;
  42695. protected _enableNoise: boolean;
  42696. /**
  42697. * This helps reducing the banding effect that could occur on the background.
  42698. */
  42699. enableNoise: boolean;
  42700. /**
  42701. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42702. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42703. * Recommended to be keep at 1.0 except for special cases.
  42704. */
  42705. fovMultiplier: number;
  42706. private _fovMultiplier;
  42707. /**
  42708. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42709. */
  42710. useEquirectangularFOV: boolean;
  42711. private _maxSimultaneousLights;
  42712. /**
  42713. * Number of Simultaneous lights allowed on the material.
  42714. */
  42715. maxSimultaneousLights: int;
  42716. /**
  42717. * Default configuration related to image processing available in the Background Material.
  42718. */
  42719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42720. /**
  42721. * Keep track of the image processing observer to allow dispose and replace.
  42722. */
  42723. private _imageProcessingObserver;
  42724. /**
  42725. * Attaches a new image processing configuration to the PBR Material.
  42726. * @param configuration (if null the scene configuration will be use)
  42727. */
  42728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42729. /**
  42730. * Gets the image processing configuration used either in this material.
  42731. */
  42732. /**
  42733. * Sets the Default image processing configuration used either in the this material.
  42734. *
  42735. * If sets to null, the scene one is in use.
  42736. */
  42737. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42738. /**
  42739. * Gets wether the color curves effect is enabled.
  42740. */
  42741. /**
  42742. * Sets wether the color curves effect is enabled.
  42743. */
  42744. cameraColorCurvesEnabled: boolean;
  42745. /**
  42746. * Gets wether the color grading effect is enabled.
  42747. */
  42748. /**
  42749. * Gets wether the color grading effect is enabled.
  42750. */
  42751. cameraColorGradingEnabled: boolean;
  42752. /**
  42753. * Gets wether tonemapping is enabled or not.
  42754. */
  42755. /**
  42756. * Sets wether tonemapping is enabled or not
  42757. */
  42758. cameraToneMappingEnabled: boolean;
  42759. /**
  42760. * The camera exposure used on this material.
  42761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42762. * This corresponds to a photographic exposure.
  42763. */
  42764. /**
  42765. * The camera exposure used on this material.
  42766. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42767. * This corresponds to a photographic exposure.
  42768. */
  42769. cameraExposure: float;
  42770. /**
  42771. * Gets The camera contrast used on this material.
  42772. */
  42773. /**
  42774. * Sets The camera contrast used on this material.
  42775. */
  42776. cameraContrast: float;
  42777. /**
  42778. * Gets the Color Grading 2D Lookup Texture.
  42779. */
  42780. /**
  42781. * Sets the Color Grading 2D Lookup Texture.
  42782. */
  42783. cameraColorGradingTexture: Nullable<BaseTexture>;
  42784. /**
  42785. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42786. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42787. * 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;
  42788. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42789. */
  42790. /**
  42791. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42792. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42793. * 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;
  42794. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42795. */
  42796. cameraColorCurves: Nullable<ColorCurves>;
  42797. /**
  42798. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42799. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42800. */
  42801. switchToBGR: boolean;
  42802. private _renderTargets;
  42803. private _reflectionControls;
  42804. private _white;
  42805. private _primaryShadowColor;
  42806. private _primaryHighlightColor;
  42807. /**
  42808. * Instantiates a Background Material in the given scene
  42809. * @param name The friendly name of the material
  42810. * @param scene The scene to add the material to
  42811. */
  42812. constructor(name: string, scene: Scene);
  42813. /**
  42814. * Gets a boolean indicating that current material needs to register RTT
  42815. */
  42816. readonly hasRenderTargetTextures: boolean;
  42817. /**
  42818. * The entire material has been created in order to prevent overdraw.
  42819. * @returns false
  42820. */
  42821. needAlphaTesting(): boolean;
  42822. /**
  42823. * The entire material has been created in order to prevent overdraw.
  42824. * @returns true if blending is enable
  42825. */
  42826. needAlphaBlending(): boolean;
  42827. /**
  42828. * Checks wether the material is ready to be rendered for a given mesh.
  42829. * @param mesh The mesh to render
  42830. * @param subMesh The submesh to check against
  42831. * @param useInstances Specify wether or not the material is used with instances
  42832. * @returns true if all the dependencies are ready (Textures, Effects...)
  42833. */
  42834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42835. /**
  42836. * Compute the primary color according to the chosen perceptual color.
  42837. */
  42838. private _computePrimaryColorFromPerceptualColor;
  42839. /**
  42840. * Compute the highlights and shadow colors according to their chosen levels.
  42841. */
  42842. private _computePrimaryColors;
  42843. /**
  42844. * Build the uniform buffer used in the material.
  42845. */
  42846. buildUniformLayout(): void;
  42847. /**
  42848. * Unbind the material.
  42849. */
  42850. unbind(): void;
  42851. /**
  42852. * Bind only the world matrix to the material.
  42853. * @param world The world matrix to bind.
  42854. */
  42855. bindOnlyWorldMatrix(world: Matrix): void;
  42856. /**
  42857. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42858. * @param world The world matrix to bind.
  42859. * @param subMesh The submesh to bind for.
  42860. */
  42861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42862. /**
  42863. * Dispose the material.
  42864. * @param forceDisposeEffect Force disposal of the associated effect.
  42865. * @param forceDisposeTextures Force disposal of the associated textures.
  42866. */
  42867. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42868. /**
  42869. * Clones the material.
  42870. * @param name The cloned name.
  42871. * @returns The cloned material.
  42872. */
  42873. clone(name: string): BackgroundMaterial;
  42874. /**
  42875. * Serializes the current material to its JSON representation.
  42876. * @returns The JSON representation.
  42877. */
  42878. serialize(): any;
  42879. /**
  42880. * Gets the class name of the material
  42881. * @returns "BackgroundMaterial"
  42882. */
  42883. getClassName(): string;
  42884. /**
  42885. * Parse a JSON input to create back a background material.
  42886. * @param source The JSON data to parse
  42887. * @param scene The scene to create the parsed material in
  42888. * @param rootUrl The root url of the assets the material depends upon
  42889. * @returns the instantiated BackgroundMaterial.
  42890. */
  42891. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42892. }
  42893. }
  42894. declare module BABYLON {
  42895. /**
  42896. * Represents the different options available during the creation of
  42897. * a Environment helper.
  42898. *
  42899. * This can control the default ground, skybox and image processing setup of your scene.
  42900. */
  42901. export interface IEnvironmentHelperOptions {
  42902. /**
  42903. * Specifies wether or not to create a ground.
  42904. * True by default.
  42905. */
  42906. createGround: boolean;
  42907. /**
  42908. * Specifies the ground size.
  42909. * 15 by default.
  42910. */
  42911. groundSize: number;
  42912. /**
  42913. * The texture used on the ground for the main color.
  42914. * Comes from the BabylonJS CDN by default.
  42915. *
  42916. * Remarks: Can be either a texture or a url.
  42917. */
  42918. groundTexture: string | BaseTexture;
  42919. /**
  42920. * The color mixed in the ground texture by default.
  42921. * BabylonJS clearColor by default.
  42922. */
  42923. groundColor: Color3;
  42924. /**
  42925. * Specifies the ground opacity.
  42926. * 1 by default.
  42927. */
  42928. groundOpacity: number;
  42929. /**
  42930. * Enables the ground to receive shadows.
  42931. * True by default.
  42932. */
  42933. enableGroundShadow: boolean;
  42934. /**
  42935. * Helps preventing the shadow to be fully black on the ground.
  42936. * 0.5 by default.
  42937. */
  42938. groundShadowLevel: number;
  42939. /**
  42940. * Creates a mirror texture attach to the ground.
  42941. * false by default.
  42942. */
  42943. enableGroundMirror: boolean;
  42944. /**
  42945. * Specifies the ground mirror size ratio.
  42946. * 0.3 by default as the default kernel is 64.
  42947. */
  42948. groundMirrorSizeRatio: number;
  42949. /**
  42950. * Specifies the ground mirror blur kernel size.
  42951. * 64 by default.
  42952. */
  42953. groundMirrorBlurKernel: number;
  42954. /**
  42955. * Specifies the ground mirror visibility amount.
  42956. * 1 by default
  42957. */
  42958. groundMirrorAmount: number;
  42959. /**
  42960. * Specifies the ground mirror reflectance weight.
  42961. * This uses the standard weight of the background material to setup the fresnel effect
  42962. * of the mirror.
  42963. * 1 by default.
  42964. */
  42965. groundMirrorFresnelWeight: number;
  42966. /**
  42967. * Specifies the ground mirror Falloff distance.
  42968. * This can helps reducing the size of the reflection.
  42969. * 0 by Default.
  42970. */
  42971. groundMirrorFallOffDistance: number;
  42972. /**
  42973. * Specifies the ground mirror texture type.
  42974. * Unsigned Int by Default.
  42975. */
  42976. groundMirrorTextureType: number;
  42977. /**
  42978. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42979. * the shown objects.
  42980. */
  42981. groundYBias: number;
  42982. /**
  42983. * Specifies wether or not to create a skybox.
  42984. * True by default.
  42985. */
  42986. createSkybox: boolean;
  42987. /**
  42988. * Specifies the skybox size.
  42989. * 20 by default.
  42990. */
  42991. skyboxSize: number;
  42992. /**
  42993. * The texture used on the skybox for the main color.
  42994. * Comes from the BabylonJS CDN by default.
  42995. *
  42996. * Remarks: Can be either a texture or a url.
  42997. */
  42998. skyboxTexture: string | BaseTexture;
  42999. /**
  43000. * The color mixed in the skybox texture by default.
  43001. * BabylonJS clearColor by default.
  43002. */
  43003. skyboxColor: Color3;
  43004. /**
  43005. * The background rotation around the Y axis of the scene.
  43006. * This helps aligning the key lights of your scene with the background.
  43007. * 0 by default.
  43008. */
  43009. backgroundYRotation: number;
  43010. /**
  43011. * Compute automatically the size of the elements to best fit with the scene.
  43012. */
  43013. sizeAuto: boolean;
  43014. /**
  43015. * Default position of the rootMesh if autoSize is not true.
  43016. */
  43017. rootPosition: Vector3;
  43018. /**
  43019. * Sets up the image processing in the scene.
  43020. * true by default.
  43021. */
  43022. setupImageProcessing: boolean;
  43023. /**
  43024. * The texture used as your environment texture in the scene.
  43025. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43026. *
  43027. * Remarks: Can be either a texture or a url.
  43028. */
  43029. environmentTexture: string | BaseTexture;
  43030. /**
  43031. * The value of the exposure to apply to the scene.
  43032. * 0.6 by default if setupImageProcessing is true.
  43033. */
  43034. cameraExposure: number;
  43035. /**
  43036. * The value of the contrast to apply to the scene.
  43037. * 1.6 by default if setupImageProcessing is true.
  43038. */
  43039. cameraContrast: number;
  43040. /**
  43041. * Specifies wether or not tonemapping should be enabled in the scene.
  43042. * true by default if setupImageProcessing is true.
  43043. */
  43044. toneMappingEnabled: boolean;
  43045. }
  43046. /**
  43047. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43048. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43049. * It also helps with the default setup of your imageProcessing configuration.
  43050. */
  43051. export class EnvironmentHelper {
  43052. /**
  43053. * Default ground texture URL.
  43054. */
  43055. private static _groundTextureCDNUrl;
  43056. /**
  43057. * Default skybox texture URL.
  43058. */
  43059. private static _skyboxTextureCDNUrl;
  43060. /**
  43061. * Default environment texture URL.
  43062. */
  43063. private static _environmentTextureCDNUrl;
  43064. /**
  43065. * Creates the default options for the helper.
  43066. */
  43067. private static _getDefaultOptions;
  43068. private _rootMesh;
  43069. /**
  43070. * Gets the root mesh created by the helper.
  43071. */
  43072. readonly rootMesh: Mesh;
  43073. private _skybox;
  43074. /**
  43075. * Gets the skybox created by the helper.
  43076. */
  43077. readonly skybox: Nullable<Mesh>;
  43078. private _skyboxTexture;
  43079. /**
  43080. * Gets the skybox texture created by the helper.
  43081. */
  43082. readonly skyboxTexture: Nullable<BaseTexture>;
  43083. private _skyboxMaterial;
  43084. /**
  43085. * Gets the skybox material created by the helper.
  43086. */
  43087. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43088. private _ground;
  43089. /**
  43090. * Gets the ground mesh created by the helper.
  43091. */
  43092. readonly ground: Nullable<Mesh>;
  43093. private _groundTexture;
  43094. /**
  43095. * Gets the ground texture created by the helper.
  43096. */
  43097. readonly groundTexture: Nullable<BaseTexture>;
  43098. private _groundMirror;
  43099. /**
  43100. * Gets the ground mirror created by the helper.
  43101. */
  43102. readonly groundMirror: Nullable<MirrorTexture>;
  43103. /**
  43104. * Gets the ground mirror render list to helps pushing the meshes
  43105. * you wish in the ground reflection.
  43106. */
  43107. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43108. private _groundMaterial;
  43109. /**
  43110. * Gets the ground material created by the helper.
  43111. */
  43112. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43113. /**
  43114. * Stores the creation options.
  43115. */
  43116. private readonly _scene;
  43117. private _options;
  43118. /**
  43119. * This observable will be notified with any error during the creation of the environment,
  43120. * mainly texture creation errors.
  43121. */
  43122. onErrorObservable: Observable<{
  43123. message?: string;
  43124. exception?: any;
  43125. }>;
  43126. /**
  43127. * constructor
  43128. * @param options Defines the options we want to customize the helper
  43129. * @param scene The scene to add the material to
  43130. */
  43131. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43132. /**
  43133. * Updates the background according to the new options
  43134. * @param options
  43135. */
  43136. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43137. /**
  43138. * Sets the primary color of all the available elements.
  43139. * @param color the main color to affect to the ground and the background
  43140. */
  43141. setMainColor(color: Color3): void;
  43142. /**
  43143. * Setup the image processing according to the specified options.
  43144. */
  43145. private _setupImageProcessing;
  43146. /**
  43147. * Setup the environment texture according to the specified options.
  43148. */
  43149. private _setupEnvironmentTexture;
  43150. /**
  43151. * Setup the background according to the specified options.
  43152. */
  43153. private _setupBackground;
  43154. /**
  43155. * Get the scene sizes according to the setup.
  43156. */
  43157. private _getSceneSize;
  43158. /**
  43159. * Setup the ground according to the specified options.
  43160. */
  43161. private _setupGround;
  43162. /**
  43163. * Setup the ground material according to the specified options.
  43164. */
  43165. private _setupGroundMaterial;
  43166. /**
  43167. * Setup the ground diffuse texture according to the specified options.
  43168. */
  43169. private _setupGroundDiffuseTexture;
  43170. /**
  43171. * Setup the ground mirror texture according to the specified options.
  43172. */
  43173. private _setupGroundMirrorTexture;
  43174. /**
  43175. * Setup the ground to receive the mirror texture.
  43176. */
  43177. private _setupMirrorInGroundMaterial;
  43178. /**
  43179. * Setup the skybox according to the specified options.
  43180. */
  43181. private _setupSkybox;
  43182. /**
  43183. * Setup the skybox material according to the specified options.
  43184. */
  43185. private _setupSkyboxMaterial;
  43186. /**
  43187. * Setup the skybox reflection texture according to the specified options.
  43188. */
  43189. private _setupSkyboxReflectionTexture;
  43190. private _errorHandler;
  43191. /**
  43192. * Dispose all the elements created by the Helper.
  43193. */
  43194. dispose(): void;
  43195. }
  43196. }
  43197. declare module BABYLON {
  43198. /**
  43199. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43200. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43201. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43202. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43203. */
  43204. export class PhotoDome extends TransformNode {
  43205. private _useDirectMapping;
  43206. /**
  43207. * The texture being displayed on the sphere
  43208. */
  43209. protected _photoTexture: Texture;
  43210. /**
  43211. * Gets or sets the texture being displayed on the sphere
  43212. */
  43213. photoTexture: Texture;
  43214. /**
  43215. * Observable raised when an error occured while loading the 360 image
  43216. */
  43217. onLoadErrorObservable: Observable<string>;
  43218. /**
  43219. * The skybox material
  43220. */
  43221. protected _material: BackgroundMaterial;
  43222. /**
  43223. * The surface used for the skybox
  43224. */
  43225. protected _mesh: Mesh;
  43226. /**
  43227. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43228. * Also see the options.resolution property.
  43229. */
  43230. fovMultiplier: number;
  43231. /**
  43232. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43233. * @param name Element's name, child elements will append suffixes for their own names.
  43234. * @param urlsOfPhoto defines the url of the photo to display
  43235. * @param options defines an object containing optional or exposed sub element properties
  43236. * @param onError defines a callback called when an error occured while loading the texture
  43237. */
  43238. constructor(name: string, urlOfPhoto: string, options: {
  43239. resolution?: number;
  43240. size?: number;
  43241. useDirectMapping?: boolean;
  43242. faceForward?: boolean;
  43243. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43244. /**
  43245. * Releases resources associated with this node.
  43246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43248. */
  43249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43250. }
  43251. }
  43252. declare module BABYLON {
  43253. /** @hidden */
  43254. export var rgbdDecodePixelShader: {
  43255. name: string;
  43256. shader: string;
  43257. };
  43258. }
  43259. declare module BABYLON {
  43260. /**
  43261. * Class used to host texture specific utilities
  43262. */
  43263. export class BRDFTextureTools {
  43264. /**
  43265. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43266. * @param texture the texture to expand.
  43267. */
  43268. private static _ExpandDefaultBRDFTexture;
  43269. /**
  43270. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43271. * @param scene defines the hosting scene
  43272. * @returns the environment BRDF texture
  43273. */
  43274. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43275. private static _environmentBRDFBase64Texture;
  43276. }
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * @hidden
  43281. */
  43282. export interface IMaterialClearCoatDefines {
  43283. CLEARCOAT: boolean;
  43284. CLEARCOAT_DEFAULTIOR: boolean;
  43285. CLEARCOAT_TEXTURE: boolean;
  43286. CLEARCOAT_TEXTUREDIRECTUV: number;
  43287. CLEARCOAT_BUMP: boolean;
  43288. CLEARCOAT_BUMPDIRECTUV: number;
  43289. CLEARCOAT_TINT: boolean;
  43290. CLEARCOAT_TINT_TEXTURE: boolean;
  43291. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43292. /** @hidden */ areTexturesDirty: boolean;
  43293. }
  43294. /**
  43295. * Define the code related to the clear coat parameters of the pbr material.
  43296. */
  43297. export class PBRClearCoatConfiguration {
  43298. /**
  43299. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43300. * The default fits with a polyurethane material.
  43301. */
  43302. private static readonly _DefaultIndiceOfRefraction;
  43303. private _isEnabled;
  43304. /**
  43305. * Defines if the clear coat is enabled in the material.
  43306. */
  43307. isEnabled: boolean;
  43308. /**
  43309. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43310. */
  43311. intensity: number;
  43312. /**
  43313. * Defines the clear coat layer roughness.
  43314. */
  43315. roughness: number;
  43316. private _indiceOfRefraction;
  43317. /**
  43318. * Defines the indice of refraction of the clear coat.
  43319. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43320. * The default fits with a polyurethane material.
  43321. * Changing the default value is more performance intensive.
  43322. */
  43323. indiceOfRefraction: number;
  43324. private _texture;
  43325. /**
  43326. * Stores the clear coat values in a texture.
  43327. */
  43328. texture: Nullable<BaseTexture>;
  43329. private _bumpTexture;
  43330. /**
  43331. * Define the clear coat specific bump texture.
  43332. */
  43333. bumpTexture: Nullable<BaseTexture>;
  43334. private _isTintEnabled;
  43335. /**
  43336. * Defines if the clear coat tint is enabled in the material.
  43337. */
  43338. isTintEnabled: boolean;
  43339. /**
  43340. * Defines the clear coat tint of the material.
  43341. * This is only use if tint is enabled
  43342. */
  43343. tintColor: Color3;
  43344. /**
  43345. * Defines the distance at which the tint color should be found in the
  43346. * clear coat media.
  43347. * This is only use if tint is enabled
  43348. */
  43349. tintColorAtDistance: number;
  43350. /**
  43351. * Defines the clear coat layer thickness.
  43352. * This is only use if tint is enabled
  43353. */
  43354. tintThickness: number;
  43355. private _tintTexture;
  43356. /**
  43357. * Stores the clear tint values in a texture.
  43358. * rgb is tint
  43359. * a is a thickness factor
  43360. */
  43361. tintTexture: Nullable<BaseTexture>;
  43362. /** @hidden */
  43363. private _internalMarkAllSubMeshesAsTexturesDirty;
  43364. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43365. /**
  43366. * Instantiate a new istance of clear coat configuration.
  43367. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43368. */
  43369. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43370. /**
  43371. * Gets wehter the submesh is ready to be used or not.
  43372. * @param defines the list of "defines" to update.
  43373. * @param scene defines the scene the material belongs to.
  43374. * @param engine defines the engine the material belongs to.
  43375. * @param disableBumpMap defines wether the material disables bump or not.
  43376. * @returns - boolean indicating that the submesh is ready or not.
  43377. */
  43378. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43379. /**
  43380. * Checks to see if a texture is used in the material.
  43381. * @param defines the list of "defines" to update.
  43382. * @param scene defines the scene to the material belongs to.
  43383. */
  43384. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43385. /**
  43386. * Binds the material data.
  43387. * @param uniformBuffer defines the Uniform buffer to fill in.
  43388. * @param scene defines the scene the material belongs to.
  43389. * @param engine defines the engine the material belongs to.
  43390. * @param disableBumpMap defines wether the material disables bump or not.
  43391. * @param isFrozen defines wether the material is frozen or not.
  43392. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43393. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43394. */
  43395. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43396. /**
  43397. * Checks to see if a texture is used in the material.
  43398. * @param texture - Base texture to use.
  43399. * @returns - Boolean specifying if a texture is used in the material.
  43400. */
  43401. hasTexture(texture: BaseTexture): boolean;
  43402. /**
  43403. * Returns an array of the actively used textures.
  43404. * @param activeTextures Array of BaseTextures
  43405. */
  43406. getActiveTextures(activeTextures: BaseTexture[]): void;
  43407. /**
  43408. * Returns the animatable textures.
  43409. * @param animatables Array of animatable textures.
  43410. */
  43411. getAnimatables(animatables: IAnimatable[]): void;
  43412. /**
  43413. * Disposes the resources of the material.
  43414. * @param forceDisposeTextures - Forces the disposal of all textures.
  43415. */
  43416. dispose(forceDisposeTextures?: boolean): void;
  43417. /**
  43418. * Get the current class name of the texture useful for serialization or dynamic coding.
  43419. * @returns "PBRClearCoatConfiguration"
  43420. */
  43421. getClassName(): string;
  43422. /**
  43423. * Add fallbacks to the effect fallbacks list.
  43424. * @param defines defines the Base texture to use.
  43425. * @param fallbacks defines the current fallback list.
  43426. * @param currentRank defines the current fallback rank.
  43427. * @returns the new fallback rank.
  43428. */
  43429. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43430. /**
  43431. * Add the required uniforms to the current list.
  43432. * @param uniforms defines the current uniform list.
  43433. */
  43434. static AddUniforms(uniforms: string[]): void;
  43435. /**
  43436. * Add the required samplers to the current list.
  43437. * @param samplers defines the current sampler list.
  43438. */
  43439. static AddSamplers(samplers: string[]): void;
  43440. /**
  43441. * Add the required uniforms to the current buffer.
  43442. * @param uniformBuffer defines the current uniform buffer.
  43443. */
  43444. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43445. /**
  43446. * Makes a duplicate of the current configuration into another one.
  43447. * @param clearCoatConfiguration define the config where to copy the info
  43448. */
  43449. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43450. /**
  43451. * Serializes this clear coat configuration.
  43452. * @returns - An object with the serialized config.
  43453. */
  43454. serialize(): any;
  43455. /**
  43456. * Parses a Clear Coat Configuration from a serialized object.
  43457. * @param source - Serialized object.
  43458. */
  43459. parse(source: any): void;
  43460. }
  43461. }
  43462. declare module BABYLON {
  43463. /**
  43464. * @hidden
  43465. */
  43466. export interface IMaterialAnisotropicDefines {
  43467. ANISOTROPIC: boolean;
  43468. ANISOTROPIC_TEXTURE: boolean;
  43469. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43470. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43471. }
  43472. /**
  43473. * Define the code related to the anisotropic parameters of the pbr material.
  43474. */
  43475. export class PBRAnisotropicConfiguration {
  43476. private _isEnabled;
  43477. /**
  43478. * Defines if the anisotropy is enabled in the material.
  43479. */
  43480. isEnabled: boolean;
  43481. /**
  43482. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43483. */
  43484. intensity: number;
  43485. /**
  43486. * Defines if the effect is along the tangents, bitangents or in between.
  43487. * By default, the effect is "strectching" the highlights along the tangents.
  43488. */
  43489. direction: Vector2;
  43490. private _texture;
  43491. /**
  43492. * Stores the anisotropy values in a texture.
  43493. * rg is direction (like normal from -1 to 1)
  43494. * b is a intensity
  43495. */
  43496. texture: Nullable<BaseTexture>;
  43497. /** @hidden */
  43498. private _internalMarkAllSubMeshesAsTexturesDirty;
  43499. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43500. /**
  43501. * Instantiate a new istance of anisotropy configuration.
  43502. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43503. */
  43504. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43505. /**
  43506. * Specifies that the submesh is ready to be used.
  43507. * @param defines the list of "defines" to update.
  43508. * @param scene defines the scene the material belongs to.
  43509. * @returns - boolean indicating that the submesh is ready or not.
  43510. */
  43511. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43512. /**
  43513. * Checks to see if a texture is used in the material.
  43514. * @param defines the list of "defines" to update.
  43515. * @param mesh the mesh we are preparing the defines for.
  43516. * @param scene defines the scene the material belongs to.
  43517. */
  43518. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43519. /**
  43520. * Binds the material data.
  43521. * @param uniformBuffer defines the Uniform buffer to fill in.
  43522. * @param scene defines the scene the material belongs to.
  43523. * @param isFrozen defines wether the material is frozen or not.
  43524. */
  43525. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43526. /**
  43527. * Checks to see if a texture is used in the material.
  43528. * @param texture - Base texture to use.
  43529. * @returns - Boolean specifying if a texture is used in the material.
  43530. */
  43531. hasTexture(texture: BaseTexture): boolean;
  43532. /**
  43533. * Returns an array of the actively used textures.
  43534. * @param activeTextures Array of BaseTextures
  43535. */
  43536. getActiveTextures(activeTextures: BaseTexture[]): void;
  43537. /**
  43538. * Returns the animatable textures.
  43539. * @param animatables Array of animatable textures.
  43540. */
  43541. getAnimatables(animatables: IAnimatable[]): void;
  43542. /**
  43543. * Disposes the resources of the material.
  43544. * @param forceDisposeTextures - Forces the disposal of all textures.
  43545. */
  43546. dispose(forceDisposeTextures?: boolean): void;
  43547. /**
  43548. * Get the current class name of the texture useful for serialization or dynamic coding.
  43549. * @returns "PBRAnisotropicConfiguration"
  43550. */
  43551. getClassName(): string;
  43552. /**
  43553. * Add fallbacks to the effect fallbacks list.
  43554. * @param defines defines the Base texture to use.
  43555. * @param fallbacks defines the current fallback list.
  43556. * @param currentRank defines the current fallback rank.
  43557. * @returns the new fallback rank.
  43558. */
  43559. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43560. /**
  43561. * Add the required uniforms to the current list.
  43562. * @param uniforms defines the current uniform list.
  43563. */
  43564. static AddUniforms(uniforms: string[]): void;
  43565. /**
  43566. * Add the required uniforms to the current buffer.
  43567. * @param uniformBuffer defines the current uniform buffer.
  43568. */
  43569. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43570. /**
  43571. * Add the required samplers to the current list.
  43572. * @param samplers defines the current sampler list.
  43573. */
  43574. static AddSamplers(samplers: string[]): void;
  43575. /**
  43576. * Makes a duplicate of the current configuration into another one.
  43577. * @param anisotropicConfiguration define the config where to copy the info
  43578. */
  43579. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43580. /**
  43581. * Serializes this anisotropy configuration.
  43582. * @returns - An object with the serialized config.
  43583. */
  43584. serialize(): any;
  43585. /**
  43586. * Parses a anisotropy Configuration from a serialized object.
  43587. * @param source - Serialized object.
  43588. */
  43589. parse(source: any): void;
  43590. }
  43591. }
  43592. declare module BABYLON {
  43593. /**
  43594. * @hidden
  43595. */
  43596. export interface IMaterialBRDFDefines {
  43597. BRDF_V_HEIGHT_CORRELATED: boolean;
  43598. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43599. SPHERICAL_HARMONICS: boolean;
  43600. /** @hidden */ areMiscDirty: boolean;
  43601. }
  43602. /**
  43603. * Define the code related to the BRDF parameters of the pbr material.
  43604. */
  43605. export class PBRBRDFConfiguration {
  43606. /**
  43607. * Default value used for the energy conservation.
  43608. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43609. */
  43610. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43611. /**
  43612. * Default value used for the Smith Visibility Height Correlated mode.
  43613. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43614. */
  43615. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43616. /**
  43617. * Default value used for the IBL diffuse part.
  43618. * This can help switching back to the polynomials mode globally which is a tiny bit
  43619. * less GPU intensive at the drawback of a lower quality.
  43620. */
  43621. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  43622. private _useEnergyConservation;
  43623. /**
  43624. * Defines if the material uses energy conservation.
  43625. */
  43626. useEnergyConservation: boolean;
  43627. private _useSmithVisibilityHeightCorrelated;
  43628. /**
  43629. * LEGACY Mode set to false
  43630. * Defines if the material uses height smith correlated visibility term.
  43631. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43632. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43633. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43634. * Not relying on height correlated will also disable energy conservation.
  43635. */
  43636. useSmithVisibilityHeightCorrelated: boolean;
  43637. private _useSphericalHarmonics;
  43638. /**
  43639. * LEGACY Mode set to false
  43640. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  43641. * diffuse part of the IBL.
  43642. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  43643. * to the ground truth.
  43644. */
  43645. useSphericalHarmonics: boolean;
  43646. /** @hidden */
  43647. private _internalMarkAllSubMeshesAsMiscDirty;
  43648. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43649. /**
  43650. * Instantiate a new istance of clear coat configuration.
  43651. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43652. */
  43653. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43654. /**
  43655. * Checks to see if a texture is used in the material.
  43656. * @param defines the list of "defines" to update.
  43657. */
  43658. prepareDefines(defines: IMaterialBRDFDefines): void;
  43659. /**
  43660. * Get the current class name of the texture useful for serialization or dynamic coding.
  43661. * @returns "PBRClearCoatConfiguration"
  43662. */
  43663. getClassName(): string;
  43664. /**
  43665. * Makes a duplicate of the current configuration into another one.
  43666. * @param brdfConfiguration define the config where to copy the info
  43667. */
  43668. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43669. /**
  43670. * Serializes this BRDF configuration.
  43671. * @returns - An object with the serialized config.
  43672. */
  43673. serialize(): any;
  43674. /**
  43675. * Parses a BRDF Configuration from a serialized object.
  43676. * @param source - Serialized object.
  43677. */
  43678. parse(source: any): void;
  43679. }
  43680. }
  43681. declare module BABYLON {
  43682. /**
  43683. * @hidden
  43684. */
  43685. export interface IMaterialSheenDefines {
  43686. SHEEN: boolean;
  43687. SHEEN_TEXTURE: boolean;
  43688. SHEEN_TEXTUREDIRECTUV: number;
  43689. SHEEN_LINKWITHALBEDO: boolean;
  43690. /** @hidden */ areTexturesDirty: boolean;
  43691. }
  43692. /**
  43693. * Define the code related to the Sheen parameters of the pbr material.
  43694. */
  43695. export class PBRSheenConfiguration {
  43696. private _isEnabled;
  43697. /**
  43698. * Defines if the material uses sheen.
  43699. */
  43700. isEnabled: boolean;
  43701. private _linkSheenWithAlbedo;
  43702. /**
  43703. * Defines if the sheen is linked to the sheen color.
  43704. */
  43705. linkSheenWithAlbedo: boolean;
  43706. /**
  43707. * Defines the sheen intensity.
  43708. */
  43709. intensity: number;
  43710. /**
  43711. * Defines the sheen color.
  43712. */
  43713. color: Color3;
  43714. private _texture;
  43715. /**
  43716. * Stores the sheen tint values in a texture.
  43717. * rgb is tint
  43718. * a is a intensity
  43719. */
  43720. texture: Nullable<BaseTexture>;
  43721. /** @hidden */
  43722. private _internalMarkAllSubMeshesAsTexturesDirty;
  43723. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43724. /**
  43725. * Instantiate a new istance of clear coat configuration.
  43726. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43727. */
  43728. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43729. /**
  43730. * Specifies that the submesh is ready to be used.
  43731. * @param defines the list of "defines" to update.
  43732. * @param scene defines the scene the material belongs to.
  43733. * @returns - boolean indicating that the submesh is ready or not.
  43734. */
  43735. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43736. /**
  43737. * Checks to see if a texture is used in the material.
  43738. * @param defines the list of "defines" to update.
  43739. * @param scene defines the scene the material belongs to.
  43740. */
  43741. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43742. /**
  43743. * Binds the material data.
  43744. * @param uniformBuffer defines the Uniform buffer to fill in.
  43745. * @param scene defines the scene the material belongs to.
  43746. * @param isFrozen defines wether the material is frozen or not.
  43747. */
  43748. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43749. /**
  43750. * Checks to see if a texture is used in the material.
  43751. * @param texture - Base texture to use.
  43752. * @returns - Boolean specifying if a texture is used in the material.
  43753. */
  43754. hasTexture(texture: BaseTexture): boolean;
  43755. /**
  43756. * Returns an array of the actively used textures.
  43757. * @param activeTextures Array of BaseTextures
  43758. */
  43759. getActiveTextures(activeTextures: BaseTexture[]): void;
  43760. /**
  43761. * Returns the animatable textures.
  43762. * @param animatables Array of animatable textures.
  43763. */
  43764. getAnimatables(animatables: IAnimatable[]): void;
  43765. /**
  43766. * Disposes the resources of the material.
  43767. * @param forceDisposeTextures - Forces the disposal of all textures.
  43768. */
  43769. dispose(forceDisposeTextures?: boolean): void;
  43770. /**
  43771. * Get the current class name of the texture useful for serialization or dynamic coding.
  43772. * @returns "PBRSheenConfiguration"
  43773. */
  43774. getClassName(): string;
  43775. /**
  43776. * Add fallbacks to the effect fallbacks list.
  43777. * @param defines defines the Base texture to use.
  43778. * @param fallbacks defines the current fallback list.
  43779. * @param currentRank defines the current fallback rank.
  43780. * @returns the new fallback rank.
  43781. */
  43782. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43783. /**
  43784. * Add the required uniforms to the current list.
  43785. * @param uniforms defines the current uniform list.
  43786. */
  43787. static AddUniforms(uniforms: string[]): void;
  43788. /**
  43789. * Add the required uniforms to the current buffer.
  43790. * @param uniformBuffer defines the current uniform buffer.
  43791. */
  43792. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43793. /**
  43794. * Add the required samplers to the current list.
  43795. * @param samplers defines the current sampler list.
  43796. */
  43797. static AddSamplers(samplers: string[]): void;
  43798. /**
  43799. * Makes a duplicate of the current configuration into another one.
  43800. * @param sheenConfiguration define the config where to copy the info
  43801. */
  43802. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43803. /**
  43804. * Serializes this BRDF configuration.
  43805. * @returns - An object with the serialized config.
  43806. */
  43807. serialize(): any;
  43808. /**
  43809. * Parses a Sheen Configuration from a serialized object.
  43810. * @param source - Serialized object.
  43811. */
  43812. parse(source: any): void;
  43813. }
  43814. }
  43815. declare module BABYLON {
  43816. /**
  43817. * @hidden
  43818. */
  43819. export interface IMaterialSubSurfaceDefines {
  43820. SUBSURFACE: boolean;
  43821. SS_REFRACTION: boolean;
  43822. SS_TRANSLUCENCY: boolean;
  43823. SS_SCATERRING: boolean;
  43824. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43825. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43826. SS_REFRACTIONMAP_3D: boolean;
  43827. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43828. SS_LODINREFRACTIONALPHA: boolean;
  43829. SS_GAMMAREFRACTION: boolean;
  43830. SS_RGBDREFRACTION: boolean;
  43831. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43832. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43833. /** @hidden */ areTexturesDirty: boolean;
  43834. }
  43835. /**
  43836. * Define the code related to the sub surface parameters of the pbr material.
  43837. */
  43838. export class PBRSubSurfaceConfiguration {
  43839. private _isRefractionEnabled;
  43840. /**
  43841. * Defines if the refraction is enabled in the material.
  43842. */
  43843. isRefractionEnabled: boolean;
  43844. private _isTranslucencyEnabled;
  43845. /**
  43846. * Defines if the translucency is enabled in the material.
  43847. */
  43848. isTranslucencyEnabled: boolean;
  43849. private _isScatteringEnabled;
  43850. /**
  43851. * Defines the refraction intensity of the material.
  43852. * The refraction when enabled replaces the Diffuse part of the material.
  43853. * The intensity helps transitionning between diffuse and refraction.
  43854. */
  43855. refractionIntensity: number;
  43856. /**
  43857. * Defines the translucency intensity of the material.
  43858. * When translucency has been enabled, this defines how much of the "translucency"
  43859. * is addded to the diffuse part of the material.
  43860. */
  43861. translucencyIntensity: number;
  43862. /**
  43863. * Defines the scattering intensity of the material.
  43864. * When scattering has been enabled, this defines how much of the "scattered light"
  43865. * is addded to the diffuse part of the material.
  43866. */
  43867. scatteringIntensity: number;
  43868. private _thicknessTexture;
  43869. /**
  43870. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43871. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43872. * 0 would mean minimumThickness
  43873. * 1 would mean maximumThickness
  43874. * The other channels might be use as a mask to vary the different effects intensity.
  43875. */
  43876. thicknessTexture: Nullable<BaseTexture>;
  43877. private _refractionTexture;
  43878. /**
  43879. * Defines the texture to use for refraction.
  43880. */
  43881. refractionTexture: Nullable<BaseTexture>;
  43882. private _indexOfRefraction;
  43883. /**
  43884. * Defines the indice of refraction used in the material.
  43885. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43886. */
  43887. indexOfRefraction: number;
  43888. private _invertRefractionY;
  43889. /**
  43890. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43891. */
  43892. invertRefractionY: boolean;
  43893. private _linkRefractionWithTransparency;
  43894. /**
  43895. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43896. * Materials half opaque for instance using refraction could benefit from this control.
  43897. */
  43898. linkRefractionWithTransparency: boolean;
  43899. /**
  43900. * Defines the minimum thickness stored in the thickness map.
  43901. * If no thickness map is defined, this value will be used to simulate thickness.
  43902. */
  43903. minimumThickness: number;
  43904. /**
  43905. * Defines the maximum thickness stored in the thickness map.
  43906. */
  43907. maximumThickness: number;
  43908. /**
  43909. * Defines the volume tint of the material.
  43910. * This is used for both translucency and scattering.
  43911. */
  43912. tintColor: Color3;
  43913. /**
  43914. * Defines the distance at which the tint color should be found in the media.
  43915. * This is used for refraction only.
  43916. */
  43917. tintColorAtDistance: number;
  43918. /**
  43919. * Defines how far each channel transmit through the media.
  43920. * It is defined as a color to simplify it selection.
  43921. */
  43922. diffusionDistance: Color3;
  43923. private _useMaskFromThicknessTexture;
  43924. /**
  43925. * Stores the intensity of the different subsurface effects in the thickness texture.
  43926. * * the green channel is the translucency intensity.
  43927. * * the blue channel is the scattering intensity.
  43928. * * the alpha channel is the refraction intensity.
  43929. */
  43930. useMaskFromThicknessTexture: boolean;
  43931. /** @hidden */
  43932. private _internalMarkAllSubMeshesAsTexturesDirty;
  43933. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43934. /**
  43935. * Instantiate a new istance of sub surface configuration.
  43936. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43937. */
  43938. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43939. /**
  43940. * Gets wehter the submesh is ready to be used or not.
  43941. * @param defines the list of "defines" to update.
  43942. * @param scene defines the scene the material belongs to.
  43943. * @returns - boolean indicating that the submesh is ready or not.
  43944. */
  43945. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43946. /**
  43947. * Checks to see if a texture is used in the material.
  43948. * @param defines the list of "defines" to update.
  43949. * @param scene defines the scene to the material belongs to.
  43950. */
  43951. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43952. /**
  43953. * Binds the material data.
  43954. * @param uniformBuffer defines the Uniform buffer to fill in.
  43955. * @param scene defines the scene the material belongs to.
  43956. * @param engine defines the engine the material belongs to.
  43957. * @param isFrozen defines wether the material is frozen or not.
  43958. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43959. */
  43960. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43961. /**
  43962. * Unbinds the material from the mesh.
  43963. * @param activeEffect defines the effect that should be unbound from.
  43964. * @returns true if unbound, otherwise false
  43965. */
  43966. unbind(activeEffect: Effect): boolean;
  43967. /**
  43968. * Returns the texture used for refraction or null if none is used.
  43969. * @param scene defines the scene the material belongs to.
  43970. * @returns - Refraction texture if present. If no refraction texture and refraction
  43971. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43972. */
  43973. private _getRefractionTexture;
  43974. /**
  43975. * Returns true if alpha blending should be disabled.
  43976. */
  43977. readonly disableAlphaBlending: boolean;
  43978. /**
  43979. * Fills the list of render target textures.
  43980. * @param renderTargets the list of render targets to update
  43981. */
  43982. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43983. /**
  43984. * Checks to see if a texture is used in the material.
  43985. * @param texture - Base texture to use.
  43986. * @returns - Boolean specifying if a texture is used in the material.
  43987. */
  43988. hasTexture(texture: BaseTexture): boolean;
  43989. /**
  43990. * Gets a boolean indicating that current material needs to register RTT
  43991. * @returns true if this uses a render target otherwise false.
  43992. */
  43993. hasRenderTargetTextures(): boolean;
  43994. /**
  43995. * Returns an array of the actively used textures.
  43996. * @param activeTextures Array of BaseTextures
  43997. */
  43998. getActiveTextures(activeTextures: BaseTexture[]): void;
  43999. /**
  44000. * Returns the animatable textures.
  44001. * @param animatables Array of animatable textures.
  44002. */
  44003. getAnimatables(animatables: IAnimatable[]): void;
  44004. /**
  44005. * Disposes the resources of the material.
  44006. * @param forceDisposeTextures - Forces the disposal of all textures.
  44007. */
  44008. dispose(forceDisposeTextures?: boolean): void;
  44009. /**
  44010. * Get the current class name of the texture useful for serialization or dynamic coding.
  44011. * @returns "PBRSubSurfaceConfiguration"
  44012. */
  44013. getClassName(): string;
  44014. /**
  44015. * Add fallbacks to the effect fallbacks list.
  44016. * @param defines defines the Base texture to use.
  44017. * @param fallbacks defines the current fallback list.
  44018. * @param currentRank defines the current fallback rank.
  44019. * @returns the new fallback rank.
  44020. */
  44021. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44022. /**
  44023. * Add the required uniforms to the current list.
  44024. * @param uniforms defines the current uniform list.
  44025. */
  44026. static AddUniforms(uniforms: string[]): void;
  44027. /**
  44028. * Add the required samplers to the current list.
  44029. * @param samplers defines the current sampler list.
  44030. */
  44031. static AddSamplers(samplers: string[]): void;
  44032. /**
  44033. * Add the required uniforms to the current buffer.
  44034. * @param uniformBuffer defines the current uniform buffer.
  44035. */
  44036. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44037. /**
  44038. * Makes a duplicate of the current configuration into another one.
  44039. * @param configuration define the config where to copy the info
  44040. */
  44041. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44042. /**
  44043. * Serializes this Sub Surface configuration.
  44044. * @returns - An object with the serialized config.
  44045. */
  44046. serialize(): any;
  44047. /**
  44048. * Parses a Sub Surface Configuration from a serialized object.
  44049. * @param source - Serialized object.
  44050. */
  44051. parse(source: any): void;
  44052. }
  44053. }
  44054. declare module BABYLON {
  44055. /** @hidden */
  44056. export var pbrFragmentDeclaration: {
  44057. name: string;
  44058. shader: string;
  44059. };
  44060. }
  44061. declare module BABYLON {
  44062. /** @hidden */
  44063. export var pbrUboDeclaration: {
  44064. name: string;
  44065. shader: string;
  44066. };
  44067. }
  44068. declare module BABYLON {
  44069. /** @hidden */
  44070. export var pbrFragmentExtraDeclaration: {
  44071. name: string;
  44072. shader: string;
  44073. };
  44074. }
  44075. declare module BABYLON {
  44076. /** @hidden */
  44077. export var pbrFragmentSamplersDeclaration: {
  44078. name: string;
  44079. shader: string;
  44080. };
  44081. }
  44082. declare module BABYLON {
  44083. /** @hidden */
  44084. export var pbrHelperFunctions: {
  44085. name: string;
  44086. shader: string;
  44087. };
  44088. }
  44089. declare module BABYLON {
  44090. /** @hidden */
  44091. export var harmonicsFunctions: {
  44092. name: string;
  44093. shader: string;
  44094. };
  44095. }
  44096. declare module BABYLON {
  44097. /** @hidden */
  44098. export var pbrDirectLightingSetupFunctions: {
  44099. name: string;
  44100. shader: string;
  44101. };
  44102. }
  44103. declare module BABYLON {
  44104. /** @hidden */
  44105. export var pbrDirectLightingFalloffFunctions: {
  44106. name: string;
  44107. shader: string;
  44108. };
  44109. }
  44110. declare module BABYLON {
  44111. /** @hidden */
  44112. export var pbrBRDFFunctions: {
  44113. name: string;
  44114. shader: string;
  44115. };
  44116. }
  44117. declare module BABYLON {
  44118. /** @hidden */
  44119. export var pbrDirectLightingFunctions: {
  44120. name: string;
  44121. shader: string;
  44122. };
  44123. }
  44124. declare module BABYLON {
  44125. /** @hidden */
  44126. export var pbrIBLFunctions: {
  44127. name: string;
  44128. shader: string;
  44129. };
  44130. }
  44131. declare module BABYLON {
  44132. /** @hidden */
  44133. export var pbrDebug: {
  44134. name: string;
  44135. shader: string;
  44136. };
  44137. }
  44138. declare module BABYLON {
  44139. /** @hidden */
  44140. export var pbrPixelShader: {
  44141. name: string;
  44142. shader: string;
  44143. };
  44144. }
  44145. declare module BABYLON {
  44146. /** @hidden */
  44147. export var pbrVertexDeclaration: {
  44148. name: string;
  44149. shader: string;
  44150. };
  44151. }
  44152. declare module BABYLON {
  44153. /** @hidden */
  44154. export var pbrVertexShader: {
  44155. name: string;
  44156. shader: string;
  44157. };
  44158. }
  44159. declare module BABYLON {
  44160. /**
  44161. * Manages the defines for the PBR Material.
  44162. * @hidden
  44163. */
  44164. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44165. PBR: boolean;
  44166. MAINUV1: boolean;
  44167. MAINUV2: boolean;
  44168. UV1: boolean;
  44169. UV2: boolean;
  44170. ALBEDO: boolean;
  44171. ALBEDODIRECTUV: number;
  44172. VERTEXCOLOR: boolean;
  44173. AMBIENT: boolean;
  44174. AMBIENTDIRECTUV: number;
  44175. AMBIENTINGRAYSCALE: boolean;
  44176. OPACITY: boolean;
  44177. VERTEXALPHA: boolean;
  44178. OPACITYDIRECTUV: number;
  44179. OPACITYRGB: boolean;
  44180. ALPHATEST: boolean;
  44181. DEPTHPREPASS: boolean;
  44182. ALPHABLEND: boolean;
  44183. ALPHAFROMALBEDO: boolean;
  44184. ALPHATESTVALUE: string;
  44185. SPECULAROVERALPHA: boolean;
  44186. RADIANCEOVERALPHA: boolean;
  44187. ALPHAFRESNEL: boolean;
  44188. LINEARALPHAFRESNEL: boolean;
  44189. PREMULTIPLYALPHA: boolean;
  44190. EMISSIVE: boolean;
  44191. EMISSIVEDIRECTUV: number;
  44192. REFLECTIVITY: boolean;
  44193. REFLECTIVITYDIRECTUV: number;
  44194. SPECULARTERM: boolean;
  44195. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44196. MICROSURFACEAUTOMATIC: boolean;
  44197. LODBASEDMICROSFURACE: boolean;
  44198. MICROSURFACEMAP: boolean;
  44199. MICROSURFACEMAPDIRECTUV: number;
  44200. METALLICWORKFLOW: boolean;
  44201. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44202. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44203. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44204. AOSTOREINMETALMAPRED: boolean;
  44205. ENVIRONMENTBRDF: boolean;
  44206. ENVIRONMENTBRDF_RGBD: boolean;
  44207. NORMAL: boolean;
  44208. TANGENT: boolean;
  44209. BUMP: boolean;
  44210. BUMPDIRECTUV: number;
  44211. OBJECTSPACE_NORMALMAP: boolean;
  44212. PARALLAX: boolean;
  44213. PARALLAXOCCLUSION: boolean;
  44214. NORMALXYSCALE: boolean;
  44215. LIGHTMAP: boolean;
  44216. LIGHTMAPDIRECTUV: number;
  44217. USELIGHTMAPASSHADOWMAP: boolean;
  44218. GAMMALIGHTMAP: boolean;
  44219. REFLECTION: boolean;
  44220. REFLECTIONMAP_3D: boolean;
  44221. REFLECTIONMAP_SPHERICAL: boolean;
  44222. REFLECTIONMAP_PLANAR: boolean;
  44223. REFLECTIONMAP_CUBIC: boolean;
  44224. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44225. REFLECTIONMAP_PROJECTION: boolean;
  44226. REFLECTIONMAP_SKYBOX: boolean;
  44227. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44228. REFLECTIONMAP_EXPLICIT: boolean;
  44229. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44230. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44231. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44232. INVERTCUBICMAP: boolean;
  44233. USESPHERICALFROMREFLECTIONMAP: boolean;
  44234. SPHERICAL_HARMONICS: boolean;
  44235. USESPHERICALINVERTEX: boolean;
  44236. REFLECTIONMAP_OPPOSITEZ: boolean;
  44237. LODINREFLECTIONALPHA: boolean;
  44238. GAMMAREFLECTION: boolean;
  44239. RGBDREFLECTION: boolean;
  44240. RADIANCEOCCLUSION: boolean;
  44241. HORIZONOCCLUSION: boolean;
  44242. INSTANCES: boolean;
  44243. NUM_BONE_INFLUENCERS: number;
  44244. BonesPerMesh: number;
  44245. BONETEXTURE: boolean;
  44246. NONUNIFORMSCALING: boolean;
  44247. MORPHTARGETS: boolean;
  44248. MORPHTARGETS_NORMAL: boolean;
  44249. MORPHTARGETS_TANGENT: boolean;
  44250. NUM_MORPH_INFLUENCERS: number;
  44251. IMAGEPROCESSING: boolean;
  44252. VIGNETTE: boolean;
  44253. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44254. VIGNETTEBLENDMODEOPAQUE: boolean;
  44255. TONEMAPPING: boolean;
  44256. TONEMAPPING_ACES: boolean;
  44257. CONTRAST: boolean;
  44258. COLORCURVES: boolean;
  44259. COLORGRADING: boolean;
  44260. COLORGRADING3D: boolean;
  44261. SAMPLER3DGREENDEPTH: boolean;
  44262. SAMPLER3DBGRMAP: boolean;
  44263. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44264. EXPOSURE: boolean;
  44265. MULTIVIEW: boolean;
  44266. USEPHYSICALLIGHTFALLOFF: boolean;
  44267. USEGLTFLIGHTFALLOFF: boolean;
  44268. TWOSIDEDLIGHTING: boolean;
  44269. SHADOWFLOAT: boolean;
  44270. CLIPPLANE: boolean;
  44271. CLIPPLANE2: boolean;
  44272. CLIPPLANE3: boolean;
  44273. CLIPPLANE4: boolean;
  44274. POINTSIZE: boolean;
  44275. FOG: boolean;
  44276. LOGARITHMICDEPTH: boolean;
  44277. FORCENORMALFORWARD: boolean;
  44278. SPECULARAA: boolean;
  44279. CLEARCOAT: boolean;
  44280. CLEARCOAT_DEFAULTIOR: boolean;
  44281. CLEARCOAT_TEXTURE: boolean;
  44282. CLEARCOAT_TEXTUREDIRECTUV: number;
  44283. CLEARCOAT_BUMP: boolean;
  44284. CLEARCOAT_BUMPDIRECTUV: number;
  44285. CLEARCOAT_TINT: boolean;
  44286. CLEARCOAT_TINT_TEXTURE: boolean;
  44287. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44288. ANISOTROPIC: boolean;
  44289. ANISOTROPIC_TEXTURE: boolean;
  44290. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44291. BRDF_V_HEIGHT_CORRELATED: boolean;
  44292. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44293. SHEEN: boolean;
  44294. SHEEN_TEXTURE: boolean;
  44295. SHEEN_TEXTUREDIRECTUV: number;
  44296. SHEEN_LINKWITHALBEDO: boolean;
  44297. SUBSURFACE: boolean;
  44298. SS_REFRACTION: boolean;
  44299. SS_TRANSLUCENCY: boolean;
  44300. SS_SCATERRING: boolean;
  44301. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44302. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44303. SS_REFRACTIONMAP_3D: boolean;
  44304. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44305. SS_LODINREFRACTIONALPHA: boolean;
  44306. SS_GAMMAREFRACTION: boolean;
  44307. SS_RGBDREFRACTION: boolean;
  44308. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44309. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44310. UNLIT: boolean;
  44311. DEBUGMODE: number;
  44312. /**
  44313. * Initializes the PBR Material defines.
  44314. */
  44315. constructor();
  44316. /**
  44317. * Resets the PBR Material defines.
  44318. */
  44319. reset(): void;
  44320. }
  44321. /**
  44322. * The Physically based material base class of BJS.
  44323. *
  44324. * This offers the main features of a standard PBR material.
  44325. * For more information, please refer to the documentation :
  44326. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44327. */
  44328. export abstract class PBRBaseMaterial extends PushMaterial {
  44329. /**
  44330. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44331. */
  44332. static readonly PBRMATERIAL_OPAQUE: number;
  44333. /**
  44334. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44335. */
  44336. static readonly PBRMATERIAL_ALPHATEST: number;
  44337. /**
  44338. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44339. */
  44340. static readonly PBRMATERIAL_ALPHABLEND: number;
  44341. /**
  44342. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44343. * They are also discarded below the alpha cutoff threshold to improve performances.
  44344. */
  44345. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44346. /**
  44347. * Defines the default value of how much AO map is occluding the analytical lights
  44348. * (point spot...).
  44349. */
  44350. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44351. /**
  44352. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44353. */
  44354. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44355. /**
  44356. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44357. * to enhance interoperability with other engines.
  44358. */
  44359. static readonly LIGHTFALLOFF_GLTF: number;
  44360. /**
  44361. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44362. * to enhance interoperability with other materials.
  44363. */
  44364. static readonly LIGHTFALLOFF_STANDARD: number;
  44365. /**
  44366. * Intensity of the direct lights e.g. the four lights available in your scene.
  44367. * This impacts both the direct diffuse and specular highlights.
  44368. */
  44369. protected _directIntensity: number;
  44370. /**
  44371. * Intensity of the emissive part of the material.
  44372. * This helps controlling the emissive effect without modifying the emissive color.
  44373. */
  44374. protected _emissiveIntensity: number;
  44375. /**
  44376. * Intensity of the environment e.g. how much the environment will light the object
  44377. * either through harmonics for rough material or through the refelction for shiny ones.
  44378. */
  44379. protected _environmentIntensity: number;
  44380. /**
  44381. * This is a special control allowing the reduction of the specular highlights coming from the
  44382. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44383. */
  44384. protected _specularIntensity: number;
  44385. /**
  44386. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44387. */
  44388. private _lightingInfos;
  44389. /**
  44390. * Debug Control allowing disabling the bump map on this material.
  44391. */
  44392. protected _disableBumpMap: boolean;
  44393. /**
  44394. * AKA Diffuse Texture in standard nomenclature.
  44395. */
  44396. protected _albedoTexture: Nullable<BaseTexture>;
  44397. /**
  44398. * AKA Occlusion Texture in other nomenclature.
  44399. */
  44400. protected _ambientTexture: Nullable<BaseTexture>;
  44401. /**
  44402. * AKA Occlusion Texture Intensity in other nomenclature.
  44403. */
  44404. protected _ambientTextureStrength: number;
  44405. /**
  44406. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44407. * 1 means it completely occludes it
  44408. * 0 mean it has no impact
  44409. */
  44410. protected _ambientTextureImpactOnAnalyticalLights: number;
  44411. /**
  44412. * Stores the alpha values in a texture.
  44413. */
  44414. protected _opacityTexture: Nullable<BaseTexture>;
  44415. /**
  44416. * Stores the reflection values in a texture.
  44417. */
  44418. protected _reflectionTexture: Nullable<BaseTexture>;
  44419. /**
  44420. * Stores the emissive values in a texture.
  44421. */
  44422. protected _emissiveTexture: Nullable<BaseTexture>;
  44423. /**
  44424. * AKA Specular texture in other nomenclature.
  44425. */
  44426. protected _reflectivityTexture: Nullable<BaseTexture>;
  44427. /**
  44428. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44429. */
  44430. protected _metallicTexture: Nullable<BaseTexture>;
  44431. /**
  44432. * Specifies the metallic scalar of the metallic/roughness workflow.
  44433. * Can also be used to scale the metalness values of the metallic texture.
  44434. */
  44435. protected _metallic: Nullable<number>;
  44436. /**
  44437. * Specifies the roughness scalar of the metallic/roughness workflow.
  44438. * Can also be used to scale the roughness values of the metallic texture.
  44439. */
  44440. protected _roughness: Nullable<number>;
  44441. /**
  44442. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44443. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44444. */
  44445. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44446. /**
  44447. * Stores surface normal data used to displace a mesh in a texture.
  44448. */
  44449. protected _bumpTexture: Nullable<BaseTexture>;
  44450. /**
  44451. * Stores the pre-calculated light information of a mesh in a texture.
  44452. */
  44453. protected _lightmapTexture: Nullable<BaseTexture>;
  44454. /**
  44455. * The color of a material in ambient lighting.
  44456. */
  44457. protected _ambientColor: Color3;
  44458. /**
  44459. * AKA Diffuse Color in other nomenclature.
  44460. */
  44461. protected _albedoColor: Color3;
  44462. /**
  44463. * AKA Specular Color in other nomenclature.
  44464. */
  44465. protected _reflectivityColor: Color3;
  44466. /**
  44467. * The color applied when light is reflected from a material.
  44468. */
  44469. protected _reflectionColor: Color3;
  44470. /**
  44471. * The color applied when light is emitted from a material.
  44472. */
  44473. protected _emissiveColor: Color3;
  44474. /**
  44475. * AKA Glossiness in other nomenclature.
  44476. */
  44477. protected _microSurface: number;
  44478. /**
  44479. * Specifies that the material will use the light map as a show map.
  44480. */
  44481. protected _useLightmapAsShadowmap: boolean;
  44482. /**
  44483. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44484. * makes the reflect vector face the model (under horizon).
  44485. */
  44486. protected _useHorizonOcclusion: boolean;
  44487. /**
  44488. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44489. * too much the area relying on ambient texture to define their ambient occlusion.
  44490. */
  44491. protected _useRadianceOcclusion: boolean;
  44492. /**
  44493. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44494. */
  44495. protected _useAlphaFromAlbedoTexture: boolean;
  44496. /**
  44497. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44498. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44499. */
  44500. protected _useSpecularOverAlpha: boolean;
  44501. /**
  44502. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44503. */
  44504. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44505. /**
  44506. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44507. */
  44508. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44509. /**
  44510. * Specifies if the metallic texture contains the roughness information in its green channel.
  44511. */
  44512. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44513. /**
  44514. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44515. */
  44516. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44517. /**
  44518. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44519. */
  44520. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44521. /**
  44522. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44523. */
  44524. protected _useAmbientInGrayScale: boolean;
  44525. /**
  44526. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44527. * The material will try to infer what glossiness each pixel should be.
  44528. */
  44529. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44530. /**
  44531. * Defines the falloff type used in this material.
  44532. * It by default is Physical.
  44533. */
  44534. protected _lightFalloff: number;
  44535. /**
  44536. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44537. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44538. */
  44539. protected _useRadianceOverAlpha: boolean;
  44540. /**
  44541. * Allows using an object space normal map (instead of tangent space).
  44542. */
  44543. protected _useObjectSpaceNormalMap: boolean;
  44544. /**
  44545. * Allows using the bump map in parallax mode.
  44546. */
  44547. protected _useParallax: boolean;
  44548. /**
  44549. * Allows using the bump map in parallax occlusion mode.
  44550. */
  44551. protected _useParallaxOcclusion: boolean;
  44552. /**
  44553. * Controls the scale bias of the parallax mode.
  44554. */
  44555. protected _parallaxScaleBias: number;
  44556. /**
  44557. * If sets to true, disables all the lights affecting the material.
  44558. */
  44559. protected _disableLighting: boolean;
  44560. /**
  44561. * Number of Simultaneous lights allowed on the material.
  44562. */
  44563. protected _maxSimultaneousLights: number;
  44564. /**
  44565. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44566. */
  44567. protected _invertNormalMapX: boolean;
  44568. /**
  44569. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44570. */
  44571. protected _invertNormalMapY: boolean;
  44572. /**
  44573. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44574. */
  44575. protected _twoSidedLighting: boolean;
  44576. /**
  44577. * Defines the alpha limits in alpha test mode.
  44578. */
  44579. protected _alphaCutOff: number;
  44580. /**
  44581. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44582. */
  44583. protected _forceAlphaTest: boolean;
  44584. /**
  44585. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44586. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44587. */
  44588. protected _useAlphaFresnel: boolean;
  44589. /**
  44590. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44591. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44592. */
  44593. protected _useLinearAlphaFresnel: boolean;
  44594. /**
  44595. * The transparency mode of the material.
  44596. */
  44597. protected _transparencyMode: Nullable<number>;
  44598. /**
  44599. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44600. * from cos thetav and roughness:
  44601. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44602. */
  44603. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44604. /**
  44605. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44606. */
  44607. protected _forceIrradianceInFragment: boolean;
  44608. /**
  44609. * Force normal to face away from face.
  44610. */
  44611. protected _forceNormalForward: boolean;
  44612. /**
  44613. * Enables specular anti aliasing in the PBR shader.
  44614. * It will both interacts on the Geometry for analytical and IBL lighting.
  44615. * It also prefilter the roughness map based on the bump values.
  44616. */
  44617. protected _enableSpecularAntiAliasing: boolean;
  44618. /**
  44619. * Default configuration related to image processing available in the PBR Material.
  44620. */
  44621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44622. /**
  44623. * Keep track of the image processing observer to allow dispose and replace.
  44624. */
  44625. private _imageProcessingObserver;
  44626. /**
  44627. * Attaches a new image processing configuration to the PBR Material.
  44628. * @param configuration
  44629. */
  44630. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44631. /**
  44632. * Stores the available render targets.
  44633. */
  44634. private _renderTargets;
  44635. /**
  44636. * Sets the global ambient color for the material used in lighting calculations.
  44637. */
  44638. private _globalAmbientColor;
  44639. /**
  44640. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44641. */
  44642. private _useLogarithmicDepth;
  44643. /**
  44644. * If set to true, no lighting calculations will be applied.
  44645. */
  44646. private _unlit;
  44647. private _debugMode;
  44648. /**
  44649. * @hidden
  44650. * This is reserved for the inspector.
  44651. * Defines the material debug mode.
  44652. * It helps seeing only some components of the material while troubleshooting.
  44653. */
  44654. debugMode: number;
  44655. /**
  44656. * @hidden
  44657. * This is reserved for the inspector.
  44658. * Specify from where on screen the debug mode should start.
  44659. * The value goes from -1 (full screen) to 1 (not visible)
  44660. * It helps with side by side comparison against the final render
  44661. * This defaults to -1
  44662. */
  44663. private debugLimit;
  44664. /**
  44665. * @hidden
  44666. * This is reserved for the inspector.
  44667. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44668. * You can use the factor to better multiply the final value.
  44669. */
  44670. private debugFactor;
  44671. /**
  44672. * Defines the clear coat layer parameters for the material.
  44673. */
  44674. readonly clearCoat: PBRClearCoatConfiguration;
  44675. /**
  44676. * Defines the anisotropic parameters for the material.
  44677. */
  44678. readonly anisotropy: PBRAnisotropicConfiguration;
  44679. /**
  44680. * Defines the BRDF parameters for the material.
  44681. */
  44682. readonly brdf: PBRBRDFConfiguration;
  44683. /**
  44684. * Defines the Sheen parameters for the material.
  44685. */
  44686. readonly sheen: PBRSheenConfiguration;
  44687. /**
  44688. * Defines the SubSurface parameters for the material.
  44689. */
  44690. readonly subSurface: PBRSubSurfaceConfiguration;
  44691. /**
  44692. * Custom callback helping to override the default shader used in the material.
  44693. */
  44694. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44695. /**
  44696. * Instantiates a new PBRMaterial instance.
  44697. *
  44698. * @param name The material name
  44699. * @param scene The scene the material will be use in.
  44700. */
  44701. constructor(name: string, scene: Scene);
  44702. /**
  44703. * Gets a boolean indicating that current material needs to register RTT
  44704. */
  44705. readonly hasRenderTargetTextures: boolean;
  44706. /**
  44707. * Gets the name of the material class.
  44708. */
  44709. getClassName(): string;
  44710. /**
  44711. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44712. */
  44713. /**
  44714. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44715. */
  44716. useLogarithmicDepth: boolean;
  44717. /**
  44718. * Gets the current transparency mode.
  44719. */
  44720. /**
  44721. * Sets the transparency mode of the material.
  44722. *
  44723. * | Value | Type | Description |
  44724. * | ----- | ----------------------------------- | ----------- |
  44725. * | 0 | OPAQUE | |
  44726. * | 1 | ALPHATEST | |
  44727. * | 2 | ALPHABLEND | |
  44728. * | 3 | ALPHATESTANDBLEND | |
  44729. *
  44730. */
  44731. transparencyMode: Nullable<number>;
  44732. /**
  44733. * Returns true if alpha blending should be disabled.
  44734. */
  44735. private readonly _disableAlphaBlending;
  44736. /**
  44737. * Specifies whether or not this material should be rendered in alpha blend mode.
  44738. */
  44739. needAlphaBlending(): boolean;
  44740. /**
  44741. * Specifies if the mesh will require alpha blending.
  44742. * @param mesh - BJS mesh.
  44743. */
  44744. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44745. /**
  44746. * Specifies whether or not this material should be rendered in alpha test mode.
  44747. */
  44748. needAlphaTesting(): boolean;
  44749. /**
  44750. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44751. */
  44752. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44753. /**
  44754. * Gets the texture used for the alpha test.
  44755. */
  44756. getAlphaTestTexture(): Nullable<BaseTexture>;
  44757. /**
  44758. * Specifies that the submesh is ready to be used.
  44759. * @param mesh - BJS mesh.
  44760. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44761. * @param useInstances - Specifies that instances should be used.
  44762. * @returns - boolean indicating that the submesh is ready or not.
  44763. */
  44764. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44765. /**
  44766. * Specifies if the material uses metallic roughness workflow.
  44767. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44768. */
  44769. isMetallicWorkflow(): boolean;
  44770. private _prepareEffect;
  44771. private _prepareDefines;
  44772. /**
  44773. * Force shader compilation
  44774. */
  44775. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44776. clipPlane: boolean;
  44777. }>): void;
  44778. /**
  44779. * Initializes the uniform buffer layout for the shader.
  44780. */
  44781. buildUniformLayout(): void;
  44782. /**
  44783. * Unbinds the material from the mesh
  44784. */
  44785. unbind(): void;
  44786. /**
  44787. * Binds the submesh data.
  44788. * @param world - The world matrix.
  44789. * @param mesh - The BJS mesh.
  44790. * @param subMesh - A submesh of the BJS mesh.
  44791. */
  44792. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44793. /**
  44794. * Returns the animatable textures.
  44795. * @returns - Array of animatable textures.
  44796. */
  44797. getAnimatables(): IAnimatable[];
  44798. /**
  44799. * Returns the texture used for reflections.
  44800. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44801. */
  44802. private _getReflectionTexture;
  44803. /**
  44804. * Returns an array of the actively used textures.
  44805. * @returns - Array of BaseTextures
  44806. */
  44807. getActiveTextures(): BaseTexture[];
  44808. /**
  44809. * Checks to see if a texture is used in the material.
  44810. * @param texture - Base texture to use.
  44811. * @returns - Boolean specifying if a texture is used in the material.
  44812. */
  44813. hasTexture(texture: BaseTexture): boolean;
  44814. /**
  44815. * Disposes the resources of the material.
  44816. * @param forceDisposeEffect - Forces the disposal of effects.
  44817. * @param forceDisposeTextures - Forces the disposal of all textures.
  44818. */
  44819. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44820. }
  44821. }
  44822. declare module BABYLON {
  44823. /**
  44824. * The Physically based material of BJS.
  44825. *
  44826. * This offers the main features of a standard PBR material.
  44827. * For more information, please refer to the documentation :
  44828. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44829. */
  44830. export class PBRMaterial extends PBRBaseMaterial {
  44831. /**
  44832. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44833. */
  44834. static readonly PBRMATERIAL_OPAQUE: number;
  44835. /**
  44836. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44837. */
  44838. static readonly PBRMATERIAL_ALPHATEST: number;
  44839. /**
  44840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44841. */
  44842. static readonly PBRMATERIAL_ALPHABLEND: number;
  44843. /**
  44844. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44845. * They are also discarded below the alpha cutoff threshold to improve performances.
  44846. */
  44847. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44848. /**
  44849. * Defines the default value of how much AO map is occluding the analytical lights
  44850. * (point spot...).
  44851. */
  44852. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44853. /**
  44854. * Intensity of the direct lights e.g. the four lights available in your scene.
  44855. * This impacts both the direct diffuse and specular highlights.
  44856. */
  44857. directIntensity: number;
  44858. /**
  44859. * Intensity of the emissive part of the material.
  44860. * This helps controlling the emissive effect without modifying the emissive color.
  44861. */
  44862. emissiveIntensity: number;
  44863. /**
  44864. * Intensity of the environment e.g. how much the environment will light the object
  44865. * either through harmonics for rough material or through the refelction for shiny ones.
  44866. */
  44867. environmentIntensity: number;
  44868. /**
  44869. * This is a special control allowing the reduction of the specular highlights coming from the
  44870. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44871. */
  44872. specularIntensity: number;
  44873. /**
  44874. * Debug Control allowing disabling the bump map on this material.
  44875. */
  44876. disableBumpMap: boolean;
  44877. /**
  44878. * AKA Diffuse Texture in standard nomenclature.
  44879. */
  44880. albedoTexture: BaseTexture;
  44881. /**
  44882. * AKA Occlusion Texture in other nomenclature.
  44883. */
  44884. ambientTexture: BaseTexture;
  44885. /**
  44886. * AKA Occlusion Texture Intensity in other nomenclature.
  44887. */
  44888. ambientTextureStrength: number;
  44889. /**
  44890. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44891. * 1 means it completely occludes it
  44892. * 0 mean it has no impact
  44893. */
  44894. ambientTextureImpactOnAnalyticalLights: number;
  44895. /**
  44896. * Stores the alpha values in a texture.
  44897. */
  44898. opacityTexture: BaseTexture;
  44899. /**
  44900. * Stores the reflection values in a texture.
  44901. */
  44902. reflectionTexture: Nullable<BaseTexture>;
  44903. /**
  44904. * Stores the emissive values in a texture.
  44905. */
  44906. emissiveTexture: BaseTexture;
  44907. /**
  44908. * AKA Specular texture in other nomenclature.
  44909. */
  44910. reflectivityTexture: BaseTexture;
  44911. /**
  44912. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44913. */
  44914. metallicTexture: BaseTexture;
  44915. /**
  44916. * Specifies the metallic scalar of the metallic/roughness workflow.
  44917. * Can also be used to scale the metalness values of the metallic texture.
  44918. */
  44919. metallic: Nullable<number>;
  44920. /**
  44921. * Specifies the roughness scalar of the metallic/roughness workflow.
  44922. * Can also be used to scale the roughness values of the metallic texture.
  44923. */
  44924. roughness: Nullable<number>;
  44925. /**
  44926. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44927. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44928. */
  44929. microSurfaceTexture: BaseTexture;
  44930. /**
  44931. * Stores surface normal data used to displace a mesh in a texture.
  44932. */
  44933. bumpTexture: BaseTexture;
  44934. /**
  44935. * Stores the pre-calculated light information of a mesh in a texture.
  44936. */
  44937. lightmapTexture: BaseTexture;
  44938. /**
  44939. * Stores the refracted light information in a texture.
  44940. */
  44941. refractionTexture: Nullable<BaseTexture>;
  44942. /**
  44943. * The color of a material in ambient lighting.
  44944. */
  44945. ambientColor: Color3;
  44946. /**
  44947. * AKA Diffuse Color in other nomenclature.
  44948. */
  44949. albedoColor: Color3;
  44950. /**
  44951. * AKA Specular Color in other nomenclature.
  44952. */
  44953. reflectivityColor: Color3;
  44954. /**
  44955. * The color reflected from the material.
  44956. */
  44957. reflectionColor: Color3;
  44958. /**
  44959. * The color emitted from the material.
  44960. */
  44961. emissiveColor: Color3;
  44962. /**
  44963. * AKA Glossiness in other nomenclature.
  44964. */
  44965. microSurface: number;
  44966. /**
  44967. * source material index of refraction (IOR)' / 'destination material IOR.
  44968. */
  44969. indexOfRefraction: number;
  44970. /**
  44971. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44972. */
  44973. invertRefractionY: boolean;
  44974. /**
  44975. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44976. * Materials half opaque for instance using refraction could benefit from this control.
  44977. */
  44978. linkRefractionWithTransparency: boolean;
  44979. /**
  44980. * If true, the light map contains occlusion information instead of lighting info.
  44981. */
  44982. useLightmapAsShadowmap: boolean;
  44983. /**
  44984. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44985. */
  44986. useAlphaFromAlbedoTexture: boolean;
  44987. /**
  44988. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44989. */
  44990. forceAlphaTest: boolean;
  44991. /**
  44992. * Defines the alpha limits in alpha test mode.
  44993. */
  44994. alphaCutOff: number;
  44995. /**
  44996. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44997. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44998. */
  44999. useSpecularOverAlpha: boolean;
  45000. /**
  45001. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45002. */
  45003. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45004. /**
  45005. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45006. */
  45007. useRoughnessFromMetallicTextureAlpha: boolean;
  45008. /**
  45009. * Specifies if the metallic texture contains the roughness information in its green channel.
  45010. */
  45011. useRoughnessFromMetallicTextureGreen: boolean;
  45012. /**
  45013. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45014. */
  45015. useMetallnessFromMetallicTextureBlue: boolean;
  45016. /**
  45017. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45018. */
  45019. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45020. /**
  45021. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45022. */
  45023. useAmbientInGrayScale: boolean;
  45024. /**
  45025. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45026. * The material will try to infer what glossiness each pixel should be.
  45027. */
  45028. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45029. /**
  45030. * BJS is using an harcoded light falloff based on a manually sets up range.
  45031. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45032. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45033. */
  45034. /**
  45035. * BJS is using an harcoded light falloff based on a manually sets up range.
  45036. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45037. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45038. */
  45039. usePhysicalLightFalloff: boolean;
  45040. /**
  45041. * In order to support the falloff compatibility with gltf, a special mode has been added
  45042. * to reproduce the gltf light falloff.
  45043. */
  45044. /**
  45045. * In order to support the falloff compatibility with gltf, a special mode has been added
  45046. * to reproduce the gltf light falloff.
  45047. */
  45048. useGLTFLightFalloff: boolean;
  45049. /**
  45050. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45051. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45052. */
  45053. useRadianceOverAlpha: boolean;
  45054. /**
  45055. * Allows using an object space normal map (instead of tangent space).
  45056. */
  45057. useObjectSpaceNormalMap: boolean;
  45058. /**
  45059. * Allows using the bump map in parallax mode.
  45060. */
  45061. useParallax: boolean;
  45062. /**
  45063. * Allows using the bump map in parallax occlusion mode.
  45064. */
  45065. useParallaxOcclusion: boolean;
  45066. /**
  45067. * Controls the scale bias of the parallax mode.
  45068. */
  45069. parallaxScaleBias: number;
  45070. /**
  45071. * If sets to true, disables all the lights affecting the material.
  45072. */
  45073. disableLighting: boolean;
  45074. /**
  45075. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45076. */
  45077. forceIrradianceInFragment: boolean;
  45078. /**
  45079. * Number of Simultaneous lights allowed on the material.
  45080. */
  45081. maxSimultaneousLights: number;
  45082. /**
  45083. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45084. */
  45085. invertNormalMapX: boolean;
  45086. /**
  45087. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45088. */
  45089. invertNormalMapY: boolean;
  45090. /**
  45091. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45092. */
  45093. twoSidedLighting: boolean;
  45094. /**
  45095. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45096. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45097. */
  45098. useAlphaFresnel: boolean;
  45099. /**
  45100. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45101. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45102. */
  45103. useLinearAlphaFresnel: boolean;
  45104. /**
  45105. * Let user defines the brdf lookup texture used for IBL.
  45106. * A default 8bit version is embedded but you could point at :
  45107. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45108. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45109. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45110. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45111. */
  45112. environmentBRDFTexture: Nullable<BaseTexture>;
  45113. /**
  45114. * Force normal to face away from face.
  45115. */
  45116. forceNormalForward: boolean;
  45117. /**
  45118. * Enables specular anti aliasing in the PBR shader.
  45119. * It will both interacts on the Geometry for analytical and IBL lighting.
  45120. * It also prefilter the roughness map based on the bump values.
  45121. */
  45122. enableSpecularAntiAliasing: boolean;
  45123. /**
  45124. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45125. * makes the reflect vector face the model (under horizon).
  45126. */
  45127. useHorizonOcclusion: boolean;
  45128. /**
  45129. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45130. * too much the area relying on ambient texture to define their ambient occlusion.
  45131. */
  45132. useRadianceOcclusion: boolean;
  45133. /**
  45134. * If set to true, no lighting calculations will be applied.
  45135. */
  45136. unlit: boolean;
  45137. /**
  45138. * Gets the image processing configuration used either in this material.
  45139. */
  45140. /**
  45141. * Sets the Default image processing configuration used either in the this material.
  45142. *
  45143. * If sets to null, the scene one is in use.
  45144. */
  45145. imageProcessingConfiguration: ImageProcessingConfiguration;
  45146. /**
  45147. * Gets wether the color curves effect is enabled.
  45148. */
  45149. /**
  45150. * Sets wether the color curves effect is enabled.
  45151. */
  45152. cameraColorCurvesEnabled: boolean;
  45153. /**
  45154. * Gets wether the color grading effect is enabled.
  45155. */
  45156. /**
  45157. * Gets wether the color grading effect is enabled.
  45158. */
  45159. cameraColorGradingEnabled: boolean;
  45160. /**
  45161. * Gets wether tonemapping is enabled or not.
  45162. */
  45163. /**
  45164. * Sets wether tonemapping is enabled or not
  45165. */
  45166. cameraToneMappingEnabled: boolean;
  45167. /**
  45168. * The camera exposure used on this material.
  45169. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45170. * This corresponds to a photographic exposure.
  45171. */
  45172. /**
  45173. * The camera exposure used on this material.
  45174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45175. * This corresponds to a photographic exposure.
  45176. */
  45177. cameraExposure: number;
  45178. /**
  45179. * Gets The camera contrast used on this material.
  45180. */
  45181. /**
  45182. * Sets The camera contrast used on this material.
  45183. */
  45184. cameraContrast: number;
  45185. /**
  45186. * Gets the Color Grading 2D Lookup Texture.
  45187. */
  45188. /**
  45189. * Sets the Color Grading 2D Lookup Texture.
  45190. */
  45191. cameraColorGradingTexture: Nullable<BaseTexture>;
  45192. /**
  45193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45195. * 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;
  45196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45197. */
  45198. /**
  45199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45201. * 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;
  45202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45203. */
  45204. cameraColorCurves: Nullable<ColorCurves>;
  45205. /**
  45206. * Instantiates a new PBRMaterial instance.
  45207. *
  45208. * @param name The material name
  45209. * @param scene The scene the material will be use in.
  45210. */
  45211. constructor(name: string, scene: Scene);
  45212. /**
  45213. * Returns the name of this material class.
  45214. */
  45215. getClassName(): string;
  45216. /**
  45217. * Makes a duplicate of the current material.
  45218. * @param name - name to use for the new material.
  45219. */
  45220. clone(name: string): PBRMaterial;
  45221. /**
  45222. * Serializes this PBR Material.
  45223. * @returns - An object with the serialized material.
  45224. */
  45225. serialize(): any;
  45226. /**
  45227. * Parses a PBR Material from a serialized object.
  45228. * @param source - Serialized object.
  45229. * @param scene - BJS scene instance.
  45230. * @param rootUrl - url for the scene object
  45231. * @returns - PBRMaterial
  45232. */
  45233. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45234. }
  45235. }
  45236. declare module BABYLON {
  45237. /**
  45238. * Direct draw surface info
  45239. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45240. */
  45241. export interface DDSInfo {
  45242. /**
  45243. * Width of the texture
  45244. */
  45245. width: number;
  45246. /**
  45247. * Width of the texture
  45248. */
  45249. height: number;
  45250. /**
  45251. * Number of Mipmaps for the texture
  45252. * @see https://en.wikipedia.org/wiki/Mipmap
  45253. */
  45254. mipmapCount: number;
  45255. /**
  45256. * If the textures format is a known fourCC format
  45257. * @see https://www.fourcc.org/
  45258. */
  45259. isFourCC: boolean;
  45260. /**
  45261. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45262. */
  45263. isRGB: boolean;
  45264. /**
  45265. * If the texture is a lumincance format
  45266. */
  45267. isLuminance: boolean;
  45268. /**
  45269. * If this is a cube texture
  45270. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45271. */
  45272. isCube: boolean;
  45273. /**
  45274. * If the texture is a compressed format eg. FOURCC_DXT1
  45275. */
  45276. isCompressed: boolean;
  45277. /**
  45278. * The dxgiFormat of the texture
  45279. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45280. */
  45281. dxgiFormat: number;
  45282. /**
  45283. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45284. */
  45285. textureType: number;
  45286. /**
  45287. * Sphericle polynomial created for the dds texture
  45288. */
  45289. sphericalPolynomial?: SphericalPolynomial;
  45290. }
  45291. /**
  45292. * Class used to provide DDS decompression tools
  45293. */
  45294. export class DDSTools {
  45295. /**
  45296. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45297. */
  45298. static StoreLODInAlphaChannel: boolean;
  45299. /**
  45300. * Gets DDS information from an array buffer
  45301. * @param arrayBuffer defines the array buffer to read data from
  45302. * @returns the DDS information
  45303. */
  45304. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45305. private static _FloatView;
  45306. private static _Int32View;
  45307. private static _ToHalfFloat;
  45308. private static _FromHalfFloat;
  45309. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45310. private static _GetHalfFloatRGBAArrayBuffer;
  45311. private static _GetFloatRGBAArrayBuffer;
  45312. private static _GetFloatAsUIntRGBAArrayBuffer;
  45313. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45314. private static _GetRGBAArrayBuffer;
  45315. private static _ExtractLongWordOrder;
  45316. private static _GetRGBArrayBuffer;
  45317. private static _GetLuminanceArrayBuffer;
  45318. /**
  45319. * Uploads DDS Levels to a Babylon Texture
  45320. * @hidden
  45321. */
  45322. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45323. }
  45324. interface Engine {
  45325. /**
  45326. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45327. * @param rootUrl defines the url where the file to load is located
  45328. * @param scene defines the current scene
  45329. * @param lodScale defines scale to apply to the mip map selection
  45330. * @param lodOffset defines offset to apply to the mip map selection
  45331. * @param onLoad defines an optional callback raised when the texture is loaded
  45332. * @param onError defines an optional callback raised if there is an issue to load the texture
  45333. * @param format defines the format of the data
  45334. * @param forcedExtension defines the extension to use to pick the right loader
  45335. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45336. * @returns the cube texture as an InternalTexture
  45337. */
  45338. 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;
  45339. }
  45340. }
  45341. declare module BABYLON {
  45342. /**
  45343. * Implementation of the DDS Texture Loader.
  45344. * @hidden
  45345. */
  45346. export class _DDSTextureLoader implements IInternalTextureLoader {
  45347. /**
  45348. * Defines wether the loader supports cascade loading the different faces.
  45349. */
  45350. readonly supportCascades: boolean;
  45351. /**
  45352. * This returns if the loader support the current file information.
  45353. * @param extension defines the file extension of the file being loaded
  45354. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45355. * @param fallback defines the fallback internal texture if any
  45356. * @param isBase64 defines whether the texture is encoded as a base64
  45357. * @param isBuffer defines whether the texture data are stored as a buffer
  45358. * @returns true if the loader can load the specified file
  45359. */
  45360. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45361. /**
  45362. * Transform the url before loading if required.
  45363. * @param rootUrl the url of the texture
  45364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45365. * @returns the transformed texture
  45366. */
  45367. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45368. /**
  45369. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45370. * @param rootUrl the url of the texture
  45371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45372. * @returns the fallback texture
  45373. */
  45374. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45375. /**
  45376. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45377. * @param data contains the texture data
  45378. * @param texture defines the BabylonJS internal texture
  45379. * @param createPolynomials will be true if polynomials have been requested
  45380. * @param onLoad defines the callback to trigger once the texture is ready
  45381. * @param onError defines the callback to trigger in case of error
  45382. */
  45383. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45384. /**
  45385. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45386. * @param data contains the texture data
  45387. * @param texture defines the BabylonJS internal texture
  45388. * @param callback defines the method to call once ready to upload
  45389. */
  45390. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45391. }
  45392. }
  45393. declare module BABYLON {
  45394. /** @hidden */
  45395. export var rgbdEncodePixelShader: {
  45396. name: string;
  45397. shader: string;
  45398. };
  45399. }
  45400. declare module BABYLON {
  45401. /**
  45402. * Raw texture data and descriptor sufficient for WebGL texture upload
  45403. */
  45404. export interface EnvironmentTextureInfo {
  45405. /**
  45406. * Version of the environment map
  45407. */
  45408. version: number;
  45409. /**
  45410. * Width of image
  45411. */
  45412. width: number;
  45413. /**
  45414. * Irradiance information stored in the file.
  45415. */
  45416. irradiance: any;
  45417. /**
  45418. * Specular information stored in the file.
  45419. */
  45420. specular: any;
  45421. }
  45422. /**
  45423. * Sets of helpers addressing the serialization and deserialization of environment texture
  45424. * stored in a BabylonJS env file.
  45425. * Those files are usually stored as .env files.
  45426. */
  45427. export class EnvironmentTextureTools {
  45428. /**
  45429. * Magic number identifying the env file.
  45430. */
  45431. private static _MagicBytes;
  45432. /**
  45433. * Gets the environment info from an env file.
  45434. * @param data The array buffer containing the .env bytes.
  45435. * @returns the environment file info (the json header) if successfully parsed.
  45436. */
  45437. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45438. /**
  45439. * Creates an environment texture from a loaded cube texture.
  45440. * @param texture defines the cube texture to convert in env file
  45441. * @return a promise containing the environment data if succesfull.
  45442. */
  45443. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45444. /**
  45445. * Creates a JSON representation of the spherical data.
  45446. * @param texture defines the texture containing the polynomials
  45447. * @return the JSON representation of the spherical info
  45448. */
  45449. private static _CreateEnvTextureIrradiance;
  45450. /**
  45451. * Uploads the texture info contained in the env file to the GPU.
  45452. * @param texture defines the internal texture to upload to
  45453. * @param arrayBuffer defines the buffer cotaining the data to load
  45454. * @param info defines the texture info retrieved through the GetEnvInfo method
  45455. * @returns a promise
  45456. */
  45457. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45458. /**
  45459. * Uploads the levels of image data to the GPU.
  45460. * @param texture defines the internal texture to upload to
  45461. * @param imageData defines the array buffer views of image data [mipmap][face]
  45462. * @returns a promise
  45463. */
  45464. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45465. /**
  45466. * Uploads spherical polynomials information to the texture.
  45467. * @param texture defines the texture we are trying to upload the information to
  45468. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45469. */
  45470. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45471. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45472. }
  45473. }
  45474. declare module BABYLON {
  45475. /**
  45476. * Implementation of the ENV Texture Loader.
  45477. * @hidden
  45478. */
  45479. export class _ENVTextureLoader implements IInternalTextureLoader {
  45480. /**
  45481. * Defines wether the loader supports cascade loading the different faces.
  45482. */
  45483. readonly supportCascades: boolean;
  45484. /**
  45485. * This returns if the loader support the current file information.
  45486. * @param extension defines the file extension of the file being loaded
  45487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45488. * @param fallback defines the fallback internal texture if any
  45489. * @param isBase64 defines whether the texture is encoded as a base64
  45490. * @param isBuffer defines whether the texture data are stored as a buffer
  45491. * @returns true if the loader can load the specified file
  45492. */
  45493. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45494. /**
  45495. * Transform the url before loading if required.
  45496. * @param rootUrl the url of the texture
  45497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45498. * @returns the transformed texture
  45499. */
  45500. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45501. /**
  45502. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45503. * @param rootUrl the url of the texture
  45504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45505. * @returns the fallback texture
  45506. */
  45507. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45508. /**
  45509. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45510. * @param data contains the texture data
  45511. * @param texture defines the BabylonJS internal texture
  45512. * @param createPolynomials will be true if polynomials have been requested
  45513. * @param onLoad defines the callback to trigger once the texture is ready
  45514. * @param onError defines the callback to trigger in case of error
  45515. */
  45516. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45517. /**
  45518. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45519. * @param data contains the texture data
  45520. * @param texture defines the BabylonJS internal texture
  45521. * @param callback defines the method to call once ready to upload
  45522. */
  45523. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45524. }
  45525. }
  45526. declare module BABYLON {
  45527. /**
  45528. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45529. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45530. */
  45531. export class KhronosTextureContainer {
  45532. /** contents of the KTX container file */
  45533. arrayBuffer: any;
  45534. private static HEADER_LEN;
  45535. private static COMPRESSED_2D;
  45536. private static COMPRESSED_3D;
  45537. private static TEX_2D;
  45538. private static TEX_3D;
  45539. /**
  45540. * Gets the openGL type
  45541. */
  45542. glType: number;
  45543. /**
  45544. * Gets the openGL type size
  45545. */
  45546. glTypeSize: number;
  45547. /**
  45548. * Gets the openGL format
  45549. */
  45550. glFormat: number;
  45551. /**
  45552. * Gets the openGL internal format
  45553. */
  45554. glInternalFormat: number;
  45555. /**
  45556. * Gets the base internal format
  45557. */
  45558. glBaseInternalFormat: number;
  45559. /**
  45560. * Gets image width in pixel
  45561. */
  45562. pixelWidth: number;
  45563. /**
  45564. * Gets image height in pixel
  45565. */
  45566. pixelHeight: number;
  45567. /**
  45568. * Gets image depth in pixels
  45569. */
  45570. pixelDepth: number;
  45571. /**
  45572. * Gets the number of array elements
  45573. */
  45574. numberOfArrayElements: number;
  45575. /**
  45576. * Gets the number of faces
  45577. */
  45578. numberOfFaces: number;
  45579. /**
  45580. * Gets the number of mipmap levels
  45581. */
  45582. numberOfMipmapLevels: number;
  45583. /**
  45584. * Gets the bytes of key value data
  45585. */
  45586. bytesOfKeyValueData: number;
  45587. /**
  45588. * Gets the load type
  45589. */
  45590. loadType: number;
  45591. /**
  45592. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45593. */
  45594. isInvalid: boolean;
  45595. /**
  45596. * Creates a new KhronosTextureContainer
  45597. * @param arrayBuffer contents of the KTX container file
  45598. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45599. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45600. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45601. */
  45602. constructor(
  45603. /** contents of the KTX container file */
  45604. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45605. /**
  45606. * Uploads KTX content to a Babylon Texture.
  45607. * It is assumed that the texture has already been created & is currently bound
  45608. * @hidden
  45609. */
  45610. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45611. private _upload2DCompressedLevels;
  45612. }
  45613. }
  45614. declare module BABYLON {
  45615. /**
  45616. * Implementation of the KTX Texture Loader.
  45617. * @hidden
  45618. */
  45619. export class _KTXTextureLoader implements IInternalTextureLoader {
  45620. /**
  45621. * Defines wether the loader supports cascade loading the different faces.
  45622. */
  45623. readonly supportCascades: boolean;
  45624. /**
  45625. * This returns if the loader support the current file information.
  45626. * @param extension defines the file extension of the file being loaded
  45627. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45628. * @param fallback defines the fallback internal texture if any
  45629. * @param isBase64 defines whether the texture is encoded as a base64
  45630. * @param isBuffer defines whether the texture data are stored as a buffer
  45631. * @returns true if the loader can load the specified file
  45632. */
  45633. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45634. /**
  45635. * Transform the url before loading if required.
  45636. * @param rootUrl the url of the texture
  45637. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45638. * @returns the transformed texture
  45639. */
  45640. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45641. /**
  45642. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45643. * @param rootUrl the url of the texture
  45644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45645. * @returns the fallback texture
  45646. */
  45647. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45648. /**
  45649. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45650. * @param data contains the texture data
  45651. * @param texture defines the BabylonJS internal texture
  45652. * @param createPolynomials will be true if polynomials have been requested
  45653. * @param onLoad defines the callback to trigger once the texture is ready
  45654. * @param onError defines the callback to trigger in case of error
  45655. */
  45656. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45657. /**
  45658. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45659. * @param data contains the texture data
  45660. * @param texture defines the BabylonJS internal texture
  45661. * @param callback defines the method to call once ready to upload
  45662. */
  45663. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45664. }
  45665. }
  45666. declare module BABYLON {
  45667. /** @hidden */
  45668. export var _forceSceneHelpersToBundle: boolean;
  45669. interface Scene {
  45670. /**
  45671. * Creates a default light for the scene.
  45672. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45673. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45674. */
  45675. createDefaultLight(replace?: boolean): void;
  45676. /**
  45677. * Creates a default camera for the scene.
  45678. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45679. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45680. * @param replace has default false, when true replaces the active camera in the scene
  45681. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45682. */
  45683. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45684. /**
  45685. * Creates a default camera and a default light.
  45686. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45687. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45688. * @param replace has the default false, when true replaces the active camera/light in the scene
  45689. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45690. */
  45691. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45692. /**
  45693. * Creates a new sky box
  45694. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45695. * @param environmentTexture defines the texture to use as environment texture
  45696. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45697. * @param scale defines the overall scale of the skybox
  45698. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45699. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45700. * @returns a new mesh holding the sky box
  45701. */
  45702. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45703. /**
  45704. * Creates a new environment
  45705. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45706. * @param options defines the options you can use to configure the environment
  45707. * @returns the new EnvironmentHelper
  45708. */
  45709. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45710. /**
  45711. * Creates a new VREXperienceHelper
  45712. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45713. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45714. * @returns a new VREXperienceHelper
  45715. */
  45716. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45717. /**
  45718. * Creates a new XREXperienceHelper
  45719. * @see http://doc.babylonjs.com/how_to/webxr
  45720. * @returns a promise for a new XREXperienceHelper
  45721. */
  45722. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45723. }
  45724. }
  45725. declare module BABYLON {
  45726. /**
  45727. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45728. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45729. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45730. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45731. */
  45732. export class VideoDome extends TransformNode {
  45733. /**
  45734. * Define the video source as a Monoscopic panoramic 360 video.
  45735. */
  45736. static readonly MODE_MONOSCOPIC: number;
  45737. /**
  45738. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45739. */
  45740. static readonly MODE_TOPBOTTOM: number;
  45741. /**
  45742. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45743. */
  45744. static readonly MODE_SIDEBYSIDE: number;
  45745. private _useDirectMapping;
  45746. /**
  45747. * The video texture being displayed on the sphere
  45748. */
  45749. protected _videoTexture: VideoTexture;
  45750. /**
  45751. * Gets the video texture being displayed on the sphere
  45752. */
  45753. readonly videoTexture: VideoTexture;
  45754. /**
  45755. * The skybox material
  45756. */
  45757. protected _material: BackgroundMaterial;
  45758. /**
  45759. * The surface used for the skybox
  45760. */
  45761. protected _mesh: Mesh;
  45762. /**
  45763. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45764. * Also see the options.resolution property.
  45765. */
  45766. fovMultiplier: number;
  45767. private _videoMode;
  45768. /**
  45769. * Gets or set the current video mode for the video. It can be:
  45770. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45771. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45772. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45773. */
  45774. videoMode: number;
  45775. /**
  45776. * Oberserver used in Stereoscopic VR Mode.
  45777. */
  45778. private _onBeforeCameraRenderObserver;
  45779. /**
  45780. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45781. * @param name Element's name, child elements will append suffixes for their own names.
  45782. * @param urlsOrVideo defines the url(s) or the video element to use
  45783. * @param options An object containing optional or exposed sub element properties
  45784. */
  45785. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45786. resolution?: number;
  45787. clickToPlay?: boolean;
  45788. autoPlay?: boolean;
  45789. loop?: boolean;
  45790. size?: number;
  45791. poster?: string;
  45792. faceForward?: boolean;
  45793. useDirectMapping?: boolean;
  45794. }, scene: Scene);
  45795. private _changeVideoMode;
  45796. /**
  45797. * Releases resources associated with this node.
  45798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45800. */
  45801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45802. }
  45803. }
  45804. declare module BABYLON {
  45805. /**
  45806. * This class can be used to get instrumentation data from a Babylon engine
  45807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45808. */
  45809. export class EngineInstrumentation implements IDisposable {
  45810. /**
  45811. * Define the instrumented engine.
  45812. */
  45813. engine: Engine;
  45814. private _captureGPUFrameTime;
  45815. private _gpuFrameTimeToken;
  45816. private _gpuFrameTime;
  45817. private _captureShaderCompilationTime;
  45818. private _shaderCompilationTime;
  45819. private _onBeginFrameObserver;
  45820. private _onEndFrameObserver;
  45821. private _onBeforeShaderCompilationObserver;
  45822. private _onAfterShaderCompilationObserver;
  45823. /**
  45824. * Gets the perf counter used for GPU frame time
  45825. */
  45826. readonly gpuFrameTimeCounter: PerfCounter;
  45827. /**
  45828. * Gets the GPU frame time capture status
  45829. */
  45830. /**
  45831. * Enable or disable the GPU frame time capture
  45832. */
  45833. captureGPUFrameTime: boolean;
  45834. /**
  45835. * Gets the perf counter used for shader compilation time
  45836. */
  45837. readonly shaderCompilationTimeCounter: PerfCounter;
  45838. /**
  45839. * Gets the shader compilation time capture status
  45840. */
  45841. /**
  45842. * Enable or disable the shader compilation time capture
  45843. */
  45844. captureShaderCompilationTime: boolean;
  45845. /**
  45846. * Instantiates a new engine instrumentation.
  45847. * This class can be used to get instrumentation data from a Babylon engine
  45848. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45849. * @param engine Defines the engine to instrument
  45850. */
  45851. constructor(
  45852. /**
  45853. * Define the instrumented engine.
  45854. */
  45855. engine: Engine);
  45856. /**
  45857. * Dispose and release associated resources.
  45858. */
  45859. dispose(): void;
  45860. }
  45861. }
  45862. declare module BABYLON {
  45863. /**
  45864. * This class can be used to get instrumentation data from a Babylon engine
  45865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45866. */
  45867. export class SceneInstrumentation implements IDisposable {
  45868. /**
  45869. * Defines the scene to instrument
  45870. */
  45871. scene: Scene;
  45872. private _captureActiveMeshesEvaluationTime;
  45873. private _activeMeshesEvaluationTime;
  45874. private _captureRenderTargetsRenderTime;
  45875. private _renderTargetsRenderTime;
  45876. private _captureFrameTime;
  45877. private _frameTime;
  45878. private _captureRenderTime;
  45879. private _renderTime;
  45880. private _captureInterFrameTime;
  45881. private _interFrameTime;
  45882. private _captureParticlesRenderTime;
  45883. private _particlesRenderTime;
  45884. private _captureSpritesRenderTime;
  45885. private _spritesRenderTime;
  45886. private _capturePhysicsTime;
  45887. private _physicsTime;
  45888. private _captureAnimationsTime;
  45889. private _animationsTime;
  45890. private _captureCameraRenderTime;
  45891. private _cameraRenderTime;
  45892. private _onBeforeActiveMeshesEvaluationObserver;
  45893. private _onAfterActiveMeshesEvaluationObserver;
  45894. private _onBeforeRenderTargetsRenderObserver;
  45895. private _onAfterRenderTargetsRenderObserver;
  45896. private _onAfterRenderObserver;
  45897. private _onBeforeDrawPhaseObserver;
  45898. private _onAfterDrawPhaseObserver;
  45899. private _onBeforeAnimationsObserver;
  45900. private _onBeforeParticlesRenderingObserver;
  45901. private _onAfterParticlesRenderingObserver;
  45902. private _onBeforeSpritesRenderingObserver;
  45903. private _onAfterSpritesRenderingObserver;
  45904. private _onBeforePhysicsObserver;
  45905. private _onAfterPhysicsObserver;
  45906. private _onAfterAnimationsObserver;
  45907. private _onBeforeCameraRenderObserver;
  45908. private _onAfterCameraRenderObserver;
  45909. /**
  45910. * Gets the perf counter used for active meshes evaluation time
  45911. */
  45912. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45913. /**
  45914. * Gets the active meshes evaluation time capture status
  45915. */
  45916. /**
  45917. * Enable or disable the active meshes evaluation time capture
  45918. */
  45919. captureActiveMeshesEvaluationTime: boolean;
  45920. /**
  45921. * Gets the perf counter used for render targets render time
  45922. */
  45923. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45924. /**
  45925. * Gets the render targets render time capture status
  45926. */
  45927. /**
  45928. * Enable or disable the render targets render time capture
  45929. */
  45930. captureRenderTargetsRenderTime: boolean;
  45931. /**
  45932. * Gets the perf counter used for particles render time
  45933. */
  45934. readonly particlesRenderTimeCounter: PerfCounter;
  45935. /**
  45936. * Gets the particles render time capture status
  45937. */
  45938. /**
  45939. * Enable or disable the particles render time capture
  45940. */
  45941. captureParticlesRenderTime: boolean;
  45942. /**
  45943. * Gets the perf counter used for sprites render time
  45944. */
  45945. readonly spritesRenderTimeCounter: PerfCounter;
  45946. /**
  45947. * Gets the sprites render time capture status
  45948. */
  45949. /**
  45950. * Enable or disable the sprites render time capture
  45951. */
  45952. captureSpritesRenderTime: boolean;
  45953. /**
  45954. * Gets the perf counter used for physics time
  45955. */
  45956. readonly physicsTimeCounter: PerfCounter;
  45957. /**
  45958. * Gets the physics time capture status
  45959. */
  45960. /**
  45961. * Enable or disable the physics time capture
  45962. */
  45963. capturePhysicsTime: boolean;
  45964. /**
  45965. * Gets the perf counter used for animations time
  45966. */
  45967. readonly animationsTimeCounter: PerfCounter;
  45968. /**
  45969. * Gets the animations time capture status
  45970. */
  45971. /**
  45972. * Enable or disable the animations time capture
  45973. */
  45974. captureAnimationsTime: boolean;
  45975. /**
  45976. * Gets the perf counter used for frame time capture
  45977. */
  45978. readonly frameTimeCounter: PerfCounter;
  45979. /**
  45980. * Gets the frame time capture status
  45981. */
  45982. /**
  45983. * Enable or disable the frame time capture
  45984. */
  45985. captureFrameTime: boolean;
  45986. /**
  45987. * Gets the perf counter used for inter-frames time capture
  45988. */
  45989. readonly interFrameTimeCounter: PerfCounter;
  45990. /**
  45991. * Gets the inter-frames time capture status
  45992. */
  45993. /**
  45994. * Enable or disable the inter-frames time capture
  45995. */
  45996. captureInterFrameTime: boolean;
  45997. /**
  45998. * Gets the perf counter used for render time capture
  45999. */
  46000. readonly renderTimeCounter: PerfCounter;
  46001. /**
  46002. * Gets the render time capture status
  46003. */
  46004. /**
  46005. * Enable or disable the render time capture
  46006. */
  46007. captureRenderTime: boolean;
  46008. /**
  46009. * Gets the perf counter used for camera render time capture
  46010. */
  46011. readonly cameraRenderTimeCounter: PerfCounter;
  46012. /**
  46013. * Gets the camera render time capture status
  46014. */
  46015. /**
  46016. * Enable or disable the camera render time capture
  46017. */
  46018. captureCameraRenderTime: boolean;
  46019. /**
  46020. * Gets the perf counter used for draw calls
  46021. */
  46022. readonly drawCallsCounter: PerfCounter;
  46023. /**
  46024. * Instantiates a new scene instrumentation.
  46025. * This class can be used to get instrumentation data from a Babylon engine
  46026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46027. * @param scene Defines the scene to instrument
  46028. */
  46029. constructor(
  46030. /**
  46031. * Defines the scene to instrument
  46032. */
  46033. scene: Scene);
  46034. /**
  46035. * Dispose and release associated resources.
  46036. */
  46037. dispose(): void;
  46038. }
  46039. }
  46040. declare module BABYLON {
  46041. /** @hidden */
  46042. export var glowMapGenerationPixelShader: {
  46043. name: string;
  46044. shader: string;
  46045. };
  46046. }
  46047. declare module BABYLON {
  46048. /** @hidden */
  46049. export var glowMapGenerationVertexShader: {
  46050. name: string;
  46051. shader: string;
  46052. };
  46053. }
  46054. declare module BABYLON {
  46055. /**
  46056. * Effect layer options. This helps customizing the behaviour
  46057. * of the effect layer.
  46058. */
  46059. export interface IEffectLayerOptions {
  46060. /**
  46061. * Multiplication factor apply to the canvas size to compute the render target size
  46062. * used to generated the objects (the smaller the faster).
  46063. */
  46064. mainTextureRatio: number;
  46065. /**
  46066. * Enforces a fixed size texture to ensure effect stability across devices.
  46067. */
  46068. mainTextureFixedSize?: number;
  46069. /**
  46070. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46071. */
  46072. alphaBlendingMode: number;
  46073. /**
  46074. * The camera attached to the layer.
  46075. */
  46076. camera: Nullable<Camera>;
  46077. /**
  46078. * The rendering group to draw the layer in.
  46079. */
  46080. renderingGroupId: number;
  46081. }
  46082. /**
  46083. * The effect layer Helps adding post process effect blended with the main pass.
  46084. *
  46085. * This can be for instance use to generate glow or higlight effects on the scene.
  46086. *
  46087. * The effect layer class can not be used directly and is intented to inherited from to be
  46088. * customized per effects.
  46089. */
  46090. export abstract class EffectLayer {
  46091. private _vertexBuffers;
  46092. private _indexBuffer;
  46093. private _cachedDefines;
  46094. private _effectLayerMapGenerationEffect;
  46095. private _effectLayerOptions;
  46096. private _mergeEffect;
  46097. protected _scene: Scene;
  46098. protected _engine: Engine;
  46099. protected _maxSize: number;
  46100. protected _mainTextureDesiredSize: ISize;
  46101. protected _mainTexture: RenderTargetTexture;
  46102. protected _shouldRender: boolean;
  46103. protected _postProcesses: PostProcess[];
  46104. protected _textures: BaseTexture[];
  46105. protected _emissiveTextureAndColor: {
  46106. texture: Nullable<BaseTexture>;
  46107. color: Color4;
  46108. };
  46109. /**
  46110. * The name of the layer
  46111. */
  46112. name: string;
  46113. /**
  46114. * The clear color of the texture used to generate the glow map.
  46115. */
  46116. neutralColor: Color4;
  46117. /**
  46118. * Specifies wether the highlight layer is enabled or not.
  46119. */
  46120. isEnabled: boolean;
  46121. /**
  46122. * Gets the camera attached to the layer.
  46123. */
  46124. readonly camera: Nullable<Camera>;
  46125. /**
  46126. * Gets the rendering group id the layer should render in.
  46127. */
  46128. readonly renderingGroupId: number;
  46129. /**
  46130. * An event triggered when the effect layer has been disposed.
  46131. */
  46132. onDisposeObservable: Observable<EffectLayer>;
  46133. /**
  46134. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46135. */
  46136. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46137. /**
  46138. * An event triggered when the generated texture is being merged in the scene.
  46139. */
  46140. onBeforeComposeObservable: Observable<EffectLayer>;
  46141. /**
  46142. * An event triggered when the generated texture has been merged in the scene.
  46143. */
  46144. onAfterComposeObservable: Observable<EffectLayer>;
  46145. /**
  46146. * An event triggered when the efffect layer changes its size.
  46147. */
  46148. onSizeChangedObservable: Observable<EffectLayer>;
  46149. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46150. /**
  46151. * Instantiates a new effect Layer and references it in the scene.
  46152. * @param name The name of the layer
  46153. * @param scene The scene to use the layer in
  46154. */
  46155. constructor(
  46156. /** The Friendly of the effect in the scene */
  46157. name: string, scene: Scene);
  46158. /**
  46159. * Get the effect name of the layer.
  46160. * @return The effect name
  46161. */
  46162. abstract getEffectName(): string;
  46163. /**
  46164. * Checks for the readiness of the element composing the layer.
  46165. * @param subMesh the mesh to check for
  46166. * @param useInstances specify wether or not to use instances to render the mesh
  46167. * @return true if ready otherwise, false
  46168. */
  46169. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46170. /**
  46171. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46172. * @returns true if the effect requires stencil during the main canvas render pass.
  46173. */
  46174. abstract needStencil(): boolean;
  46175. /**
  46176. * Create the merge effect. This is the shader use to blit the information back
  46177. * to the main canvas at the end of the scene rendering.
  46178. * @returns The effect containing the shader used to merge the effect on the main canvas
  46179. */
  46180. protected abstract _createMergeEffect(): Effect;
  46181. /**
  46182. * Creates the render target textures and post processes used in the effect layer.
  46183. */
  46184. protected abstract _createTextureAndPostProcesses(): void;
  46185. /**
  46186. * Implementation specific of rendering the generating effect on the main canvas.
  46187. * @param effect The effect used to render through
  46188. */
  46189. protected abstract _internalRender(effect: Effect): void;
  46190. /**
  46191. * Sets the required values for both the emissive texture and and the main color.
  46192. */
  46193. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46194. /**
  46195. * Free any resources and references associated to a mesh.
  46196. * Internal use
  46197. * @param mesh The mesh to free.
  46198. */
  46199. abstract _disposeMesh(mesh: Mesh): void;
  46200. /**
  46201. * Serializes this layer (Glow or Highlight for example)
  46202. * @returns a serialized layer object
  46203. */
  46204. abstract serialize?(): any;
  46205. /**
  46206. * Initializes the effect layer with the required options.
  46207. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46208. */
  46209. protected _init(options: Partial<IEffectLayerOptions>): void;
  46210. /**
  46211. * Generates the index buffer of the full screen quad blending to the main canvas.
  46212. */
  46213. private _generateIndexBuffer;
  46214. /**
  46215. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46216. */
  46217. private _generateVertexBuffer;
  46218. /**
  46219. * Sets the main texture desired size which is the closest power of two
  46220. * of the engine canvas size.
  46221. */
  46222. private _setMainTextureSize;
  46223. /**
  46224. * Creates the main texture for the effect layer.
  46225. */
  46226. protected _createMainTexture(): void;
  46227. /**
  46228. * Adds specific effects defines.
  46229. * @param defines The defines to add specifics to.
  46230. */
  46231. protected _addCustomEffectDefines(defines: string[]): void;
  46232. /**
  46233. * Checks for the readiness of the element composing the layer.
  46234. * @param subMesh the mesh to check for
  46235. * @param useInstances specify wether or not to use instances to render the mesh
  46236. * @param emissiveTexture the associated emissive texture used to generate the glow
  46237. * @return true if ready otherwise, false
  46238. */
  46239. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46240. /**
  46241. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46242. */
  46243. render(): void;
  46244. /**
  46245. * Determine if a given mesh will be used in the current effect.
  46246. * @param mesh mesh to test
  46247. * @returns true if the mesh will be used
  46248. */
  46249. hasMesh(mesh: AbstractMesh): boolean;
  46250. /**
  46251. * Returns true if the layer contains information to display, otherwise false.
  46252. * @returns true if the glow layer should be rendered
  46253. */
  46254. shouldRender(): boolean;
  46255. /**
  46256. * Returns true if the mesh should render, otherwise false.
  46257. * @param mesh The mesh to render
  46258. * @returns true if it should render otherwise false
  46259. */
  46260. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46261. /**
  46262. * Returns true if the mesh can be rendered, otherwise false.
  46263. * @param mesh The mesh to render
  46264. * @param material The material used on the mesh
  46265. * @returns true if it can be rendered otherwise false
  46266. */
  46267. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46268. /**
  46269. * Returns true if the mesh should render, otherwise false.
  46270. * @param mesh The mesh to render
  46271. * @returns true if it should render otherwise false
  46272. */
  46273. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46274. /**
  46275. * Renders the submesh passed in parameter to the generation map.
  46276. */
  46277. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46278. /**
  46279. * Rebuild the required buffers.
  46280. * @hidden Internal use only.
  46281. */ rebuild(): void;
  46282. /**
  46283. * Dispose only the render target textures and post process.
  46284. */
  46285. private _disposeTextureAndPostProcesses;
  46286. /**
  46287. * Dispose the highlight layer and free resources.
  46288. */
  46289. dispose(): void;
  46290. /**
  46291. * Gets the class name of the effect layer
  46292. * @returns the string with the class name of the effect layer
  46293. */
  46294. getClassName(): string;
  46295. /**
  46296. * Creates an effect layer from parsed effect layer data
  46297. * @param parsedEffectLayer defines effect layer data
  46298. * @param scene defines the current scene
  46299. * @param rootUrl defines the root URL containing the effect layer information
  46300. * @returns a parsed effect Layer
  46301. */
  46302. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46303. }
  46304. }
  46305. declare module BABYLON {
  46306. interface AbstractScene {
  46307. /**
  46308. * The list of effect layers (highlights/glow) added to the scene
  46309. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46310. * @see http://doc.babylonjs.com/how_to/glow_layer
  46311. */
  46312. effectLayers: Array<EffectLayer>;
  46313. /**
  46314. * Removes the given effect layer from this scene.
  46315. * @param toRemove defines the effect layer to remove
  46316. * @returns the index of the removed effect layer
  46317. */
  46318. removeEffectLayer(toRemove: EffectLayer): number;
  46319. /**
  46320. * Adds the given effect layer to this scene
  46321. * @param newEffectLayer defines the effect layer to add
  46322. */
  46323. addEffectLayer(newEffectLayer: EffectLayer): void;
  46324. }
  46325. /**
  46326. * Defines the layer scene component responsible to manage any effect layers
  46327. * in a given scene.
  46328. */
  46329. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46330. /**
  46331. * The component name helpfull to identify the component in the list of scene components.
  46332. */
  46333. readonly name: string;
  46334. /**
  46335. * The scene the component belongs to.
  46336. */
  46337. scene: Scene;
  46338. private _engine;
  46339. private _renderEffects;
  46340. private _needStencil;
  46341. private _previousStencilState;
  46342. /**
  46343. * Creates a new instance of the component for the given scene
  46344. * @param scene Defines the scene to register the component in
  46345. */
  46346. constructor(scene: Scene);
  46347. /**
  46348. * Registers the component in a given scene
  46349. */
  46350. register(): void;
  46351. /**
  46352. * Rebuilds the elements related to this component in case of
  46353. * context lost for instance.
  46354. */
  46355. rebuild(): void;
  46356. /**
  46357. * Serializes the component data to the specified json object
  46358. * @param serializationObject The object to serialize to
  46359. */
  46360. serialize(serializationObject: any): void;
  46361. /**
  46362. * Adds all the element from the container to the scene
  46363. * @param container the container holding the elements
  46364. */
  46365. addFromContainer(container: AbstractScene): void;
  46366. /**
  46367. * Removes all the elements in the container from the scene
  46368. * @param container contains the elements to remove
  46369. * @param dispose if the removed element should be disposed (default: false)
  46370. */
  46371. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46372. /**
  46373. * Disposes the component and the associated ressources.
  46374. */
  46375. dispose(): void;
  46376. private _isReadyForMesh;
  46377. private _renderMainTexture;
  46378. private _setStencil;
  46379. private _setStencilBack;
  46380. private _draw;
  46381. private _drawCamera;
  46382. private _drawRenderingGroup;
  46383. }
  46384. }
  46385. declare module BABYLON {
  46386. /** @hidden */
  46387. export var glowMapMergePixelShader: {
  46388. name: string;
  46389. shader: string;
  46390. };
  46391. }
  46392. declare module BABYLON {
  46393. /** @hidden */
  46394. export var glowMapMergeVertexShader: {
  46395. name: string;
  46396. shader: string;
  46397. };
  46398. }
  46399. declare module BABYLON {
  46400. interface AbstractScene {
  46401. /**
  46402. * Return a the first highlight layer of the scene with a given name.
  46403. * @param name The name of the highlight layer to look for.
  46404. * @return The highlight layer if found otherwise null.
  46405. */
  46406. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46407. }
  46408. /**
  46409. * Glow layer options. This helps customizing the behaviour
  46410. * of the glow layer.
  46411. */
  46412. export interface IGlowLayerOptions {
  46413. /**
  46414. * Multiplication factor apply to the canvas size to compute the render target size
  46415. * used to generated the glowing objects (the smaller the faster).
  46416. */
  46417. mainTextureRatio: number;
  46418. /**
  46419. * Enforces a fixed size texture to ensure resize independant blur.
  46420. */
  46421. mainTextureFixedSize?: number;
  46422. /**
  46423. * How big is the kernel of the blur texture.
  46424. */
  46425. blurKernelSize: number;
  46426. /**
  46427. * The camera attached to the layer.
  46428. */
  46429. camera: Nullable<Camera>;
  46430. /**
  46431. * Enable MSAA by chosing the number of samples.
  46432. */
  46433. mainTextureSamples?: number;
  46434. /**
  46435. * The rendering group to draw the layer in.
  46436. */
  46437. renderingGroupId: number;
  46438. }
  46439. /**
  46440. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46441. *
  46442. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46443. * glowy meshes to your scene.
  46444. *
  46445. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46446. */
  46447. export class GlowLayer extends EffectLayer {
  46448. /**
  46449. * Effect Name of the layer.
  46450. */
  46451. static readonly EffectName: string;
  46452. /**
  46453. * The default blur kernel size used for the glow.
  46454. */
  46455. static DefaultBlurKernelSize: number;
  46456. /**
  46457. * The default texture size ratio used for the glow.
  46458. */
  46459. static DefaultTextureRatio: number;
  46460. /**
  46461. * Sets the kernel size of the blur.
  46462. */
  46463. /**
  46464. * Gets the kernel size of the blur.
  46465. */
  46466. blurKernelSize: number;
  46467. /**
  46468. * Sets the glow intensity.
  46469. */
  46470. /**
  46471. * Gets the glow intensity.
  46472. */
  46473. intensity: number;
  46474. private _options;
  46475. private _intensity;
  46476. private _horizontalBlurPostprocess1;
  46477. private _verticalBlurPostprocess1;
  46478. private _horizontalBlurPostprocess2;
  46479. private _verticalBlurPostprocess2;
  46480. private _blurTexture1;
  46481. private _blurTexture2;
  46482. private _postProcesses1;
  46483. private _postProcesses2;
  46484. private _includedOnlyMeshes;
  46485. private _excludedMeshes;
  46486. /**
  46487. * Callback used to let the user override the color selection on a per mesh basis
  46488. */
  46489. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46490. /**
  46491. * Callback used to let the user override the texture selection on a per mesh basis
  46492. */
  46493. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46494. /**
  46495. * Instantiates a new glow Layer and references it to the scene.
  46496. * @param name The name of the layer
  46497. * @param scene The scene to use the layer in
  46498. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46499. */
  46500. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46501. /**
  46502. * Get the effect name of the layer.
  46503. * @return The effect name
  46504. */
  46505. getEffectName(): string;
  46506. /**
  46507. * Create the merge effect. This is the shader use to blit the information back
  46508. * to the main canvas at the end of the scene rendering.
  46509. */
  46510. protected _createMergeEffect(): Effect;
  46511. /**
  46512. * Creates the render target textures and post processes used in the glow layer.
  46513. */
  46514. protected _createTextureAndPostProcesses(): void;
  46515. /**
  46516. * Checks for the readiness of the element composing the layer.
  46517. * @param subMesh the mesh to check for
  46518. * @param useInstances specify wether or not to use instances to render the mesh
  46519. * @param emissiveTexture the associated emissive texture used to generate the glow
  46520. * @return true if ready otherwise, false
  46521. */
  46522. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46523. /**
  46524. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46525. */
  46526. needStencil(): boolean;
  46527. /**
  46528. * Returns true if the mesh can be rendered, otherwise false.
  46529. * @param mesh The mesh to render
  46530. * @param material The material used on the mesh
  46531. * @returns true if it can be rendered otherwise false
  46532. */
  46533. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46534. /**
  46535. * Implementation specific of rendering the generating effect on the main canvas.
  46536. * @param effect The effect used to render through
  46537. */
  46538. protected _internalRender(effect: Effect): void;
  46539. /**
  46540. * Sets the required values for both the emissive texture and and the main color.
  46541. */
  46542. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46543. /**
  46544. * Returns true if the mesh should render, otherwise false.
  46545. * @param mesh The mesh to render
  46546. * @returns true if it should render otherwise false
  46547. */
  46548. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46549. /**
  46550. * Adds specific effects defines.
  46551. * @param defines The defines to add specifics to.
  46552. */
  46553. protected _addCustomEffectDefines(defines: string[]): void;
  46554. /**
  46555. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46556. * @param mesh The mesh to exclude from the glow layer
  46557. */
  46558. addExcludedMesh(mesh: Mesh): void;
  46559. /**
  46560. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46561. * @param mesh The mesh to remove
  46562. */
  46563. removeExcludedMesh(mesh: Mesh): void;
  46564. /**
  46565. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46566. * @param mesh The mesh to include in the glow layer
  46567. */
  46568. addIncludedOnlyMesh(mesh: Mesh): void;
  46569. /**
  46570. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46571. * @param mesh The mesh to remove
  46572. */
  46573. removeIncludedOnlyMesh(mesh: Mesh): void;
  46574. /**
  46575. * Determine if a given mesh will be used in the glow layer
  46576. * @param mesh The mesh to test
  46577. * @returns true if the mesh will be highlighted by the current glow layer
  46578. */
  46579. hasMesh(mesh: AbstractMesh): boolean;
  46580. /**
  46581. * Free any resources and references associated to a mesh.
  46582. * Internal use
  46583. * @param mesh The mesh to free.
  46584. * @hidden
  46585. */ disposeMesh(mesh: Mesh): void;
  46586. /**
  46587. * Gets the class name of the effect layer
  46588. * @returns the string with the class name of the effect layer
  46589. */
  46590. getClassName(): string;
  46591. /**
  46592. * Serializes this glow layer
  46593. * @returns a serialized glow layer object
  46594. */
  46595. serialize(): any;
  46596. /**
  46597. * Creates a Glow Layer from parsed glow layer data
  46598. * @param parsedGlowLayer defines glow layer data
  46599. * @param scene defines the current scene
  46600. * @param rootUrl defines the root URL containing the glow layer information
  46601. * @returns a parsed Glow Layer
  46602. */
  46603. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46604. }
  46605. }
  46606. declare module BABYLON {
  46607. /** @hidden */
  46608. export var glowBlurPostProcessPixelShader: {
  46609. name: string;
  46610. shader: string;
  46611. };
  46612. }
  46613. declare module BABYLON {
  46614. interface AbstractScene {
  46615. /**
  46616. * Return a the first highlight layer of the scene with a given name.
  46617. * @param name The name of the highlight layer to look for.
  46618. * @return The highlight layer if found otherwise null.
  46619. */
  46620. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46621. }
  46622. /**
  46623. * Highlight layer options. This helps customizing the behaviour
  46624. * of the highlight layer.
  46625. */
  46626. export interface IHighlightLayerOptions {
  46627. /**
  46628. * Multiplication factor apply to the canvas size to compute the render target size
  46629. * used to generated the glowing objects (the smaller the faster).
  46630. */
  46631. mainTextureRatio: number;
  46632. /**
  46633. * Enforces a fixed size texture to ensure resize independant blur.
  46634. */
  46635. mainTextureFixedSize?: number;
  46636. /**
  46637. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46638. * of the picture to blur (the smaller the faster).
  46639. */
  46640. blurTextureSizeRatio: number;
  46641. /**
  46642. * How big in texel of the blur texture is the vertical blur.
  46643. */
  46644. blurVerticalSize: number;
  46645. /**
  46646. * How big in texel of the blur texture is the horizontal blur.
  46647. */
  46648. blurHorizontalSize: number;
  46649. /**
  46650. * Alpha blending mode used to apply the blur. Default is combine.
  46651. */
  46652. alphaBlendingMode: number;
  46653. /**
  46654. * The camera attached to the layer.
  46655. */
  46656. camera: Nullable<Camera>;
  46657. /**
  46658. * Should we display highlight as a solid stroke?
  46659. */
  46660. isStroke?: boolean;
  46661. /**
  46662. * The rendering group to draw the layer in.
  46663. */
  46664. renderingGroupId: number;
  46665. }
  46666. /**
  46667. * The highlight layer Helps adding a glow effect around a mesh.
  46668. *
  46669. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46670. * glowy meshes to your scene.
  46671. *
  46672. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46673. */
  46674. export class HighlightLayer extends EffectLayer {
  46675. name: string;
  46676. /**
  46677. * Effect Name of the highlight layer.
  46678. */
  46679. static readonly EffectName: string;
  46680. /**
  46681. * The neutral color used during the preparation of the glow effect.
  46682. * This is black by default as the blend operation is a blend operation.
  46683. */
  46684. static NeutralColor: Color4;
  46685. /**
  46686. * Stencil value used for glowing meshes.
  46687. */
  46688. static GlowingMeshStencilReference: number;
  46689. /**
  46690. * Stencil value used for the other meshes in the scene.
  46691. */
  46692. static NormalMeshStencilReference: number;
  46693. /**
  46694. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46695. */
  46696. innerGlow: boolean;
  46697. /**
  46698. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46699. */
  46700. outerGlow: boolean;
  46701. /**
  46702. * Specifies the horizontal size of the blur.
  46703. */
  46704. /**
  46705. * Gets the horizontal size of the blur.
  46706. */
  46707. blurHorizontalSize: number;
  46708. /**
  46709. * Specifies the vertical size of the blur.
  46710. */
  46711. /**
  46712. * Gets the vertical size of the blur.
  46713. */
  46714. blurVerticalSize: number;
  46715. /**
  46716. * An event triggered when the highlight layer is being blurred.
  46717. */
  46718. onBeforeBlurObservable: Observable<HighlightLayer>;
  46719. /**
  46720. * An event triggered when the highlight layer has been blurred.
  46721. */
  46722. onAfterBlurObservable: Observable<HighlightLayer>;
  46723. private _instanceGlowingMeshStencilReference;
  46724. private _options;
  46725. private _downSamplePostprocess;
  46726. private _horizontalBlurPostprocess;
  46727. private _verticalBlurPostprocess;
  46728. private _blurTexture;
  46729. private _meshes;
  46730. private _excludedMeshes;
  46731. /**
  46732. * Instantiates a new highlight Layer and references it to the scene..
  46733. * @param name The name of the layer
  46734. * @param scene The scene to use the layer in
  46735. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46736. */
  46737. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46738. /**
  46739. * Get the effect name of the layer.
  46740. * @return The effect name
  46741. */
  46742. getEffectName(): string;
  46743. /**
  46744. * Create the merge effect. This is the shader use to blit the information back
  46745. * to the main canvas at the end of the scene rendering.
  46746. */
  46747. protected _createMergeEffect(): Effect;
  46748. /**
  46749. * Creates the render target textures and post processes used in the highlight layer.
  46750. */
  46751. protected _createTextureAndPostProcesses(): void;
  46752. /**
  46753. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46754. */
  46755. needStencil(): boolean;
  46756. /**
  46757. * Checks for the readiness of the element composing the layer.
  46758. * @param subMesh the mesh to check for
  46759. * @param useInstances specify wether or not to use instances to render the mesh
  46760. * @param emissiveTexture the associated emissive texture used to generate the glow
  46761. * @return true if ready otherwise, false
  46762. */
  46763. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46764. /**
  46765. * Implementation specific of rendering the generating effect on the main canvas.
  46766. * @param effect The effect used to render through
  46767. */
  46768. protected _internalRender(effect: Effect): void;
  46769. /**
  46770. * Returns true if the layer contains information to display, otherwise false.
  46771. */
  46772. shouldRender(): boolean;
  46773. /**
  46774. * Returns true if the mesh should render, otherwise false.
  46775. * @param mesh The mesh to render
  46776. * @returns true if it should render otherwise false
  46777. */
  46778. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46779. /**
  46780. * Sets the required values for both the emissive texture and and the main color.
  46781. */
  46782. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46783. /**
  46784. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46785. * @param mesh The mesh to exclude from the highlight layer
  46786. */
  46787. addExcludedMesh(mesh: Mesh): void;
  46788. /**
  46789. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46790. * @param mesh The mesh to highlight
  46791. */
  46792. removeExcludedMesh(mesh: Mesh): void;
  46793. /**
  46794. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46795. * @param mesh mesh to test
  46796. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46797. */
  46798. hasMesh(mesh: AbstractMesh): boolean;
  46799. /**
  46800. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46801. * @param mesh The mesh to highlight
  46802. * @param color The color of the highlight
  46803. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46804. */
  46805. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46806. /**
  46807. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46808. * @param mesh The mesh to highlight
  46809. */
  46810. removeMesh(mesh: Mesh): void;
  46811. /**
  46812. * Force the stencil to the normal expected value for none glowing parts
  46813. */
  46814. private _defaultStencilReference;
  46815. /**
  46816. * Free any resources and references associated to a mesh.
  46817. * Internal use
  46818. * @param mesh The mesh to free.
  46819. * @hidden
  46820. */ disposeMesh(mesh: Mesh): void;
  46821. /**
  46822. * Dispose the highlight layer and free resources.
  46823. */
  46824. dispose(): void;
  46825. /**
  46826. * Gets the class name of the effect layer
  46827. * @returns the string with the class name of the effect layer
  46828. */
  46829. getClassName(): string;
  46830. /**
  46831. * Serializes this Highlight layer
  46832. * @returns a serialized Highlight layer object
  46833. */
  46834. serialize(): any;
  46835. /**
  46836. * Creates a Highlight layer from parsed Highlight layer data
  46837. * @param parsedHightlightLayer defines the Highlight layer data
  46838. * @param scene defines the current scene
  46839. * @param rootUrl defines the root URL containing the Highlight layer information
  46840. * @returns a parsed Highlight layer
  46841. */
  46842. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46843. }
  46844. }
  46845. declare module BABYLON {
  46846. /** @hidden */
  46847. export var lensFlarePixelShader: {
  46848. name: string;
  46849. shader: string;
  46850. };
  46851. }
  46852. declare module BABYLON {
  46853. /** @hidden */
  46854. export var lensFlareVertexShader: {
  46855. name: string;
  46856. shader: string;
  46857. };
  46858. }
  46859. declare module BABYLON {
  46860. /**
  46861. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46862. * It is usually composed of several `lensFlare`.
  46863. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46864. */
  46865. export class LensFlareSystem {
  46866. /**
  46867. * Define the name of the lens flare system
  46868. */
  46869. name: string;
  46870. /**
  46871. * List of lens flares used in this system.
  46872. */
  46873. lensFlares: LensFlare[];
  46874. /**
  46875. * Define a limit from the border the lens flare can be visible.
  46876. */
  46877. borderLimit: number;
  46878. /**
  46879. * Define a viewport border we do not want to see the lens flare in.
  46880. */
  46881. viewportBorder: number;
  46882. /**
  46883. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46884. */
  46885. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46886. /**
  46887. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46888. */
  46889. layerMask: number;
  46890. /**
  46891. * Define the id of the lens flare system in the scene.
  46892. * (equal to name by default)
  46893. */
  46894. id: string;
  46895. private _scene;
  46896. private _emitter;
  46897. private _vertexBuffers;
  46898. private _indexBuffer;
  46899. private _effect;
  46900. private _positionX;
  46901. private _positionY;
  46902. private _isEnabled;
  46903. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46904. /**
  46905. * Instantiates a lens flare system.
  46906. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46907. * It is usually composed of several `lensFlare`.
  46908. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46909. * @param name Define the name of the lens flare system in the scene
  46910. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46911. * @param scene Define the scene the lens flare system belongs to
  46912. */
  46913. constructor(
  46914. /**
  46915. * Define the name of the lens flare system
  46916. */
  46917. name: string, emitter: any, scene: Scene);
  46918. /**
  46919. * Define if the lens flare system is enabled.
  46920. */
  46921. isEnabled: boolean;
  46922. /**
  46923. * Get the scene the effects belongs to.
  46924. * @returns the scene holding the lens flare system
  46925. */
  46926. getScene(): Scene;
  46927. /**
  46928. * Get the emitter of the lens flare system.
  46929. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46930. * @returns the emitter of the lens flare system
  46931. */
  46932. getEmitter(): any;
  46933. /**
  46934. * Set the emitter of the lens flare system.
  46935. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46936. * @param newEmitter Define the new emitter of the system
  46937. */
  46938. setEmitter(newEmitter: any): void;
  46939. /**
  46940. * Get the lens flare system emitter position.
  46941. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46942. * @returns the position
  46943. */
  46944. getEmitterPosition(): Vector3;
  46945. /**
  46946. * @hidden
  46947. */
  46948. computeEffectivePosition(globalViewport: Viewport): boolean;
  46949. /** @hidden */ isVisible(): boolean;
  46950. /**
  46951. * @hidden
  46952. */
  46953. render(): boolean;
  46954. /**
  46955. * Dispose and release the lens flare with its associated resources.
  46956. */
  46957. dispose(): void;
  46958. /**
  46959. * Parse a lens flare system from a JSON repressentation
  46960. * @param parsedLensFlareSystem Define the JSON to parse
  46961. * @param scene Define the scene the parsed system should be instantiated in
  46962. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46963. * @returns the parsed system
  46964. */
  46965. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46966. /**
  46967. * Serialize the current Lens Flare System into a JSON representation.
  46968. * @returns the serialized JSON
  46969. */
  46970. serialize(): any;
  46971. }
  46972. }
  46973. declare module BABYLON {
  46974. /**
  46975. * This represents one of the lens effect in a `lensFlareSystem`.
  46976. * It controls one of the indiviual texture used in the effect.
  46977. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46978. */
  46979. export class LensFlare {
  46980. /**
  46981. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46982. */
  46983. size: number;
  46984. /**
  46985. * 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.
  46986. */
  46987. position: number;
  46988. /**
  46989. * Define the lens color.
  46990. */
  46991. color: Color3;
  46992. /**
  46993. * Define the lens texture.
  46994. */
  46995. texture: Nullable<Texture>;
  46996. /**
  46997. * Define the alpha mode to render this particular lens.
  46998. */
  46999. alphaMode: number;
  47000. private _system;
  47001. /**
  47002. * Creates a new Lens Flare.
  47003. * This represents one of the lens effect in a `lensFlareSystem`.
  47004. * It controls one of the indiviual texture used in the effect.
  47005. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47006. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47007. * @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.
  47008. * @param color Define the lens color
  47009. * @param imgUrl Define the lens texture url
  47010. * @param system Define the `lensFlareSystem` this flare is part of
  47011. * @returns The newly created Lens Flare
  47012. */
  47013. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47014. /**
  47015. * Instantiates a new Lens Flare.
  47016. * This represents one of the lens effect in a `lensFlareSystem`.
  47017. * It controls one of the indiviual texture used in the effect.
  47018. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47019. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47020. * @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.
  47021. * @param color Define the lens color
  47022. * @param imgUrl Define the lens texture url
  47023. * @param system Define the `lensFlareSystem` this flare is part of
  47024. */
  47025. constructor(
  47026. /**
  47027. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47028. */
  47029. size: number,
  47030. /**
  47031. * 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.
  47032. */
  47033. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47034. /**
  47035. * Dispose and release the lens flare with its associated resources.
  47036. */
  47037. dispose(): void;
  47038. }
  47039. }
  47040. declare module BABYLON {
  47041. interface AbstractScene {
  47042. /**
  47043. * The list of lens flare system added to the scene
  47044. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47045. */
  47046. lensFlareSystems: Array<LensFlareSystem>;
  47047. /**
  47048. * Removes the given lens flare system from this scene.
  47049. * @param toRemove The lens flare system to remove
  47050. * @returns The index of the removed lens flare system
  47051. */
  47052. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47053. /**
  47054. * Adds the given lens flare system to this scene
  47055. * @param newLensFlareSystem The lens flare system to add
  47056. */
  47057. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47058. /**
  47059. * Gets a lens flare system using its name
  47060. * @param name defines the name to look for
  47061. * @returns the lens flare system or null if not found
  47062. */
  47063. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47064. /**
  47065. * Gets a lens flare system using its id
  47066. * @param id defines the id to look for
  47067. * @returns the lens flare system or null if not found
  47068. */
  47069. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47070. }
  47071. /**
  47072. * Defines the lens flare scene component responsible to manage any lens flares
  47073. * in a given scene.
  47074. */
  47075. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47076. /**
  47077. * The component name helpfull to identify the component in the list of scene components.
  47078. */
  47079. readonly name: string;
  47080. /**
  47081. * The scene the component belongs to.
  47082. */
  47083. scene: Scene;
  47084. /**
  47085. * Creates a new instance of the component for the given scene
  47086. * @param scene Defines the scene to register the component in
  47087. */
  47088. constructor(scene: Scene);
  47089. /**
  47090. * Registers the component in a given scene
  47091. */
  47092. register(): void;
  47093. /**
  47094. * Rebuilds the elements related to this component in case of
  47095. * context lost for instance.
  47096. */
  47097. rebuild(): void;
  47098. /**
  47099. * Adds all the element from the container to the scene
  47100. * @param container the container holding the elements
  47101. */
  47102. addFromContainer(container: AbstractScene): void;
  47103. /**
  47104. * Removes all the elements in the container from the scene
  47105. * @param container contains the elements to remove
  47106. * @param dispose if the removed element should be disposed (default: false)
  47107. */
  47108. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47109. /**
  47110. * Serializes the component data to the specified json object
  47111. * @param serializationObject The object to serialize to
  47112. */
  47113. serialize(serializationObject: any): void;
  47114. /**
  47115. * Disposes the component and the associated ressources.
  47116. */
  47117. dispose(): void;
  47118. private _draw;
  47119. }
  47120. }
  47121. declare module BABYLON {
  47122. /**
  47123. * Defines the shadow generator component responsible to manage any shadow generators
  47124. * in a given scene.
  47125. */
  47126. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47127. /**
  47128. * The component name helpfull to identify the component in the list of scene components.
  47129. */
  47130. readonly name: string;
  47131. /**
  47132. * The scene the component belongs to.
  47133. */
  47134. scene: Scene;
  47135. /**
  47136. * Creates a new instance of the component for the given scene
  47137. * @param scene Defines the scene to register the component in
  47138. */
  47139. constructor(scene: Scene);
  47140. /**
  47141. * Registers the component in a given scene
  47142. */
  47143. register(): void;
  47144. /**
  47145. * Rebuilds the elements related to this component in case of
  47146. * context lost for instance.
  47147. */
  47148. rebuild(): void;
  47149. /**
  47150. * Serializes the component data to the specified json object
  47151. * @param serializationObject The object to serialize to
  47152. */
  47153. serialize(serializationObject: any): void;
  47154. /**
  47155. * Adds all the element from the container to the scene
  47156. * @param container the container holding the elements
  47157. */
  47158. addFromContainer(container: AbstractScene): void;
  47159. /**
  47160. * Removes all the elements in the container from the scene
  47161. * @param container contains the elements to remove
  47162. * @param dispose if the removed element should be disposed (default: false)
  47163. */
  47164. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47165. /**
  47166. * Rebuilds the elements related to this component in case of
  47167. * context lost for instance.
  47168. */
  47169. dispose(): void;
  47170. private _gatherRenderTargets;
  47171. }
  47172. }
  47173. declare module BABYLON {
  47174. /**
  47175. * A point light is a light defined by an unique point in world space.
  47176. * The light is emitted in every direction from this point.
  47177. * A good example of a point light is a standard light bulb.
  47178. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47179. */
  47180. export class PointLight extends ShadowLight {
  47181. private _shadowAngle;
  47182. /**
  47183. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47184. * This specifies what angle the shadow will use to be created.
  47185. *
  47186. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47187. */
  47188. /**
  47189. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47190. * This specifies what angle the shadow will use to be created.
  47191. *
  47192. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47193. */
  47194. shadowAngle: number;
  47195. /**
  47196. * Gets the direction if it has been set.
  47197. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47198. */
  47199. /**
  47200. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47201. */
  47202. direction: Vector3;
  47203. /**
  47204. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47205. * A PointLight emits the light in every direction.
  47206. * It can cast shadows.
  47207. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47208. * ```javascript
  47209. * var pointLight = new PointLight("pl", camera.position, scene);
  47210. * ```
  47211. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47212. * @param name The light friendly name
  47213. * @param position The position of the point light in the scene
  47214. * @param scene The scene the lights belongs to
  47215. */
  47216. constructor(name: string, position: Vector3, scene: Scene);
  47217. /**
  47218. * Returns the string "PointLight"
  47219. * @returns the class name
  47220. */
  47221. getClassName(): string;
  47222. /**
  47223. * Returns the integer 0.
  47224. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47225. */
  47226. getTypeID(): number;
  47227. /**
  47228. * Specifies wether or not the shadowmap should be a cube texture.
  47229. * @returns true if the shadowmap needs to be a cube texture.
  47230. */
  47231. needCube(): boolean;
  47232. /**
  47233. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47234. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47235. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47236. */
  47237. getShadowDirection(faceIndex?: number): Vector3;
  47238. /**
  47239. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47240. * - fov = PI / 2
  47241. * - aspect ratio : 1.0
  47242. * - z-near and far equal to the active camera minZ and maxZ.
  47243. * Returns the PointLight.
  47244. */
  47245. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47246. protected _buildUniformLayout(): void;
  47247. /**
  47248. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47249. * @param effect The effect to update
  47250. * @param lightIndex The index of the light in the effect to update
  47251. * @returns The point light
  47252. */
  47253. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47254. /**
  47255. * Prepares the list of defines specific to the light type.
  47256. * @param defines the list of defines
  47257. * @param lightIndex defines the index of the light for the effect
  47258. */
  47259. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47260. }
  47261. }
  47262. declare module BABYLON {
  47263. /**
  47264. * Header information of HDR texture files.
  47265. */
  47266. export interface HDRInfo {
  47267. /**
  47268. * The height of the texture in pixels.
  47269. */
  47270. height: number;
  47271. /**
  47272. * The width of the texture in pixels.
  47273. */
  47274. width: number;
  47275. /**
  47276. * The index of the beginning of the data in the binary file.
  47277. */
  47278. dataPosition: number;
  47279. }
  47280. /**
  47281. * This groups tools to convert HDR texture to native colors array.
  47282. */
  47283. export class HDRTools {
  47284. private static Ldexp;
  47285. private static Rgbe2float;
  47286. private static readStringLine;
  47287. /**
  47288. * Reads header information from an RGBE texture stored in a native array.
  47289. * More information on this format are available here:
  47290. * https://en.wikipedia.org/wiki/RGBE_image_format
  47291. *
  47292. * @param uint8array The binary file stored in native array.
  47293. * @return The header information.
  47294. */
  47295. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47296. /**
  47297. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47298. * This RGBE texture needs to store the information as a panorama.
  47299. *
  47300. * More information on this format are available here:
  47301. * https://en.wikipedia.org/wiki/RGBE_image_format
  47302. *
  47303. * @param buffer The binary file stored in an array buffer.
  47304. * @param size The expected size of the extracted cubemap.
  47305. * @return The Cube Map information.
  47306. */
  47307. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47308. /**
  47309. * Returns the pixels data extracted from an RGBE texture.
  47310. * This pixels will be stored left to right up to down in the R G B order in one array.
  47311. *
  47312. * More information on this format are available here:
  47313. * https://en.wikipedia.org/wiki/RGBE_image_format
  47314. *
  47315. * @param uint8array The binary file stored in an array buffer.
  47316. * @param hdrInfo The header information of the file.
  47317. * @return The pixels data in RGB right to left up to down order.
  47318. */
  47319. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47320. private static RGBE_ReadPixels_RLE;
  47321. }
  47322. }
  47323. declare module BABYLON {
  47324. /**
  47325. * This represents a texture coming from an HDR input.
  47326. *
  47327. * The only supported format is currently panorama picture stored in RGBE format.
  47328. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47329. */
  47330. export class HDRCubeTexture extends BaseTexture {
  47331. private static _facesMapping;
  47332. private _generateHarmonics;
  47333. private _noMipmap;
  47334. private _textureMatrix;
  47335. private _size;
  47336. private _onLoad;
  47337. private _onError;
  47338. /**
  47339. * The texture URL.
  47340. */
  47341. url: string;
  47342. /**
  47343. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47344. */
  47345. coordinatesMode: number;
  47346. protected _isBlocking: boolean;
  47347. /**
  47348. * Sets wether or not the texture is blocking during loading.
  47349. */
  47350. /**
  47351. * Gets wether or not the texture is blocking during loading.
  47352. */
  47353. isBlocking: boolean;
  47354. protected _rotationY: number;
  47355. /**
  47356. * Sets texture matrix rotation angle around Y axis in radians.
  47357. */
  47358. /**
  47359. * Gets texture matrix rotation angle around Y axis radians.
  47360. */
  47361. rotationY: number;
  47362. /**
  47363. * Gets or sets the center of the bounding box associated with the cube texture
  47364. * It must define where the camera used to render the texture was set
  47365. */
  47366. boundingBoxPosition: Vector3;
  47367. private _boundingBoxSize;
  47368. /**
  47369. * Gets or sets the size of the bounding box associated with the cube texture
  47370. * When defined, the cubemap will switch to local mode
  47371. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47372. * @example https://www.babylonjs-playground.com/#RNASML
  47373. */
  47374. boundingBoxSize: Vector3;
  47375. /**
  47376. * Instantiates an HDRTexture from the following parameters.
  47377. *
  47378. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47379. * @param scene The scene the texture will be used in
  47380. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47381. * @param noMipmap Forces to not generate the mipmap if true
  47382. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47383. * @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)
  47384. * @param reserved Reserved flag for internal use.
  47385. */
  47386. 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>);
  47387. /**
  47388. * Get the current class name of the texture useful for serialization or dynamic coding.
  47389. * @returns "HDRCubeTexture"
  47390. */
  47391. getClassName(): string;
  47392. /**
  47393. * Occurs when the file is raw .hdr file.
  47394. */
  47395. private loadTexture;
  47396. clone(): HDRCubeTexture;
  47397. delayLoad(): void;
  47398. /**
  47399. * Get the texture reflection matrix used to rotate/transform the reflection.
  47400. * @returns the reflection matrix
  47401. */
  47402. getReflectionTextureMatrix(): Matrix;
  47403. /**
  47404. * Set the texture reflection matrix used to rotate/transform the reflection.
  47405. * @param value Define the reflection matrix to set
  47406. */
  47407. setReflectionTextureMatrix(value: Matrix): void;
  47408. /**
  47409. * Parses a JSON representation of an HDR Texture in order to create the texture
  47410. * @param parsedTexture Define the JSON representation
  47411. * @param scene Define the scene the texture should be created in
  47412. * @param rootUrl Define the root url in case we need to load relative dependencies
  47413. * @returns the newly created texture after parsing
  47414. */
  47415. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47416. serialize(): any;
  47417. }
  47418. }
  47419. declare module BABYLON {
  47420. /**
  47421. * Class used to control physics engine
  47422. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47423. */
  47424. export class PhysicsEngine implements IPhysicsEngine {
  47425. private _physicsPlugin;
  47426. /**
  47427. * Global value used to control the smallest number supported by the simulation
  47428. */
  47429. static Epsilon: number;
  47430. private _impostors;
  47431. private _joints;
  47432. /**
  47433. * Gets the gravity vector used by the simulation
  47434. */
  47435. gravity: Vector3;
  47436. /**
  47437. * Factory used to create the default physics plugin.
  47438. * @returns The default physics plugin
  47439. */
  47440. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47441. /**
  47442. * Creates a new Physics Engine
  47443. * @param gravity defines the gravity vector used by the simulation
  47444. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47445. */
  47446. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47447. /**
  47448. * Sets the gravity vector used by the simulation
  47449. * @param gravity defines the gravity vector to use
  47450. */
  47451. setGravity(gravity: Vector3): void;
  47452. /**
  47453. * Set the time step of the physics engine.
  47454. * Default is 1/60.
  47455. * To slow it down, enter 1/600 for example.
  47456. * To speed it up, 1/30
  47457. * @param newTimeStep defines the new timestep to apply to this world.
  47458. */
  47459. setTimeStep(newTimeStep?: number): void;
  47460. /**
  47461. * Get the time step of the physics engine.
  47462. * @returns the current time step
  47463. */
  47464. getTimeStep(): number;
  47465. /**
  47466. * Release all resources
  47467. */
  47468. dispose(): void;
  47469. /**
  47470. * Gets the name of the current physics plugin
  47471. * @returns the name of the plugin
  47472. */
  47473. getPhysicsPluginName(): string;
  47474. /**
  47475. * Adding a new impostor for the impostor tracking.
  47476. * This will be done by the impostor itself.
  47477. * @param impostor the impostor to add
  47478. */
  47479. addImpostor(impostor: PhysicsImpostor): void;
  47480. /**
  47481. * Remove an impostor from the engine.
  47482. * This impostor and its mesh will not longer be updated by the physics engine.
  47483. * @param impostor the impostor to remove
  47484. */
  47485. removeImpostor(impostor: PhysicsImpostor): void;
  47486. /**
  47487. * Add a joint to the physics engine
  47488. * @param mainImpostor defines the main impostor to which the joint is added.
  47489. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47490. * @param joint defines the joint that will connect both impostors.
  47491. */
  47492. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47493. /**
  47494. * Removes a joint from the simulation
  47495. * @param mainImpostor defines the impostor used with the joint
  47496. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47497. * @param joint defines the joint to remove
  47498. */
  47499. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47500. /**
  47501. * Called by the scene. No need to call it.
  47502. * @param delta defines the timespam between frames
  47503. */ step(delta: number): void;
  47504. /**
  47505. * Gets the current plugin used to run the simulation
  47506. * @returns current plugin
  47507. */
  47508. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47509. /**
  47510. * Gets the list of physic impostors
  47511. * @returns an array of PhysicsImpostor
  47512. */
  47513. getImpostors(): Array<PhysicsImpostor>;
  47514. /**
  47515. * Gets the impostor for a physics enabled object
  47516. * @param object defines the object impersonated by the impostor
  47517. * @returns the PhysicsImpostor or null if not found
  47518. */
  47519. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47520. /**
  47521. * Gets the impostor for a physics body object
  47522. * @param body defines physics body used by the impostor
  47523. * @returns the PhysicsImpostor or null if not found
  47524. */
  47525. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47526. /**
  47527. * Does a raycast in the physics world
  47528. * @param from when should the ray start?
  47529. * @param to when should the ray end?
  47530. * @returns PhysicsRaycastResult
  47531. */
  47532. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47533. }
  47534. }
  47535. declare module BABYLON {
  47536. /** @hidden */
  47537. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47538. private _useDeltaForWorldStep;
  47539. world: any;
  47540. name: string;
  47541. private _physicsMaterials;
  47542. private _fixedTimeStep;
  47543. private _cannonRaycastResult;
  47544. private _raycastResult;
  47545. private _removeAfterStep;
  47546. BJSCANNON: any;
  47547. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47548. setGravity(gravity: Vector3): void;
  47549. setTimeStep(timeStep: number): void;
  47550. getTimeStep(): number;
  47551. executeStep(delta: number): void;
  47552. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47553. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47554. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47555. private _processChildMeshes;
  47556. removePhysicsBody(impostor: PhysicsImpostor): void;
  47557. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47558. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47559. private _addMaterial;
  47560. private _checkWithEpsilon;
  47561. private _createShape;
  47562. private _createHeightmap;
  47563. private _minus90X;
  47564. private _plus90X;
  47565. private _tmpPosition;
  47566. private _tmpDeltaPosition;
  47567. private _tmpUnityRotation;
  47568. private _updatePhysicsBodyTransformation;
  47569. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47570. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47571. isSupported(): boolean;
  47572. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47573. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47574. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47575. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47576. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47577. getBodyMass(impostor: PhysicsImpostor): number;
  47578. getBodyFriction(impostor: PhysicsImpostor): number;
  47579. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47580. getBodyRestitution(impostor: PhysicsImpostor): number;
  47581. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47582. sleepBody(impostor: PhysicsImpostor): void;
  47583. wakeUpBody(impostor: PhysicsImpostor): void;
  47584. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47585. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47586. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47587. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47588. getRadius(impostor: PhysicsImpostor): number;
  47589. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47590. dispose(): void;
  47591. private _extendNamespace;
  47592. /**
  47593. * Does a raycast in the physics world
  47594. * @param from when should the ray start?
  47595. * @param to when should the ray end?
  47596. * @returns PhysicsRaycastResult
  47597. */
  47598. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47599. }
  47600. }
  47601. declare module BABYLON {
  47602. /** @hidden */
  47603. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47604. world: any;
  47605. name: string;
  47606. BJSOIMO: any;
  47607. private _raycastResult;
  47608. constructor(iterations?: number, oimoInjection?: any);
  47609. setGravity(gravity: Vector3): void;
  47610. setTimeStep(timeStep: number): void;
  47611. getTimeStep(): number;
  47612. private _tmpImpostorsArray;
  47613. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47617. private _tmpPositionVector;
  47618. removePhysicsBody(impostor: PhysicsImpostor): void;
  47619. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47621. isSupported(): boolean;
  47622. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47623. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47624. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47625. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47626. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47627. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47628. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47629. getBodyMass(impostor: PhysicsImpostor): number;
  47630. getBodyFriction(impostor: PhysicsImpostor): number;
  47631. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47632. getBodyRestitution(impostor: PhysicsImpostor): number;
  47633. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47634. sleepBody(impostor: PhysicsImpostor): void;
  47635. wakeUpBody(impostor: PhysicsImpostor): void;
  47636. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47637. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47638. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47639. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47640. getRadius(impostor: PhysicsImpostor): number;
  47641. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47642. dispose(): void;
  47643. /**
  47644. * Does a raycast in the physics world
  47645. * @param from when should the ray start?
  47646. * @param to when should the ray end?
  47647. * @returns PhysicsRaycastResult
  47648. */
  47649. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47650. }
  47651. }
  47652. declare module BABYLON {
  47653. /**
  47654. * Class containing static functions to help procedurally build meshes
  47655. */
  47656. export class RibbonBuilder {
  47657. /**
  47658. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47659. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47660. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47661. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47662. * * 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
  47663. * * 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
  47664. * * 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
  47665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47666. * * 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
  47667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47668. * * 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
  47669. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47670. * * 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
  47671. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47673. * @param name defines the name of the mesh
  47674. * @param options defines the options used to create the mesh
  47675. * @param scene defines the hosting scene
  47676. * @returns the ribbon mesh
  47677. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47678. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47679. */
  47680. static CreateRibbon(name: string, options: {
  47681. pathArray: Vector3[][];
  47682. closeArray?: boolean;
  47683. closePath?: boolean;
  47684. offset?: number;
  47685. updatable?: boolean;
  47686. sideOrientation?: number;
  47687. frontUVs?: Vector4;
  47688. backUVs?: Vector4;
  47689. instance?: Mesh;
  47690. invertUV?: boolean;
  47691. uvs?: Vector2[];
  47692. colors?: Color4[];
  47693. }, scene?: Nullable<Scene>): Mesh;
  47694. }
  47695. }
  47696. declare module BABYLON {
  47697. /**
  47698. * Class containing static functions to help procedurally build meshes
  47699. */
  47700. export class ShapeBuilder {
  47701. /**
  47702. * 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.
  47703. * * 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.
  47704. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47705. * * 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.
  47706. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47707. * * 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
  47708. * * 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
  47709. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47711. * * 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
  47712. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47714. * @param name defines the name of the mesh
  47715. * @param options defines the options used to create the mesh
  47716. * @param scene defines the hosting scene
  47717. * @returns the extruded shape mesh
  47718. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47720. */
  47721. static ExtrudeShape(name: string, options: {
  47722. shape: Vector3[];
  47723. path: Vector3[];
  47724. scale?: number;
  47725. rotation?: number;
  47726. cap?: number;
  47727. updatable?: boolean;
  47728. sideOrientation?: number;
  47729. frontUVs?: Vector4;
  47730. backUVs?: Vector4;
  47731. instance?: Mesh;
  47732. invertUV?: boolean;
  47733. }, scene?: Nullable<Scene>): Mesh;
  47734. /**
  47735. * Creates an custom extruded shape mesh.
  47736. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47737. * * 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.
  47738. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47739. * * 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
  47740. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47741. * * 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
  47742. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47743. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47744. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47745. * * 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
  47746. * * 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
  47747. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47749. * * 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
  47750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47752. * @param name defines the name of the mesh
  47753. * @param options defines the options used to create the mesh
  47754. * @param scene defines the hosting scene
  47755. * @returns the custom extruded shape mesh
  47756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47759. */
  47760. static ExtrudeShapeCustom(name: string, options: {
  47761. shape: Vector3[];
  47762. path: Vector3[];
  47763. scaleFunction?: any;
  47764. rotationFunction?: any;
  47765. ribbonCloseArray?: boolean;
  47766. ribbonClosePath?: boolean;
  47767. cap?: number;
  47768. updatable?: boolean;
  47769. sideOrientation?: number;
  47770. frontUVs?: Vector4;
  47771. backUVs?: Vector4;
  47772. instance?: Mesh;
  47773. invertUV?: boolean;
  47774. }, scene?: Nullable<Scene>): Mesh;
  47775. private static _ExtrudeShapeGeneric;
  47776. }
  47777. }
  47778. declare module BABYLON {
  47779. /**
  47780. * AmmoJS Physics plugin
  47781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47782. * @see https://github.com/kripken/ammo.js/
  47783. */
  47784. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47785. private _useDeltaForWorldStep;
  47786. /**
  47787. * Reference to the Ammo library
  47788. */
  47789. bjsAMMO: any;
  47790. /**
  47791. * Created ammoJS world which physics bodies are added to
  47792. */
  47793. world: any;
  47794. /**
  47795. * Name of the plugin
  47796. */
  47797. name: string;
  47798. private _timeStep;
  47799. private _fixedTimeStep;
  47800. private _maxSteps;
  47801. private _tmpQuaternion;
  47802. private _tmpAmmoTransform;
  47803. private _tmpAmmoQuaternion;
  47804. private _tmpAmmoConcreteContactResultCallback;
  47805. private _collisionConfiguration;
  47806. private _dispatcher;
  47807. private _overlappingPairCache;
  47808. private _solver;
  47809. private _softBodySolver;
  47810. private _tmpAmmoVectorA;
  47811. private _tmpAmmoVectorB;
  47812. private _tmpAmmoVectorC;
  47813. private _tmpAmmoVectorD;
  47814. private _tmpContactCallbackResult;
  47815. private _tmpAmmoVectorRCA;
  47816. private _tmpAmmoVectorRCB;
  47817. private _raycastResult;
  47818. private static readonly DISABLE_COLLISION_FLAG;
  47819. private static readonly KINEMATIC_FLAG;
  47820. private static readonly DISABLE_DEACTIVATION_FLAG;
  47821. /**
  47822. * Initializes the ammoJS plugin
  47823. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47824. * @param ammoInjection can be used to inject your own ammo reference
  47825. */
  47826. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47827. /**
  47828. * Sets the gravity of the physics world (m/(s^2))
  47829. * @param gravity Gravity to set
  47830. */
  47831. setGravity(gravity: Vector3): void;
  47832. /**
  47833. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47834. * @param timeStep timestep to use in seconds
  47835. */
  47836. setTimeStep(timeStep: number): void;
  47837. /**
  47838. * 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)
  47839. * @param fixedTimeStep fixedTimeStep to use in seconds
  47840. */
  47841. setFixedTimeStep(fixedTimeStep: number): void;
  47842. /**
  47843. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47844. * @param maxSteps the maximum number of steps by the physics engine per frame
  47845. */
  47846. setMaxSteps(maxSteps: number): void;
  47847. /**
  47848. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47849. * @returns the current timestep in seconds
  47850. */
  47851. getTimeStep(): number;
  47852. private _isImpostorInContact;
  47853. private _isImpostorPairInContact;
  47854. private _stepSimulation;
  47855. /**
  47856. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47857. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47858. * After the step the babylon meshes are set to the position of the physics imposters
  47859. * @param delta amount of time to step forward
  47860. * @param impostors array of imposters to update before/after the step
  47861. */
  47862. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47863. /**
  47864. * Update babylon mesh to match physics world object
  47865. * @param impostor imposter to match
  47866. */
  47867. private _afterSoftStep;
  47868. /**
  47869. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47870. * @param impostor imposter to match
  47871. */
  47872. private _ropeStep;
  47873. /**
  47874. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47875. * @param impostor imposter to match
  47876. */
  47877. private _softbodyOrClothStep;
  47878. private _tmpVector;
  47879. private _tmpMatrix;
  47880. /**
  47881. * Applies an impulse on the imposter
  47882. * @param impostor imposter to apply impulse to
  47883. * @param force amount of force to be applied to the imposter
  47884. * @param contactPoint the location to apply the impulse on the imposter
  47885. */
  47886. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47887. /**
  47888. * Applies a force on the imposter
  47889. * @param impostor imposter to apply force
  47890. * @param force amount of force to be applied to the imposter
  47891. * @param contactPoint the location to apply the force on the imposter
  47892. */
  47893. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47894. /**
  47895. * Creates a physics body using the plugin
  47896. * @param impostor the imposter to create the physics body on
  47897. */
  47898. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47899. /**
  47900. * Removes the physics body from the imposter and disposes of the body's memory
  47901. * @param impostor imposter to remove the physics body from
  47902. */
  47903. removePhysicsBody(impostor: PhysicsImpostor): void;
  47904. /**
  47905. * Generates a joint
  47906. * @param impostorJoint the imposter joint to create the joint with
  47907. */
  47908. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47909. /**
  47910. * Removes a joint
  47911. * @param impostorJoint the imposter joint to remove the joint from
  47912. */
  47913. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47914. private _addMeshVerts;
  47915. /**
  47916. * Initialise the soft body vertices to match its object's (mesh) vertices
  47917. * Softbody vertices (nodes) are in world space and to match this
  47918. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47919. * @param impostor to create the softbody for
  47920. */
  47921. private _softVertexData;
  47922. /**
  47923. * Create an impostor's soft body
  47924. * @param impostor to create the softbody for
  47925. */
  47926. private _createSoftbody;
  47927. /**
  47928. * Create cloth for an impostor
  47929. * @param impostor to create the softbody for
  47930. */
  47931. private _createCloth;
  47932. /**
  47933. * Create rope for an impostor
  47934. * @param impostor to create the softbody for
  47935. */
  47936. private _createRope;
  47937. private _addHullVerts;
  47938. private _createShape;
  47939. /**
  47940. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47941. * @param impostor imposter containing the physics body and babylon object
  47942. */
  47943. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47944. /**
  47945. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47946. * @param impostor imposter containing the physics body and babylon object
  47947. * @param newPosition new position
  47948. * @param newRotation new rotation
  47949. */
  47950. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47951. /**
  47952. * If this plugin is supported
  47953. * @returns true if its supported
  47954. */
  47955. isSupported(): boolean;
  47956. /**
  47957. * Sets the linear velocity of the physics body
  47958. * @param impostor imposter to set the velocity on
  47959. * @param velocity velocity to set
  47960. */
  47961. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47962. /**
  47963. * Sets the angular velocity of the physics body
  47964. * @param impostor imposter to set the velocity on
  47965. * @param velocity velocity to set
  47966. */
  47967. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47968. /**
  47969. * gets the linear velocity
  47970. * @param impostor imposter to get linear velocity from
  47971. * @returns linear velocity
  47972. */
  47973. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47974. /**
  47975. * gets the angular velocity
  47976. * @param impostor imposter to get angular velocity from
  47977. * @returns angular velocity
  47978. */
  47979. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47980. /**
  47981. * Sets the mass of physics body
  47982. * @param impostor imposter to set the mass on
  47983. * @param mass mass to set
  47984. */
  47985. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47986. /**
  47987. * Gets the mass of the physics body
  47988. * @param impostor imposter to get the mass from
  47989. * @returns mass
  47990. */
  47991. getBodyMass(impostor: PhysicsImpostor): number;
  47992. /**
  47993. * Gets friction of the impostor
  47994. * @param impostor impostor to get friction from
  47995. * @returns friction value
  47996. */
  47997. getBodyFriction(impostor: PhysicsImpostor): number;
  47998. /**
  47999. * Sets friction of the impostor
  48000. * @param impostor impostor to set friction on
  48001. * @param friction friction value
  48002. */
  48003. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48004. /**
  48005. * Gets restitution of the impostor
  48006. * @param impostor impostor to get restitution from
  48007. * @returns restitution value
  48008. */
  48009. getBodyRestitution(impostor: PhysicsImpostor): number;
  48010. /**
  48011. * Sets resitution of the impostor
  48012. * @param impostor impostor to set resitution on
  48013. * @param restitution resitution value
  48014. */
  48015. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48016. /**
  48017. * Gets pressure inside the impostor
  48018. * @param impostor impostor to get pressure from
  48019. * @returns pressure value
  48020. */
  48021. getBodyPressure(impostor: PhysicsImpostor): number;
  48022. /**
  48023. * Sets pressure inside a soft body impostor
  48024. * Cloth and rope must remain 0 pressure
  48025. * @param impostor impostor to set pressure on
  48026. * @param pressure pressure value
  48027. */
  48028. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48029. /**
  48030. * Gets stiffness of the impostor
  48031. * @param impostor impostor to get stiffness from
  48032. * @returns pressure value
  48033. */
  48034. getBodyStiffness(impostor: PhysicsImpostor): number;
  48035. /**
  48036. * Sets stiffness of the impostor
  48037. * @param impostor impostor to set stiffness on
  48038. * @param stiffness stiffness value from 0 to 1
  48039. */
  48040. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48041. /**
  48042. * Gets velocityIterations of the impostor
  48043. * @param impostor impostor to get velocity iterations from
  48044. * @returns velocityIterations value
  48045. */
  48046. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48047. /**
  48048. * Sets velocityIterations of the impostor
  48049. * @param impostor impostor to set velocity iterations on
  48050. * @param velocityIterations velocityIterations value
  48051. */
  48052. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48053. /**
  48054. * Gets positionIterations of the impostor
  48055. * @param impostor impostor to get position iterations from
  48056. * @returns positionIterations value
  48057. */
  48058. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48059. /**
  48060. * Sets positionIterations of the impostor
  48061. * @param impostor impostor to set position on
  48062. * @param positionIterations positionIterations value
  48063. */
  48064. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48065. /**
  48066. * Append an anchor to a cloth object
  48067. * @param impostor is the cloth impostor to add anchor to
  48068. * @param otherImpostor is the rigid impostor to anchor to
  48069. * @param width ratio across width from 0 to 1
  48070. * @param height ratio up height from 0 to 1
  48071. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48072. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48073. */
  48074. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48075. /**
  48076. * Append an hook to a rope object
  48077. * @param impostor is the rope impostor to add hook to
  48078. * @param otherImpostor is the rigid impostor to hook to
  48079. * @param length ratio along the rope from 0 to 1
  48080. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48081. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48082. */
  48083. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48084. /**
  48085. * Sleeps the physics body and stops it from being active
  48086. * @param impostor impostor to sleep
  48087. */
  48088. sleepBody(impostor: PhysicsImpostor): void;
  48089. /**
  48090. * Activates the physics body
  48091. * @param impostor impostor to activate
  48092. */
  48093. wakeUpBody(impostor: PhysicsImpostor): void;
  48094. /**
  48095. * Updates the distance parameters of the joint
  48096. * @param joint joint to update
  48097. * @param maxDistance maximum distance of the joint
  48098. * @param minDistance minimum distance of the joint
  48099. */
  48100. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48101. /**
  48102. * Sets a motor on the joint
  48103. * @param joint joint to set motor on
  48104. * @param speed speed of the motor
  48105. * @param maxForce maximum force of the motor
  48106. * @param motorIndex index of the motor
  48107. */
  48108. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48109. /**
  48110. * Sets the motors limit
  48111. * @param joint joint to set limit on
  48112. * @param upperLimit upper limit
  48113. * @param lowerLimit lower limit
  48114. */
  48115. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48116. /**
  48117. * Syncs the position and rotation of a mesh with the impostor
  48118. * @param mesh mesh to sync
  48119. * @param impostor impostor to update the mesh with
  48120. */
  48121. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48122. /**
  48123. * Gets the radius of the impostor
  48124. * @param impostor impostor to get radius from
  48125. * @returns the radius
  48126. */
  48127. getRadius(impostor: PhysicsImpostor): number;
  48128. /**
  48129. * Gets the box size of the impostor
  48130. * @param impostor impostor to get box size from
  48131. * @param result the resulting box size
  48132. */
  48133. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48134. /**
  48135. * Disposes of the impostor
  48136. */
  48137. dispose(): void;
  48138. /**
  48139. * Does a raycast in the physics world
  48140. * @param from when should the ray start?
  48141. * @param to when should the ray end?
  48142. * @returns PhysicsRaycastResult
  48143. */
  48144. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48145. }
  48146. }
  48147. declare module BABYLON {
  48148. interface AbstractScene {
  48149. /**
  48150. * The list of reflection probes added to the scene
  48151. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48152. */
  48153. reflectionProbes: Array<ReflectionProbe>;
  48154. /**
  48155. * Removes the given reflection probe from this scene.
  48156. * @param toRemove The reflection probe to remove
  48157. * @returns The index of the removed reflection probe
  48158. */
  48159. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48160. /**
  48161. * Adds the given reflection probe to this scene.
  48162. * @param newReflectionProbe The reflection probe to add
  48163. */
  48164. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48165. }
  48166. /**
  48167. * Class used to generate realtime reflection / refraction cube textures
  48168. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48169. */
  48170. export class ReflectionProbe {
  48171. /** defines the name of the probe */
  48172. name: string;
  48173. private _scene;
  48174. private _renderTargetTexture;
  48175. private _projectionMatrix;
  48176. private _viewMatrix;
  48177. private _target;
  48178. private _add;
  48179. private _attachedMesh;
  48180. private _invertYAxis;
  48181. /** Gets or sets probe position (center of the cube map) */
  48182. position: Vector3;
  48183. /**
  48184. * Creates a new reflection probe
  48185. * @param name defines the name of the probe
  48186. * @param size defines the texture resolution (for each face)
  48187. * @param scene defines the hosting scene
  48188. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48189. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48190. */
  48191. constructor(
  48192. /** defines the name of the probe */
  48193. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48194. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48195. samples: number;
  48196. /** Gets or sets the refresh rate to use (on every frame by default) */
  48197. refreshRate: number;
  48198. /**
  48199. * Gets the hosting scene
  48200. * @returns a Scene
  48201. */
  48202. getScene(): Scene;
  48203. /** Gets the internal CubeTexture used to render to */
  48204. readonly cubeTexture: RenderTargetTexture;
  48205. /** Gets the list of meshes to render */
  48206. readonly renderList: Nullable<AbstractMesh[]>;
  48207. /**
  48208. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48209. * @param mesh defines the mesh to attach to
  48210. */
  48211. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48212. /**
  48213. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48214. * @param renderingGroupId The rendering group id corresponding to its index
  48215. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48216. */
  48217. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48218. /**
  48219. * Clean all associated resources
  48220. */
  48221. dispose(): void;
  48222. /**
  48223. * Converts the reflection probe information to a readable string for debug purpose.
  48224. * @param fullDetails Supports for multiple levels of logging within scene loading
  48225. * @returns the human readable reflection probe info
  48226. */
  48227. toString(fullDetails?: boolean): string;
  48228. /**
  48229. * Get the class name of the relfection probe.
  48230. * @returns "ReflectionProbe"
  48231. */
  48232. getClassName(): string;
  48233. /**
  48234. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48235. * @returns The JSON representation of the texture
  48236. */
  48237. serialize(): any;
  48238. /**
  48239. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48240. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48241. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48242. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48243. * @returns The parsed reflection probe if successful
  48244. */
  48245. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48246. }
  48247. }
  48248. declare module BABYLON {
  48249. /** @hidden */
  48250. export var _BabylonLoaderRegistered: boolean;
  48251. }
  48252. declare module BABYLON {
  48253. /**
  48254. * The Physically based simple base material of BJS.
  48255. *
  48256. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48257. * It is used as the base class for both the specGloss and metalRough conventions.
  48258. */
  48259. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48260. /**
  48261. * Number of Simultaneous lights allowed on the material.
  48262. */
  48263. maxSimultaneousLights: number;
  48264. /**
  48265. * If sets to true, disables all the lights affecting the material.
  48266. */
  48267. disableLighting: boolean;
  48268. /**
  48269. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48270. */
  48271. environmentTexture: BaseTexture;
  48272. /**
  48273. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48274. */
  48275. invertNormalMapX: boolean;
  48276. /**
  48277. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48278. */
  48279. invertNormalMapY: boolean;
  48280. /**
  48281. * Normal map used in the model.
  48282. */
  48283. normalTexture: BaseTexture;
  48284. /**
  48285. * Emissivie color used to self-illuminate the model.
  48286. */
  48287. emissiveColor: Color3;
  48288. /**
  48289. * Emissivie texture used to self-illuminate the model.
  48290. */
  48291. emissiveTexture: BaseTexture;
  48292. /**
  48293. * Occlusion Channel Strenght.
  48294. */
  48295. occlusionStrength: number;
  48296. /**
  48297. * Occlusion Texture of the material (adding extra occlusion effects).
  48298. */
  48299. occlusionTexture: BaseTexture;
  48300. /**
  48301. * Defines the alpha limits in alpha test mode.
  48302. */
  48303. alphaCutOff: number;
  48304. /**
  48305. * Gets the current double sided mode.
  48306. */
  48307. /**
  48308. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48309. */
  48310. doubleSided: boolean;
  48311. /**
  48312. * Stores the pre-calculated light information of a mesh in a texture.
  48313. */
  48314. lightmapTexture: BaseTexture;
  48315. /**
  48316. * If true, the light map contains occlusion information instead of lighting info.
  48317. */
  48318. useLightmapAsShadowmap: boolean;
  48319. /**
  48320. * Instantiates a new PBRMaterial instance.
  48321. *
  48322. * @param name The material name
  48323. * @param scene The scene the material will be use in.
  48324. */
  48325. constructor(name: string, scene: Scene);
  48326. getClassName(): string;
  48327. }
  48328. }
  48329. declare module BABYLON {
  48330. /**
  48331. * The PBR material of BJS following the metal roughness convention.
  48332. *
  48333. * This fits to the PBR convention in the GLTF definition:
  48334. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48335. */
  48336. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48337. /**
  48338. * The base color has two different interpretations depending on the value of metalness.
  48339. * When the material is a metal, the base color is the specific measured reflectance value
  48340. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48341. * of the material.
  48342. */
  48343. baseColor: Color3;
  48344. /**
  48345. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48346. * well as opacity information in the alpha channel.
  48347. */
  48348. baseTexture: BaseTexture;
  48349. /**
  48350. * Specifies the metallic scalar value of the material.
  48351. * Can also be used to scale the metalness values of the metallic texture.
  48352. */
  48353. metallic: number;
  48354. /**
  48355. * Specifies the roughness scalar value of the material.
  48356. * Can also be used to scale the roughness values of the metallic texture.
  48357. */
  48358. roughness: number;
  48359. /**
  48360. * Texture containing both the metallic value in the B channel and the
  48361. * roughness value in the G channel to keep better precision.
  48362. */
  48363. metallicRoughnessTexture: BaseTexture;
  48364. /**
  48365. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48366. *
  48367. * @param name The material name
  48368. * @param scene The scene the material will be use in.
  48369. */
  48370. constructor(name: string, scene: Scene);
  48371. /**
  48372. * Return the currrent class name of the material.
  48373. */
  48374. getClassName(): string;
  48375. /**
  48376. * Makes a duplicate of the current material.
  48377. * @param name - name to use for the new material.
  48378. */
  48379. clone(name: string): PBRMetallicRoughnessMaterial;
  48380. /**
  48381. * Serialize the material to a parsable JSON object.
  48382. */
  48383. serialize(): any;
  48384. /**
  48385. * Parses a JSON object correponding to the serialize function.
  48386. */
  48387. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48388. }
  48389. }
  48390. declare module BABYLON {
  48391. /**
  48392. * The PBR material of BJS following the specular glossiness convention.
  48393. *
  48394. * This fits to the PBR convention in the GLTF definition:
  48395. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48396. */
  48397. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48398. /**
  48399. * Specifies the diffuse color of the material.
  48400. */
  48401. diffuseColor: Color3;
  48402. /**
  48403. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48404. * channel.
  48405. */
  48406. diffuseTexture: BaseTexture;
  48407. /**
  48408. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48409. */
  48410. specularColor: Color3;
  48411. /**
  48412. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48413. */
  48414. glossiness: number;
  48415. /**
  48416. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48417. */
  48418. specularGlossinessTexture: BaseTexture;
  48419. /**
  48420. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48421. *
  48422. * @param name The material name
  48423. * @param scene The scene the material will be use in.
  48424. */
  48425. constructor(name: string, scene: Scene);
  48426. /**
  48427. * Return the currrent class name of the material.
  48428. */
  48429. getClassName(): string;
  48430. /**
  48431. * Makes a duplicate of the current material.
  48432. * @param name - name to use for the new material.
  48433. */
  48434. clone(name: string): PBRSpecularGlossinessMaterial;
  48435. /**
  48436. * Serialize the material to a parsable JSON object.
  48437. */
  48438. serialize(): any;
  48439. /**
  48440. * Parses a JSON object correponding to the serialize function.
  48441. */
  48442. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48443. }
  48444. }
  48445. declare module BABYLON {
  48446. /**
  48447. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48448. * It can help converting any input color in a desired output one. This can then be used to create effects
  48449. * from sepia, black and white to sixties or futuristic rendering...
  48450. *
  48451. * The only supported format is currently 3dl.
  48452. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48453. */
  48454. export class ColorGradingTexture extends BaseTexture {
  48455. /**
  48456. * The current texture matrix. (will always be identity in color grading texture)
  48457. */
  48458. private _textureMatrix;
  48459. /**
  48460. * The texture URL.
  48461. */
  48462. url: string;
  48463. /**
  48464. * Empty line regex stored for GC.
  48465. */
  48466. private static _noneEmptyLineRegex;
  48467. private _engine;
  48468. /**
  48469. * Instantiates a ColorGradingTexture from the following parameters.
  48470. *
  48471. * @param url The location of the color gradind data (currently only supporting 3dl)
  48472. * @param scene The scene the texture will be used in
  48473. */
  48474. constructor(url: string, scene: Scene);
  48475. /**
  48476. * Returns the texture matrix used in most of the material.
  48477. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48478. */
  48479. getTextureMatrix(): Matrix;
  48480. /**
  48481. * Occurs when the file being loaded is a .3dl LUT file.
  48482. */
  48483. private load3dlTexture;
  48484. /**
  48485. * Starts the loading process of the texture.
  48486. */
  48487. private loadTexture;
  48488. /**
  48489. * Clones the color gradind texture.
  48490. */
  48491. clone(): ColorGradingTexture;
  48492. /**
  48493. * Called during delayed load for textures.
  48494. */
  48495. delayLoad(): void;
  48496. /**
  48497. * Parses a color grading texture serialized by Babylon.
  48498. * @param parsedTexture The texture information being parsedTexture
  48499. * @param scene The scene to load the texture in
  48500. * @param rootUrl The root url of the data assets to load
  48501. * @return A color gradind texture
  48502. */
  48503. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48504. /**
  48505. * Serializes the LUT texture to json format.
  48506. */
  48507. serialize(): any;
  48508. }
  48509. }
  48510. declare module BABYLON {
  48511. /**
  48512. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48513. */
  48514. export class EquiRectangularCubeTexture extends BaseTexture {
  48515. /** The six faces of the cube. */
  48516. private static _FacesMapping;
  48517. private _noMipmap;
  48518. private _onLoad;
  48519. private _onError;
  48520. /** The size of the cubemap. */
  48521. private _size;
  48522. /** The buffer of the image. */
  48523. private _buffer;
  48524. /** The width of the input image. */
  48525. private _width;
  48526. /** The height of the input image. */
  48527. private _height;
  48528. /** The URL to the image. */
  48529. url: string;
  48530. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48531. coordinatesMode: number;
  48532. /**
  48533. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48534. * @param url The location of the image
  48535. * @param scene The scene the texture will be used in
  48536. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48537. * @param noMipmap Forces to not generate the mipmap if true
  48538. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48539. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48540. * @param onLoad — defines a callback called when texture is loaded
  48541. * @param onError — defines a callback called if there is an error
  48542. */
  48543. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48544. /**
  48545. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48546. */
  48547. private loadImage;
  48548. /**
  48549. * Convert the image buffer into a cubemap and create a CubeTexture.
  48550. */
  48551. private loadTexture;
  48552. /**
  48553. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48554. * @param buffer The ArrayBuffer that should be converted.
  48555. * @returns The buffer as Float32Array.
  48556. */
  48557. private getFloat32ArrayFromArrayBuffer;
  48558. /**
  48559. * Get the current class name of the texture useful for serialization or dynamic coding.
  48560. * @returns "EquiRectangularCubeTexture"
  48561. */
  48562. getClassName(): string;
  48563. /**
  48564. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48565. * @returns A clone of the current EquiRectangularCubeTexture.
  48566. */
  48567. clone(): EquiRectangularCubeTexture;
  48568. }
  48569. }
  48570. declare module BABYLON {
  48571. /**
  48572. * Based on jsTGALoader - Javascript loader for TGA file
  48573. * By Vincent Thibault
  48574. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48575. */
  48576. export class TGATools {
  48577. private static _TYPE_INDEXED;
  48578. private static _TYPE_RGB;
  48579. private static _TYPE_GREY;
  48580. private static _TYPE_RLE_INDEXED;
  48581. private static _TYPE_RLE_RGB;
  48582. private static _TYPE_RLE_GREY;
  48583. private static _ORIGIN_MASK;
  48584. private static _ORIGIN_SHIFT;
  48585. private static _ORIGIN_BL;
  48586. private static _ORIGIN_BR;
  48587. private static _ORIGIN_UL;
  48588. private static _ORIGIN_UR;
  48589. /**
  48590. * Gets the header of a TGA file
  48591. * @param data defines the TGA data
  48592. * @returns the header
  48593. */
  48594. static GetTGAHeader(data: Uint8Array): any;
  48595. /**
  48596. * Uploads TGA content to a Babylon Texture
  48597. * @hidden
  48598. */
  48599. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48600. /** @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;
  48601. /** @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;
  48602. /** @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;
  48603. /** @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;
  48604. /** @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;
  48605. /** @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;
  48606. }
  48607. }
  48608. declare module BABYLON {
  48609. /**
  48610. * Implementation of the TGA Texture Loader.
  48611. * @hidden
  48612. */
  48613. export class _TGATextureLoader implements IInternalTextureLoader {
  48614. /**
  48615. * Defines wether the loader supports cascade loading the different faces.
  48616. */
  48617. readonly supportCascades: boolean;
  48618. /**
  48619. * This returns if the loader support the current file information.
  48620. * @param extension defines the file extension of the file being loaded
  48621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48622. * @param fallback defines the fallback internal texture if any
  48623. * @param isBase64 defines whether the texture is encoded as a base64
  48624. * @param isBuffer defines whether the texture data are stored as a buffer
  48625. * @returns true if the loader can load the specified file
  48626. */
  48627. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48628. /**
  48629. * Transform the url before loading if required.
  48630. * @param rootUrl the url of the texture
  48631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48632. * @returns the transformed texture
  48633. */
  48634. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48635. /**
  48636. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48637. * @param rootUrl the url of the texture
  48638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48639. * @returns the fallback texture
  48640. */
  48641. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48642. /**
  48643. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48644. * @param data contains the texture data
  48645. * @param texture defines the BabylonJS internal texture
  48646. * @param createPolynomials will be true if polynomials have been requested
  48647. * @param onLoad defines the callback to trigger once the texture is ready
  48648. * @param onError defines the callback to trigger in case of error
  48649. */
  48650. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48651. /**
  48652. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48653. * @param data contains the texture data
  48654. * @param texture defines the BabylonJS internal texture
  48655. * @param callback defines the method to call once ready to upload
  48656. */
  48657. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48658. }
  48659. }
  48660. declare module BABYLON {
  48661. /**
  48662. * 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.
  48663. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48664. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48665. */
  48666. export class CustomProceduralTexture extends ProceduralTexture {
  48667. private _animate;
  48668. private _time;
  48669. private _config;
  48670. private _texturePath;
  48671. /**
  48672. * Instantiates a new Custom Procedural Texture.
  48673. * 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.
  48674. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48675. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48676. * @param name Define the name of the texture
  48677. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48678. * @param size Define the size of the texture to create
  48679. * @param scene Define the scene the texture belongs to
  48680. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48681. * @param generateMipMaps Define if the texture should creates mip maps or not
  48682. */
  48683. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48684. private _loadJson;
  48685. /**
  48686. * Is the texture ready to be used ? (rendered at least once)
  48687. * @returns true if ready, otherwise, false.
  48688. */
  48689. isReady(): boolean;
  48690. /**
  48691. * Render the texture to its associated render target.
  48692. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48693. */
  48694. render(useCameraPostProcess?: boolean): void;
  48695. /**
  48696. * Update the list of dependant textures samplers in the shader.
  48697. */
  48698. updateTextures(): void;
  48699. /**
  48700. * Update the uniform values of the procedural texture in the shader.
  48701. */
  48702. updateShaderUniforms(): void;
  48703. /**
  48704. * Define if the texture animates or not.
  48705. */
  48706. animate: boolean;
  48707. }
  48708. }
  48709. declare module BABYLON {
  48710. /** @hidden */
  48711. export var noisePixelShader: {
  48712. name: string;
  48713. shader: string;
  48714. };
  48715. }
  48716. declare module BABYLON {
  48717. /**
  48718. * Class used to generate noise procedural textures
  48719. */
  48720. export class NoiseProceduralTexture extends ProceduralTexture {
  48721. private _time;
  48722. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48723. brightness: number;
  48724. /** Defines the number of octaves to process */
  48725. octaves: number;
  48726. /** Defines the level of persistence (0.8 by default) */
  48727. persistence: number;
  48728. /** Gets or sets animation speed factor (default is 1) */
  48729. animationSpeedFactor: number;
  48730. /**
  48731. * Creates a new NoiseProceduralTexture
  48732. * @param name defines the name fo the texture
  48733. * @param size defines the size of the texture (default is 256)
  48734. * @param scene defines the hosting scene
  48735. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48736. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48737. */
  48738. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48739. private _updateShaderUniforms;
  48740. protected _getDefines(): string;
  48741. /** Generate the current state of the procedural texture */
  48742. render(useCameraPostProcess?: boolean): void;
  48743. /**
  48744. * Serializes this noise procedural texture
  48745. * @returns a serialized noise procedural texture object
  48746. */
  48747. serialize(): any;
  48748. /**
  48749. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48750. * @param parsedTexture defines parsed texture data
  48751. * @param scene defines the current scene
  48752. * @param rootUrl defines the root URL containing noise procedural texture information
  48753. * @returns a parsed NoiseProceduralTexture
  48754. */
  48755. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48756. }
  48757. }
  48758. declare module BABYLON {
  48759. /**
  48760. * Raw cube texture where the raw buffers are passed in
  48761. */
  48762. export class RawCubeTexture extends CubeTexture {
  48763. /**
  48764. * Creates a cube texture where the raw buffers are passed in.
  48765. * @param scene defines the scene the texture is attached to
  48766. * @param data defines the array of data to use to create each face
  48767. * @param size defines the size of the textures
  48768. * @param format defines the format of the data
  48769. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48770. * @param generateMipMaps defines if the engine should generate the mip levels
  48771. * @param invertY defines if data must be stored with Y axis inverted
  48772. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48773. * @param compression defines the compression used (null by default)
  48774. */
  48775. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48776. /**
  48777. * Updates the raw cube texture.
  48778. * @param data defines the data to store
  48779. * @param format defines the data format
  48780. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48781. * @param invertY defines if data must be stored with Y axis inverted
  48782. * @param compression defines the compression used (null by default)
  48783. * @param level defines which level of the texture to update
  48784. */
  48785. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48786. /**
  48787. * Updates a raw cube texture with RGBD encoded data.
  48788. * @param data defines the array of data [mipmap][face] to use to create each face
  48789. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48792. * @returns a promsie that resolves when the operation is complete
  48793. */
  48794. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48795. /**
  48796. * Clones the raw cube texture.
  48797. * @return a new cube texture
  48798. */
  48799. clone(): CubeTexture;
  48800. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48801. }
  48802. }
  48803. declare module BABYLON {
  48804. /**
  48805. * Class used to store 3D textures containing user data
  48806. */
  48807. export class RawTexture3D extends Texture {
  48808. /** Gets or sets the texture format to use */
  48809. format: number;
  48810. private _engine;
  48811. /**
  48812. * Create a new RawTexture3D
  48813. * @param data defines the data of the texture
  48814. * @param width defines the width of the texture
  48815. * @param height defines the height of the texture
  48816. * @param depth defines the depth of the texture
  48817. * @param format defines the texture format to use
  48818. * @param scene defines the hosting scene
  48819. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48820. * @param invertY defines if texture must be stored with Y axis inverted
  48821. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48822. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48823. */
  48824. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48825. /** Gets or sets the texture format to use */
  48826. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48827. /**
  48828. * Update the texture with new data
  48829. * @param data defines the data to store in the texture
  48830. */
  48831. update(data: ArrayBufferView): void;
  48832. }
  48833. }
  48834. declare module BABYLON {
  48835. /**
  48836. * Creates a refraction texture used by refraction channel of the standard material.
  48837. * It is like a mirror but to see through a material.
  48838. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48839. */
  48840. export class RefractionTexture extends RenderTargetTexture {
  48841. /**
  48842. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48843. * 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.
  48844. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48845. */
  48846. refractionPlane: Plane;
  48847. /**
  48848. * Define how deep under the surface we should see.
  48849. */
  48850. depth: number;
  48851. /**
  48852. * Creates a refraction texture used by refraction channel of the standard material.
  48853. * It is like a mirror but to see through a material.
  48854. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48855. * @param name Define the texture name
  48856. * @param size Define the size of the underlying texture
  48857. * @param scene Define the scene the refraction belongs to
  48858. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48859. */
  48860. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48861. /**
  48862. * Clone the refraction texture.
  48863. * @returns the cloned texture
  48864. */
  48865. clone(): RefractionTexture;
  48866. /**
  48867. * Serialize the texture to a JSON representation you could use in Parse later on
  48868. * @returns the serialized JSON representation
  48869. */
  48870. serialize(): any;
  48871. }
  48872. }
  48873. declare module BABYLON {
  48874. /**
  48875. * Defines the options related to the creation of an HtmlElementTexture
  48876. */
  48877. export interface IHtmlElementTextureOptions {
  48878. /**
  48879. * Defines wether mip maps should be created or not.
  48880. */
  48881. generateMipMaps?: boolean;
  48882. /**
  48883. * Defines the sampling mode of the texture.
  48884. */
  48885. samplingMode?: number;
  48886. /**
  48887. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  48888. */
  48889. engine: Nullable<Engine>;
  48890. /**
  48891. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  48892. */
  48893. scene: Nullable<Scene>;
  48894. }
  48895. /**
  48896. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  48897. * To be as efficient as possible depending on your constraints nothing aside the first upload
  48898. * is automatically managed.
  48899. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  48900. * in your application.
  48901. *
  48902. * As the update is not automatic, you need to call them manually.
  48903. */
  48904. export class HtmlElementTexture extends BaseTexture {
  48905. /**
  48906. * The texture URL.
  48907. */
  48908. element: HTMLVideoElement | HTMLCanvasElement;
  48909. private static readonly DefaultOptions;
  48910. private _textureMatrix;
  48911. private _engine;
  48912. private _isVideo;
  48913. private _generateMipMaps;
  48914. private _samplingMode;
  48915. /**
  48916. * Instantiates a HtmlElementTexture from the following parameters.
  48917. *
  48918. * @param name Defines the name of the texture
  48919. * @param element Defines the video or canvas the texture is filled with
  48920. * @param options Defines the other none mandatory texture creation options
  48921. */
  48922. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  48923. private _createInternalTexture;
  48924. /**
  48925. * Returns the texture matrix used in most of the material.
  48926. */
  48927. getTextureMatrix(): Matrix;
  48928. /**
  48929. * Updates the content of the texture.
  48930. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  48931. */
  48932. update(invertY?: Nullable<boolean>): void;
  48933. }
  48934. }
  48935. declare module BABYLON {
  48936. /**
  48937. * Helper class to push actions to a pool of workers.
  48938. */
  48939. export class WorkerPool implements IDisposable {
  48940. private _workerInfos;
  48941. private _pendingActions;
  48942. /**
  48943. * Constructor
  48944. * @param workers Array of workers to use for actions
  48945. */
  48946. constructor(workers: Array<Worker>);
  48947. /**
  48948. * Terminates all workers and clears any pending actions.
  48949. */
  48950. dispose(): void;
  48951. /**
  48952. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48953. * pended until a worker has completed its action.
  48954. * @param action The action to perform. Call onComplete when the action is complete.
  48955. */
  48956. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48957. private _execute;
  48958. }
  48959. }
  48960. declare module BABYLON {
  48961. /**
  48962. * Configuration for Draco compression
  48963. */
  48964. export interface IDracoCompressionConfiguration {
  48965. /**
  48966. * Configuration for the decoder.
  48967. */
  48968. decoder: {
  48969. /**
  48970. * The url to the WebAssembly module.
  48971. */
  48972. wasmUrl?: string;
  48973. /**
  48974. * The url to the WebAssembly binary.
  48975. */
  48976. wasmBinaryUrl?: string;
  48977. /**
  48978. * The url to the fallback JavaScript module.
  48979. */
  48980. fallbackUrl?: string;
  48981. };
  48982. }
  48983. /**
  48984. * Draco compression (https://google.github.io/draco/)
  48985. *
  48986. * This class wraps the Draco module.
  48987. *
  48988. * **Encoder**
  48989. *
  48990. * The encoder is not currently implemented.
  48991. *
  48992. * **Decoder**
  48993. *
  48994. * 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.
  48995. *
  48996. * To update the configuration, use the following code:
  48997. * ```javascript
  48998. * DracoCompression.Configuration = {
  48999. * decoder: {
  49000. * wasmUrl: "<url to the WebAssembly library>",
  49001. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49002. * fallbackUrl: "<url to the fallback JavaScript library>",
  49003. * }
  49004. * };
  49005. * ```
  49006. *
  49007. * 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.
  49008. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49009. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49010. *
  49011. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49012. * ```javascript
  49013. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49014. * ```
  49015. *
  49016. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49017. */
  49018. export class DracoCompression implements IDisposable {
  49019. private _workerPoolPromise?;
  49020. private _decoderModulePromise?;
  49021. /**
  49022. * The configuration. Defaults to the following urls:
  49023. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49024. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49025. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49026. */
  49027. static Configuration: IDracoCompressionConfiguration;
  49028. /**
  49029. * Returns true if the decoder configuration is available.
  49030. */
  49031. static readonly DecoderAvailable: boolean;
  49032. /**
  49033. * Default number of workers to create when creating the draco compression object.
  49034. */
  49035. static DefaultNumWorkers: number;
  49036. private static GetDefaultNumWorkers;
  49037. private static _Default;
  49038. /**
  49039. * Default instance for the draco compression object.
  49040. */
  49041. static readonly Default: DracoCompression;
  49042. /**
  49043. * Constructor
  49044. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49045. */
  49046. constructor(numWorkers?: number);
  49047. /**
  49048. * Stop all async operations and release resources.
  49049. */
  49050. dispose(): void;
  49051. /**
  49052. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49053. * @returns a promise that resolves when ready
  49054. */
  49055. whenReadyAsync(): Promise<void>;
  49056. /**
  49057. * Decode Draco compressed mesh data to vertex data.
  49058. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49059. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49060. * @returns A promise that resolves with the decoded vertex data
  49061. */
  49062. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49063. [kind: string]: number;
  49064. }): Promise<VertexData>;
  49065. }
  49066. }
  49067. declare module BABYLON {
  49068. /**
  49069. * Class for building Constructive Solid Geometry
  49070. */
  49071. export class CSG {
  49072. private polygons;
  49073. /**
  49074. * The world matrix
  49075. */
  49076. matrix: Matrix;
  49077. /**
  49078. * Stores the position
  49079. */
  49080. position: Vector3;
  49081. /**
  49082. * Stores the rotation
  49083. */
  49084. rotation: Vector3;
  49085. /**
  49086. * Stores the rotation quaternion
  49087. */
  49088. rotationQuaternion: Nullable<Quaternion>;
  49089. /**
  49090. * Stores the scaling vector
  49091. */
  49092. scaling: Vector3;
  49093. /**
  49094. * Convert the Mesh to CSG
  49095. * @param mesh The Mesh to convert to CSG
  49096. * @returns A new CSG from the Mesh
  49097. */
  49098. static FromMesh(mesh: Mesh): CSG;
  49099. /**
  49100. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49101. * @param polygons Polygons used to construct a CSG solid
  49102. */
  49103. private static FromPolygons;
  49104. /**
  49105. * Clones, or makes a deep copy, of the CSG
  49106. * @returns A new CSG
  49107. */
  49108. clone(): CSG;
  49109. /**
  49110. * Unions this CSG with another CSG
  49111. * @param csg The CSG to union against this CSG
  49112. * @returns The unioned CSG
  49113. */
  49114. union(csg: CSG): CSG;
  49115. /**
  49116. * Unions this CSG with another CSG in place
  49117. * @param csg The CSG to union against this CSG
  49118. */
  49119. unionInPlace(csg: CSG): void;
  49120. /**
  49121. * Subtracts this CSG with another CSG
  49122. * @param csg The CSG to subtract against this CSG
  49123. * @returns A new CSG
  49124. */
  49125. subtract(csg: CSG): CSG;
  49126. /**
  49127. * Subtracts this CSG with another CSG in place
  49128. * @param csg The CSG to subtact against this CSG
  49129. */
  49130. subtractInPlace(csg: CSG): void;
  49131. /**
  49132. * Intersect this CSG with another CSG
  49133. * @param csg The CSG to intersect against this CSG
  49134. * @returns A new CSG
  49135. */
  49136. intersect(csg: CSG): CSG;
  49137. /**
  49138. * Intersects this CSG with another CSG in place
  49139. * @param csg The CSG to intersect against this CSG
  49140. */
  49141. intersectInPlace(csg: CSG): void;
  49142. /**
  49143. * Return a new CSG solid with solid and empty space switched. This solid is
  49144. * not modified.
  49145. * @returns A new CSG solid with solid and empty space switched
  49146. */
  49147. inverse(): CSG;
  49148. /**
  49149. * Inverses the CSG in place
  49150. */
  49151. inverseInPlace(): void;
  49152. /**
  49153. * This is used to keep meshes transformations so they can be restored
  49154. * when we build back a Babylon Mesh
  49155. * NB : All CSG operations are performed in world coordinates
  49156. * @param csg The CSG to copy the transform attributes from
  49157. * @returns This CSG
  49158. */
  49159. copyTransformAttributes(csg: CSG): CSG;
  49160. /**
  49161. * Build Raw mesh from CSG
  49162. * Coordinates here are in world space
  49163. * @param name The name of the mesh geometry
  49164. * @param scene The Scene
  49165. * @param keepSubMeshes Specifies if the submeshes should be kept
  49166. * @returns A new Mesh
  49167. */
  49168. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49169. /**
  49170. * Build Mesh from CSG taking material and transforms into account
  49171. * @param name The name of the Mesh
  49172. * @param material The material of the Mesh
  49173. * @param scene The Scene
  49174. * @param keepSubMeshes Specifies if submeshes should be kept
  49175. * @returns The new Mesh
  49176. */
  49177. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49178. }
  49179. }
  49180. declare module BABYLON {
  49181. /**
  49182. * Class used to create a trail following a mesh
  49183. */
  49184. export class TrailMesh extends Mesh {
  49185. private _generator;
  49186. private _autoStart;
  49187. private _running;
  49188. private _diameter;
  49189. private _length;
  49190. private _sectionPolygonPointsCount;
  49191. private _sectionVectors;
  49192. private _sectionNormalVectors;
  49193. private _beforeRenderObserver;
  49194. /**
  49195. * @constructor
  49196. * @param name The value used by scene.getMeshByName() to do a lookup.
  49197. * @param generator The mesh to generate a trail.
  49198. * @param scene The scene to add this mesh to.
  49199. * @param diameter Diameter of trailing mesh. Default is 1.
  49200. * @param length Length of trailing mesh. Default is 60.
  49201. * @param autoStart Automatically start trailing mesh. Default true.
  49202. */
  49203. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49204. /**
  49205. * "TrailMesh"
  49206. * @returns "TrailMesh"
  49207. */
  49208. getClassName(): string;
  49209. private _createMesh;
  49210. /**
  49211. * Start trailing mesh.
  49212. */
  49213. start(): void;
  49214. /**
  49215. * Stop trailing mesh.
  49216. */
  49217. stop(): void;
  49218. /**
  49219. * Update trailing mesh geometry.
  49220. */
  49221. update(): void;
  49222. /**
  49223. * Returns a new TrailMesh object.
  49224. * @param name is a string, the name given to the new mesh
  49225. * @param newGenerator use new generator object for cloned trail mesh
  49226. * @returns a new mesh
  49227. */
  49228. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49229. /**
  49230. * Serializes this trail mesh
  49231. * @param serializationObject object to write serialization to
  49232. */
  49233. serialize(serializationObject: any): void;
  49234. /**
  49235. * Parses a serialized trail mesh
  49236. * @param parsedMesh the serialized mesh
  49237. * @param scene the scene to create the trail mesh in
  49238. * @returns the created trail mesh
  49239. */
  49240. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49241. }
  49242. }
  49243. declare module BABYLON {
  49244. /**
  49245. * Class containing static functions to help procedurally build meshes
  49246. */
  49247. export class TorusKnotBuilder {
  49248. /**
  49249. * Creates a torus knot mesh
  49250. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49251. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49252. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49253. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49255. * * 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
  49256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49257. * @param name defines the name of the mesh
  49258. * @param options defines the options used to create the mesh
  49259. * @param scene defines the hosting scene
  49260. * @returns the torus knot mesh
  49261. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49262. */
  49263. static CreateTorusKnot(name: string, options: {
  49264. radius?: number;
  49265. tube?: number;
  49266. radialSegments?: number;
  49267. tubularSegments?: number;
  49268. p?: number;
  49269. q?: number;
  49270. updatable?: boolean;
  49271. sideOrientation?: number;
  49272. frontUVs?: Vector4;
  49273. backUVs?: Vector4;
  49274. }, scene: any): Mesh;
  49275. }
  49276. }
  49277. declare module BABYLON {
  49278. /**
  49279. * Polygon
  49280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49281. */
  49282. export class Polygon {
  49283. /**
  49284. * Creates a rectangle
  49285. * @param xmin bottom X coord
  49286. * @param ymin bottom Y coord
  49287. * @param xmax top X coord
  49288. * @param ymax top Y coord
  49289. * @returns points that make the resulting rectation
  49290. */
  49291. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49292. /**
  49293. * Creates a circle
  49294. * @param radius radius of circle
  49295. * @param cx scale in x
  49296. * @param cy scale in y
  49297. * @param numberOfSides number of sides that make up the circle
  49298. * @returns points that make the resulting circle
  49299. */
  49300. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49301. /**
  49302. * Creates a polygon from input string
  49303. * @param input Input polygon data
  49304. * @returns the parsed points
  49305. */
  49306. static Parse(input: string): Vector2[];
  49307. /**
  49308. * Starts building a polygon from x and y coordinates
  49309. * @param x x coordinate
  49310. * @param y y coordinate
  49311. * @returns the started path2
  49312. */
  49313. static StartingAt(x: number, y: number): Path2;
  49314. }
  49315. /**
  49316. * Builds a polygon
  49317. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49318. */
  49319. export class PolygonMeshBuilder {
  49320. private _points;
  49321. private _outlinepoints;
  49322. private _holes;
  49323. private _name;
  49324. private _scene;
  49325. private _epoints;
  49326. private _eholes;
  49327. private _addToepoint;
  49328. /**
  49329. * Babylon reference to the earcut plugin.
  49330. */
  49331. bjsEarcut: any;
  49332. /**
  49333. * Creates a PolygonMeshBuilder
  49334. * @param name name of the builder
  49335. * @param contours Path of the polygon
  49336. * @param scene scene to add to when creating the mesh
  49337. * @param earcutInjection can be used to inject your own earcut reference
  49338. */
  49339. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49340. /**
  49341. * Adds a whole within the polygon
  49342. * @param hole Array of points defining the hole
  49343. * @returns this
  49344. */
  49345. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49346. /**
  49347. * Creates the polygon
  49348. * @param updatable If the mesh should be updatable
  49349. * @param depth The depth of the mesh created
  49350. * @returns the created mesh
  49351. */
  49352. build(updatable?: boolean, depth?: number): Mesh;
  49353. /**
  49354. * Creates the polygon
  49355. * @param depth The depth of the mesh created
  49356. * @returns the created VertexData
  49357. */
  49358. buildVertexData(depth?: number): VertexData;
  49359. /**
  49360. * Adds a side to the polygon
  49361. * @param positions points that make the polygon
  49362. * @param normals normals of the polygon
  49363. * @param uvs uvs of the polygon
  49364. * @param indices indices of the polygon
  49365. * @param bounds bounds of the polygon
  49366. * @param points points of the polygon
  49367. * @param depth depth of the polygon
  49368. * @param flip flip of the polygon
  49369. */
  49370. private addSide;
  49371. }
  49372. }
  49373. declare module BABYLON {
  49374. /**
  49375. * Class containing static functions to help procedurally build meshes
  49376. */
  49377. export class PolygonBuilder {
  49378. /**
  49379. * Creates a polygon mesh
  49380. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49381. * * 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
  49382. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49384. * * 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)
  49385. * * Remember you can only change the shape positions, not their number when updating a polygon
  49386. * @param name defines the name of the mesh
  49387. * @param options defines the options used to create the mesh
  49388. * @param scene defines the hosting scene
  49389. * @param earcutInjection can be used to inject your own earcut reference
  49390. * @returns the polygon mesh
  49391. */
  49392. static CreatePolygon(name: string, options: {
  49393. shape: Vector3[];
  49394. holes?: Vector3[][];
  49395. depth?: number;
  49396. faceUV?: Vector4[];
  49397. faceColors?: Color4[];
  49398. updatable?: boolean;
  49399. sideOrientation?: number;
  49400. frontUVs?: Vector4;
  49401. backUVs?: Vector4;
  49402. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49403. /**
  49404. * Creates an extruded polygon mesh, with depth in the Y direction.
  49405. * * 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)
  49406. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49407. * @param name defines the name of the mesh
  49408. * @param options defines the options used to create the mesh
  49409. * @param scene defines the hosting scene
  49410. * @param earcutInjection can be used to inject your own earcut reference
  49411. * @returns the polygon mesh
  49412. */
  49413. static ExtrudePolygon(name: string, options: {
  49414. shape: Vector3[];
  49415. holes?: Vector3[][];
  49416. depth?: number;
  49417. faceUV?: Vector4[];
  49418. faceColors?: Color4[];
  49419. updatable?: boolean;
  49420. sideOrientation?: number;
  49421. frontUVs?: Vector4;
  49422. backUVs?: Vector4;
  49423. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49424. }
  49425. }
  49426. declare module BABYLON {
  49427. /**
  49428. * Class containing static functions to help procedurally build meshes
  49429. */
  49430. export class LatheBuilder {
  49431. /**
  49432. * Creates lathe mesh.
  49433. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49434. * * 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
  49435. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49436. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49437. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49438. * * 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
  49439. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49440. * * 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
  49441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49442. * * 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
  49443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49445. * @param name defines the name of the mesh
  49446. * @param options defines the options used to create the mesh
  49447. * @param scene defines the hosting scene
  49448. * @returns the lathe mesh
  49449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49450. */
  49451. static CreateLathe(name: string, options: {
  49452. shape: Vector3[];
  49453. radius?: number;
  49454. tessellation?: number;
  49455. clip?: number;
  49456. arc?: number;
  49457. closed?: boolean;
  49458. updatable?: boolean;
  49459. sideOrientation?: number;
  49460. frontUVs?: Vector4;
  49461. backUVs?: Vector4;
  49462. cap?: number;
  49463. invertUV?: boolean;
  49464. }, scene?: Nullable<Scene>): Mesh;
  49465. }
  49466. }
  49467. declare module BABYLON {
  49468. /**
  49469. * Class containing static functions to help procedurally build meshes
  49470. */
  49471. export class TubeBuilder {
  49472. /**
  49473. * Creates a tube mesh.
  49474. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49475. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49476. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49477. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49478. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49479. * * 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)
  49480. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49481. * * 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
  49482. * * 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
  49483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49484. * * 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
  49485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49487. * @param name defines the name of the mesh
  49488. * @param options defines the options used to create the mesh
  49489. * @param scene defines the hosting scene
  49490. * @returns the tube mesh
  49491. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49492. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49493. */
  49494. static CreateTube(name: string, options: {
  49495. path: Vector3[];
  49496. radius?: number;
  49497. tessellation?: number;
  49498. radiusFunction?: {
  49499. (i: number, distance: number): number;
  49500. };
  49501. cap?: number;
  49502. arc?: number;
  49503. updatable?: boolean;
  49504. sideOrientation?: number;
  49505. frontUVs?: Vector4;
  49506. backUVs?: Vector4;
  49507. instance?: Mesh;
  49508. invertUV?: boolean;
  49509. }, scene?: Nullable<Scene>): Mesh;
  49510. }
  49511. }
  49512. declare module BABYLON {
  49513. /**
  49514. * Class containing static functions to help procedurally build meshes
  49515. */
  49516. export class IcoSphereBuilder {
  49517. /**
  49518. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49519. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49520. * * 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`)
  49521. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49522. * * 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
  49523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49524. * * 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
  49525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49526. * @param name defines the name of the mesh
  49527. * @param options defines the options used to create the mesh
  49528. * @param scene defines the hosting scene
  49529. * @returns the icosahedron mesh
  49530. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49531. */
  49532. static CreateIcoSphere(name: string, options: {
  49533. radius?: number;
  49534. radiusX?: number;
  49535. radiusY?: number;
  49536. radiusZ?: number;
  49537. flat?: boolean;
  49538. subdivisions?: number;
  49539. sideOrientation?: number;
  49540. frontUVs?: Vector4;
  49541. backUVs?: Vector4;
  49542. updatable?: boolean;
  49543. }, scene?: Nullable<Scene>): Mesh;
  49544. }
  49545. }
  49546. declare module BABYLON {
  49547. /**
  49548. * Class containing static functions to help procedurally build meshes
  49549. */
  49550. export class DecalBuilder {
  49551. /**
  49552. * Creates a decal mesh.
  49553. * 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
  49554. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49555. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49556. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49557. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49558. * @param name defines the name of the mesh
  49559. * @param sourceMesh defines the mesh where the decal must be applied
  49560. * @param options defines the options used to create the mesh
  49561. * @param scene defines the hosting scene
  49562. * @returns the decal mesh
  49563. * @see https://doc.babylonjs.com/how_to/decals
  49564. */
  49565. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49566. position?: Vector3;
  49567. normal?: Vector3;
  49568. size?: Vector3;
  49569. angle?: number;
  49570. }): Mesh;
  49571. }
  49572. }
  49573. declare module BABYLON {
  49574. /**
  49575. * Class containing static functions to help procedurally build meshes
  49576. */
  49577. export class MeshBuilder {
  49578. /**
  49579. * Creates a box mesh
  49580. * * The parameter `size` sets the size (float) of each box side (default 1)
  49581. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49582. * * 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)
  49583. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49585. * * 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
  49586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49587. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49588. * @param name defines the name of the mesh
  49589. * @param options defines the options used to create the mesh
  49590. * @param scene defines the hosting scene
  49591. * @returns the box mesh
  49592. */
  49593. static CreateBox(name: string, options: {
  49594. size?: number;
  49595. width?: number;
  49596. height?: number;
  49597. depth?: number;
  49598. faceUV?: Vector4[];
  49599. faceColors?: Color4[];
  49600. sideOrientation?: number;
  49601. frontUVs?: Vector4;
  49602. backUVs?: Vector4;
  49603. updatable?: boolean;
  49604. }, scene?: Nullable<Scene>): Mesh;
  49605. /**
  49606. * Creates a sphere mesh
  49607. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49608. * * 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`)
  49609. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49610. * * 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
  49611. * * 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)
  49612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49613. * * 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
  49614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49615. * @param name defines the name of the mesh
  49616. * @param options defines the options used to create the mesh
  49617. * @param scene defines the hosting scene
  49618. * @returns the sphere mesh
  49619. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49620. */
  49621. static CreateSphere(name: string, options: {
  49622. segments?: number;
  49623. diameter?: number;
  49624. diameterX?: number;
  49625. diameterY?: number;
  49626. diameterZ?: number;
  49627. arc?: number;
  49628. slice?: number;
  49629. sideOrientation?: number;
  49630. frontUVs?: Vector4;
  49631. backUVs?: Vector4;
  49632. updatable?: boolean;
  49633. }, scene?: Nullable<Scene>): Mesh;
  49634. /**
  49635. * Creates a plane polygonal mesh. By default, this is a disc
  49636. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49637. * * 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
  49638. * * 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
  49639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49640. * * 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
  49641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49642. * @param name defines the name of the mesh
  49643. * @param options defines the options used to create the mesh
  49644. * @param scene defines the hosting scene
  49645. * @returns the plane polygonal mesh
  49646. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49647. */
  49648. static CreateDisc(name: string, options: {
  49649. radius?: number;
  49650. tessellation?: number;
  49651. arc?: number;
  49652. updatable?: boolean;
  49653. sideOrientation?: number;
  49654. frontUVs?: Vector4;
  49655. backUVs?: Vector4;
  49656. }, scene?: Nullable<Scene>): Mesh;
  49657. /**
  49658. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49659. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49660. * * 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`)
  49661. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49662. * * 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
  49663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49664. * * 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
  49665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49666. * @param name defines the name of the mesh
  49667. * @param options defines the options used to create the mesh
  49668. * @param scene defines the hosting scene
  49669. * @returns the icosahedron mesh
  49670. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49671. */
  49672. static CreateIcoSphere(name: string, options: {
  49673. radius?: number;
  49674. radiusX?: number;
  49675. radiusY?: number;
  49676. radiusZ?: number;
  49677. flat?: boolean;
  49678. subdivisions?: number;
  49679. sideOrientation?: number;
  49680. frontUVs?: Vector4;
  49681. backUVs?: Vector4;
  49682. updatable?: boolean;
  49683. }, scene?: Nullable<Scene>): Mesh;
  49684. /**
  49685. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49686. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49687. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49688. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49689. * * 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
  49690. * * 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
  49691. * * 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
  49692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49693. * * 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
  49694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49695. * * 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
  49696. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49697. * * 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
  49698. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49700. * @param name defines the name of the mesh
  49701. * @param options defines the options used to create the mesh
  49702. * @param scene defines the hosting scene
  49703. * @returns the ribbon mesh
  49704. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49706. */
  49707. static CreateRibbon(name: string, options: {
  49708. pathArray: Vector3[][];
  49709. closeArray?: boolean;
  49710. closePath?: boolean;
  49711. offset?: number;
  49712. updatable?: boolean;
  49713. sideOrientation?: number;
  49714. frontUVs?: Vector4;
  49715. backUVs?: Vector4;
  49716. instance?: Mesh;
  49717. invertUV?: boolean;
  49718. uvs?: Vector2[];
  49719. colors?: Color4[];
  49720. }, scene?: Nullable<Scene>): Mesh;
  49721. /**
  49722. * Creates a cylinder or a cone mesh
  49723. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49724. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49725. * * 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.
  49726. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49727. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49728. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49729. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49730. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49731. * * 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).
  49732. * * 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
  49733. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49734. * * 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
  49735. * * 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.
  49736. * * If `enclose` is false, a ring surface is one element.
  49737. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49738. * * 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
  49739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49740. * * 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
  49741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49742. * @param name defines the name of the mesh
  49743. * @param options defines the options used to create the mesh
  49744. * @param scene defines the hosting scene
  49745. * @returns the cylinder mesh
  49746. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49747. */
  49748. static CreateCylinder(name: string, options: {
  49749. height?: number;
  49750. diameterTop?: number;
  49751. diameterBottom?: number;
  49752. diameter?: number;
  49753. tessellation?: number;
  49754. subdivisions?: number;
  49755. arc?: number;
  49756. faceColors?: Color4[];
  49757. faceUV?: Vector4[];
  49758. updatable?: boolean;
  49759. hasRings?: boolean;
  49760. enclose?: boolean;
  49761. sideOrientation?: number;
  49762. frontUVs?: Vector4;
  49763. backUVs?: Vector4;
  49764. }, scene?: Nullable<Scene>): Mesh;
  49765. /**
  49766. * Creates a torus mesh
  49767. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49768. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49769. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49771. * * 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
  49772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49773. * @param name defines the name of the mesh
  49774. * @param options defines the options used to create the mesh
  49775. * @param scene defines the hosting scene
  49776. * @returns the torus mesh
  49777. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49778. */
  49779. static CreateTorus(name: string, options: {
  49780. diameter?: number;
  49781. thickness?: number;
  49782. tessellation?: number;
  49783. updatable?: boolean;
  49784. sideOrientation?: number;
  49785. frontUVs?: Vector4;
  49786. backUVs?: Vector4;
  49787. }, scene?: Nullable<Scene>): Mesh;
  49788. /**
  49789. * Creates a torus knot mesh
  49790. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49791. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49792. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49793. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49795. * * 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
  49796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49797. * @param name defines the name of the mesh
  49798. * @param options defines the options used to create the mesh
  49799. * @param scene defines the hosting scene
  49800. * @returns the torus knot mesh
  49801. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49802. */
  49803. static CreateTorusKnot(name: string, options: {
  49804. radius?: number;
  49805. tube?: number;
  49806. radialSegments?: number;
  49807. tubularSegments?: number;
  49808. p?: number;
  49809. q?: number;
  49810. updatable?: boolean;
  49811. sideOrientation?: number;
  49812. frontUVs?: Vector4;
  49813. backUVs?: Vector4;
  49814. }, scene?: Nullable<Scene>): Mesh;
  49815. /**
  49816. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49817. * * 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
  49818. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49819. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49820. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49821. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49822. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49823. * * 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
  49824. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49827. * @param name defines the name of the new line system
  49828. * @param options defines the options used to create the line system
  49829. * @param scene defines the hosting scene
  49830. * @returns a new line system mesh
  49831. */
  49832. static CreateLineSystem(name: string, options: {
  49833. lines: Vector3[][];
  49834. updatable?: boolean;
  49835. instance?: Nullable<LinesMesh>;
  49836. colors?: Nullable<Color4[][]>;
  49837. useVertexAlpha?: boolean;
  49838. }, scene: Nullable<Scene>): LinesMesh;
  49839. /**
  49840. * Creates a line mesh
  49841. * 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
  49842. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49843. * * The parameter `points` is an array successive Vector3
  49844. * * 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
  49845. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49846. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49847. * * When updating an instance, remember that only point positions can change, not the number of points
  49848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49850. * @param name defines the name of the new line system
  49851. * @param options defines the options used to create the line system
  49852. * @param scene defines the hosting scene
  49853. * @returns a new line mesh
  49854. */
  49855. static CreateLines(name: string, options: {
  49856. points: Vector3[];
  49857. updatable?: boolean;
  49858. instance?: Nullable<LinesMesh>;
  49859. colors?: Color4[];
  49860. useVertexAlpha?: boolean;
  49861. }, scene?: Nullable<Scene>): LinesMesh;
  49862. /**
  49863. * Creates a dashed line mesh
  49864. * * 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
  49865. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49866. * * The parameter `points` is an array successive Vector3
  49867. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49868. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49869. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49870. * * 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
  49871. * * When updating an instance, remember that only point positions can change, not the number of points
  49872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49873. * @param name defines the name of the mesh
  49874. * @param options defines the options used to create the mesh
  49875. * @param scene defines the hosting scene
  49876. * @returns the dashed line mesh
  49877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49878. */
  49879. static CreateDashedLines(name: string, options: {
  49880. points: Vector3[];
  49881. dashSize?: number;
  49882. gapSize?: number;
  49883. dashNb?: number;
  49884. updatable?: boolean;
  49885. instance?: LinesMesh;
  49886. }, scene?: Nullable<Scene>): LinesMesh;
  49887. /**
  49888. * 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.
  49889. * * 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.
  49890. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49891. * * 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.
  49892. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49893. * * 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
  49894. * * 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
  49895. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49897. * * 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
  49898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49900. * @param name defines the name of the mesh
  49901. * @param options defines the options used to create the mesh
  49902. * @param scene defines the hosting scene
  49903. * @returns the extruded shape mesh
  49904. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49906. */
  49907. static ExtrudeShape(name: string, options: {
  49908. shape: Vector3[];
  49909. path: Vector3[];
  49910. scale?: number;
  49911. rotation?: number;
  49912. cap?: number;
  49913. updatable?: boolean;
  49914. sideOrientation?: number;
  49915. frontUVs?: Vector4;
  49916. backUVs?: Vector4;
  49917. instance?: Mesh;
  49918. invertUV?: boolean;
  49919. }, scene?: Nullable<Scene>): Mesh;
  49920. /**
  49921. * Creates an custom extruded shape mesh.
  49922. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49923. * * 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.
  49924. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49925. * * 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
  49926. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49927. * * 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
  49928. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49929. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49930. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49931. * * 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
  49932. * * 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
  49933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49935. * * 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
  49936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49938. * @param name defines the name of the mesh
  49939. * @param options defines the options used to create the mesh
  49940. * @param scene defines the hosting scene
  49941. * @returns the custom extruded shape mesh
  49942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49945. */
  49946. static ExtrudeShapeCustom(name: string, options: {
  49947. shape: Vector3[];
  49948. path: Vector3[];
  49949. scaleFunction?: any;
  49950. rotationFunction?: any;
  49951. ribbonCloseArray?: boolean;
  49952. ribbonClosePath?: boolean;
  49953. cap?: number;
  49954. updatable?: boolean;
  49955. sideOrientation?: number;
  49956. frontUVs?: Vector4;
  49957. backUVs?: Vector4;
  49958. instance?: Mesh;
  49959. invertUV?: boolean;
  49960. }, scene?: Nullable<Scene>): Mesh;
  49961. /**
  49962. * Creates lathe mesh.
  49963. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49964. * * 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
  49965. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49966. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49967. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49968. * * 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
  49969. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49970. * * 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
  49971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49972. * * 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
  49973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49975. * @param name defines the name of the mesh
  49976. * @param options defines the options used to create the mesh
  49977. * @param scene defines the hosting scene
  49978. * @returns the lathe mesh
  49979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49980. */
  49981. static CreateLathe(name: string, options: {
  49982. shape: Vector3[];
  49983. radius?: number;
  49984. tessellation?: number;
  49985. clip?: number;
  49986. arc?: number;
  49987. closed?: boolean;
  49988. updatable?: boolean;
  49989. sideOrientation?: number;
  49990. frontUVs?: Vector4;
  49991. backUVs?: Vector4;
  49992. cap?: number;
  49993. invertUV?: boolean;
  49994. }, scene?: Nullable<Scene>): Mesh;
  49995. /**
  49996. * Creates a plane mesh
  49997. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49998. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49999. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50001. * * 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
  50002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50003. * @param name defines the name of the mesh
  50004. * @param options defines the options used to create the mesh
  50005. * @param scene defines the hosting scene
  50006. * @returns the plane mesh
  50007. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50008. */
  50009. static CreatePlane(name: string, options: {
  50010. size?: number;
  50011. width?: number;
  50012. height?: number;
  50013. sideOrientation?: number;
  50014. frontUVs?: Vector4;
  50015. backUVs?: Vector4;
  50016. updatable?: boolean;
  50017. sourcePlane?: Plane;
  50018. }, scene?: Nullable<Scene>): Mesh;
  50019. /**
  50020. * Creates a ground mesh
  50021. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50022. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50024. * @param name defines the name of the mesh
  50025. * @param options defines the options used to create the mesh
  50026. * @param scene defines the hosting scene
  50027. * @returns the ground mesh
  50028. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50029. */
  50030. static CreateGround(name: string, options: {
  50031. width?: number;
  50032. height?: number;
  50033. subdivisions?: number;
  50034. subdivisionsX?: number;
  50035. subdivisionsY?: number;
  50036. updatable?: boolean;
  50037. }, scene?: Nullable<Scene>): Mesh;
  50038. /**
  50039. * Creates a tiled ground mesh
  50040. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50041. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50042. * * 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
  50043. * * 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
  50044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50045. * @param name defines the name of the mesh
  50046. * @param options defines the options used to create the mesh
  50047. * @param scene defines the hosting scene
  50048. * @returns the tiled ground mesh
  50049. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50050. */
  50051. static CreateTiledGround(name: string, options: {
  50052. xmin: number;
  50053. zmin: number;
  50054. xmax: number;
  50055. zmax: number;
  50056. subdivisions?: {
  50057. w: number;
  50058. h: number;
  50059. };
  50060. precision?: {
  50061. w: number;
  50062. h: number;
  50063. };
  50064. updatable?: boolean;
  50065. }, scene?: Nullable<Scene>): Mesh;
  50066. /**
  50067. * Creates a ground mesh from a height map
  50068. * * The parameter `url` sets the URL of the height map image resource.
  50069. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50070. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50071. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50072. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50073. * * 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.
  50074. * * 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).
  50075. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50077. * @param name defines the name of the mesh
  50078. * @param url defines the url to the height map
  50079. * @param options defines the options used to create the mesh
  50080. * @param scene defines the hosting scene
  50081. * @returns the ground mesh
  50082. * @see https://doc.babylonjs.com/babylon101/height_map
  50083. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50084. */
  50085. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50086. width?: number;
  50087. height?: number;
  50088. subdivisions?: number;
  50089. minHeight?: number;
  50090. maxHeight?: number;
  50091. colorFilter?: Color3;
  50092. alphaFilter?: number;
  50093. updatable?: boolean;
  50094. onReady?: (mesh: GroundMesh) => void;
  50095. }, scene?: Nullable<Scene>): GroundMesh;
  50096. /**
  50097. * Creates a polygon mesh
  50098. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50099. * * 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
  50100. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50102. * * 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)
  50103. * * Remember you can only change the shape positions, not their number when updating a polygon
  50104. * @param name defines the name of the mesh
  50105. * @param options defines the options used to create the mesh
  50106. * @param scene defines the hosting scene
  50107. * @param earcutInjection can be used to inject your own earcut reference
  50108. * @returns the polygon mesh
  50109. */
  50110. static CreatePolygon(name: string, options: {
  50111. shape: Vector3[];
  50112. holes?: Vector3[][];
  50113. depth?: number;
  50114. faceUV?: Vector4[];
  50115. faceColors?: Color4[];
  50116. updatable?: boolean;
  50117. sideOrientation?: number;
  50118. frontUVs?: Vector4;
  50119. backUVs?: Vector4;
  50120. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50121. /**
  50122. * Creates an extruded polygon mesh, with depth in the Y direction.
  50123. * * 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)
  50124. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50125. * @param name defines the name of the mesh
  50126. * @param options defines the options used to create the mesh
  50127. * @param scene defines the hosting scene
  50128. * @param earcutInjection can be used to inject your own earcut reference
  50129. * @returns the polygon mesh
  50130. */
  50131. static ExtrudePolygon(name: string, options: {
  50132. shape: Vector3[];
  50133. holes?: Vector3[][];
  50134. depth?: number;
  50135. faceUV?: Vector4[];
  50136. faceColors?: Color4[];
  50137. updatable?: boolean;
  50138. sideOrientation?: number;
  50139. frontUVs?: Vector4;
  50140. backUVs?: Vector4;
  50141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50142. /**
  50143. * Creates a tube mesh.
  50144. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50145. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50146. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50147. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50148. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50149. * * 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)
  50150. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50151. * * 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
  50152. * * 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
  50153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50154. * * 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
  50155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50157. * @param name defines the name of the mesh
  50158. * @param options defines the options used to create the mesh
  50159. * @param scene defines the hosting scene
  50160. * @returns the tube mesh
  50161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50162. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50163. */
  50164. static CreateTube(name: string, options: {
  50165. path: Vector3[];
  50166. radius?: number;
  50167. tessellation?: number;
  50168. radiusFunction?: {
  50169. (i: number, distance: number): number;
  50170. };
  50171. cap?: number;
  50172. arc?: number;
  50173. updatable?: boolean;
  50174. sideOrientation?: number;
  50175. frontUVs?: Vector4;
  50176. backUVs?: Vector4;
  50177. instance?: Mesh;
  50178. invertUV?: boolean;
  50179. }, scene?: Nullable<Scene>): Mesh;
  50180. /**
  50181. * Creates a polyhedron mesh
  50182. * * 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
  50183. * * The parameter `size` (positive float, default 1) sets the polygon size
  50184. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50185. * * 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`
  50186. * * 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
  50187. * * 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)`)
  50188. * * 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
  50189. * * 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
  50190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50191. * * 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
  50192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50193. * @param name defines the name of the mesh
  50194. * @param options defines the options used to create the mesh
  50195. * @param scene defines the hosting scene
  50196. * @returns the polyhedron mesh
  50197. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50198. */
  50199. static CreatePolyhedron(name: string, options: {
  50200. type?: number;
  50201. size?: number;
  50202. sizeX?: number;
  50203. sizeY?: number;
  50204. sizeZ?: number;
  50205. custom?: any;
  50206. faceUV?: Vector4[];
  50207. faceColors?: Color4[];
  50208. flat?: boolean;
  50209. updatable?: boolean;
  50210. sideOrientation?: number;
  50211. frontUVs?: Vector4;
  50212. backUVs?: Vector4;
  50213. }, scene?: Nullable<Scene>): Mesh;
  50214. /**
  50215. * Creates a decal mesh.
  50216. * 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
  50217. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50218. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50219. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50220. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50221. * @param name defines the name of the mesh
  50222. * @param sourceMesh defines the mesh where the decal must be applied
  50223. * @param options defines the options used to create the mesh
  50224. * @param scene defines the hosting scene
  50225. * @returns the decal mesh
  50226. * @see https://doc.babylonjs.com/how_to/decals
  50227. */
  50228. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50229. position?: Vector3;
  50230. normal?: Vector3;
  50231. size?: Vector3;
  50232. angle?: number;
  50233. }): Mesh;
  50234. }
  50235. }
  50236. declare module BABYLON {
  50237. /**
  50238. * A simplifier interface for future simplification implementations
  50239. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50240. */
  50241. export interface ISimplifier {
  50242. /**
  50243. * Simplification of a given mesh according to the given settings.
  50244. * Since this requires computation, it is assumed that the function runs async.
  50245. * @param settings The settings of the simplification, including quality and distance
  50246. * @param successCallback A callback that will be called after the mesh was simplified.
  50247. * @param errorCallback in case of an error, this callback will be called. optional.
  50248. */
  50249. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50250. }
  50251. /**
  50252. * Expected simplification settings.
  50253. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50254. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50255. */
  50256. export interface ISimplificationSettings {
  50257. /**
  50258. * Gets or sets the expected quality
  50259. */
  50260. quality: number;
  50261. /**
  50262. * Gets or sets the distance when this optimized version should be used
  50263. */
  50264. distance: number;
  50265. /**
  50266. * Gets an already optimized mesh
  50267. */
  50268. optimizeMesh?: boolean;
  50269. }
  50270. /**
  50271. * Class used to specify simplification options
  50272. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50273. */
  50274. export class SimplificationSettings implements ISimplificationSettings {
  50275. /** expected quality */
  50276. quality: number;
  50277. /** distance when this optimized version should be used */
  50278. distance: number;
  50279. /** already optimized mesh */
  50280. optimizeMesh?: boolean | undefined;
  50281. /**
  50282. * Creates a SimplificationSettings
  50283. * @param quality expected quality
  50284. * @param distance distance when this optimized version should be used
  50285. * @param optimizeMesh already optimized mesh
  50286. */
  50287. constructor(
  50288. /** expected quality */
  50289. quality: number,
  50290. /** distance when this optimized version should be used */
  50291. distance: number,
  50292. /** already optimized mesh */
  50293. optimizeMesh?: boolean | undefined);
  50294. }
  50295. /**
  50296. * Interface used to define a simplification task
  50297. */
  50298. export interface ISimplificationTask {
  50299. /**
  50300. * Array of settings
  50301. */
  50302. settings: Array<ISimplificationSettings>;
  50303. /**
  50304. * Simplification type
  50305. */
  50306. simplificationType: SimplificationType;
  50307. /**
  50308. * Mesh to simplify
  50309. */
  50310. mesh: Mesh;
  50311. /**
  50312. * Callback called on success
  50313. */
  50314. successCallback?: () => void;
  50315. /**
  50316. * Defines if parallel processing can be used
  50317. */
  50318. parallelProcessing: boolean;
  50319. }
  50320. /**
  50321. * Queue used to order the simplification tasks
  50322. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50323. */
  50324. export class SimplificationQueue {
  50325. private _simplificationArray;
  50326. /**
  50327. * Gets a boolean indicating that the process is still running
  50328. */
  50329. running: boolean;
  50330. /**
  50331. * Creates a new queue
  50332. */
  50333. constructor();
  50334. /**
  50335. * Adds a new simplification task
  50336. * @param task defines a task to add
  50337. */
  50338. addTask(task: ISimplificationTask): void;
  50339. /**
  50340. * Execute next task
  50341. */
  50342. executeNext(): void;
  50343. /**
  50344. * Execute a simplification task
  50345. * @param task defines the task to run
  50346. */
  50347. runSimplification(task: ISimplificationTask): void;
  50348. private getSimplifier;
  50349. }
  50350. /**
  50351. * The implemented types of simplification
  50352. * At the moment only Quadratic Error Decimation is implemented
  50353. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50354. */
  50355. export enum SimplificationType {
  50356. /** Quadratic error decimation */
  50357. QUADRATIC = 0
  50358. }
  50359. }
  50360. declare module BABYLON {
  50361. interface Scene {
  50362. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  50363. /**
  50364. * Gets or sets the simplification queue attached to the scene
  50365. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50366. */
  50367. simplificationQueue: SimplificationQueue;
  50368. }
  50369. interface Mesh {
  50370. /**
  50371. * Simplify the mesh according to the given array of settings.
  50372. * Function will return immediately and will simplify async
  50373. * @param settings a collection of simplification settings
  50374. * @param parallelProcessing should all levels calculate parallel or one after the other
  50375. * @param simplificationType the type of simplification to run
  50376. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50377. * @returns the current mesh
  50378. */
  50379. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50380. }
  50381. /**
  50382. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50383. * created in a scene
  50384. */
  50385. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50386. /**
  50387. * The component name helpfull to identify the component in the list of scene components.
  50388. */
  50389. readonly name: string;
  50390. /**
  50391. * The scene the component belongs to.
  50392. */
  50393. scene: Scene;
  50394. /**
  50395. * Creates a new instance of the component for the given scene
  50396. * @param scene Defines the scene to register the component in
  50397. */
  50398. constructor(scene: Scene);
  50399. /**
  50400. * Registers the component in a given scene
  50401. */
  50402. register(): void;
  50403. /**
  50404. * Rebuilds the elements related to this component in case of
  50405. * context lost for instance.
  50406. */
  50407. rebuild(): void;
  50408. /**
  50409. * Disposes the component and the associated ressources
  50410. */
  50411. dispose(): void;
  50412. private _beforeCameraUpdate;
  50413. }
  50414. }
  50415. declare module BABYLON {
  50416. /**
  50417. * Class used to enable access to IndexedDB
  50418. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50419. */
  50420. export class Database implements IOfflineProvider {
  50421. private _callbackManifestChecked;
  50422. private _currentSceneUrl;
  50423. private _db;
  50424. private _enableSceneOffline;
  50425. private _enableTexturesOffline;
  50426. private _manifestVersionFound;
  50427. private _mustUpdateRessources;
  50428. private _hasReachedQuota;
  50429. private _isSupported;
  50430. private _idbFactory;
  50431. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50432. private static IsUASupportingBlobStorage;
  50433. /**
  50434. * Gets a boolean indicating if Database storate is enabled (off by default)
  50435. */
  50436. static IDBStorageEnabled: boolean;
  50437. /**
  50438. * Gets a boolean indicating if scene must be saved in the database
  50439. */
  50440. readonly enableSceneOffline: boolean;
  50441. /**
  50442. * Gets a boolean indicating if textures must be saved in the database
  50443. */
  50444. readonly enableTexturesOffline: boolean;
  50445. /**
  50446. * Creates a new Database
  50447. * @param urlToScene defines the url to load the scene
  50448. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50449. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50450. */
  50451. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50452. private static _ParseURL;
  50453. private static _ReturnFullUrlLocation;
  50454. private _checkManifestFile;
  50455. /**
  50456. * Open the database and make it available
  50457. * @param successCallback defines the callback to call on success
  50458. * @param errorCallback defines the callback to call on error
  50459. */
  50460. open(successCallback: () => void, errorCallback: () => void): void;
  50461. /**
  50462. * Loads an image from the database
  50463. * @param url defines the url to load from
  50464. * @param image defines the target DOM image
  50465. */
  50466. loadImage(url: string, image: HTMLImageElement): void;
  50467. private _loadImageFromDBAsync;
  50468. private _saveImageIntoDBAsync;
  50469. private _checkVersionFromDB;
  50470. private _loadVersionFromDBAsync;
  50471. private _saveVersionIntoDBAsync;
  50472. /**
  50473. * Loads a file from database
  50474. * @param url defines the URL to load from
  50475. * @param sceneLoaded defines a callback to call on success
  50476. * @param progressCallBack defines a callback to call when progress changed
  50477. * @param errorCallback defines a callback to call on error
  50478. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50479. */
  50480. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50481. private _loadFileAsync;
  50482. private _saveFileAsync;
  50483. /**
  50484. * Validates if xhr data is correct
  50485. * @param xhr defines the request to validate
  50486. * @param dataType defines the expected data type
  50487. * @returns true if data is correct
  50488. */
  50489. private static _ValidateXHRData;
  50490. }
  50491. }
  50492. declare module BABYLON {
  50493. /** @hidden */
  50494. export var gpuUpdateParticlesPixelShader: {
  50495. name: string;
  50496. shader: string;
  50497. };
  50498. }
  50499. declare module BABYLON {
  50500. /** @hidden */
  50501. export var gpuUpdateParticlesVertexShader: {
  50502. name: string;
  50503. shader: string;
  50504. };
  50505. }
  50506. declare module BABYLON {
  50507. /** @hidden */
  50508. export var clipPlaneFragmentDeclaration2: {
  50509. name: string;
  50510. shader: string;
  50511. };
  50512. }
  50513. declare module BABYLON {
  50514. /** @hidden */
  50515. export var gpuRenderParticlesPixelShader: {
  50516. name: string;
  50517. shader: string;
  50518. };
  50519. }
  50520. declare module BABYLON {
  50521. /** @hidden */
  50522. export var clipPlaneVertexDeclaration2: {
  50523. name: string;
  50524. shader: string;
  50525. };
  50526. }
  50527. declare module BABYLON {
  50528. /** @hidden */
  50529. export var gpuRenderParticlesVertexShader: {
  50530. name: string;
  50531. shader: string;
  50532. };
  50533. }
  50534. declare module BABYLON {
  50535. /**
  50536. * This represents a GPU particle system in Babylon
  50537. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50538. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50539. */
  50540. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50541. /**
  50542. * The layer mask we are rendering the particles through.
  50543. */
  50544. layerMask: number;
  50545. private _capacity;
  50546. private _activeCount;
  50547. private _currentActiveCount;
  50548. private _accumulatedCount;
  50549. private _renderEffect;
  50550. private _updateEffect;
  50551. private _buffer0;
  50552. private _buffer1;
  50553. private _spriteBuffer;
  50554. private _updateVAO;
  50555. private _renderVAO;
  50556. private _targetIndex;
  50557. private _sourceBuffer;
  50558. private _targetBuffer;
  50559. private _engine;
  50560. private _currentRenderId;
  50561. private _started;
  50562. private _stopped;
  50563. private _timeDelta;
  50564. private _randomTexture;
  50565. private _randomTexture2;
  50566. private _attributesStrideSize;
  50567. private _updateEffectOptions;
  50568. private _randomTextureSize;
  50569. private _actualFrame;
  50570. private readonly _rawTextureWidth;
  50571. /**
  50572. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50573. */
  50574. static readonly IsSupported: boolean;
  50575. /**
  50576. * An event triggered when the system is disposed.
  50577. */
  50578. onDisposeObservable: Observable<GPUParticleSystem>;
  50579. /**
  50580. * Gets the maximum number of particles active at the same time.
  50581. * @returns The max number of active particles.
  50582. */
  50583. getCapacity(): number;
  50584. /**
  50585. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50586. * to override the particles.
  50587. */
  50588. forceDepthWrite: boolean;
  50589. /**
  50590. * Gets or set the number of active particles
  50591. */
  50592. activeParticleCount: number;
  50593. private _preWarmDone;
  50594. /**
  50595. * Is this system ready to be used/rendered
  50596. * @return true if the system is ready
  50597. */
  50598. isReady(): boolean;
  50599. /**
  50600. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50601. * @returns True if it has been started, otherwise false.
  50602. */
  50603. isStarted(): boolean;
  50604. /**
  50605. * Starts the particle system and begins to emit
  50606. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50607. */
  50608. start(delay?: number): void;
  50609. /**
  50610. * Stops the particle system.
  50611. */
  50612. stop(): void;
  50613. /**
  50614. * Remove all active particles
  50615. */
  50616. reset(): void;
  50617. /**
  50618. * Returns the string "GPUParticleSystem"
  50619. * @returns a string containing the class name
  50620. */
  50621. getClassName(): string;
  50622. private _colorGradientsTexture;
  50623. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50624. /**
  50625. * Adds a new color gradient
  50626. * @param gradient defines the gradient to use (between 0 and 1)
  50627. * @param color1 defines the color to affect to the specified gradient
  50628. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50629. * @returns the current particle system
  50630. */
  50631. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50632. /**
  50633. * Remove a specific color gradient
  50634. * @param gradient defines the gradient to remove
  50635. * @returns the current particle system
  50636. */
  50637. removeColorGradient(gradient: number): GPUParticleSystem;
  50638. private _angularSpeedGradientsTexture;
  50639. private _sizeGradientsTexture;
  50640. private _velocityGradientsTexture;
  50641. private _limitVelocityGradientsTexture;
  50642. private _dragGradientsTexture;
  50643. private _addFactorGradient;
  50644. /**
  50645. * Adds a new size gradient
  50646. * @param gradient defines the gradient to use (between 0 and 1)
  50647. * @param factor defines the size factor to affect to the specified gradient
  50648. * @returns the current particle system
  50649. */
  50650. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50651. /**
  50652. * Remove a specific size gradient
  50653. * @param gradient defines the gradient to remove
  50654. * @returns the current particle system
  50655. */
  50656. removeSizeGradient(gradient: number): GPUParticleSystem;
  50657. /**
  50658. * Adds a new angular speed gradient
  50659. * @param gradient defines the gradient to use (between 0 and 1)
  50660. * @param factor defines the angular speed to affect to the specified gradient
  50661. * @returns the current particle system
  50662. */
  50663. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50664. /**
  50665. * Remove a specific angular speed gradient
  50666. * @param gradient defines the gradient to remove
  50667. * @returns the current particle system
  50668. */
  50669. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50670. /**
  50671. * Adds a new velocity gradient
  50672. * @param gradient defines the gradient to use (between 0 and 1)
  50673. * @param factor defines the velocity to affect to the specified gradient
  50674. * @returns the current particle system
  50675. */
  50676. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50677. /**
  50678. * Remove a specific velocity gradient
  50679. * @param gradient defines the gradient to remove
  50680. * @returns the current particle system
  50681. */
  50682. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50683. /**
  50684. * Adds a new limit velocity gradient
  50685. * @param gradient defines the gradient to use (between 0 and 1)
  50686. * @param factor defines the limit velocity value to affect to the specified gradient
  50687. * @returns the current particle system
  50688. */
  50689. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50690. /**
  50691. * Remove a specific limit velocity gradient
  50692. * @param gradient defines the gradient to remove
  50693. * @returns the current particle system
  50694. */
  50695. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50696. /**
  50697. * Adds a new drag gradient
  50698. * @param gradient defines the gradient to use (between 0 and 1)
  50699. * @param factor defines the drag value to affect to the specified gradient
  50700. * @returns the current particle system
  50701. */
  50702. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50703. /**
  50704. * Remove a specific drag gradient
  50705. * @param gradient defines the gradient to remove
  50706. * @returns the current particle system
  50707. */
  50708. removeDragGradient(gradient: number): GPUParticleSystem;
  50709. /**
  50710. * Not supported by GPUParticleSystem
  50711. * @param gradient defines the gradient to use (between 0 and 1)
  50712. * @param factor defines the emit rate value to affect to the specified gradient
  50713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50714. * @returns the current particle system
  50715. */
  50716. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50717. /**
  50718. * Not supported by GPUParticleSystem
  50719. * @param gradient defines the gradient to remove
  50720. * @returns the current particle system
  50721. */
  50722. removeEmitRateGradient(gradient: number): IParticleSystem;
  50723. /**
  50724. * Not supported by GPUParticleSystem
  50725. * @param gradient defines the gradient to use (between 0 and 1)
  50726. * @param factor defines the start size value to affect to the specified gradient
  50727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50728. * @returns the current particle system
  50729. */
  50730. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50731. /**
  50732. * Not supported by GPUParticleSystem
  50733. * @param gradient defines the gradient to remove
  50734. * @returns the current particle system
  50735. */
  50736. removeStartSizeGradient(gradient: number): IParticleSystem;
  50737. /**
  50738. * Not supported by GPUParticleSystem
  50739. * @param gradient defines the gradient to use (between 0 and 1)
  50740. * @param min defines the color remap minimal range
  50741. * @param max defines the color remap maximal range
  50742. * @returns the current particle system
  50743. */
  50744. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50745. /**
  50746. * Not supported by GPUParticleSystem
  50747. * @param gradient defines the gradient to remove
  50748. * @returns the current particle system
  50749. */
  50750. removeColorRemapGradient(): IParticleSystem;
  50751. /**
  50752. * Not supported by GPUParticleSystem
  50753. * @param gradient defines the gradient to use (between 0 and 1)
  50754. * @param min defines the alpha remap minimal range
  50755. * @param max defines the alpha remap maximal range
  50756. * @returns the current particle system
  50757. */
  50758. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50759. /**
  50760. * Not supported by GPUParticleSystem
  50761. * @param gradient defines the gradient to remove
  50762. * @returns the current particle system
  50763. */
  50764. removeAlphaRemapGradient(): IParticleSystem;
  50765. /**
  50766. * Not supported by GPUParticleSystem
  50767. * @param gradient defines the gradient to use (between 0 and 1)
  50768. * @param color defines the color to affect to the specified gradient
  50769. * @returns the current particle system
  50770. */
  50771. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50772. /**
  50773. * Not supported by GPUParticleSystem
  50774. * @param gradient defines the gradient to remove
  50775. * @returns the current particle system
  50776. */
  50777. removeRampGradient(): IParticleSystem;
  50778. /**
  50779. * Not supported by GPUParticleSystem
  50780. * @returns the list of ramp gradients
  50781. */
  50782. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50783. /**
  50784. * Not supported by GPUParticleSystem
  50785. * Gets or sets a boolean indicating that ramp gradients must be used
  50786. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50787. */
  50788. useRampGradients: boolean;
  50789. /**
  50790. * Not supported by GPUParticleSystem
  50791. * @param gradient defines the gradient to use (between 0 and 1)
  50792. * @param factor defines the life time factor to affect to the specified gradient
  50793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50794. * @returns the current particle system
  50795. */
  50796. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50797. /**
  50798. * Not supported by GPUParticleSystem
  50799. * @param gradient defines the gradient to remove
  50800. * @returns the current particle system
  50801. */
  50802. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50803. /**
  50804. * Instantiates a GPU particle system.
  50805. * 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.
  50806. * @param name The name of the particle system
  50807. * @param options The options used to create the system
  50808. * @param scene The scene the particle system belongs to
  50809. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50810. */
  50811. constructor(name: string, options: Partial<{
  50812. capacity: number;
  50813. randomTextureSize: number;
  50814. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50815. protected _reset(): void;
  50816. private _createUpdateVAO;
  50817. private _createRenderVAO;
  50818. private _initialize;
  50819. /** @hidden */ recreateUpdateEffect(): void;
  50820. /** @hidden */ recreateRenderEffect(): void;
  50821. /**
  50822. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50823. * @param preWarm defines if we are in the pre-warmimg phase
  50824. */
  50825. animate(preWarm?: boolean): void;
  50826. private _createFactorGradientTexture;
  50827. private _createSizeGradientTexture;
  50828. private _createAngularSpeedGradientTexture;
  50829. private _createVelocityGradientTexture;
  50830. private _createLimitVelocityGradientTexture;
  50831. private _createDragGradientTexture;
  50832. private _createColorGradientTexture;
  50833. /**
  50834. * Renders the particle system in its current state
  50835. * @param preWarm defines if the system should only update the particles but not render them
  50836. * @returns the current number of particles
  50837. */
  50838. render(preWarm?: boolean): number;
  50839. /**
  50840. * Rebuilds the particle system
  50841. */
  50842. rebuild(): void;
  50843. private _releaseBuffers;
  50844. private _releaseVAOs;
  50845. /**
  50846. * Disposes the particle system and free the associated resources
  50847. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50848. */
  50849. dispose(disposeTexture?: boolean): void;
  50850. /**
  50851. * Clones the particle system.
  50852. * @param name The name of the cloned object
  50853. * @param newEmitter The new emitter to use
  50854. * @returns the cloned particle system
  50855. */
  50856. clone(name: string, newEmitter: any): GPUParticleSystem;
  50857. /**
  50858. * Serializes the particle system to a JSON object.
  50859. * @returns the JSON object
  50860. */
  50861. serialize(): any;
  50862. /**
  50863. * Parses a JSON object to create a GPU particle system.
  50864. * @param parsedParticleSystem The JSON object to parse
  50865. * @param scene The scene to create the particle system in
  50866. * @param rootUrl The root url to use to load external dependencies like texture
  50867. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50868. * @returns the parsed GPU particle system
  50869. */
  50870. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50871. }
  50872. }
  50873. declare module BABYLON {
  50874. /**
  50875. * Represents a set of particle systems working together to create a specific effect
  50876. */
  50877. export class ParticleSystemSet implements IDisposable {
  50878. private _emitterCreationOptions;
  50879. private _emitterNode;
  50880. /**
  50881. * Gets the particle system list
  50882. */
  50883. systems: IParticleSystem[];
  50884. /**
  50885. * Gets the emitter node used with this set
  50886. */
  50887. readonly emitterNode: Nullable<TransformNode>;
  50888. /**
  50889. * Creates a new emitter mesh as a sphere
  50890. * @param options defines the options used to create the sphere
  50891. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50892. * @param scene defines the hosting scene
  50893. */
  50894. setEmitterAsSphere(options: {
  50895. diameter: number;
  50896. segments: number;
  50897. color: Color3;
  50898. }, renderingGroupId: number, scene: Scene): void;
  50899. /**
  50900. * Starts all particle systems of the set
  50901. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50902. */
  50903. start(emitter?: AbstractMesh): void;
  50904. /**
  50905. * Release all associated resources
  50906. */
  50907. dispose(): void;
  50908. /**
  50909. * Serialize the set into a JSON compatible object
  50910. * @returns a JSON compatible representation of the set
  50911. */
  50912. serialize(): any;
  50913. /**
  50914. * Parse a new ParticleSystemSet from a serialized source
  50915. * @param data defines a JSON compatible representation of the set
  50916. * @param scene defines the hosting scene
  50917. * @param gpu defines if we want GPU particles or CPU particles
  50918. * @returns a new ParticleSystemSet
  50919. */
  50920. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50921. }
  50922. }
  50923. declare module BABYLON {
  50924. /**
  50925. * This class is made for on one-liner static method to help creating particle system set.
  50926. */
  50927. export class ParticleHelper {
  50928. /**
  50929. * Gets or sets base Assets URL
  50930. */
  50931. static BaseAssetsUrl: string;
  50932. /**
  50933. * Create a default particle system that you can tweak
  50934. * @param emitter defines the emitter to use
  50935. * @param capacity defines the system capacity (default is 500 particles)
  50936. * @param scene defines the hosting scene
  50937. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50938. * @returns the new Particle system
  50939. */
  50940. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50941. /**
  50942. * This is the main static method (one-liner) of this helper to create different particle systems
  50943. * @param type This string represents the type to the particle system to create
  50944. * @param scene The scene where the particle system should live
  50945. * @param gpu If the system will use gpu
  50946. * @returns the ParticleSystemSet created
  50947. */
  50948. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50949. /**
  50950. * Static function used to export a particle system to a ParticleSystemSet variable.
  50951. * Please note that the emitter shape is not exported
  50952. * @param systems defines the particle systems to export
  50953. * @returns the created particle system set
  50954. */
  50955. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50956. }
  50957. }
  50958. declare module BABYLON {
  50959. interface Engine {
  50960. /**
  50961. * Create an effect to use with particle systems.
  50962. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50963. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50964. * @param uniformsNames defines a list of attribute names
  50965. * @param samplers defines an array of string used to represent textures
  50966. * @param defines defines the string containing the defines to use to compile the shaders
  50967. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50968. * @param onCompiled defines a function to call when the effect creation is successful
  50969. * @param onError defines a function to call when the effect creation has failed
  50970. * @returns the new Effect
  50971. */
  50972. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50973. }
  50974. interface Mesh {
  50975. /**
  50976. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50977. * @returns an array of IParticleSystem
  50978. */
  50979. getEmittedParticleSystems(): IParticleSystem[];
  50980. /**
  50981. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50982. * @returns an array of IParticleSystem
  50983. */
  50984. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50985. }
  50986. /**
  50987. * @hidden
  50988. */
  50989. export var _IDoNeedToBeInTheBuild: number;
  50990. }
  50991. declare module BABYLON {
  50992. interface Scene {
  50993. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50994. /**
  50995. * Gets the current physics engine
  50996. * @returns a IPhysicsEngine or null if none attached
  50997. */
  50998. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50999. /**
  51000. * Enables physics to the current scene
  51001. * @param gravity defines the scene's gravity for the physics engine
  51002. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51003. * @return a boolean indicating if the physics engine was initialized
  51004. */
  51005. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51006. /**
  51007. * Disables and disposes the physics engine associated with the scene
  51008. */
  51009. disablePhysicsEngine(): void;
  51010. /**
  51011. * Gets a boolean indicating if there is an active physics engine
  51012. * @returns a boolean indicating if there is an active physics engine
  51013. */
  51014. isPhysicsEnabled(): boolean;
  51015. /**
  51016. * Deletes a physics compound impostor
  51017. * @param compound defines the compound to delete
  51018. */
  51019. deleteCompoundImpostor(compound: any): void;
  51020. /**
  51021. * An event triggered when physic simulation is about to be run
  51022. */
  51023. onBeforePhysicsObservable: Observable<Scene>;
  51024. /**
  51025. * An event triggered when physic simulation has been done
  51026. */
  51027. onAfterPhysicsObservable: Observable<Scene>;
  51028. }
  51029. interface AbstractMesh {
  51030. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  51031. /**
  51032. * Gets or sets impostor used for physic simulation
  51033. * @see http://doc.babylonjs.com/features/physics_engine
  51034. */
  51035. physicsImpostor: Nullable<PhysicsImpostor>;
  51036. /**
  51037. * Gets the current physics impostor
  51038. * @see http://doc.babylonjs.com/features/physics_engine
  51039. * @returns a physics impostor or null
  51040. */
  51041. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51042. /** Apply a physic impulse to the mesh
  51043. * @param force defines the force to apply
  51044. * @param contactPoint defines where to apply the force
  51045. * @returns the current mesh
  51046. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51047. */
  51048. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51049. /**
  51050. * Creates a physic joint between two meshes
  51051. * @param otherMesh defines the other mesh to use
  51052. * @param pivot1 defines the pivot to use on this mesh
  51053. * @param pivot2 defines the pivot to use on the other mesh
  51054. * @param options defines additional options (can be plugin dependent)
  51055. * @returns the current mesh
  51056. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51057. */
  51058. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51059. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  51060. }
  51061. /**
  51062. * Defines the physics engine scene component responsible to manage a physics engine
  51063. */
  51064. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51065. /**
  51066. * The component name helpful to identify the component in the list of scene components.
  51067. */
  51068. readonly name: string;
  51069. /**
  51070. * The scene the component belongs to.
  51071. */
  51072. scene: Scene;
  51073. /**
  51074. * Creates a new instance of the component for the given scene
  51075. * @param scene Defines the scene to register the component in
  51076. */
  51077. constructor(scene: Scene);
  51078. /**
  51079. * Registers the component in a given scene
  51080. */
  51081. register(): void;
  51082. /**
  51083. * Rebuilds the elements related to this component in case of
  51084. * context lost for instance.
  51085. */
  51086. rebuild(): void;
  51087. /**
  51088. * Disposes the component and the associated ressources
  51089. */
  51090. dispose(): void;
  51091. }
  51092. }
  51093. declare module BABYLON {
  51094. /**
  51095. * A helper for physics simulations
  51096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51097. */
  51098. export class PhysicsHelper {
  51099. private _scene;
  51100. private _physicsEngine;
  51101. /**
  51102. * Initializes the Physics helper
  51103. * @param scene Babylon.js scene
  51104. */
  51105. constructor(scene: Scene);
  51106. /**
  51107. * Applies a radial explosion impulse
  51108. * @param origin the origin of the explosion
  51109. * @param radiusOrEventOptions the radius or the options of radial explosion
  51110. * @param strength the explosion strength
  51111. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51112. * @returns A physics radial explosion event, or null
  51113. */
  51114. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51115. /**
  51116. * Applies a radial explosion force
  51117. * @param origin the origin of the explosion
  51118. * @param radiusOrEventOptions the radius or the options of radial explosion
  51119. * @param strength the explosion strength
  51120. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51121. * @returns A physics radial explosion event, or null
  51122. */
  51123. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51124. /**
  51125. * Creates a gravitational field
  51126. * @param origin the origin of the explosion
  51127. * @param radiusOrEventOptions the radius or the options of radial explosion
  51128. * @param strength the explosion strength
  51129. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51130. * @returns A physics gravitational field event, or null
  51131. */
  51132. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51133. /**
  51134. * Creates a physics updraft event
  51135. * @param origin the origin of the updraft
  51136. * @param radiusOrEventOptions the radius or the options of the updraft
  51137. * @param strength the strength of the updraft
  51138. * @param height the height of the updraft
  51139. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51140. * @returns A physics updraft event, or null
  51141. */
  51142. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51143. /**
  51144. * Creates a physics vortex event
  51145. * @param origin the of the vortex
  51146. * @param radiusOrEventOptions the radius or the options of the vortex
  51147. * @param strength the strength of the vortex
  51148. * @param height the height of the vortex
  51149. * @returns a Physics vortex event, or null
  51150. * A physics vortex event or null
  51151. */
  51152. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51153. }
  51154. /**
  51155. * Represents a physics radial explosion event
  51156. */
  51157. class PhysicsRadialExplosionEvent {
  51158. private _scene;
  51159. private _options;
  51160. private _sphere;
  51161. private _dataFetched;
  51162. /**
  51163. * Initializes a radial explosioin event
  51164. * @param _scene BabylonJS scene
  51165. * @param _options The options for the vortex event
  51166. */
  51167. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51168. /**
  51169. * Returns the data related to the radial explosion event (sphere).
  51170. * @returns The radial explosion event data
  51171. */
  51172. getData(): PhysicsRadialExplosionEventData;
  51173. /**
  51174. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51175. * @param impostor A physics imposter
  51176. * @param origin the origin of the explosion
  51177. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51178. */
  51179. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51180. /**
  51181. * Triggers affecterd impostors callbacks
  51182. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51183. */
  51184. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51185. /**
  51186. * Disposes the sphere.
  51187. * @param force Specifies if the sphere should be disposed by force
  51188. */
  51189. dispose(force?: boolean): void;
  51190. /*** Helpers ***/
  51191. private _prepareSphere;
  51192. private _intersectsWithSphere;
  51193. }
  51194. /**
  51195. * Represents a gravitational field event
  51196. */
  51197. class PhysicsGravitationalFieldEvent {
  51198. private _physicsHelper;
  51199. private _scene;
  51200. private _origin;
  51201. private _options;
  51202. private _tickCallback;
  51203. private _sphere;
  51204. private _dataFetched;
  51205. /**
  51206. * Initializes the physics gravitational field event
  51207. * @param _physicsHelper A physics helper
  51208. * @param _scene BabylonJS scene
  51209. * @param _origin The origin position of the gravitational field event
  51210. * @param _options The options for the vortex event
  51211. */
  51212. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51213. /**
  51214. * Returns the data related to the gravitational field event (sphere).
  51215. * @returns A gravitational field event
  51216. */
  51217. getData(): PhysicsGravitationalFieldEventData;
  51218. /**
  51219. * Enables the gravitational field.
  51220. */
  51221. enable(): void;
  51222. /**
  51223. * Disables the gravitational field.
  51224. */
  51225. disable(): void;
  51226. /**
  51227. * Disposes the sphere.
  51228. * @param force The force to dispose from the gravitational field event
  51229. */
  51230. dispose(force?: boolean): void;
  51231. private _tick;
  51232. }
  51233. /**
  51234. * Represents a physics updraft event
  51235. */
  51236. class PhysicsUpdraftEvent {
  51237. private _scene;
  51238. private _origin;
  51239. private _options;
  51240. private _physicsEngine;
  51241. private _originTop;
  51242. private _originDirection;
  51243. private _tickCallback;
  51244. private _cylinder;
  51245. private _cylinderPosition;
  51246. private _dataFetched;
  51247. /**
  51248. * Initializes the physics updraft event
  51249. * @param _scene BabylonJS scene
  51250. * @param _origin The origin position of the updraft
  51251. * @param _options The options for the updraft event
  51252. */
  51253. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51254. /**
  51255. * Returns the data related to the updraft event (cylinder).
  51256. * @returns A physics updraft event
  51257. */
  51258. getData(): PhysicsUpdraftEventData;
  51259. /**
  51260. * Enables the updraft.
  51261. */
  51262. enable(): void;
  51263. /**
  51264. * Disables the updraft.
  51265. */
  51266. disable(): void;
  51267. /**
  51268. * Disposes the cylinder.
  51269. * @param force Specifies if the updraft should be disposed by force
  51270. */
  51271. dispose(force?: boolean): void;
  51272. private getImpostorHitData;
  51273. private _tick;
  51274. /*** Helpers ***/
  51275. private _prepareCylinder;
  51276. private _intersectsWithCylinder;
  51277. }
  51278. /**
  51279. * Represents a physics vortex event
  51280. */
  51281. class PhysicsVortexEvent {
  51282. private _scene;
  51283. private _origin;
  51284. private _options;
  51285. private _physicsEngine;
  51286. private _originTop;
  51287. private _tickCallback;
  51288. private _cylinder;
  51289. private _cylinderPosition;
  51290. private _dataFetched;
  51291. /**
  51292. * Initializes the physics vortex event
  51293. * @param _scene The BabylonJS scene
  51294. * @param _origin The origin position of the vortex
  51295. * @param _options The options for the vortex event
  51296. */
  51297. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51298. /**
  51299. * Returns the data related to the vortex event (cylinder).
  51300. * @returns The physics vortex event data
  51301. */
  51302. getData(): PhysicsVortexEventData;
  51303. /**
  51304. * Enables the vortex.
  51305. */
  51306. enable(): void;
  51307. /**
  51308. * Disables the cortex.
  51309. */
  51310. disable(): void;
  51311. /**
  51312. * Disposes the sphere.
  51313. * @param force
  51314. */
  51315. dispose(force?: boolean): void;
  51316. private getImpostorHitData;
  51317. private _tick;
  51318. /*** Helpers ***/
  51319. private _prepareCylinder;
  51320. private _intersectsWithCylinder;
  51321. }
  51322. /**
  51323. * Options fot the radial explosion event
  51324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51325. */
  51326. export class PhysicsRadialExplosionEventOptions {
  51327. /**
  51328. * The radius of the sphere for the radial explosion.
  51329. */
  51330. radius: number;
  51331. /**
  51332. * The strenth of the explosion.
  51333. */
  51334. strength: number;
  51335. /**
  51336. * The strenght of the force in correspondence to the distance of the affected object
  51337. */
  51338. falloff: PhysicsRadialImpulseFalloff;
  51339. /**
  51340. * Sphere options for the radial explosion.
  51341. */
  51342. sphere: {
  51343. segments: number;
  51344. diameter: number;
  51345. };
  51346. /**
  51347. * Sphere options for the radial explosion.
  51348. */
  51349. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51350. }
  51351. /**
  51352. * Options fot the updraft event
  51353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51354. */
  51355. export class PhysicsUpdraftEventOptions {
  51356. /**
  51357. * The radius of the cylinder for the vortex
  51358. */
  51359. radius: number;
  51360. /**
  51361. * The strenth of the updraft.
  51362. */
  51363. strength: number;
  51364. /**
  51365. * The height of the cylinder for the updraft.
  51366. */
  51367. height: number;
  51368. /**
  51369. * The mode for the the updraft.
  51370. */
  51371. updraftMode: PhysicsUpdraftMode;
  51372. }
  51373. /**
  51374. * Options fot the vortex event
  51375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51376. */
  51377. export class PhysicsVortexEventOptions {
  51378. /**
  51379. * The radius of the cylinder for the vortex
  51380. */
  51381. radius: number;
  51382. /**
  51383. * The strenth of the vortex.
  51384. */
  51385. strength: number;
  51386. /**
  51387. * The height of the cylinder for the vortex.
  51388. */
  51389. height: number;
  51390. /**
  51391. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51392. */
  51393. centripetalForceThreshold: number;
  51394. /**
  51395. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51396. */
  51397. centripetalForceMultiplier: number;
  51398. /**
  51399. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51400. */
  51401. centrifugalForceMultiplier: number;
  51402. /**
  51403. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51404. */
  51405. updraftForceMultiplier: number;
  51406. }
  51407. /**
  51408. * The strenght of the force in correspondence to the distance of the affected object
  51409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51410. */
  51411. export enum PhysicsRadialImpulseFalloff {
  51412. /** Defines that impulse is constant in strength across it's whole radius */
  51413. Constant = 0,
  51414. /** Defines that impulse gets weaker if it's further from the origin */
  51415. Linear = 1
  51416. }
  51417. /**
  51418. * The strength of the force in correspondence to the distance of the affected object
  51419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51420. */
  51421. export enum PhysicsUpdraftMode {
  51422. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51423. Center = 0,
  51424. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51425. Perpendicular = 1
  51426. }
  51427. /**
  51428. * Interface for a physics hit data
  51429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51430. */
  51431. export interface PhysicsHitData {
  51432. /**
  51433. * The force applied at the contact point
  51434. */
  51435. force: Vector3;
  51436. /**
  51437. * The contact point
  51438. */
  51439. contactPoint: Vector3;
  51440. /**
  51441. * The distance from the origin to the contact point
  51442. */
  51443. distanceFromOrigin: number;
  51444. }
  51445. /**
  51446. * Interface for radial explosion event data
  51447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51448. */
  51449. export interface PhysicsRadialExplosionEventData {
  51450. /**
  51451. * A sphere used for the radial explosion event
  51452. */
  51453. sphere: Mesh;
  51454. }
  51455. /**
  51456. * Interface for gravitational field event data
  51457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51458. */
  51459. export interface PhysicsGravitationalFieldEventData {
  51460. /**
  51461. * A sphere mesh used for the gravitational field event
  51462. */
  51463. sphere: Mesh;
  51464. }
  51465. /**
  51466. * Interface for updraft event data
  51467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51468. */
  51469. export interface PhysicsUpdraftEventData {
  51470. /**
  51471. * A cylinder used for the updraft event
  51472. */
  51473. cylinder: Mesh;
  51474. }
  51475. /**
  51476. * Interface for vortex event data
  51477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51478. */
  51479. export interface PhysicsVortexEventData {
  51480. /**
  51481. * A cylinder used for the vortex event
  51482. */
  51483. cylinder: Mesh;
  51484. }
  51485. /**
  51486. * Interface for an affected physics impostor
  51487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51488. */
  51489. export interface PhysicsAffectedImpostorWithData {
  51490. /**
  51491. * The impostor affected by the effect
  51492. */
  51493. impostor: PhysicsImpostor;
  51494. /**
  51495. * The data about the hit/horce from the explosion
  51496. */
  51497. hitData: PhysicsHitData;
  51498. }
  51499. }
  51500. declare module BABYLON {
  51501. /** @hidden */
  51502. export var blackAndWhitePixelShader: {
  51503. name: string;
  51504. shader: string;
  51505. };
  51506. }
  51507. declare module BABYLON {
  51508. /**
  51509. * Post process used to render in black and white
  51510. */
  51511. export class BlackAndWhitePostProcess extends PostProcess {
  51512. /**
  51513. * Linear about to convert he result to black and white (default: 1)
  51514. */
  51515. degree: number;
  51516. /**
  51517. * Creates a black and white post process
  51518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51519. * @param name The name of the effect.
  51520. * @param options The required width/height ratio to downsize to before computing the render pass.
  51521. * @param camera The camera to apply the render pass to.
  51522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51523. * @param engine The engine which the post process will be applied. (default: current engine)
  51524. * @param reusable If the post process can be reused on the same frame. (default: false)
  51525. */
  51526. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51527. }
  51528. }
  51529. declare module BABYLON {
  51530. /**
  51531. * This represents a set of one or more post processes in Babylon.
  51532. * A post process can be used to apply a shader to a texture after it is rendered.
  51533. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51534. */
  51535. export class PostProcessRenderEffect {
  51536. private _postProcesses;
  51537. private _getPostProcesses;
  51538. private _singleInstance;
  51539. private _cameras;
  51540. private _indicesForCamera;
  51541. /**
  51542. * Name of the effect
  51543. * @hidden
  51544. */ name: string;
  51545. /**
  51546. * Instantiates a post process render effect.
  51547. * A post process can be used to apply a shader to a texture after it is rendered.
  51548. * @param engine The engine the effect is tied to
  51549. * @param name The name of the effect
  51550. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51551. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51552. */
  51553. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51554. /**
  51555. * Checks if all the post processes in the effect are supported.
  51556. */
  51557. readonly isSupported: boolean;
  51558. /**
  51559. * Updates the current state of the effect
  51560. * @hidden
  51561. */ update(): void;
  51562. /**
  51563. * Attaches the effect on cameras
  51564. * @param cameras The camera to attach to.
  51565. * @hidden
  51566. */ attachCameras(cameras: Camera): void;
  51567. /**
  51568. * Attaches the effect on cameras
  51569. * @param cameras The camera to attach to.
  51570. * @hidden
  51571. */ attachCameras(cameras: Camera[]): void;
  51572. /**
  51573. * Detaches the effect on cameras
  51574. * @param cameras The camera to detatch from.
  51575. * @hidden
  51576. */ detachCameras(cameras: Camera): void;
  51577. /**
  51578. * Detatches the effect on cameras
  51579. * @param cameras The camera to detatch from.
  51580. * @hidden
  51581. */ detachCameras(cameras: Camera[]): void;
  51582. /**
  51583. * Enables the effect on given cameras
  51584. * @param cameras The camera to enable.
  51585. * @hidden
  51586. */ enable(cameras: Camera): void;
  51587. /**
  51588. * Enables the effect on given cameras
  51589. * @param cameras The camera to enable.
  51590. * @hidden
  51591. */ enable(cameras: Nullable<Camera[]>): void;
  51592. /**
  51593. * Disables the effect on the given cameras
  51594. * @param cameras The camera to disable.
  51595. * @hidden
  51596. */ disable(cameras: Camera): void;
  51597. /**
  51598. * Disables the effect on the given cameras
  51599. * @param cameras The camera to disable.
  51600. * @hidden
  51601. */ disable(cameras: Nullable<Camera[]>): void;
  51602. /**
  51603. * Gets a list of the post processes contained in the effect.
  51604. * @param camera The camera to get the post processes on.
  51605. * @returns The list of the post processes in the effect.
  51606. */
  51607. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51608. }
  51609. }
  51610. declare module BABYLON {
  51611. /** @hidden */
  51612. export var extractHighlightsPixelShader: {
  51613. name: string;
  51614. shader: string;
  51615. };
  51616. }
  51617. declare module BABYLON {
  51618. /**
  51619. * 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.
  51620. */
  51621. export class ExtractHighlightsPostProcess extends PostProcess {
  51622. /**
  51623. * The luminance threshold, pixels below this value will be set to black.
  51624. */
  51625. threshold: number;
  51626. /** @hidden */ exposure: number;
  51627. /**
  51628. * Post process which has the input texture to be used when performing highlight extraction
  51629. * @hidden
  51630. */ inputPostProcess: Nullable<PostProcess>;
  51631. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51632. }
  51633. }
  51634. declare module BABYLON {
  51635. /** @hidden */
  51636. export var bloomMergePixelShader: {
  51637. name: string;
  51638. shader: string;
  51639. };
  51640. }
  51641. declare module BABYLON {
  51642. /**
  51643. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51644. */
  51645. export class BloomMergePostProcess extends PostProcess {
  51646. /** Weight of the bloom to be added to the original input. */
  51647. weight: number;
  51648. /**
  51649. * Creates a new instance of @see BloomMergePostProcess
  51650. * @param name The name of the effect.
  51651. * @param originalFromInput Post process which's input will be used for the merge.
  51652. * @param blurred Blurred highlights post process which's output will be used.
  51653. * @param weight Weight of the bloom to be added to the original input.
  51654. * @param options The required width/height ratio to downsize to before computing the render pass.
  51655. * @param camera The camera to apply the render pass to.
  51656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51657. * @param engine The engine which the post process will be applied. (default: current engine)
  51658. * @param reusable If the post process can be reused on the same frame. (default: false)
  51659. * @param textureType Type of textures used when performing the post process. (default: 0)
  51660. * @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)
  51661. */
  51662. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51663. /** Weight of the bloom to be added to the original input. */
  51664. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51665. }
  51666. }
  51667. declare module BABYLON {
  51668. /**
  51669. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51670. */
  51671. export class BloomEffect extends PostProcessRenderEffect {
  51672. private bloomScale;
  51673. /**
  51674. * @hidden Internal
  51675. */ effects: Array<PostProcess>;
  51676. /**
  51677. * @hidden Internal
  51678. */ downscale: ExtractHighlightsPostProcess;
  51679. private _blurX;
  51680. private _blurY;
  51681. private _merge;
  51682. /**
  51683. * The luminance threshold to find bright areas of the image to bloom.
  51684. */
  51685. threshold: number;
  51686. /**
  51687. * The strength of the bloom.
  51688. */
  51689. weight: number;
  51690. /**
  51691. * Specifies the size of the bloom blur kernel, relative to the final output size
  51692. */
  51693. kernel: number;
  51694. /**
  51695. * Creates a new instance of @see BloomEffect
  51696. * @param scene The scene the effect belongs to.
  51697. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51698. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51699. * @param bloomWeight The the strength of bloom.
  51700. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51701. * @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)
  51702. */
  51703. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51704. /**
  51705. * Disposes each of the internal effects for a given camera.
  51706. * @param camera The camera to dispose the effect on.
  51707. */
  51708. disposeEffects(camera: Camera): void;
  51709. /**
  51710. * @hidden Internal
  51711. */ updateEffects(): void;
  51712. /**
  51713. * Internal
  51714. * @returns if all the contained post processes are ready.
  51715. * @hidden
  51716. */ isReady(): boolean;
  51717. }
  51718. }
  51719. declare module BABYLON {
  51720. /** @hidden */
  51721. export var chromaticAberrationPixelShader: {
  51722. name: string;
  51723. shader: string;
  51724. };
  51725. }
  51726. declare module BABYLON {
  51727. /**
  51728. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51729. */
  51730. export class ChromaticAberrationPostProcess extends PostProcess {
  51731. /**
  51732. * The amount of seperation of rgb channels (default: 30)
  51733. */
  51734. aberrationAmount: number;
  51735. /**
  51736. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51737. */
  51738. radialIntensity: number;
  51739. /**
  51740. * 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))
  51741. */
  51742. direction: Vector2;
  51743. /**
  51744. * 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))
  51745. */
  51746. centerPosition: Vector2;
  51747. /**
  51748. * Creates a new instance ChromaticAberrationPostProcess
  51749. * @param name The name of the effect.
  51750. * @param screenWidth The width of the screen to apply the effect on.
  51751. * @param screenHeight The height of the screen to apply the effect on.
  51752. * @param options The required width/height ratio to downsize to before computing the render pass.
  51753. * @param camera The camera to apply the render pass to.
  51754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51755. * @param engine The engine which the post process will be applied. (default: current engine)
  51756. * @param reusable If the post process can be reused on the same frame. (default: false)
  51757. * @param textureType Type of textures used when performing the post process. (default: 0)
  51758. * @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)
  51759. */
  51760. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51761. }
  51762. }
  51763. declare module BABYLON {
  51764. /** @hidden */
  51765. export var circleOfConfusionPixelShader: {
  51766. name: string;
  51767. shader: string;
  51768. };
  51769. }
  51770. declare module BABYLON {
  51771. /**
  51772. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51773. */
  51774. export class CircleOfConfusionPostProcess extends PostProcess {
  51775. /**
  51776. * 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.
  51777. */
  51778. lensSize: number;
  51779. /**
  51780. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51781. */
  51782. fStop: number;
  51783. /**
  51784. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51785. */
  51786. focusDistance: number;
  51787. /**
  51788. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51789. */
  51790. focalLength: number;
  51791. private _depthTexture;
  51792. /**
  51793. * Creates a new instance CircleOfConfusionPostProcess
  51794. * @param name The name of the effect.
  51795. * @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.
  51796. * @param options The required width/height ratio to downsize to before computing the render pass.
  51797. * @param camera The camera to apply the render pass to.
  51798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51799. * @param engine The engine which the post process will be applied. (default: current engine)
  51800. * @param reusable If the post process can be reused on the same frame. (default: false)
  51801. * @param textureType Type of textures used when performing the post process. (default: 0)
  51802. * @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)
  51803. */
  51804. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51805. /**
  51806. * 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.
  51807. */
  51808. depthTexture: RenderTargetTexture;
  51809. }
  51810. }
  51811. declare module BABYLON {
  51812. /** @hidden */
  51813. export var colorCorrectionPixelShader: {
  51814. name: string;
  51815. shader: string;
  51816. };
  51817. }
  51818. declare module BABYLON {
  51819. /**
  51820. *
  51821. * This post-process allows the modification of rendered colors by using
  51822. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51823. *
  51824. * The object needs to be provided an url to a texture containing the color
  51825. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51826. * Use an image editing software to tweak the LUT to match your needs.
  51827. *
  51828. * For an example of a color LUT, see here:
  51829. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51830. * For explanations on color grading, see here:
  51831. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51832. *
  51833. */
  51834. export class ColorCorrectionPostProcess extends PostProcess {
  51835. private _colorTableTexture;
  51836. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51837. }
  51838. }
  51839. declare module BABYLON {
  51840. /** @hidden */
  51841. export var convolutionPixelShader: {
  51842. name: string;
  51843. shader: string;
  51844. };
  51845. }
  51846. declare module BABYLON {
  51847. /**
  51848. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51849. * input texture to perform effects such as edge detection or sharpening
  51850. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51851. */
  51852. export class ConvolutionPostProcess extends PostProcess {
  51853. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51854. kernel: number[];
  51855. /**
  51856. * Creates a new instance ConvolutionPostProcess
  51857. * @param name The name of the effect.
  51858. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51859. * @param options The required width/height ratio to downsize to before computing the render pass.
  51860. * @param camera The camera to apply the render pass to.
  51861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51862. * @param engine The engine which the post process will be applied. (default: current engine)
  51863. * @param reusable If the post process can be reused on the same frame. (default: false)
  51864. * @param textureType Type of textures used when performing the post process. (default: 0)
  51865. */
  51866. constructor(name: string,
  51867. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51868. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51869. /**
  51870. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51871. */
  51872. static EdgeDetect0Kernel: number[];
  51873. /**
  51874. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51875. */
  51876. static EdgeDetect1Kernel: number[];
  51877. /**
  51878. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51879. */
  51880. static EdgeDetect2Kernel: number[];
  51881. /**
  51882. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51883. */
  51884. static SharpenKernel: number[];
  51885. /**
  51886. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51887. */
  51888. static EmbossKernel: number[];
  51889. /**
  51890. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51891. */
  51892. static GaussianKernel: number[];
  51893. }
  51894. }
  51895. declare module BABYLON {
  51896. /**
  51897. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51898. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51899. * based on samples that have a large difference in distance than the center pixel.
  51900. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51901. */
  51902. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51903. direction: Vector2;
  51904. /**
  51905. * Creates a new instance CircleOfConfusionPostProcess
  51906. * @param name The name of the effect.
  51907. * @param scene The scene the effect belongs to.
  51908. * @param direction The direction the blur should be applied.
  51909. * @param kernel The size of the kernel used to blur.
  51910. * @param options The required width/height ratio to downsize to before computing the render pass.
  51911. * @param camera The camera to apply the render pass to.
  51912. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51913. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51915. * @param engine The engine which the post process will be applied. (default: current engine)
  51916. * @param reusable If the post process can be reused on the same frame. (default: false)
  51917. * @param textureType Type of textures used when performing the post process. (default: 0)
  51918. * @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)
  51919. */
  51920. 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);
  51921. }
  51922. }
  51923. declare module BABYLON {
  51924. /** @hidden */
  51925. export var depthOfFieldMergePixelShader: {
  51926. name: string;
  51927. shader: string;
  51928. };
  51929. }
  51930. declare module BABYLON {
  51931. /**
  51932. * Options to be set when merging outputs from the default pipeline.
  51933. */
  51934. export class DepthOfFieldMergePostProcessOptions {
  51935. /**
  51936. * The original image to merge on top of
  51937. */
  51938. originalFromInput: PostProcess;
  51939. /**
  51940. * Parameters to perform the merge of the depth of field effect
  51941. */
  51942. depthOfField?: {
  51943. circleOfConfusion: PostProcess;
  51944. blurSteps: Array<PostProcess>;
  51945. };
  51946. /**
  51947. * Parameters to perform the merge of bloom effect
  51948. */
  51949. bloom?: {
  51950. blurred: PostProcess;
  51951. weight: number;
  51952. };
  51953. }
  51954. /**
  51955. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51956. */
  51957. export class DepthOfFieldMergePostProcess extends PostProcess {
  51958. private blurSteps;
  51959. /**
  51960. * Creates a new instance of DepthOfFieldMergePostProcess
  51961. * @param name The name of the effect.
  51962. * @param originalFromInput Post process which's input will be used for the merge.
  51963. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51964. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51965. * @param options The required width/height ratio to downsize to before computing the render pass.
  51966. * @param camera The camera to apply the render pass to.
  51967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51968. * @param engine The engine which the post process will be applied. (default: current engine)
  51969. * @param reusable If the post process can be reused on the same frame. (default: false)
  51970. * @param textureType Type of textures used when performing the post process. (default: 0)
  51971. * @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)
  51972. */
  51973. 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);
  51974. /**
  51975. * Updates the effect with the current post process compile time values and recompiles the shader.
  51976. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51977. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51978. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51979. * @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
  51980. * @param onCompiled Called when the shader has been compiled.
  51981. * @param onError Called if there is an error when compiling a shader.
  51982. */
  51983. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51984. }
  51985. }
  51986. declare module BABYLON {
  51987. /**
  51988. * Specifies the level of max blur that should be applied when using the depth of field effect
  51989. */
  51990. export enum DepthOfFieldEffectBlurLevel {
  51991. /**
  51992. * Subtle blur
  51993. */
  51994. Low = 0,
  51995. /**
  51996. * Medium blur
  51997. */
  51998. Medium = 1,
  51999. /**
  52000. * Large blur
  52001. */
  52002. High = 2
  52003. }
  52004. /**
  52005. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52006. */
  52007. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52008. private _circleOfConfusion;
  52009. /**
  52010. * @hidden Internal, blurs from high to low
  52011. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52012. private _depthOfFieldBlurY;
  52013. private _dofMerge;
  52014. /**
  52015. * @hidden Internal post processes in depth of field effect
  52016. */ effects: Array<PostProcess>;
  52017. /**
  52018. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52019. */
  52020. focalLength: number;
  52021. /**
  52022. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52023. */
  52024. fStop: number;
  52025. /**
  52026. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52027. */
  52028. focusDistance: number;
  52029. /**
  52030. * 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.
  52031. */
  52032. lensSize: number;
  52033. /**
  52034. * Creates a new instance DepthOfFieldEffect
  52035. * @param scene The scene the effect belongs to.
  52036. * @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.
  52037. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52038. * @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)
  52039. */
  52040. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52041. /**
  52042. * Get the current class name of the current effet
  52043. * @returns "DepthOfFieldEffect"
  52044. */
  52045. getClassName(): string;
  52046. /**
  52047. * 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.
  52048. */
  52049. depthTexture: RenderTargetTexture;
  52050. /**
  52051. * Disposes each of the internal effects for a given camera.
  52052. * @param camera The camera to dispose the effect on.
  52053. */
  52054. disposeEffects(camera: Camera): void;
  52055. /**
  52056. * @hidden Internal
  52057. */ updateEffects(): void;
  52058. /**
  52059. * Internal
  52060. * @returns if all the contained post processes are ready.
  52061. * @hidden
  52062. */ isReady(): boolean;
  52063. }
  52064. }
  52065. declare module BABYLON {
  52066. /** @hidden */
  52067. export var displayPassPixelShader: {
  52068. name: string;
  52069. shader: string;
  52070. };
  52071. }
  52072. declare module BABYLON {
  52073. /**
  52074. * DisplayPassPostProcess which produces an output the same as it's input
  52075. */
  52076. export class DisplayPassPostProcess extends PostProcess {
  52077. /**
  52078. * Creates the DisplayPassPostProcess
  52079. * @param name The name of the effect.
  52080. * @param options The required width/height ratio to downsize to before computing the render pass.
  52081. * @param camera The camera to apply the render pass to.
  52082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52083. * @param engine The engine which the post process will be applied. (default: current engine)
  52084. * @param reusable If the post process can be reused on the same frame. (default: false)
  52085. */
  52086. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52087. }
  52088. }
  52089. declare module BABYLON {
  52090. /** @hidden */
  52091. export var filterPixelShader: {
  52092. name: string;
  52093. shader: string;
  52094. };
  52095. }
  52096. declare module BABYLON {
  52097. /**
  52098. * Applies a kernel filter to the image
  52099. */
  52100. export class FilterPostProcess extends PostProcess {
  52101. /** The matrix to be applied to the image */
  52102. kernelMatrix: Matrix;
  52103. /**
  52104. *
  52105. * @param name The name of the effect.
  52106. * @param kernelMatrix The matrix to be applied to the image
  52107. * @param options The required width/height ratio to downsize to before computing the render pass.
  52108. * @param camera The camera to apply the render pass to.
  52109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52110. * @param engine The engine which the post process will be applied. (default: current engine)
  52111. * @param reusable If the post process can be reused on the same frame. (default: false)
  52112. */
  52113. constructor(name: string,
  52114. /** The matrix to be applied to the image */
  52115. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52116. }
  52117. }
  52118. declare module BABYLON {
  52119. /** @hidden */
  52120. export var fxaaPixelShader: {
  52121. name: string;
  52122. shader: string;
  52123. };
  52124. }
  52125. declare module BABYLON {
  52126. /** @hidden */
  52127. export var fxaaVertexShader: {
  52128. name: string;
  52129. shader: string;
  52130. };
  52131. }
  52132. declare module BABYLON {
  52133. /**
  52134. * Fxaa post process
  52135. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52136. */
  52137. export class FxaaPostProcess extends PostProcess {
  52138. /** @hidden */
  52139. texelWidth: number;
  52140. /** @hidden */
  52141. texelHeight: number;
  52142. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52143. private _getDefines;
  52144. }
  52145. }
  52146. declare module BABYLON {
  52147. /** @hidden */
  52148. export var grainPixelShader: {
  52149. name: string;
  52150. shader: string;
  52151. };
  52152. }
  52153. declare module BABYLON {
  52154. /**
  52155. * The GrainPostProcess adds noise to the image at mid luminance levels
  52156. */
  52157. export class GrainPostProcess extends PostProcess {
  52158. /**
  52159. * The intensity of the grain added (default: 30)
  52160. */
  52161. intensity: number;
  52162. /**
  52163. * If the grain should be randomized on every frame
  52164. */
  52165. animated: boolean;
  52166. /**
  52167. * Creates a new instance of @see GrainPostProcess
  52168. * @param name The name of the effect.
  52169. * @param options The required width/height ratio to downsize to before computing the render pass.
  52170. * @param camera The camera to apply the render pass to.
  52171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52172. * @param engine The engine which the post process will be applied. (default: current engine)
  52173. * @param reusable If the post process can be reused on the same frame. (default: false)
  52174. * @param textureType Type of textures used when performing the post process. (default: 0)
  52175. * @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)
  52176. */
  52177. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52178. }
  52179. }
  52180. declare module BABYLON {
  52181. /** @hidden */
  52182. export var highlightsPixelShader: {
  52183. name: string;
  52184. shader: string;
  52185. };
  52186. }
  52187. declare module BABYLON {
  52188. /**
  52189. * Extracts highlights from the image
  52190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52191. */
  52192. export class HighlightsPostProcess extends PostProcess {
  52193. /**
  52194. * Extracts highlights from the image
  52195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52196. * @param name The name of the effect.
  52197. * @param options The required width/height ratio to downsize to before computing the render pass.
  52198. * @param camera The camera to apply the render pass to.
  52199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52200. * @param engine The engine which the post process will be applied. (default: current engine)
  52201. * @param reusable If the post process can be reused on the same frame. (default: false)
  52202. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52203. */
  52204. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52205. }
  52206. }
  52207. declare module BABYLON {
  52208. /** @hidden */
  52209. export var mrtFragmentDeclaration: {
  52210. name: string;
  52211. shader: string;
  52212. };
  52213. }
  52214. declare module BABYLON {
  52215. /** @hidden */
  52216. export var geometryPixelShader: {
  52217. name: string;
  52218. shader: string;
  52219. };
  52220. }
  52221. declare module BABYLON {
  52222. /** @hidden */
  52223. export var geometryVertexShader: {
  52224. name: string;
  52225. shader: string;
  52226. };
  52227. }
  52228. declare module BABYLON {
  52229. /**
  52230. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52231. */
  52232. export class GeometryBufferRenderer {
  52233. /**
  52234. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52235. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52236. */
  52237. static readonly POSITION_TEXTURE_TYPE: number;
  52238. /**
  52239. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52240. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52241. */
  52242. static readonly VELOCITY_TEXTURE_TYPE: number;
  52243. /**
  52244. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52245. * in order to compute objects velocities when enableVelocity is set to "true"
  52246. * @hidden
  52247. */ previousTransformationMatrices: {
  52248. [index: number]: Matrix;
  52249. };
  52250. private _scene;
  52251. private _multiRenderTarget;
  52252. private _ratio;
  52253. private _enablePosition;
  52254. private _enableVelocity;
  52255. private _positionIndex;
  52256. private _velocityIndex;
  52257. protected _effect: Effect;
  52258. protected _cachedDefines: string;
  52259. /**
  52260. * Set the render list (meshes to be rendered) used in the G buffer.
  52261. */
  52262. renderList: Mesh[];
  52263. /**
  52264. * Gets wether or not G buffer are supported by the running hardware.
  52265. * This requires draw buffer supports
  52266. */
  52267. readonly isSupported: boolean;
  52268. /**
  52269. * Returns the index of the given texture type in the G-Buffer textures array
  52270. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52271. * @returns the index of the given texture type in the G-Buffer textures array
  52272. */
  52273. getTextureIndex(textureType: number): number;
  52274. /**
  52275. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52276. */
  52277. /**
  52278. * Sets whether or not objects positions are enabled for the G buffer.
  52279. */
  52280. enablePosition: boolean;
  52281. /**
  52282. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52283. */
  52284. /**
  52285. * Sets wether or not objects velocities are enabled for the G buffer.
  52286. */
  52287. enableVelocity: boolean;
  52288. /**
  52289. * Gets the scene associated with the buffer.
  52290. */
  52291. readonly scene: Scene;
  52292. /**
  52293. * Gets the ratio used by the buffer during its creation.
  52294. * How big is the buffer related to the main canvas.
  52295. */
  52296. readonly ratio: number;
  52297. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  52298. /**
  52299. * Creates a new G Buffer for the scene
  52300. * @param scene The scene the buffer belongs to
  52301. * @param ratio How big is the buffer related to the main canvas.
  52302. */
  52303. constructor(scene: Scene, ratio?: number);
  52304. /**
  52305. * Checks wether everything is ready to render a submesh to the G buffer.
  52306. * @param subMesh the submesh to check readiness for
  52307. * @param useInstances is the mesh drawn using instance or not
  52308. * @returns true if ready otherwise false
  52309. */
  52310. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52311. /**
  52312. * Gets the current underlying G Buffer.
  52313. * @returns the buffer
  52314. */
  52315. getGBuffer(): MultiRenderTarget;
  52316. /**
  52317. * Gets the number of samples used to render the buffer (anti aliasing).
  52318. */
  52319. /**
  52320. * Sets the number of samples used to render the buffer (anti aliasing).
  52321. */
  52322. samples: number;
  52323. /**
  52324. * Disposes the renderer and frees up associated resources.
  52325. */
  52326. dispose(): void;
  52327. protected _createRenderTargets(): void;
  52328. }
  52329. }
  52330. declare module BABYLON {
  52331. interface Scene {
  52332. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52333. /**
  52334. * Gets or Sets the current geometry buffer associated to the scene.
  52335. */
  52336. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52337. /**
  52338. * Enables a GeometryBufferRender and associates it with the scene
  52339. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52340. * @returns the GeometryBufferRenderer
  52341. */
  52342. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52343. /**
  52344. * Disables the GeometryBufferRender associated with the scene
  52345. */
  52346. disableGeometryBufferRenderer(): void;
  52347. }
  52348. /**
  52349. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52350. * in several rendering techniques.
  52351. */
  52352. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52353. /**
  52354. * The component name helpful to identify the component in the list of scene components.
  52355. */
  52356. readonly name: string;
  52357. /**
  52358. * The scene the component belongs to.
  52359. */
  52360. scene: Scene;
  52361. /**
  52362. * Creates a new instance of the component for the given scene
  52363. * @param scene Defines the scene to register the component in
  52364. */
  52365. constructor(scene: Scene);
  52366. /**
  52367. * Registers the component in a given scene
  52368. */
  52369. register(): void;
  52370. /**
  52371. * Rebuilds the elements related to this component in case of
  52372. * context lost for instance.
  52373. */
  52374. rebuild(): void;
  52375. /**
  52376. * Disposes the component and the associated ressources
  52377. */
  52378. dispose(): void;
  52379. private _gatherRenderTargets;
  52380. }
  52381. }
  52382. declare module BABYLON {
  52383. /** @hidden */
  52384. export var motionBlurPixelShader: {
  52385. name: string;
  52386. shader: string;
  52387. };
  52388. }
  52389. declare module BABYLON {
  52390. /**
  52391. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52392. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52393. * As an example, all you have to do is to create the post-process:
  52394. * var mb = new BABYLON.MotionBlurPostProcess(
  52395. * 'mb', // The name of the effect.
  52396. * scene, // The scene containing the objects to blur according to their velocity.
  52397. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52398. * camera // The camera to apply the render pass to.
  52399. * );
  52400. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52401. */
  52402. export class MotionBlurPostProcess extends PostProcess {
  52403. /**
  52404. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52405. */
  52406. motionStrength: number;
  52407. /**
  52408. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52409. */
  52410. /**
  52411. * Sets the number of iterations to be used for motion blur quality
  52412. */
  52413. motionBlurSamples: number;
  52414. private _motionBlurSamples;
  52415. private _geometryBufferRenderer;
  52416. /**
  52417. * Creates a new instance MotionBlurPostProcess
  52418. * @param name The name of the effect.
  52419. * @param scene The scene containing the objects to blur according to their velocity.
  52420. * @param options The required width/height ratio to downsize to before computing the render pass.
  52421. * @param camera The camera to apply the render pass to.
  52422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52423. * @param engine The engine which the post process will be applied. (default: current engine)
  52424. * @param reusable If the post process can be reused on the same frame. (default: false)
  52425. * @param textureType Type of textures used when performing the post process. (default: 0)
  52426. * @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)
  52427. */
  52428. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52429. /**
  52430. * Disposes the post process.
  52431. * @param camera The camera to dispose the post process on.
  52432. */
  52433. dispose(camera?: Camera): void;
  52434. }
  52435. }
  52436. declare module BABYLON {
  52437. /** @hidden */
  52438. export var refractionPixelShader: {
  52439. name: string;
  52440. shader: string;
  52441. };
  52442. }
  52443. declare module BABYLON {
  52444. /**
  52445. * Post process which applies a refractin texture
  52446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52447. */
  52448. export class RefractionPostProcess extends PostProcess {
  52449. /** the base color of the refraction (used to taint the rendering) */
  52450. color: Color3;
  52451. /** simulated refraction depth */
  52452. depth: number;
  52453. /** the coefficient of the base color (0 to remove base color tainting) */
  52454. colorLevel: number;
  52455. private _refTexture;
  52456. private _ownRefractionTexture;
  52457. /**
  52458. * Gets or sets the refraction texture
  52459. * Please note that you are responsible for disposing the texture if you set it manually
  52460. */
  52461. refractionTexture: Texture;
  52462. /**
  52463. * Initializes the RefractionPostProcess
  52464. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52465. * @param name The name of the effect.
  52466. * @param refractionTextureUrl Url of the refraction texture to use
  52467. * @param color the base color of the refraction (used to taint the rendering)
  52468. * @param depth simulated refraction depth
  52469. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52470. * @param camera The camera to apply the render pass to.
  52471. * @param options The required width/height ratio to downsize to before computing the render pass.
  52472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52473. * @param engine The engine which the post process will be applied. (default: current engine)
  52474. * @param reusable If the post process can be reused on the same frame. (default: false)
  52475. */
  52476. constructor(name: string, refractionTextureUrl: string,
  52477. /** the base color of the refraction (used to taint the rendering) */
  52478. color: Color3,
  52479. /** simulated refraction depth */
  52480. depth: number,
  52481. /** the coefficient of the base color (0 to remove base color tainting) */
  52482. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52483. /**
  52484. * Disposes of the post process
  52485. * @param camera Camera to dispose post process on
  52486. */
  52487. dispose(camera: Camera): void;
  52488. }
  52489. }
  52490. declare module BABYLON {
  52491. /** @hidden */
  52492. export var sharpenPixelShader: {
  52493. name: string;
  52494. shader: string;
  52495. };
  52496. }
  52497. declare module BABYLON {
  52498. /**
  52499. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52500. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52501. */
  52502. export class SharpenPostProcess extends PostProcess {
  52503. /**
  52504. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52505. */
  52506. colorAmount: number;
  52507. /**
  52508. * How much sharpness should be applied (default: 0.3)
  52509. */
  52510. edgeAmount: number;
  52511. /**
  52512. * Creates a new instance ConvolutionPostProcess
  52513. * @param name The name of the effect.
  52514. * @param options The required width/height ratio to downsize to before computing the render pass.
  52515. * @param camera The camera to apply the render pass to.
  52516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52517. * @param engine The engine which the post process will be applied. (default: current engine)
  52518. * @param reusable If the post process can be reused on the same frame. (default: false)
  52519. * @param textureType Type of textures used when performing the post process. (default: 0)
  52520. * @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)
  52521. */
  52522. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52523. }
  52524. }
  52525. declare module BABYLON {
  52526. /**
  52527. * PostProcessRenderPipeline
  52528. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52529. */
  52530. export class PostProcessRenderPipeline {
  52531. private engine;
  52532. private _renderEffects;
  52533. private _renderEffectsForIsolatedPass;
  52534. /**
  52535. * List of inspectable custom properties (used by the Inspector)
  52536. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52537. */
  52538. inspectableCustomProperties: IInspectable[];
  52539. /**
  52540. * @hidden
  52541. */
  52542. protected _cameras: Camera[];
  52543. /** @hidden */ name: string;
  52544. /**
  52545. * Gets pipeline name
  52546. */
  52547. readonly name: string;
  52548. /**
  52549. * Initializes a PostProcessRenderPipeline
  52550. * @param engine engine to add the pipeline to
  52551. * @param name name of the pipeline
  52552. */
  52553. constructor(engine: Engine, name: string);
  52554. /**
  52555. * Gets the class name
  52556. * @returns "PostProcessRenderPipeline"
  52557. */
  52558. getClassName(): string;
  52559. /**
  52560. * If all the render effects in the pipeline are supported
  52561. */
  52562. readonly isSupported: boolean;
  52563. /**
  52564. * Adds an effect to the pipeline
  52565. * @param renderEffect the effect to add
  52566. */
  52567. addEffect(renderEffect: PostProcessRenderEffect): void;
  52568. /** @hidden */ rebuild(): void;
  52569. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52570. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52571. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52572. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52573. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52574. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52575. /** @hidden */ detachCameras(cameras: Camera): void;
  52576. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52577. /** @hidden */ update(): void;
  52578. /** @hidden */ reset(): void;
  52579. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52580. /**
  52581. * Disposes of the pipeline
  52582. */
  52583. dispose(): void;
  52584. }
  52585. }
  52586. declare module BABYLON {
  52587. /**
  52588. * PostProcessRenderPipelineManager class
  52589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52590. */
  52591. export class PostProcessRenderPipelineManager {
  52592. private _renderPipelines;
  52593. /**
  52594. * Initializes a PostProcessRenderPipelineManager
  52595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52596. */
  52597. constructor();
  52598. /**
  52599. * Gets the list of supported render pipelines
  52600. */
  52601. readonly supportedPipelines: PostProcessRenderPipeline[];
  52602. /**
  52603. * Adds a pipeline to the manager
  52604. * @param renderPipeline The pipeline to add
  52605. */
  52606. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52607. /**
  52608. * Attaches a camera to the pipeline
  52609. * @param renderPipelineName The name of the pipeline to attach to
  52610. * @param cameras the camera to attach
  52611. * @param unique if the camera can be attached multiple times to the pipeline
  52612. */
  52613. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52614. /**
  52615. * Detaches a camera from the pipeline
  52616. * @param renderPipelineName The name of the pipeline to detach from
  52617. * @param cameras the camera to detach
  52618. */
  52619. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52620. /**
  52621. * Enables an effect by name on a pipeline
  52622. * @param renderPipelineName the name of the pipeline to enable the effect in
  52623. * @param renderEffectName the name of the effect to enable
  52624. * @param cameras the cameras that the effect should be enabled on
  52625. */
  52626. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52627. /**
  52628. * Disables an effect by name on a pipeline
  52629. * @param renderPipelineName the name of the pipeline to disable the effect in
  52630. * @param renderEffectName the name of the effect to disable
  52631. * @param cameras the cameras that the effect should be disabled on
  52632. */
  52633. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52634. /**
  52635. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52636. */
  52637. update(): void;
  52638. /** @hidden */ rebuild(): void;
  52639. /**
  52640. * Disposes of the manager and pipelines
  52641. */
  52642. dispose(): void;
  52643. }
  52644. }
  52645. declare module BABYLON {
  52646. interface Scene {
  52647. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52648. /**
  52649. * Gets the postprocess render pipeline manager
  52650. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52651. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52652. */
  52653. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52654. }
  52655. /**
  52656. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52657. */
  52658. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52659. /**
  52660. * The component name helpfull to identify the component in the list of scene components.
  52661. */
  52662. readonly name: string;
  52663. /**
  52664. * The scene the component belongs to.
  52665. */
  52666. scene: Scene;
  52667. /**
  52668. * Creates a new instance of the component for the given scene
  52669. * @param scene Defines the scene to register the component in
  52670. */
  52671. constructor(scene: Scene);
  52672. /**
  52673. * Registers the component in a given scene
  52674. */
  52675. register(): void;
  52676. /**
  52677. * Rebuilds the elements related to this component in case of
  52678. * context lost for instance.
  52679. */
  52680. rebuild(): void;
  52681. /**
  52682. * Disposes the component and the associated ressources
  52683. */
  52684. dispose(): void;
  52685. private _gatherRenderTargets;
  52686. }
  52687. }
  52688. declare module BABYLON {
  52689. /**
  52690. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52691. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52692. */
  52693. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52694. private _scene;
  52695. private _camerasToBeAttached;
  52696. /**
  52697. * ID of the sharpen post process,
  52698. */
  52699. private readonly SharpenPostProcessId;
  52700. /**
  52701. * @ignore
  52702. * ID of the image processing post process;
  52703. */
  52704. readonly ImageProcessingPostProcessId: string;
  52705. /**
  52706. * @ignore
  52707. * ID of the Fast Approximate Anti-Aliasing post process;
  52708. */
  52709. readonly FxaaPostProcessId: string;
  52710. /**
  52711. * ID of the chromatic aberration post process,
  52712. */
  52713. private readonly ChromaticAberrationPostProcessId;
  52714. /**
  52715. * ID of the grain post process
  52716. */
  52717. private readonly GrainPostProcessId;
  52718. /**
  52719. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52720. */
  52721. sharpen: SharpenPostProcess;
  52722. private _sharpenEffect;
  52723. private bloom;
  52724. /**
  52725. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52726. */
  52727. depthOfField: DepthOfFieldEffect;
  52728. /**
  52729. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52730. */
  52731. fxaa: FxaaPostProcess;
  52732. /**
  52733. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52734. */
  52735. imageProcessing: ImageProcessingPostProcess;
  52736. /**
  52737. * Chromatic aberration post process which will shift rgb colors in the image
  52738. */
  52739. chromaticAberration: ChromaticAberrationPostProcess;
  52740. private _chromaticAberrationEffect;
  52741. /**
  52742. * Grain post process which add noise to the image
  52743. */
  52744. grain: GrainPostProcess;
  52745. private _grainEffect;
  52746. /**
  52747. * Glow post process which adds a glow to emissive areas of the image
  52748. */
  52749. private _glowLayer;
  52750. /**
  52751. * Animations which can be used to tweak settings over a period of time
  52752. */
  52753. animations: Animation[];
  52754. private _imageProcessingConfigurationObserver;
  52755. private _sharpenEnabled;
  52756. private _bloomEnabled;
  52757. private _depthOfFieldEnabled;
  52758. private _depthOfFieldBlurLevel;
  52759. private _fxaaEnabled;
  52760. private _imageProcessingEnabled;
  52761. private _defaultPipelineTextureType;
  52762. private _bloomScale;
  52763. private _chromaticAberrationEnabled;
  52764. private _grainEnabled;
  52765. private _buildAllowed;
  52766. /**
  52767. * Gets active scene
  52768. */
  52769. readonly scene: Scene;
  52770. /**
  52771. * Enable or disable the sharpen process from the pipeline
  52772. */
  52773. sharpenEnabled: boolean;
  52774. private _resizeObserver;
  52775. private _hardwareScaleLevel;
  52776. private _bloomKernel;
  52777. /**
  52778. * Specifies the size of the bloom blur kernel, relative to the final output size
  52779. */
  52780. bloomKernel: number;
  52781. /**
  52782. * Specifies the weight of the bloom in the final rendering
  52783. */
  52784. private _bloomWeight;
  52785. /**
  52786. * Specifies the luma threshold for the area that will be blurred by the bloom
  52787. */
  52788. private _bloomThreshold;
  52789. private _hdr;
  52790. /**
  52791. * The strength of the bloom.
  52792. */
  52793. bloomWeight: number;
  52794. /**
  52795. * The strength of the bloom.
  52796. */
  52797. bloomThreshold: number;
  52798. /**
  52799. * The scale of the bloom, lower value will provide better performance.
  52800. */
  52801. bloomScale: number;
  52802. /**
  52803. * Enable or disable the bloom from the pipeline
  52804. */
  52805. bloomEnabled: boolean;
  52806. private _rebuildBloom;
  52807. /**
  52808. * If the depth of field is enabled.
  52809. */
  52810. depthOfFieldEnabled: boolean;
  52811. /**
  52812. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52813. */
  52814. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52815. /**
  52816. * If the anti aliasing is enabled.
  52817. */
  52818. fxaaEnabled: boolean;
  52819. private _samples;
  52820. /**
  52821. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52822. */
  52823. samples: number;
  52824. /**
  52825. * If image processing is enabled.
  52826. */
  52827. imageProcessingEnabled: boolean;
  52828. /**
  52829. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52830. */
  52831. glowLayerEnabled: boolean;
  52832. /**
  52833. * Gets the glow layer (or null if not defined)
  52834. */
  52835. readonly glowLayer: Nullable<GlowLayer>;
  52836. /**
  52837. * Enable or disable the chromaticAberration process from the pipeline
  52838. */
  52839. chromaticAberrationEnabled: boolean;
  52840. /**
  52841. * Enable or disable the grain process from the pipeline
  52842. */
  52843. grainEnabled: boolean;
  52844. /**
  52845. * @constructor
  52846. * @param name - The rendering pipeline name (default: "")
  52847. * @param hdr - If high dynamic range textures should be used (default: true)
  52848. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52849. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52850. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52851. */
  52852. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52853. /**
  52854. * Get the class name
  52855. * @returns "DefaultRenderingPipeline"
  52856. */
  52857. getClassName(): string;
  52858. /**
  52859. * Force the compilation of the entire pipeline.
  52860. */
  52861. prepare(): void;
  52862. private _hasCleared;
  52863. private _prevPostProcess;
  52864. private _prevPrevPostProcess;
  52865. private _setAutoClearAndTextureSharing;
  52866. private _depthOfFieldSceneObserver;
  52867. private _buildPipeline;
  52868. private _disposePostProcesses;
  52869. /**
  52870. * Adds a camera to the pipeline
  52871. * @param camera the camera to be added
  52872. */
  52873. addCamera(camera: Camera): void;
  52874. /**
  52875. * Removes a camera from the pipeline
  52876. * @param camera the camera to remove
  52877. */
  52878. removeCamera(camera: Camera): void;
  52879. /**
  52880. * Dispose of the pipeline and stop all post processes
  52881. */
  52882. dispose(): void;
  52883. /**
  52884. * Serialize the rendering pipeline (Used when exporting)
  52885. * @returns the serialized object
  52886. */
  52887. serialize(): any;
  52888. /**
  52889. * Parse the serialized pipeline
  52890. * @param source Source pipeline.
  52891. * @param scene The scene to load the pipeline to.
  52892. * @param rootUrl The URL of the serialized pipeline.
  52893. * @returns An instantiated pipeline from the serialized object.
  52894. */
  52895. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52896. }
  52897. }
  52898. declare module BABYLON {
  52899. /** @hidden */
  52900. export var lensHighlightsPixelShader: {
  52901. name: string;
  52902. shader: string;
  52903. };
  52904. }
  52905. declare module BABYLON {
  52906. /** @hidden */
  52907. export var depthOfFieldPixelShader: {
  52908. name: string;
  52909. shader: string;
  52910. };
  52911. }
  52912. declare module BABYLON {
  52913. /**
  52914. * BABYLON.JS Chromatic Aberration GLSL Shader
  52915. * Author: Olivier Guyot
  52916. * Separates very slightly R, G and B colors on the edges of the screen
  52917. * Inspired by Francois Tarlier & Martins Upitis
  52918. */
  52919. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52920. /**
  52921. * @ignore
  52922. * The chromatic aberration PostProcess id in the pipeline
  52923. */
  52924. LensChromaticAberrationEffect: string;
  52925. /**
  52926. * @ignore
  52927. * The highlights enhancing PostProcess id in the pipeline
  52928. */
  52929. HighlightsEnhancingEffect: string;
  52930. /**
  52931. * @ignore
  52932. * The depth-of-field PostProcess id in the pipeline
  52933. */
  52934. LensDepthOfFieldEffect: string;
  52935. private _scene;
  52936. private _depthTexture;
  52937. private _grainTexture;
  52938. private _chromaticAberrationPostProcess;
  52939. private _highlightsPostProcess;
  52940. private _depthOfFieldPostProcess;
  52941. private _edgeBlur;
  52942. private _grainAmount;
  52943. private _chromaticAberration;
  52944. private _distortion;
  52945. private _highlightsGain;
  52946. private _highlightsThreshold;
  52947. private _dofDistance;
  52948. private _dofAperture;
  52949. private _dofDarken;
  52950. private _dofPentagon;
  52951. private _blurNoise;
  52952. /**
  52953. * @constructor
  52954. *
  52955. * Effect parameters are as follow:
  52956. * {
  52957. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52958. * edge_blur: number; // from 0 to x (1 for realism)
  52959. * distortion: number; // from 0 to x (1 for realism)
  52960. * grain_amount: number; // from 0 to 1
  52961. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52962. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52963. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52964. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52965. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52966. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52967. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52968. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52969. * }
  52970. * Note: if an effect parameter is unset, effect is disabled
  52971. *
  52972. * @param name The rendering pipeline name
  52973. * @param parameters - An object containing all parameters (see above)
  52974. * @param scene The scene linked to this pipeline
  52975. * @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)
  52976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52977. */
  52978. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52979. /**
  52980. * Get the class name
  52981. * @returns "LensRenderingPipeline"
  52982. */
  52983. getClassName(): string;
  52984. /**
  52985. * Gets associated scene
  52986. */
  52987. readonly scene: Scene;
  52988. /**
  52989. * Gets or sets the edge blur
  52990. */
  52991. edgeBlur: number;
  52992. /**
  52993. * Gets or sets the grain amount
  52994. */
  52995. grainAmount: number;
  52996. /**
  52997. * Gets or sets the chromatic aberration amount
  52998. */
  52999. chromaticAberration: number;
  53000. /**
  53001. * Gets or sets the depth of field aperture
  53002. */
  53003. dofAperture: number;
  53004. /**
  53005. * Gets or sets the edge distortion
  53006. */
  53007. edgeDistortion: number;
  53008. /**
  53009. * Gets or sets the depth of field distortion
  53010. */
  53011. dofDistortion: number;
  53012. /**
  53013. * Gets or sets the darken out of focus amount
  53014. */
  53015. darkenOutOfFocus: number;
  53016. /**
  53017. * Gets or sets a boolean indicating if blur noise is enabled
  53018. */
  53019. blurNoise: boolean;
  53020. /**
  53021. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53022. */
  53023. pentagonBokeh: boolean;
  53024. /**
  53025. * Gets or sets the highlight grain amount
  53026. */
  53027. highlightsGain: number;
  53028. /**
  53029. * Gets or sets the highlight threshold
  53030. */
  53031. highlightsThreshold: number;
  53032. /**
  53033. * Sets the amount of blur at the edges
  53034. * @param amount blur amount
  53035. */
  53036. setEdgeBlur(amount: number): void;
  53037. /**
  53038. * Sets edge blur to 0
  53039. */
  53040. disableEdgeBlur(): void;
  53041. /**
  53042. * Sets the amout of grain
  53043. * @param amount Amount of grain
  53044. */
  53045. setGrainAmount(amount: number): void;
  53046. /**
  53047. * Set grain amount to 0
  53048. */
  53049. disableGrain(): void;
  53050. /**
  53051. * Sets the chromatic aberration amount
  53052. * @param amount amount of chromatic aberration
  53053. */
  53054. setChromaticAberration(amount: number): void;
  53055. /**
  53056. * Sets chromatic aberration amount to 0
  53057. */
  53058. disableChromaticAberration(): void;
  53059. /**
  53060. * Sets the EdgeDistortion amount
  53061. * @param amount amount of EdgeDistortion
  53062. */
  53063. setEdgeDistortion(amount: number): void;
  53064. /**
  53065. * Sets edge distortion to 0
  53066. */
  53067. disableEdgeDistortion(): void;
  53068. /**
  53069. * Sets the FocusDistance amount
  53070. * @param amount amount of FocusDistance
  53071. */
  53072. setFocusDistance(amount: number): void;
  53073. /**
  53074. * Disables depth of field
  53075. */
  53076. disableDepthOfField(): void;
  53077. /**
  53078. * Sets the Aperture amount
  53079. * @param amount amount of Aperture
  53080. */
  53081. setAperture(amount: number): void;
  53082. /**
  53083. * Sets the DarkenOutOfFocus amount
  53084. * @param amount amount of DarkenOutOfFocus
  53085. */
  53086. setDarkenOutOfFocus(amount: number): void;
  53087. private _pentagonBokehIsEnabled;
  53088. /**
  53089. * Creates a pentagon bokeh effect
  53090. */
  53091. enablePentagonBokeh(): void;
  53092. /**
  53093. * Disables the pentagon bokeh effect
  53094. */
  53095. disablePentagonBokeh(): void;
  53096. /**
  53097. * Enables noise blur
  53098. */
  53099. enableNoiseBlur(): void;
  53100. /**
  53101. * Disables noise blur
  53102. */
  53103. disableNoiseBlur(): void;
  53104. /**
  53105. * Sets the HighlightsGain amount
  53106. * @param amount amount of HighlightsGain
  53107. */
  53108. setHighlightsGain(amount: number): void;
  53109. /**
  53110. * Sets the HighlightsThreshold amount
  53111. * @param amount amount of HighlightsThreshold
  53112. */
  53113. setHighlightsThreshold(amount: number): void;
  53114. /**
  53115. * Disables highlights
  53116. */
  53117. disableHighlights(): void;
  53118. /**
  53119. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53120. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53121. */
  53122. dispose(disableDepthRender?: boolean): void;
  53123. private _createChromaticAberrationPostProcess;
  53124. private _createHighlightsPostProcess;
  53125. private _createDepthOfFieldPostProcess;
  53126. private _createGrainTexture;
  53127. }
  53128. }
  53129. declare module BABYLON {
  53130. /** @hidden */
  53131. export var ssao2PixelShader: {
  53132. name: string;
  53133. shader: string;
  53134. };
  53135. }
  53136. declare module BABYLON {
  53137. /** @hidden */
  53138. export var ssaoCombinePixelShader: {
  53139. name: string;
  53140. shader: string;
  53141. };
  53142. }
  53143. declare module BABYLON {
  53144. /**
  53145. * Render pipeline to produce ssao effect
  53146. */
  53147. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53148. /**
  53149. * @ignore
  53150. * The PassPostProcess id in the pipeline that contains the original scene color
  53151. */
  53152. SSAOOriginalSceneColorEffect: string;
  53153. /**
  53154. * @ignore
  53155. * The SSAO PostProcess id in the pipeline
  53156. */
  53157. SSAORenderEffect: string;
  53158. /**
  53159. * @ignore
  53160. * The horizontal blur PostProcess id in the pipeline
  53161. */
  53162. SSAOBlurHRenderEffect: string;
  53163. /**
  53164. * @ignore
  53165. * The vertical blur PostProcess id in the pipeline
  53166. */
  53167. SSAOBlurVRenderEffect: string;
  53168. /**
  53169. * @ignore
  53170. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53171. */
  53172. SSAOCombineRenderEffect: string;
  53173. /**
  53174. * The output strength of the SSAO post-process. Default value is 1.0.
  53175. */
  53176. totalStrength: number;
  53177. /**
  53178. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53179. */
  53180. maxZ: number;
  53181. /**
  53182. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53183. */
  53184. minZAspect: number;
  53185. private _samples;
  53186. /**
  53187. * Number of samples used for the SSAO calculations. Default value is 8
  53188. */
  53189. samples: number;
  53190. private _textureSamples;
  53191. /**
  53192. * Number of samples to use for antialiasing
  53193. */
  53194. textureSamples: number;
  53195. /**
  53196. * Ratio object used for SSAO ratio and blur ratio
  53197. */
  53198. private _ratio;
  53199. /**
  53200. * Dynamically generated sphere sampler.
  53201. */
  53202. private _sampleSphere;
  53203. /**
  53204. * Blur filter offsets
  53205. */
  53206. private _samplerOffsets;
  53207. private _expensiveBlur;
  53208. /**
  53209. * If bilateral blur should be used
  53210. */
  53211. expensiveBlur: boolean;
  53212. /**
  53213. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53214. */
  53215. radius: number;
  53216. /**
  53217. * The base color of the SSAO post-process
  53218. * The final result is "base + ssao" between [0, 1]
  53219. */
  53220. base: number;
  53221. /**
  53222. * Support test.
  53223. */
  53224. static readonly IsSupported: boolean;
  53225. private _scene;
  53226. private _depthTexture;
  53227. private _normalTexture;
  53228. private _randomTexture;
  53229. private _originalColorPostProcess;
  53230. private _ssaoPostProcess;
  53231. private _blurHPostProcess;
  53232. private _blurVPostProcess;
  53233. private _ssaoCombinePostProcess;
  53234. private _firstUpdate;
  53235. /**
  53236. * Gets active scene
  53237. */
  53238. readonly scene: Scene;
  53239. /**
  53240. * @constructor
  53241. * @param name The rendering pipeline name
  53242. * @param scene The scene linked to this pipeline
  53243. * @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 }
  53244. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53245. */
  53246. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53247. /**
  53248. * Get the class name
  53249. * @returns "SSAO2RenderingPipeline"
  53250. */
  53251. getClassName(): string;
  53252. /**
  53253. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53254. */
  53255. dispose(disableGeometryBufferRenderer?: boolean): void;
  53256. private _createBlurPostProcess;
  53257. /** @hidden */ rebuild(): void;
  53258. private _bits;
  53259. private _radicalInverse_VdC;
  53260. private _hammersley;
  53261. private _hemisphereSample_uniform;
  53262. private _generateHemisphere;
  53263. private _createSSAOPostProcess;
  53264. private _createSSAOCombinePostProcess;
  53265. private _createRandomTexture;
  53266. /**
  53267. * Serialize the rendering pipeline (Used when exporting)
  53268. * @returns the serialized object
  53269. */
  53270. serialize(): any;
  53271. /**
  53272. * Parse the serialized pipeline
  53273. * @param source Source pipeline.
  53274. * @param scene The scene to load the pipeline to.
  53275. * @param rootUrl The URL of the serialized pipeline.
  53276. * @returns An instantiated pipeline from the serialized object.
  53277. */
  53278. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /** @hidden */
  53283. export var ssaoPixelShader: {
  53284. name: string;
  53285. shader: string;
  53286. };
  53287. }
  53288. declare module BABYLON {
  53289. /**
  53290. * Render pipeline to produce ssao effect
  53291. */
  53292. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53293. /**
  53294. * @ignore
  53295. * The PassPostProcess id in the pipeline that contains the original scene color
  53296. */
  53297. SSAOOriginalSceneColorEffect: string;
  53298. /**
  53299. * @ignore
  53300. * The SSAO PostProcess id in the pipeline
  53301. */
  53302. SSAORenderEffect: string;
  53303. /**
  53304. * @ignore
  53305. * The horizontal blur PostProcess id in the pipeline
  53306. */
  53307. SSAOBlurHRenderEffect: string;
  53308. /**
  53309. * @ignore
  53310. * The vertical blur PostProcess id in the pipeline
  53311. */
  53312. SSAOBlurVRenderEffect: string;
  53313. /**
  53314. * @ignore
  53315. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53316. */
  53317. SSAOCombineRenderEffect: string;
  53318. /**
  53319. * The output strength of the SSAO post-process. Default value is 1.0.
  53320. */
  53321. totalStrength: number;
  53322. /**
  53323. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53324. */
  53325. radius: number;
  53326. /**
  53327. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53328. * Must not be equal to fallOff and superior to fallOff.
  53329. * Default value is 0.0075
  53330. */
  53331. area: number;
  53332. /**
  53333. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53334. * Must not be equal to area and inferior to area.
  53335. * Default value is 0.000001
  53336. */
  53337. fallOff: number;
  53338. /**
  53339. * The base color of the SSAO post-process
  53340. * The final result is "base + ssao" between [0, 1]
  53341. */
  53342. base: number;
  53343. private _scene;
  53344. private _depthTexture;
  53345. private _randomTexture;
  53346. private _originalColorPostProcess;
  53347. private _ssaoPostProcess;
  53348. private _blurHPostProcess;
  53349. private _blurVPostProcess;
  53350. private _ssaoCombinePostProcess;
  53351. private _firstUpdate;
  53352. /**
  53353. * Gets active scene
  53354. */
  53355. readonly scene: Scene;
  53356. /**
  53357. * @constructor
  53358. * @param name - The rendering pipeline name
  53359. * @param scene - The scene linked to this pipeline
  53360. * @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 }
  53361. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53362. */
  53363. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53364. /**
  53365. * Get the class name
  53366. * @returns "SSAORenderingPipeline"
  53367. */
  53368. getClassName(): string;
  53369. /**
  53370. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53371. */
  53372. dispose(disableDepthRender?: boolean): void;
  53373. private _createBlurPostProcess;
  53374. /** @hidden */ rebuild(): void;
  53375. private _createSSAOPostProcess;
  53376. private _createSSAOCombinePostProcess;
  53377. private _createRandomTexture;
  53378. }
  53379. }
  53380. declare module BABYLON {
  53381. /** @hidden */
  53382. export var standardPixelShader: {
  53383. name: string;
  53384. shader: string;
  53385. };
  53386. }
  53387. declare module BABYLON {
  53388. /**
  53389. * Standard rendering pipeline
  53390. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53391. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53392. */
  53393. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53394. /**
  53395. * Public members
  53396. */
  53397. /**
  53398. * Post-process which contains the original scene color before the pipeline applies all the effects
  53399. */
  53400. originalPostProcess: Nullable<PostProcess>;
  53401. /**
  53402. * Post-process used to down scale an image x4
  53403. */
  53404. downSampleX4PostProcess: Nullable<PostProcess>;
  53405. /**
  53406. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53407. */
  53408. brightPassPostProcess: Nullable<PostProcess>;
  53409. /**
  53410. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53411. */
  53412. blurHPostProcesses: PostProcess[];
  53413. /**
  53414. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53415. */
  53416. blurVPostProcesses: PostProcess[];
  53417. /**
  53418. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53419. */
  53420. textureAdderPostProcess: Nullable<PostProcess>;
  53421. /**
  53422. * Post-process used to create volumetric lighting effect
  53423. */
  53424. volumetricLightPostProcess: Nullable<PostProcess>;
  53425. /**
  53426. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53427. */
  53428. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53429. /**
  53430. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53431. */
  53432. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53433. /**
  53434. * Post-process used to merge the volumetric light effect and the real scene color
  53435. */
  53436. volumetricLightMergePostProces: Nullable<PostProcess>;
  53437. /**
  53438. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53439. */
  53440. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53441. /**
  53442. * Base post-process used to calculate the average luminance of the final image for HDR
  53443. */
  53444. luminancePostProcess: Nullable<PostProcess>;
  53445. /**
  53446. * Post-processes used to create down sample post-processes in order to get
  53447. * the average luminance of the final image for HDR
  53448. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53449. */
  53450. luminanceDownSamplePostProcesses: PostProcess[];
  53451. /**
  53452. * Post-process used to create a HDR effect (light adaptation)
  53453. */
  53454. hdrPostProcess: Nullable<PostProcess>;
  53455. /**
  53456. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53457. */
  53458. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53459. /**
  53460. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53461. */
  53462. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53463. /**
  53464. * Post-process used to merge the final HDR post-process and the real scene color
  53465. */
  53466. hdrFinalPostProcess: Nullable<PostProcess>;
  53467. /**
  53468. * Post-process used to create a lens flare effect
  53469. */
  53470. lensFlarePostProcess: Nullable<PostProcess>;
  53471. /**
  53472. * Post-process that merges the result of the lens flare post-process and the real scene color
  53473. */
  53474. lensFlareComposePostProcess: Nullable<PostProcess>;
  53475. /**
  53476. * Post-process used to create a motion blur effect
  53477. */
  53478. motionBlurPostProcess: Nullable<PostProcess>;
  53479. /**
  53480. * Post-process used to create a depth of field effect
  53481. */
  53482. depthOfFieldPostProcess: Nullable<PostProcess>;
  53483. /**
  53484. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53485. */
  53486. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53487. /**
  53488. * Represents the brightness threshold in order to configure the illuminated surfaces
  53489. */
  53490. brightThreshold: number;
  53491. /**
  53492. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53493. */
  53494. blurWidth: number;
  53495. /**
  53496. * Sets if the blur for highlighted surfaces must be only horizontal
  53497. */
  53498. horizontalBlur: boolean;
  53499. /**
  53500. * Gets the overall exposure used by the pipeline
  53501. */
  53502. /**
  53503. * Sets the overall exposure used by the pipeline
  53504. */
  53505. exposure: number;
  53506. /**
  53507. * Texture used typically to simulate "dirty" on camera lens
  53508. */
  53509. lensTexture: Nullable<Texture>;
  53510. /**
  53511. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53512. */
  53513. volumetricLightCoefficient: number;
  53514. /**
  53515. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53516. */
  53517. volumetricLightPower: number;
  53518. /**
  53519. * Used the set the blur intensity to smooth the volumetric lights
  53520. */
  53521. volumetricLightBlurScale: number;
  53522. /**
  53523. * Light (spot or directional) used to generate the volumetric lights rays
  53524. * The source light must have a shadow generate so the pipeline can get its
  53525. * depth map
  53526. */
  53527. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53528. /**
  53529. * For eye adaptation, represents the minimum luminance the eye can see
  53530. */
  53531. hdrMinimumLuminance: number;
  53532. /**
  53533. * For eye adaptation, represents the decrease luminance speed
  53534. */
  53535. hdrDecreaseRate: number;
  53536. /**
  53537. * For eye adaptation, represents the increase luminance speed
  53538. */
  53539. hdrIncreaseRate: number;
  53540. /**
  53541. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53542. */
  53543. /**
  53544. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53545. */
  53546. hdrAutoExposure: boolean;
  53547. /**
  53548. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53549. */
  53550. lensColorTexture: Nullable<Texture>;
  53551. /**
  53552. * The overall strengh for the lens flare effect
  53553. */
  53554. lensFlareStrength: number;
  53555. /**
  53556. * Dispersion coefficient for lens flare ghosts
  53557. */
  53558. lensFlareGhostDispersal: number;
  53559. /**
  53560. * Main lens flare halo width
  53561. */
  53562. lensFlareHaloWidth: number;
  53563. /**
  53564. * Based on the lens distortion effect, defines how much the lens flare result
  53565. * is distorted
  53566. */
  53567. lensFlareDistortionStrength: number;
  53568. /**
  53569. * Lens star texture must be used to simulate rays on the flares and is available
  53570. * in the documentation
  53571. */
  53572. lensStarTexture: Nullable<Texture>;
  53573. /**
  53574. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53575. * flare effect by taking account of the dirt texture
  53576. */
  53577. lensFlareDirtTexture: Nullable<Texture>;
  53578. /**
  53579. * Represents the focal length for the depth of field effect
  53580. */
  53581. depthOfFieldDistance: number;
  53582. /**
  53583. * Represents the blur intensity for the blurred part of the depth of field effect
  53584. */
  53585. depthOfFieldBlurWidth: number;
  53586. /**
  53587. * For motion blur, defines how much the image is blurred by the movement
  53588. */
  53589. motionStrength: number;
  53590. /**
  53591. * List of animations for the pipeline (IAnimatable implementation)
  53592. */
  53593. animations: Animation[];
  53594. /**
  53595. * Private members
  53596. */
  53597. private _scene;
  53598. private _currentDepthOfFieldSource;
  53599. private _basePostProcess;
  53600. private _fixedExposure;
  53601. private _currentExposure;
  53602. private _hdrAutoExposure;
  53603. private _hdrCurrentLuminance;
  53604. private _floatTextureType;
  53605. private _ratio;
  53606. private _bloomEnabled;
  53607. private _depthOfFieldEnabled;
  53608. private _vlsEnabled;
  53609. private _lensFlareEnabled;
  53610. private _hdrEnabled;
  53611. private _motionBlurEnabled;
  53612. private _fxaaEnabled;
  53613. private _motionBlurSamples;
  53614. private _volumetricLightStepsCount;
  53615. private _samples;
  53616. /**
  53617. * @ignore
  53618. * Specifies if the bloom pipeline is enabled
  53619. */
  53620. BloomEnabled: boolean;
  53621. /**
  53622. * @ignore
  53623. * Specifies if the depth of field pipeline is enabed
  53624. */
  53625. DepthOfFieldEnabled: boolean;
  53626. /**
  53627. * @ignore
  53628. * Specifies if the lens flare pipeline is enabed
  53629. */
  53630. LensFlareEnabled: boolean;
  53631. /**
  53632. * @ignore
  53633. * Specifies if the HDR pipeline is enabled
  53634. */
  53635. HDREnabled: boolean;
  53636. /**
  53637. * @ignore
  53638. * Specifies if the volumetric lights scattering effect is enabled
  53639. */
  53640. VLSEnabled: boolean;
  53641. /**
  53642. * @ignore
  53643. * Specifies if the motion blur effect is enabled
  53644. */
  53645. MotionBlurEnabled: boolean;
  53646. /**
  53647. * Specifies if anti-aliasing is enabled
  53648. */
  53649. fxaaEnabled: boolean;
  53650. /**
  53651. * Specifies the number of steps used to calculate the volumetric lights
  53652. * Typically in interval [50, 200]
  53653. */
  53654. volumetricLightStepsCount: number;
  53655. /**
  53656. * Specifies the number of samples used for the motion blur effect
  53657. * Typically in interval [16, 64]
  53658. */
  53659. motionBlurSamples: number;
  53660. /**
  53661. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53662. */
  53663. samples: number;
  53664. /**
  53665. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53666. * @constructor
  53667. * @param name The rendering pipeline name
  53668. * @param scene The scene linked to this pipeline
  53669. * @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)
  53670. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53671. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53672. */
  53673. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53674. private _buildPipeline;
  53675. private _createDownSampleX4PostProcess;
  53676. private _createBrightPassPostProcess;
  53677. private _createBlurPostProcesses;
  53678. private _createTextureAdderPostProcess;
  53679. private _createVolumetricLightPostProcess;
  53680. private _createLuminancePostProcesses;
  53681. private _createHdrPostProcess;
  53682. private _createLensFlarePostProcess;
  53683. private _createDepthOfFieldPostProcess;
  53684. private _createMotionBlurPostProcess;
  53685. private _getDepthTexture;
  53686. private _disposePostProcesses;
  53687. /**
  53688. * Dispose of the pipeline and stop all post processes
  53689. */
  53690. dispose(): void;
  53691. /**
  53692. * Serialize the rendering pipeline (Used when exporting)
  53693. * @returns the serialized object
  53694. */
  53695. serialize(): any;
  53696. /**
  53697. * Parse the serialized pipeline
  53698. * @param source Source pipeline.
  53699. * @param scene The scene to load the pipeline to.
  53700. * @param rootUrl The URL of the serialized pipeline.
  53701. * @returns An instantiated pipeline from the serialized object.
  53702. */
  53703. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53704. /**
  53705. * Luminance steps
  53706. */
  53707. static LuminanceSteps: number;
  53708. }
  53709. }
  53710. declare module BABYLON {
  53711. /** @hidden */
  53712. export var tonemapPixelShader: {
  53713. name: string;
  53714. shader: string;
  53715. };
  53716. }
  53717. declare module BABYLON {
  53718. /** Defines operator used for tonemapping */
  53719. export enum TonemappingOperator {
  53720. /** Hable */
  53721. Hable = 0,
  53722. /** Reinhard */
  53723. Reinhard = 1,
  53724. /** HejiDawson */
  53725. HejiDawson = 2,
  53726. /** Photographic */
  53727. Photographic = 3
  53728. }
  53729. /**
  53730. * Defines a post process to apply tone mapping
  53731. */
  53732. export class TonemapPostProcess extends PostProcess {
  53733. private _operator;
  53734. /** Defines the required exposure adjustement */
  53735. exposureAdjustment: number;
  53736. /**
  53737. * Creates a new TonemapPostProcess
  53738. * @param name defines the name of the postprocess
  53739. * @param _operator defines the operator to use
  53740. * @param exposureAdjustment defines the required exposure adjustement
  53741. * @param camera defines the camera to use (can be null)
  53742. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53743. * @param engine defines the hosting engine (can be ignore if camera is set)
  53744. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53745. */
  53746. constructor(name: string, _operator: TonemappingOperator,
  53747. /** Defines the required exposure adjustement */
  53748. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53749. }
  53750. }
  53751. declare module BABYLON {
  53752. /** @hidden */
  53753. export var depthVertexShader: {
  53754. name: string;
  53755. shader: string;
  53756. };
  53757. }
  53758. declare module BABYLON {
  53759. /** @hidden */
  53760. export var volumetricLightScatteringPixelShader: {
  53761. name: string;
  53762. shader: string;
  53763. };
  53764. }
  53765. declare module BABYLON {
  53766. /** @hidden */
  53767. export var volumetricLightScatteringPassPixelShader: {
  53768. name: string;
  53769. shader: string;
  53770. };
  53771. }
  53772. declare module BABYLON {
  53773. /**
  53774. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53775. */
  53776. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53777. private _volumetricLightScatteringPass;
  53778. private _volumetricLightScatteringRTT;
  53779. private _viewPort;
  53780. private _screenCoordinates;
  53781. private _cachedDefines;
  53782. /**
  53783. * If not undefined, the mesh position is computed from the attached node position
  53784. */
  53785. attachedNode: {
  53786. position: Vector3;
  53787. };
  53788. /**
  53789. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53790. */
  53791. customMeshPosition: Vector3;
  53792. /**
  53793. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53794. */
  53795. useCustomMeshPosition: boolean;
  53796. /**
  53797. * If the post-process should inverse the light scattering direction
  53798. */
  53799. invert: boolean;
  53800. /**
  53801. * The internal mesh used by the post-process
  53802. */
  53803. mesh: Mesh;
  53804. /**
  53805. * @hidden
  53806. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53807. */
  53808. useDiffuseColor: boolean;
  53809. /**
  53810. * Array containing the excluded meshes not rendered in the internal pass
  53811. */
  53812. excludedMeshes: AbstractMesh[];
  53813. /**
  53814. * Controls the overall intensity of the post-process
  53815. */
  53816. exposure: number;
  53817. /**
  53818. * Dissipates each sample's contribution in range [0, 1]
  53819. */
  53820. decay: number;
  53821. /**
  53822. * Controls the overall intensity of each sample
  53823. */
  53824. weight: number;
  53825. /**
  53826. * Controls the density of each sample
  53827. */
  53828. density: number;
  53829. /**
  53830. * @constructor
  53831. * @param name The post-process name
  53832. * @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)
  53833. * @param camera The camera that the post-process will be attached to
  53834. * @param mesh The mesh used to create the light scattering
  53835. * @param samples The post-process quality, default 100
  53836. * @param samplingModeThe post-process filtering mode
  53837. * @param engine The babylon engine
  53838. * @param reusable If the post-process is reusable
  53839. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53840. */
  53841. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53842. /**
  53843. * Returns the string "VolumetricLightScatteringPostProcess"
  53844. * @returns "VolumetricLightScatteringPostProcess"
  53845. */
  53846. getClassName(): string;
  53847. private _isReady;
  53848. /**
  53849. * Sets the new light position for light scattering effect
  53850. * @param position The new custom light position
  53851. */
  53852. setCustomMeshPosition(position: Vector3): void;
  53853. /**
  53854. * Returns the light position for light scattering effect
  53855. * @return Vector3 The custom light position
  53856. */
  53857. getCustomMeshPosition(): Vector3;
  53858. /**
  53859. * Disposes the internal assets and detaches the post-process from the camera
  53860. */
  53861. dispose(camera: Camera): void;
  53862. /**
  53863. * Returns the render target texture used by the post-process
  53864. * @return the render target texture used by the post-process
  53865. */
  53866. getPass(): RenderTargetTexture;
  53867. private _meshExcluded;
  53868. private _createPass;
  53869. private _updateMeshScreenCoordinates;
  53870. /**
  53871. * Creates a default mesh for the Volumeric Light Scattering post-process
  53872. * @param name The mesh name
  53873. * @param scene The scene where to create the mesh
  53874. * @return the default mesh
  53875. */
  53876. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53877. }
  53878. }
  53879. declare module BABYLON {
  53880. interface Scene {
  53881. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53882. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53883. /**
  53884. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53885. */
  53886. forceShowBoundingBoxes: boolean;
  53887. /**
  53888. * Gets the bounding box renderer associated with the scene
  53889. * @returns a BoundingBoxRenderer
  53890. */
  53891. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53892. }
  53893. interface AbstractMesh {
  53894. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53895. /**
  53896. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53897. */
  53898. showBoundingBox: boolean;
  53899. }
  53900. /**
  53901. * Component responsible of rendering the bounding box of the meshes in a scene.
  53902. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53903. */
  53904. export class BoundingBoxRenderer implements ISceneComponent {
  53905. /**
  53906. * The component name helpfull to identify the component in the list of scene components.
  53907. */
  53908. readonly name: string;
  53909. /**
  53910. * The scene the component belongs to.
  53911. */
  53912. scene: Scene;
  53913. /**
  53914. * Color of the bounding box lines placed in front of an object
  53915. */
  53916. frontColor: Color3;
  53917. /**
  53918. * Color of the bounding box lines placed behind an object
  53919. */
  53920. backColor: Color3;
  53921. /**
  53922. * Defines if the renderer should show the back lines or not
  53923. */
  53924. showBackLines: boolean;
  53925. /**
  53926. * @hidden
  53927. */
  53928. renderList: SmartArray<BoundingBox>;
  53929. private _colorShader;
  53930. private _vertexBuffers;
  53931. private _indexBuffer;
  53932. /**
  53933. * Instantiates a new bounding box renderer in a scene.
  53934. * @param scene the scene the renderer renders in
  53935. */
  53936. constructor(scene: Scene);
  53937. /**
  53938. * Registers the component in a given scene
  53939. */
  53940. register(): void;
  53941. private _evaluateSubMesh;
  53942. private _activeMesh;
  53943. private _prepareRessources;
  53944. private _createIndexBuffer;
  53945. /**
  53946. * Rebuilds the elements related to this component in case of
  53947. * context lost for instance.
  53948. */
  53949. rebuild(): void;
  53950. /**
  53951. * @hidden
  53952. */
  53953. reset(): void;
  53954. /**
  53955. * Render the bounding boxes of a specific rendering group
  53956. * @param renderingGroupId defines the rendering group to render
  53957. */
  53958. render(renderingGroupId: number): void;
  53959. /**
  53960. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53961. * @param mesh Define the mesh to render the occlusion bounding box for
  53962. */
  53963. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53964. /**
  53965. * Dispose and release the resources attached to this renderer.
  53966. */
  53967. dispose(): void;
  53968. }
  53969. }
  53970. declare module BABYLON {
  53971. /** @hidden */
  53972. export var depthPixelShader: {
  53973. name: string;
  53974. shader: string;
  53975. };
  53976. }
  53977. declare module BABYLON {
  53978. /**
  53979. * This represents a depth renderer in Babylon.
  53980. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53981. */
  53982. export class DepthRenderer {
  53983. private _scene;
  53984. private _depthMap;
  53985. private _effect;
  53986. private _cachedDefines;
  53987. private _camera;
  53988. /**
  53989. * Specifiess that the depth renderer will only be used within
  53990. * the camera it is created for.
  53991. * This can help forcing its rendering during the camera processing.
  53992. */
  53993. useOnlyInActiveCamera: boolean;
  53994. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53995. /**
  53996. * Instantiates a depth renderer
  53997. * @param scene The scene the renderer belongs to
  53998. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53999. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54000. */
  54001. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54002. /**
  54003. * Creates the depth rendering effect and checks if the effect is ready.
  54004. * @param subMesh The submesh to be used to render the depth map of
  54005. * @param useInstances If multiple world instances should be used
  54006. * @returns if the depth renderer is ready to render the depth map
  54007. */
  54008. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54009. /**
  54010. * Gets the texture which the depth map will be written to.
  54011. * @returns The depth map texture
  54012. */
  54013. getDepthMap(): RenderTargetTexture;
  54014. /**
  54015. * Disposes of the depth renderer.
  54016. */
  54017. dispose(): void;
  54018. }
  54019. }
  54020. declare module BABYLON {
  54021. interface Scene {
  54022. /** @hidden (Backing field) */ depthRenderer: {
  54023. [id: string]: DepthRenderer;
  54024. };
  54025. /**
  54026. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54027. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54028. * @returns the created depth renderer
  54029. */
  54030. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54031. /**
  54032. * Disables a depth renderer for a given camera
  54033. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54034. */
  54035. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54036. }
  54037. /**
  54038. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54039. * in several rendering techniques.
  54040. */
  54041. export class DepthRendererSceneComponent implements ISceneComponent {
  54042. /**
  54043. * The component name helpfull to identify the component in the list of scene components.
  54044. */
  54045. readonly name: string;
  54046. /**
  54047. * The scene the component belongs to.
  54048. */
  54049. scene: Scene;
  54050. /**
  54051. * Creates a new instance of the component for the given scene
  54052. * @param scene Defines the scene to register the component in
  54053. */
  54054. constructor(scene: Scene);
  54055. /**
  54056. * Registers the component in a given scene
  54057. */
  54058. register(): void;
  54059. /**
  54060. * Rebuilds the elements related to this component in case of
  54061. * context lost for instance.
  54062. */
  54063. rebuild(): void;
  54064. /**
  54065. * Disposes the component and the associated ressources
  54066. */
  54067. dispose(): void;
  54068. private _gatherRenderTargets;
  54069. private _gatherActiveCameraRenderTargets;
  54070. }
  54071. }
  54072. declare module BABYLON {
  54073. /** @hidden */
  54074. export var outlinePixelShader: {
  54075. name: string;
  54076. shader: string;
  54077. };
  54078. }
  54079. declare module BABYLON {
  54080. /** @hidden */
  54081. export var outlineVertexShader: {
  54082. name: string;
  54083. shader: string;
  54084. };
  54085. }
  54086. declare module BABYLON {
  54087. interface Scene {
  54088. /** @hidden */ outlineRenderer: OutlineRenderer;
  54089. /**
  54090. * Gets the outline renderer associated with the scene
  54091. * @returns a OutlineRenderer
  54092. */
  54093. getOutlineRenderer(): OutlineRenderer;
  54094. }
  54095. interface AbstractMesh {
  54096. /** @hidden (Backing field) */ renderOutline: boolean;
  54097. /**
  54098. * Gets or sets a boolean indicating if the outline must be rendered as well
  54099. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54100. */
  54101. renderOutline: boolean;
  54102. /** @hidden (Backing field) */ renderOverlay: boolean;
  54103. /**
  54104. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54105. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54106. */
  54107. renderOverlay: boolean;
  54108. }
  54109. /**
  54110. * This class is responsible to draw bothe outline/overlay of meshes.
  54111. * It should not be used directly but through the available method on mesh.
  54112. */
  54113. export class OutlineRenderer implements ISceneComponent {
  54114. /**
  54115. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54116. */
  54117. private static _StencilReference;
  54118. /**
  54119. * The name of the component. Each component must have a unique name.
  54120. */
  54121. name: string;
  54122. /**
  54123. * The scene the component belongs to.
  54124. */
  54125. scene: Scene;
  54126. /**
  54127. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54128. */
  54129. zOffset: number;
  54130. private _engine;
  54131. private _effect;
  54132. private _cachedDefines;
  54133. private _savedDepthWrite;
  54134. /**
  54135. * Instantiates a new outline renderer. (There could be only one per scene).
  54136. * @param scene Defines the scene it belongs to
  54137. */
  54138. constructor(scene: Scene);
  54139. /**
  54140. * Register the component to one instance of a scene.
  54141. */
  54142. register(): void;
  54143. /**
  54144. * Rebuilds the elements related to this component in case of
  54145. * context lost for instance.
  54146. */
  54147. rebuild(): void;
  54148. /**
  54149. * Disposes the component and the associated ressources.
  54150. */
  54151. dispose(): void;
  54152. /**
  54153. * Renders the outline in the canvas.
  54154. * @param subMesh Defines the sumesh to render
  54155. * @param batch Defines the batch of meshes in case of instances
  54156. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54157. */
  54158. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54159. /**
  54160. * Returns whether or not the outline renderer is ready for a given submesh.
  54161. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54162. * @param subMesh Defines the submesh to check readyness for
  54163. * @param useInstances Defines wheter wee are trying to render instances or not
  54164. * @returns true if ready otherwise false
  54165. */
  54166. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54167. private _beforeRenderingMesh;
  54168. private _afterRenderingMesh;
  54169. }
  54170. }
  54171. declare module BABYLON {
  54172. /**
  54173. * Defines the list of states available for a task inside a AssetsManager
  54174. */
  54175. export enum AssetTaskState {
  54176. /**
  54177. * Initialization
  54178. */
  54179. INIT = 0,
  54180. /**
  54181. * Running
  54182. */
  54183. RUNNING = 1,
  54184. /**
  54185. * Done
  54186. */
  54187. DONE = 2,
  54188. /**
  54189. * Error
  54190. */
  54191. ERROR = 3
  54192. }
  54193. /**
  54194. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54195. */
  54196. export abstract class AbstractAssetTask {
  54197. /**
  54198. * Task name
  54199. */ name: string;
  54200. /**
  54201. * Callback called when the task is successful
  54202. */
  54203. onSuccess: (task: any) => void;
  54204. /**
  54205. * Callback called when the task is not successful
  54206. */
  54207. onError: (task: any, message?: string, exception?: any) => void;
  54208. /**
  54209. * Creates a new AssetsManager
  54210. * @param name defines the name of the task
  54211. */
  54212. constructor(
  54213. /**
  54214. * Task name
  54215. */ name: string);
  54216. private _isCompleted;
  54217. private _taskState;
  54218. private _errorObject;
  54219. /**
  54220. * Get if the task is completed
  54221. */
  54222. readonly isCompleted: boolean;
  54223. /**
  54224. * Gets the current state of the task
  54225. */
  54226. readonly taskState: AssetTaskState;
  54227. /**
  54228. * Gets the current error object (if task is in error)
  54229. */
  54230. readonly errorObject: {
  54231. message?: string;
  54232. exception?: any;
  54233. };
  54234. /**
  54235. * Internal only
  54236. * @hidden
  54237. */ setErrorObject(message?: string, exception?: any): void;
  54238. /**
  54239. * Execute the current task
  54240. * @param scene defines the scene where you want your assets to be loaded
  54241. * @param onSuccess is a callback called when the task is successfully executed
  54242. * @param onError is a callback called if an error occurs
  54243. */
  54244. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54245. /**
  54246. * Execute the current task
  54247. * @param scene defines the scene where you want your assets to be loaded
  54248. * @param onSuccess is a callback called when the task is successfully executed
  54249. * @param onError is a callback called if an error occurs
  54250. */
  54251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54252. /**
  54253. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54254. * This can be used with failed tasks that have the reason for failure fixed.
  54255. */
  54256. reset(): void;
  54257. private onErrorCallback;
  54258. private onDoneCallback;
  54259. }
  54260. /**
  54261. * Define the interface used by progress events raised during assets loading
  54262. */
  54263. export interface IAssetsProgressEvent {
  54264. /**
  54265. * Defines the number of remaining tasks to process
  54266. */
  54267. remainingCount: number;
  54268. /**
  54269. * Defines the total number of tasks
  54270. */
  54271. totalCount: number;
  54272. /**
  54273. * Defines the task that was just processed
  54274. */
  54275. task: AbstractAssetTask;
  54276. }
  54277. /**
  54278. * Class used to share progress information about assets loading
  54279. */
  54280. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54281. /**
  54282. * Defines the number of remaining tasks to process
  54283. */
  54284. remainingCount: number;
  54285. /**
  54286. * Defines the total number of tasks
  54287. */
  54288. totalCount: number;
  54289. /**
  54290. * Defines the task that was just processed
  54291. */
  54292. task: AbstractAssetTask;
  54293. /**
  54294. * Creates a AssetsProgressEvent
  54295. * @param remainingCount defines the number of remaining tasks to process
  54296. * @param totalCount defines the total number of tasks
  54297. * @param task defines the task that was just processed
  54298. */
  54299. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54300. }
  54301. /**
  54302. * Define a task used by AssetsManager to load meshes
  54303. */
  54304. export class MeshAssetTask extends AbstractAssetTask {
  54305. /**
  54306. * Defines the name of the task
  54307. */
  54308. name: string;
  54309. /**
  54310. * Defines the list of mesh's names you want to load
  54311. */
  54312. meshesNames: any;
  54313. /**
  54314. * Defines the root url to use as a base to load your meshes and associated resources
  54315. */
  54316. rootUrl: string;
  54317. /**
  54318. * Defines the filename of the scene to load from
  54319. */
  54320. sceneFilename: string;
  54321. /**
  54322. * Gets the list of loaded meshes
  54323. */
  54324. loadedMeshes: Array<AbstractMesh>;
  54325. /**
  54326. * Gets the list of loaded particle systems
  54327. */
  54328. loadedParticleSystems: Array<IParticleSystem>;
  54329. /**
  54330. * Gets the list of loaded skeletons
  54331. */
  54332. loadedSkeletons: Array<Skeleton>;
  54333. /**
  54334. * Gets the list of loaded animation groups
  54335. */
  54336. loadedAnimationGroups: Array<AnimationGroup>;
  54337. /**
  54338. * Callback called when the task is successful
  54339. */
  54340. onSuccess: (task: MeshAssetTask) => void;
  54341. /**
  54342. * Callback called when the task is successful
  54343. */
  54344. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54345. /**
  54346. * Creates a new MeshAssetTask
  54347. * @param name defines the name of the task
  54348. * @param meshesNames defines the list of mesh's names you want to load
  54349. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54350. * @param sceneFilename defines the filename of the scene to load from
  54351. */
  54352. constructor(
  54353. /**
  54354. * Defines the name of the task
  54355. */
  54356. name: string,
  54357. /**
  54358. * Defines the list of mesh's names you want to load
  54359. */
  54360. meshesNames: any,
  54361. /**
  54362. * Defines the root url to use as a base to load your meshes and associated resources
  54363. */
  54364. rootUrl: string,
  54365. /**
  54366. * Defines the filename of the scene to load from
  54367. */
  54368. sceneFilename: string);
  54369. /**
  54370. * Execute the current task
  54371. * @param scene defines the scene where you want your assets to be loaded
  54372. * @param onSuccess is a callback called when the task is successfully executed
  54373. * @param onError is a callback called if an error occurs
  54374. */
  54375. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54376. }
  54377. /**
  54378. * Define a task used by AssetsManager to load text content
  54379. */
  54380. export class TextFileAssetTask extends AbstractAssetTask {
  54381. /**
  54382. * Defines the name of the task
  54383. */
  54384. name: string;
  54385. /**
  54386. * Defines the location of the file to load
  54387. */
  54388. url: string;
  54389. /**
  54390. * Gets the loaded text string
  54391. */
  54392. text: string;
  54393. /**
  54394. * Callback called when the task is successful
  54395. */
  54396. onSuccess: (task: TextFileAssetTask) => void;
  54397. /**
  54398. * Callback called when the task is successful
  54399. */
  54400. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54401. /**
  54402. * Creates a new TextFileAssetTask object
  54403. * @param name defines the name of the task
  54404. * @param url defines the location of the file to load
  54405. */
  54406. constructor(
  54407. /**
  54408. * Defines the name of the task
  54409. */
  54410. name: string,
  54411. /**
  54412. * Defines the location of the file to load
  54413. */
  54414. url: string);
  54415. /**
  54416. * Execute the current task
  54417. * @param scene defines the scene where you want your assets to be loaded
  54418. * @param onSuccess is a callback called when the task is successfully executed
  54419. * @param onError is a callback called if an error occurs
  54420. */
  54421. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54422. }
  54423. /**
  54424. * Define a task used by AssetsManager to load binary data
  54425. */
  54426. export class BinaryFileAssetTask extends AbstractAssetTask {
  54427. /**
  54428. * Defines the name of the task
  54429. */
  54430. name: string;
  54431. /**
  54432. * Defines the location of the file to load
  54433. */
  54434. url: string;
  54435. /**
  54436. * Gets the lodaded data (as an array buffer)
  54437. */
  54438. data: ArrayBuffer;
  54439. /**
  54440. * Callback called when the task is successful
  54441. */
  54442. onSuccess: (task: BinaryFileAssetTask) => void;
  54443. /**
  54444. * Callback called when the task is successful
  54445. */
  54446. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54447. /**
  54448. * Creates a new BinaryFileAssetTask object
  54449. * @param name defines the name of the new task
  54450. * @param url defines the location of the file to load
  54451. */
  54452. constructor(
  54453. /**
  54454. * Defines the name of the task
  54455. */
  54456. name: string,
  54457. /**
  54458. * Defines the location of the file to load
  54459. */
  54460. url: string);
  54461. /**
  54462. * Execute the current task
  54463. * @param scene defines the scene where you want your assets to be loaded
  54464. * @param onSuccess is a callback called when the task is successfully executed
  54465. * @param onError is a callback called if an error occurs
  54466. */
  54467. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54468. }
  54469. /**
  54470. * Define a task used by AssetsManager to load images
  54471. */
  54472. export class ImageAssetTask extends AbstractAssetTask {
  54473. /**
  54474. * Defines the name of the task
  54475. */
  54476. name: string;
  54477. /**
  54478. * Defines the location of the image to load
  54479. */
  54480. url: string;
  54481. /**
  54482. * Gets the loaded images
  54483. */
  54484. image: HTMLImageElement;
  54485. /**
  54486. * Callback called when the task is successful
  54487. */
  54488. onSuccess: (task: ImageAssetTask) => void;
  54489. /**
  54490. * Callback called when the task is successful
  54491. */
  54492. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54493. /**
  54494. * Creates a new ImageAssetTask
  54495. * @param name defines the name of the task
  54496. * @param url defines the location of the image to load
  54497. */
  54498. constructor(
  54499. /**
  54500. * Defines the name of the task
  54501. */
  54502. name: string,
  54503. /**
  54504. * Defines the location of the image to load
  54505. */
  54506. url: string);
  54507. /**
  54508. * Execute the current task
  54509. * @param scene defines the scene where you want your assets to be loaded
  54510. * @param onSuccess is a callback called when the task is successfully executed
  54511. * @param onError is a callback called if an error occurs
  54512. */
  54513. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54514. }
  54515. /**
  54516. * Defines the interface used by texture loading tasks
  54517. */
  54518. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54519. /**
  54520. * Gets the loaded texture
  54521. */
  54522. texture: TEX;
  54523. }
  54524. /**
  54525. * Define a task used by AssetsManager to load 2D textures
  54526. */
  54527. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54528. /**
  54529. * Defines the name of the task
  54530. */
  54531. name: string;
  54532. /**
  54533. * Defines the location of the file to load
  54534. */
  54535. url: string;
  54536. /**
  54537. * Defines if mipmap should not be generated (default is false)
  54538. */
  54539. noMipmap?: boolean | undefined;
  54540. /**
  54541. * Defines if texture must be inverted on Y axis (default is false)
  54542. */
  54543. invertY?: boolean | undefined;
  54544. /**
  54545. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54546. */
  54547. samplingMode: number;
  54548. /**
  54549. * Gets the loaded texture
  54550. */
  54551. texture: Texture;
  54552. /**
  54553. * Callback called when the task is successful
  54554. */
  54555. onSuccess: (task: TextureAssetTask) => void;
  54556. /**
  54557. * Callback called when the task is successful
  54558. */
  54559. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54560. /**
  54561. * Creates a new TextureAssetTask object
  54562. * @param name defines the name of the task
  54563. * @param url defines the location of the file to load
  54564. * @param noMipmap defines if mipmap should not be generated (default is false)
  54565. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54566. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54567. */
  54568. constructor(
  54569. /**
  54570. * Defines the name of the task
  54571. */
  54572. name: string,
  54573. /**
  54574. * Defines the location of the file to load
  54575. */
  54576. url: string,
  54577. /**
  54578. * Defines if mipmap should not be generated (default is false)
  54579. */
  54580. noMipmap?: boolean | undefined,
  54581. /**
  54582. * Defines if texture must be inverted on Y axis (default is false)
  54583. */
  54584. invertY?: boolean | undefined,
  54585. /**
  54586. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54587. */
  54588. samplingMode?: number);
  54589. /**
  54590. * Execute the current task
  54591. * @param scene defines the scene where you want your assets to be loaded
  54592. * @param onSuccess is a callback called when the task is successfully executed
  54593. * @param onError is a callback called if an error occurs
  54594. */
  54595. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54596. }
  54597. /**
  54598. * Define a task used by AssetsManager to load cube textures
  54599. */
  54600. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54601. /**
  54602. * Defines the name of the task
  54603. */
  54604. name: string;
  54605. /**
  54606. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54607. */
  54608. url: string;
  54609. /**
  54610. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54611. */
  54612. extensions?: string[] | undefined;
  54613. /**
  54614. * Defines if mipmaps should not be generated (default is false)
  54615. */
  54616. noMipmap?: boolean | undefined;
  54617. /**
  54618. * Defines the explicit list of files (undefined by default)
  54619. */
  54620. files?: string[] | undefined;
  54621. /**
  54622. * Gets the loaded texture
  54623. */
  54624. texture: CubeTexture;
  54625. /**
  54626. * Callback called when the task is successful
  54627. */
  54628. onSuccess: (task: CubeTextureAssetTask) => void;
  54629. /**
  54630. * Callback called when the task is successful
  54631. */
  54632. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54633. /**
  54634. * Creates a new CubeTextureAssetTask
  54635. * @param name defines the name of the task
  54636. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54637. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54638. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54639. * @param files defines the explicit list of files (undefined by default)
  54640. */
  54641. constructor(
  54642. /**
  54643. * Defines the name of the task
  54644. */
  54645. name: string,
  54646. /**
  54647. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54648. */
  54649. url: string,
  54650. /**
  54651. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54652. */
  54653. extensions?: string[] | undefined,
  54654. /**
  54655. * Defines if mipmaps should not be generated (default is false)
  54656. */
  54657. noMipmap?: boolean | undefined,
  54658. /**
  54659. * Defines the explicit list of files (undefined by default)
  54660. */
  54661. files?: string[] | undefined);
  54662. /**
  54663. * Execute the current task
  54664. * @param scene defines the scene where you want your assets to be loaded
  54665. * @param onSuccess is a callback called when the task is successfully executed
  54666. * @param onError is a callback called if an error occurs
  54667. */
  54668. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54669. }
  54670. /**
  54671. * Define a task used by AssetsManager to load HDR cube textures
  54672. */
  54673. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54674. /**
  54675. * Defines the name of the task
  54676. */
  54677. name: string;
  54678. /**
  54679. * Defines the location of the file to load
  54680. */
  54681. url: string;
  54682. /**
  54683. * Defines the desired size (the more it increases the longer the generation will be)
  54684. */
  54685. size: number;
  54686. /**
  54687. * Defines if mipmaps should not be generated (default is false)
  54688. */
  54689. noMipmap: boolean;
  54690. /**
  54691. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54692. */
  54693. generateHarmonics: boolean;
  54694. /**
  54695. * 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)
  54696. */
  54697. gammaSpace: boolean;
  54698. /**
  54699. * Internal Use Only
  54700. */
  54701. reserved: boolean;
  54702. /**
  54703. * Gets the loaded texture
  54704. */
  54705. texture: HDRCubeTexture;
  54706. /**
  54707. * Callback called when the task is successful
  54708. */
  54709. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54710. /**
  54711. * Callback called when the task is successful
  54712. */
  54713. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54714. /**
  54715. * Creates a new HDRCubeTextureAssetTask object
  54716. * @param name defines the name of the task
  54717. * @param url defines the location of the file to load
  54718. * @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.
  54719. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54720. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54721. * @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)
  54722. * @param reserved Internal use only
  54723. */
  54724. constructor(
  54725. /**
  54726. * Defines the name of the task
  54727. */
  54728. name: string,
  54729. /**
  54730. * Defines the location of the file to load
  54731. */
  54732. url: string,
  54733. /**
  54734. * Defines the desired size (the more it increases the longer the generation will be)
  54735. */
  54736. size: number,
  54737. /**
  54738. * Defines if mipmaps should not be generated (default is false)
  54739. */
  54740. noMipmap?: boolean,
  54741. /**
  54742. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54743. */
  54744. generateHarmonics?: boolean,
  54745. /**
  54746. * 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)
  54747. */
  54748. gammaSpace?: boolean,
  54749. /**
  54750. * Internal Use Only
  54751. */
  54752. reserved?: boolean);
  54753. /**
  54754. * Execute the current task
  54755. * @param scene defines the scene where you want your assets to be loaded
  54756. * @param onSuccess is a callback called when the task is successfully executed
  54757. * @param onError is a callback called if an error occurs
  54758. */
  54759. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54760. }
  54761. /**
  54762. * Define a task used by AssetsManager to load Equirectangular cube textures
  54763. */
  54764. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54765. /**
  54766. * Defines the name of the task
  54767. */
  54768. name: string;
  54769. /**
  54770. * Defines the location of the file to load
  54771. */
  54772. url: string;
  54773. /**
  54774. * Defines the desired size (the more it increases the longer the generation will be)
  54775. */
  54776. size: number;
  54777. /**
  54778. * Defines if mipmaps should not be generated (default is false)
  54779. */
  54780. noMipmap: boolean;
  54781. /**
  54782. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54783. * but the standard material would require them in Gamma space) (default is true)
  54784. */
  54785. gammaSpace: boolean;
  54786. /**
  54787. * Gets the loaded texture
  54788. */
  54789. texture: EquiRectangularCubeTexture;
  54790. /**
  54791. * Callback called when the task is successful
  54792. */
  54793. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54794. /**
  54795. * Callback called when the task is successful
  54796. */
  54797. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54798. /**
  54799. * Creates a new EquiRectangularCubeTextureAssetTask object
  54800. * @param name defines the name of the task
  54801. * @param url defines the location of the file to load
  54802. * @param size defines the desired size (the more it increases the longer the generation will be)
  54803. * If the size is omitted this implies you are using a preprocessed cubemap.
  54804. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54805. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54806. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54807. * (default is true)
  54808. */
  54809. constructor(
  54810. /**
  54811. * Defines the name of the task
  54812. */
  54813. name: string,
  54814. /**
  54815. * Defines the location of the file to load
  54816. */
  54817. url: string,
  54818. /**
  54819. * Defines the desired size (the more it increases the longer the generation will be)
  54820. */
  54821. size: number,
  54822. /**
  54823. * Defines if mipmaps should not be generated (default is false)
  54824. */
  54825. noMipmap?: boolean,
  54826. /**
  54827. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54828. * but the standard material would require them in Gamma space) (default is true)
  54829. */
  54830. gammaSpace?: boolean);
  54831. /**
  54832. * Execute the current task
  54833. * @param scene defines the scene where you want your assets to be loaded
  54834. * @param onSuccess is a callback called when the task is successfully executed
  54835. * @param onError is a callback called if an error occurs
  54836. */
  54837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54838. }
  54839. /**
  54840. * This class can be used to easily import assets into a scene
  54841. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54842. */
  54843. export class AssetsManager {
  54844. private _scene;
  54845. private _isLoading;
  54846. protected _tasks: AbstractAssetTask[];
  54847. protected _waitingTasksCount: number;
  54848. protected _totalTasksCount: number;
  54849. /**
  54850. * Callback called when all tasks are processed
  54851. */
  54852. onFinish: (tasks: AbstractAssetTask[]) => void;
  54853. /**
  54854. * Callback called when a task is successful
  54855. */
  54856. onTaskSuccess: (task: AbstractAssetTask) => void;
  54857. /**
  54858. * Callback called when a task had an error
  54859. */
  54860. onTaskError: (task: AbstractAssetTask) => void;
  54861. /**
  54862. * Callback called when a task is done (whatever the result is)
  54863. */
  54864. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54865. /**
  54866. * Observable called when all tasks are processed
  54867. */
  54868. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54869. /**
  54870. * Observable called when a task had an error
  54871. */
  54872. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54873. /**
  54874. * Observable called when all tasks were executed
  54875. */
  54876. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54877. /**
  54878. * Observable called when a task is done (whatever the result is)
  54879. */
  54880. onProgressObservable: Observable<IAssetsProgressEvent>;
  54881. /**
  54882. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54884. */
  54885. useDefaultLoadingScreen: boolean;
  54886. /**
  54887. * Creates a new AssetsManager
  54888. * @param scene defines the scene to work on
  54889. */
  54890. constructor(scene: Scene);
  54891. /**
  54892. * Add a MeshAssetTask to the list of active tasks
  54893. * @param taskName defines the name of the new task
  54894. * @param meshesNames defines the name of meshes to load
  54895. * @param rootUrl defines the root url to use to locate files
  54896. * @param sceneFilename defines the filename of the scene file
  54897. * @returns a new MeshAssetTask object
  54898. */
  54899. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54900. /**
  54901. * Add a TextFileAssetTask to the list of active tasks
  54902. * @param taskName defines the name of the new task
  54903. * @param url defines the url of the file to load
  54904. * @returns a new TextFileAssetTask object
  54905. */
  54906. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54907. /**
  54908. * Add a BinaryFileAssetTask to the list of active tasks
  54909. * @param taskName defines the name of the new task
  54910. * @param url defines the url of the file to load
  54911. * @returns a new BinaryFileAssetTask object
  54912. */
  54913. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54914. /**
  54915. * Add a ImageAssetTask to the list of active tasks
  54916. * @param taskName defines the name of the new task
  54917. * @param url defines the url of the file to load
  54918. * @returns a new ImageAssetTask object
  54919. */
  54920. addImageTask(taskName: string, url: string): ImageAssetTask;
  54921. /**
  54922. * Add a TextureAssetTask to the list of active tasks
  54923. * @param taskName defines the name of the new task
  54924. * @param url defines the url of the file to load
  54925. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54926. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54927. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54928. * @returns a new TextureAssetTask object
  54929. */
  54930. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54931. /**
  54932. * Add a CubeTextureAssetTask to the list of active tasks
  54933. * @param taskName defines the name of the new task
  54934. * @param url defines the url of the file to load
  54935. * @param extensions defines the extension to use to load the cube map (can be null)
  54936. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54937. * @param files defines the list of files to load (can be null)
  54938. * @returns a new CubeTextureAssetTask object
  54939. */
  54940. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54941. /**
  54942. *
  54943. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54944. * @param taskName defines the name of the new task
  54945. * @param url defines the url of the file to load
  54946. * @param size defines the size you want for the cubemap (can be null)
  54947. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54948. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54949. * @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)
  54950. * @param reserved Internal use only
  54951. * @returns a new HDRCubeTextureAssetTask object
  54952. */
  54953. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54954. /**
  54955. *
  54956. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54957. * @param taskName defines the name of the new task
  54958. * @param url defines the url of the file to load
  54959. * @param size defines the size you want for the cubemap (can be null)
  54960. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54961. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54962. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54963. * @returns a new EquiRectangularCubeTextureAssetTask object
  54964. */
  54965. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54966. /**
  54967. * Remove a task from the assets manager.
  54968. * @param task the task to remove
  54969. */
  54970. removeTask(task: AbstractAssetTask): void;
  54971. private _decreaseWaitingTasksCount;
  54972. private _runTask;
  54973. /**
  54974. * Reset the AssetsManager and remove all tasks
  54975. * @return the current instance of the AssetsManager
  54976. */
  54977. reset(): AssetsManager;
  54978. /**
  54979. * Start the loading process
  54980. * @return the current instance of the AssetsManager
  54981. */
  54982. load(): AssetsManager;
  54983. /**
  54984. * Start the loading process as an async operation
  54985. * @return a promise returning the list of failed tasks
  54986. */
  54987. loadAsync(): Promise<void>;
  54988. }
  54989. }
  54990. declare module BABYLON {
  54991. /**
  54992. * Wrapper class for promise with external resolve and reject.
  54993. */
  54994. export class Deferred<T> {
  54995. /**
  54996. * The promise associated with this deferred object.
  54997. */
  54998. readonly promise: Promise<T>;
  54999. private _resolve;
  55000. private _reject;
  55001. /**
  55002. * The resolve method of the promise associated with this deferred object.
  55003. */
  55004. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55005. /**
  55006. * The reject method of the promise associated with this deferred object.
  55007. */
  55008. readonly reject: (reason?: any) => void;
  55009. /**
  55010. * Constructor for this deferred object.
  55011. */
  55012. constructor();
  55013. }
  55014. }
  55015. declare module BABYLON {
  55016. /**
  55017. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55018. */
  55019. export class MeshExploder {
  55020. private _centerMesh;
  55021. private _meshes;
  55022. private _meshesOrigins;
  55023. private _toCenterVectors;
  55024. private _scaledDirection;
  55025. private _newPosition;
  55026. private _centerPosition;
  55027. /**
  55028. * Explodes meshes from a center mesh.
  55029. * @param meshes The meshes to explode.
  55030. * @param centerMesh The mesh to be center of explosion.
  55031. */
  55032. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55033. private _setCenterMesh;
  55034. /**
  55035. * Get class name
  55036. * @returns "MeshExploder"
  55037. */
  55038. getClassName(): string;
  55039. /**
  55040. * "Exploded meshes"
  55041. * @returns Array of meshes with the centerMesh at index 0.
  55042. */
  55043. getMeshes(): Array<Mesh>;
  55044. /**
  55045. * Explodes meshes giving a specific direction
  55046. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55047. */
  55048. explode(direction?: number): void;
  55049. }
  55050. }
  55051. declare module BABYLON {
  55052. /**
  55053. * Class used to help managing file picking and drag'n'drop
  55054. */
  55055. export class FilesInput {
  55056. /**
  55057. * List of files ready to be loaded
  55058. */
  55059. static readonly FilesToLoad: {
  55060. [key: string]: File;
  55061. };
  55062. /**
  55063. * Callback called when a file is processed
  55064. */
  55065. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55066. private _engine;
  55067. private _currentScene;
  55068. private _sceneLoadedCallback;
  55069. private _progressCallback;
  55070. private _additionalRenderLoopLogicCallback;
  55071. private _textureLoadingCallback;
  55072. private _startingProcessingFilesCallback;
  55073. private _onReloadCallback;
  55074. private _errorCallback;
  55075. private _elementToMonitor;
  55076. private _sceneFileToLoad;
  55077. private _filesToLoad;
  55078. /**
  55079. * Creates a new FilesInput
  55080. * @param engine defines the rendering engine
  55081. * @param scene defines the hosting scene
  55082. * @param sceneLoadedCallback callback called when scene is loaded
  55083. * @param progressCallback callback called to track progress
  55084. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55085. * @param textureLoadingCallback callback called when a texture is loading
  55086. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55087. * @param onReloadCallback callback called when a reload is requested
  55088. * @param errorCallback callback call if an error occurs
  55089. */
  55090. 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);
  55091. private _dragEnterHandler;
  55092. private _dragOverHandler;
  55093. private _dropHandler;
  55094. /**
  55095. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55096. * @param elementToMonitor defines the DOM element to track
  55097. */
  55098. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55099. /**
  55100. * Release all associated resources
  55101. */
  55102. dispose(): void;
  55103. private renderFunction;
  55104. private drag;
  55105. private drop;
  55106. private _traverseFolder;
  55107. private _processFiles;
  55108. /**
  55109. * Load files from a drop event
  55110. * @param event defines the drop event to use as source
  55111. */
  55112. loadFiles(event: any): void;
  55113. private _processReload;
  55114. /**
  55115. * Reload the current scene from the loaded files
  55116. */
  55117. reload(): void;
  55118. }
  55119. }
  55120. declare module BABYLON {
  55121. /**
  55122. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55124. */
  55125. export class SceneOptimization {
  55126. /**
  55127. * Defines the priority of this optimization (0 by default which means first in the list)
  55128. */
  55129. priority: number;
  55130. /**
  55131. * Gets a string describing the action executed by the current optimization
  55132. * @returns description string
  55133. */
  55134. getDescription(): string;
  55135. /**
  55136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55137. * @param scene defines the current scene where to apply this optimization
  55138. * @param optimizer defines the current optimizer
  55139. * @returns true if everything that can be done was applied
  55140. */
  55141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55142. /**
  55143. * Creates the SceneOptimization object
  55144. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55145. * @param desc defines the description associated with the optimization
  55146. */
  55147. constructor(
  55148. /**
  55149. * Defines the priority of this optimization (0 by default which means first in the list)
  55150. */
  55151. priority?: number);
  55152. }
  55153. /**
  55154. * Defines an optimization used to reduce the size of render target textures
  55155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55156. */
  55157. export class TextureOptimization extends SceneOptimization {
  55158. /**
  55159. * Defines the priority of this optimization (0 by default which means first in the list)
  55160. */
  55161. priority: number;
  55162. /**
  55163. * 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
  55164. */
  55165. maximumSize: number;
  55166. /**
  55167. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55168. */
  55169. step: number;
  55170. /**
  55171. * Gets a string describing the action executed by the current optimization
  55172. * @returns description string
  55173. */
  55174. getDescription(): string;
  55175. /**
  55176. * Creates the TextureOptimization object
  55177. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55178. * @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
  55179. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55180. */
  55181. constructor(
  55182. /**
  55183. * Defines the priority of this optimization (0 by default which means first in the list)
  55184. */
  55185. priority?: number,
  55186. /**
  55187. * 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
  55188. */
  55189. maximumSize?: number,
  55190. /**
  55191. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55192. */
  55193. step?: number);
  55194. /**
  55195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55196. * @param scene defines the current scene where to apply this optimization
  55197. * @param optimizer defines the current optimizer
  55198. * @returns true if everything that can be done was applied
  55199. */
  55200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55201. }
  55202. /**
  55203. * Defines an optimization used to increase or decrease the rendering resolution
  55204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55205. */
  55206. export class HardwareScalingOptimization extends SceneOptimization {
  55207. /**
  55208. * Defines the priority of this optimization (0 by default which means first in the list)
  55209. */
  55210. priority: number;
  55211. /**
  55212. * Defines the maximum scale to use (2 by default)
  55213. */
  55214. maximumScale: number;
  55215. /**
  55216. * Defines the step to use between two passes (0.5 by default)
  55217. */
  55218. step: number;
  55219. private _currentScale;
  55220. private _directionOffset;
  55221. /**
  55222. * Gets a string describing the action executed by the current optimization
  55223. * @return description string
  55224. */
  55225. getDescription(): string;
  55226. /**
  55227. * Creates the HardwareScalingOptimization object
  55228. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55229. * @param maximumScale defines the maximum scale to use (2 by default)
  55230. * @param step defines the step to use between two passes (0.5 by default)
  55231. */
  55232. constructor(
  55233. /**
  55234. * Defines the priority of this optimization (0 by default which means first in the list)
  55235. */
  55236. priority?: number,
  55237. /**
  55238. * Defines the maximum scale to use (2 by default)
  55239. */
  55240. maximumScale?: number,
  55241. /**
  55242. * Defines the step to use between two passes (0.5 by default)
  55243. */
  55244. step?: number);
  55245. /**
  55246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55247. * @param scene defines the current scene where to apply this optimization
  55248. * @param optimizer defines the current optimizer
  55249. * @returns true if everything that can be done was applied
  55250. */
  55251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55252. }
  55253. /**
  55254. * Defines an optimization used to remove shadows
  55255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55256. */
  55257. export class ShadowsOptimization extends SceneOptimization {
  55258. /**
  55259. * Gets a string describing the action executed by the current optimization
  55260. * @return description string
  55261. */
  55262. getDescription(): string;
  55263. /**
  55264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55265. * @param scene defines the current scene where to apply this optimization
  55266. * @param optimizer defines the current optimizer
  55267. * @returns true if everything that can be done was applied
  55268. */
  55269. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55270. }
  55271. /**
  55272. * Defines an optimization used to turn post-processes off
  55273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55274. */
  55275. export class PostProcessesOptimization extends SceneOptimization {
  55276. /**
  55277. * Gets a string describing the action executed by the current optimization
  55278. * @return description string
  55279. */
  55280. getDescription(): string;
  55281. /**
  55282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55283. * @param scene defines the current scene where to apply this optimization
  55284. * @param optimizer defines the current optimizer
  55285. * @returns true if everything that can be done was applied
  55286. */
  55287. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55288. }
  55289. /**
  55290. * Defines an optimization used to turn lens flares off
  55291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55292. */
  55293. export class LensFlaresOptimization extends SceneOptimization {
  55294. /**
  55295. * Gets a string describing the action executed by the current optimization
  55296. * @return description string
  55297. */
  55298. getDescription(): string;
  55299. /**
  55300. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55301. * @param scene defines the current scene where to apply this optimization
  55302. * @param optimizer defines the current optimizer
  55303. * @returns true if everything that can be done was applied
  55304. */
  55305. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55306. }
  55307. /**
  55308. * Defines an optimization based on user defined callback.
  55309. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55310. */
  55311. export class CustomOptimization extends SceneOptimization {
  55312. /**
  55313. * Callback called to apply the custom optimization.
  55314. */
  55315. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55316. /**
  55317. * Callback called to get custom description
  55318. */
  55319. onGetDescription: () => string;
  55320. /**
  55321. * Gets a string describing the action executed by the current optimization
  55322. * @returns description string
  55323. */
  55324. getDescription(): string;
  55325. /**
  55326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55327. * @param scene defines the current scene where to apply this optimization
  55328. * @param optimizer defines the current optimizer
  55329. * @returns true if everything that can be done was applied
  55330. */
  55331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55332. }
  55333. /**
  55334. * Defines an optimization used to turn particles off
  55335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55336. */
  55337. export class ParticlesOptimization extends SceneOptimization {
  55338. /**
  55339. * Gets a string describing the action executed by the current optimization
  55340. * @return description string
  55341. */
  55342. getDescription(): string;
  55343. /**
  55344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55345. * @param scene defines the current scene where to apply this optimization
  55346. * @param optimizer defines the current optimizer
  55347. * @returns true if everything that can be done was applied
  55348. */
  55349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55350. }
  55351. /**
  55352. * Defines an optimization used to turn render targets off
  55353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55354. */
  55355. export class RenderTargetsOptimization extends SceneOptimization {
  55356. /**
  55357. * Gets a string describing the action executed by the current optimization
  55358. * @return description string
  55359. */
  55360. getDescription(): string;
  55361. /**
  55362. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55363. * @param scene defines the current scene where to apply this optimization
  55364. * @param optimizer defines the current optimizer
  55365. * @returns true if everything that can be done was applied
  55366. */
  55367. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55368. }
  55369. /**
  55370. * Defines an optimization used to merge meshes with compatible materials
  55371. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55372. */
  55373. export class MergeMeshesOptimization extends SceneOptimization {
  55374. private static _UpdateSelectionTree;
  55375. /**
  55376. * Gets or sets a boolean which defines if optimization octree has to be updated
  55377. */
  55378. /**
  55379. * Gets or sets a boolean which defines if optimization octree has to be updated
  55380. */
  55381. static UpdateSelectionTree: boolean;
  55382. /**
  55383. * Gets a string describing the action executed by the current optimization
  55384. * @return description string
  55385. */
  55386. getDescription(): string;
  55387. private _canBeMerged;
  55388. /**
  55389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55390. * @param scene defines the current scene where to apply this optimization
  55391. * @param optimizer defines the current optimizer
  55392. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55393. * @returns true if everything that can be done was applied
  55394. */
  55395. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55396. }
  55397. /**
  55398. * Defines a list of options used by SceneOptimizer
  55399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55400. */
  55401. export class SceneOptimizerOptions {
  55402. /**
  55403. * Defines the target frame rate to reach (60 by default)
  55404. */
  55405. targetFrameRate: number;
  55406. /**
  55407. * Defines the interval between two checkes (2000ms by default)
  55408. */
  55409. trackerDuration: number;
  55410. /**
  55411. * Gets the list of optimizations to apply
  55412. */
  55413. optimizations: SceneOptimization[];
  55414. /**
  55415. * Creates a new list of options used by SceneOptimizer
  55416. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55417. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55418. */
  55419. constructor(
  55420. /**
  55421. * Defines the target frame rate to reach (60 by default)
  55422. */
  55423. targetFrameRate?: number,
  55424. /**
  55425. * Defines the interval between two checkes (2000ms by default)
  55426. */
  55427. trackerDuration?: number);
  55428. /**
  55429. * Add a new optimization
  55430. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55431. * @returns the current SceneOptimizerOptions
  55432. */
  55433. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55434. /**
  55435. * Add a new custom optimization
  55436. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55437. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55438. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55439. * @returns the current SceneOptimizerOptions
  55440. */
  55441. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55442. /**
  55443. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55444. * @param targetFrameRate defines the target frame rate (60 by default)
  55445. * @returns a SceneOptimizerOptions object
  55446. */
  55447. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55448. /**
  55449. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55450. * @param targetFrameRate defines the target frame rate (60 by default)
  55451. * @returns a SceneOptimizerOptions object
  55452. */
  55453. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55454. /**
  55455. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55456. * @param targetFrameRate defines the target frame rate (60 by default)
  55457. * @returns a SceneOptimizerOptions object
  55458. */
  55459. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55460. }
  55461. /**
  55462. * Class used to run optimizations in order to reach a target frame rate
  55463. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55464. */
  55465. export class SceneOptimizer implements IDisposable {
  55466. private _isRunning;
  55467. private _options;
  55468. private _scene;
  55469. private _currentPriorityLevel;
  55470. private _targetFrameRate;
  55471. private _trackerDuration;
  55472. private _currentFrameRate;
  55473. private _sceneDisposeObserver;
  55474. private _improvementMode;
  55475. /**
  55476. * Defines an observable called when the optimizer reaches the target frame rate
  55477. */
  55478. onSuccessObservable: Observable<SceneOptimizer>;
  55479. /**
  55480. * Defines an observable called when the optimizer enables an optimization
  55481. */
  55482. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55483. /**
  55484. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55485. */
  55486. onFailureObservable: Observable<SceneOptimizer>;
  55487. /**
  55488. * Gets a boolean indicating if the optimizer is in improvement mode
  55489. */
  55490. readonly isInImprovementMode: boolean;
  55491. /**
  55492. * Gets the current priority level (0 at start)
  55493. */
  55494. readonly currentPriorityLevel: number;
  55495. /**
  55496. * Gets the current frame rate checked by the SceneOptimizer
  55497. */
  55498. readonly currentFrameRate: number;
  55499. /**
  55500. * Gets or sets the current target frame rate (60 by default)
  55501. */
  55502. /**
  55503. * Gets or sets the current target frame rate (60 by default)
  55504. */
  55505. targetFrameRate: number;
  55506. /**
  55507. * Gets or sets the current interval between two checks (every 2000ms by default)
  55508. */
  55509. /**
  55510. * Gets or sets the current interval between two checks (every 2000ms by default)
  55511. */
  55512. trackerDuration: number;
  55513. /**
  55514. * Gets the list of active optimizations
  55515. */
  55516. readonly optimizations: SceneOptimization[];
  55517. /**
  55518. * Creates a new SceneOptimizer
  55519. * @param scene defines the scene to work on
  55520. * @param options defines the options to use with the SceneOptimizer
  55521. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55522. * @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)
  55523. */
  55524. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55525. /**
  55526. * Stops the current optimizer
  55527. */
  55528. stop(): void;
  55529. /**
  55530. * Reset the optimizer to initial step (current priority level = 0)
  55531. */
  55532. reset(): void;
  55533. /**
  55534. * Start the optimizer. By default it will try to reach a specific framerate
  55535. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55536. */
  55537. start(): void;
  55538. private _checkCurrentState;
  55539. /**
  55540. * Release all resources
  55541. */
  55542. dispose(): void;
  55543. /**
  55544. * Helper function to create a SceneOptimizer with one single line of code
  55545. * @param scene defines the scene to work on
  55546. * @param options defines the options to use with the SceneOptimizer
  55547. * @param onSuccess defines a callback to call on success
  55548. * @param onFailure defines a callback to call on failure
  55549. * @returns the new SceneOptimizer object
  55550. */
  55551. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55552. }
  55553. }
  55554. declare module BABYLON {
  55555. /**
  55556. * Class used to serialize a scene into a string
  55557. */
  55558. export class SceneSerializer {
  55559. /**
  55560. * Clear cache used by a previous serialization
  55561. */
  55562. static ClearCache(): void;
  55563. /**
  55564. * Serialize a scene into a JSON compatible object
  55565. * @param scene defines the scene to serialize
  55566. * @returns a JSON compatible object
  55567. */
  55568. static Serialize(scene: Scene): any;
  55569. /**
  55570. * Serialize a mesh into a JSON compatible object
  55571. * @param toSerialize defines the mesh to serialize
  55572. * @param withParents defines if parents must be serialized as well
  55573. * @param withChildren defines if children must be serialized as well
  55574. * @returns a JSON compatible object
  55575. */
  55576. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55577. }
  55578. }
  55579. declare module BABYLON {
  55580. /**
  55581. * Class used to host texture specific utilities
  55582. */
  55583. export class TextureTools {
  55584. /**
  55585. * Uses the GPU to create a copy texture rescaled at a given size
  55586. * @param texture Texture to copy from
  55587. * @param width defines the desired width
  55588. * @param height defines the desired height
  55589. * @param useBilinearMode defines if bilinear mode has to be used
  55590. * @return the generated texture
  55591. */
  55592. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55593. }
  55594. }
  55595. declare module BABYLON {
  55596. /**
  55597. * This represents the different options avilable for the video capture.
  55598. */
  55599. export interface VideoRecorderOptions {
  55600. /** Defines the mime type of the video */
  55601. mimeType: string;
  55602. /** Defines the video the video should be recorded at */
  55603. fps: number;
  55604. /** Defines the chunk size for the recording data */
  55605. recordChunckSize: number;
  55606. /** The audio tracks to attach to the record */
  55607. audioTracks?: MediaStreamTrack[];
  55608. }
  55609. /**
  55610. * This can helps recording videos from BabylonJS.
  55611. * This is based on the available WebRTC functionalities of the browser.
  55612. *
  55613. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55614. */
  55615. export class VideoRecorder {
  55616. private static readonly _defaultOptions;
  55617. /**
  55618. * Returns wehther or not the VideoRecorder is available in your browser.
  55619. * @param engine Defines the Babylon Engine to check the support for
  55620. * @returns true if supported otherwise false
  55621. */
  55622. static IsSupported(engine: Engine): boolean;
  55623. private readonly _options;
  55624. private _canvas;
  55625. private _mediaRecorder;
  55626. private _recordedChunks;
  55627. private _fileName;
  55628. private _resolve;
  55629. private _reject;
  55630. /**
  55631. * True wether a recording is already in progress.
  55632. */
  55633. readonly isRecording: boolean;
  55634. /**
  55635. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55636. * a video file.
  55637. * @param engine Defines the BabylonJS Engine you wish to record
  55638. * @param options Defines options that can be used to customized the capture
  55639. */
  55640. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55641. /**
  55642. * Stops the current recording before the default capture timeout passed in the startRecording
  55643. * functions.
  55644. */
  55645. stopRecording(): void;
  55646. /**
  55647. * Starts recording the canvas for a max duration specified in parameters.
  55648. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  55649. * @param maxDuration Defines the maximum recording time in seconds.
  55650. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55651. * @return a promise callback at the end of the recording with the video data in Blob.
  55652. */
  55653. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55654. /**
  55655. * Releases internal resources used during the recording.
  55656. */
  55657. dispose(): void;
  55658. private _handleDataAvailable;
  55659. private _handleError;
  55660. private _handleStop;
  55661. }
  55662. }
  55663. declare module BABYLON {
  55664. /**
  55665. * Class containing a set of static utilities functions for screenshots
  55666. */
  55667. export class ScreenshotTools {
  55668. /**
  55669. * Captures a screenshot of the current rendering
  55670. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55671. * @param engine defines the rendering engine
  55672. * @param camera defines the source camera
  55673. * @param size This parameter can be set to a single number or to an object with the
  55674. * following (optional) properties: precision, width, height. If a single number is passed,
  55675. * it will be used for both width and height. If an object is passed, the screenshot size
  55676. * will be derived from the parameters. The precision property is a multiplier allowing
  55677. * rendering at a higher or lower resolution
  55678. * @param successCallback defines the callback receives a single parameter which contains the
  55679. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55680. * src parameter of an <img> to display it
  55681. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55682. * Check your browser for supported MIME types
  55683. */
  55684. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55685. /**
  55686. * Generates an image screenshot from the specified camera.
  55687. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55688. * @param engine The engine to use for rendering
  55689. * @param camera The camera to use for rendering
  55690. * @param size This parameter can be set to a single number or to an object with the
  55691. * following (optional) properties: precision, width, height. If a single number is passed,
  55692. * it will be used for both width and height. If an object is passed, the screenshot size
  55693. * will be derived from the parameters. The precision property is a multiplier allowing
  55694. * rendering at a higher or lower resolution
  55695. * @param successCallback The callback receives a single parameter which contains the
  55696. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55697. * src parameter of an <img> to display it
  55698. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55699. * Check your browser for supported MIME types
  55700. * @param samples Texture samples (default: 1)
  55701. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55702. * @param fileName A name for for the downloaded file.
  55703. */
  55704. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55705. }
  55706. }
  55707. declare module BABYLON {
  55708. /**
  55709. * A cursor which tracks a point on a path
  55710. */
  55711. export class PathCursor {
  55712. private path;
  55713. /**
  55714. * Stores path cursor callbacks for when an onchange event is triggered
  55715. */
  55716. private _onchange;
  55717. /**
  55718. * The value of the path cursor
  55719. */
  55720. value: number;
  55721. /**
  55722. * The animation array of the path cursor
  55723. */
  55724. animations: Animation[];
  55725. /**
  55726. * Initializes the path cursor
  55727. * @param path The path to track
  55728. */
  55729. constructor(path: Path2);
  55730. /**
  55731. * Gets the cursor point on the path
  55732. * @returns A point on the path cursor at the cursor location
  55733. */
  55734. getPoint(): Vector3;
  55735. /**
  55736. * Moves the cursor ahead by the step amount
  55737. * @param step The amount to move the cursor forward
  55738. * @returns This path cursor
  55739. */
  55740. moveAhead(step?: number): PathCursor;
  55741. /**
  55742. * Moves the cursor behind by the step amount
  55743. * @param step The amount to move the cursor back
  55744. * @returns This path cursor
  55745. */
  55746. moveBack(step?: number): PathCursor;
  55747. /**
  55748. * Moves the cursor by the step amount
  55749. * If the step amount is greater than one, an exception is thrown
  55750. * @param step The amount to move the cursor
  55751. * @returns This path cursor
  55752. */
  55753. move(step: number): PathCursor;
  55754. /**
  55755. * Ensures that the value is limited between zero and one
  55756. * @returns This path cursor
  55757. */
  55758. private ensureLimits;
  55759. /**
  55760. * Runs onchange callbacks on change (used by the animation engine)
  55761. * @returns This path cursor
  55762. */
  55763. private raiseOnChange;
  55764. /**
  55765. * Executes a function on change
  55766. * @param f A path cursor onchange callback
  55767. * @returns This path cursor
  55768. */
  55769. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55770. }
  55771. }
  55772. declare module BABYLON {
  55773. /** @hidden */
  55774. export var blurPixelShader: {
  55775. name: string;
  55776. shader: string;
  55777. };
  55778. }
  55779. declare module BABYLON {
  55780. /** @hidden */
  55781. export var bones300Declaration: {
  55782. name: string;
  55783. shader: string;
  55784. };
  55785. }
  55786. declare module BABYLON {
  55787. /** @hidden */
  55788. export var instances300Declaration: {
  55789. name: string;
  55790. shader: string;
  55791. };
  55792. }
  55793. declare module BABYLON {
  55794. /** @hidden */
  55795. export var pointCloudVertexDeclaration: {
  55796. name: string;
  55797. shader: string;
  55798. };
  55799. }
  55800. // Mixins
  55801. interface Window {
  55802. mozIndexedDB: IDBFactory;
  55803. webkitIndexedDB: IDBFactory;
  55804. msIndexedDB: IDBFactory;
  55805. webkitURL: typeof URL;
  55806. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55807. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55808. WebGLRenderingContext: WebGLRenderingContext;
  55809. MSGesture: MSGesture;
  55810. CANNON: any;
  55811. AudioContext: AudioContext;
  55812. webkitAudioContext: AudioContext;
  55813. PointerEvent: any;
  55814. Math: Math;
  55815. Uint8Array: Uint8ArrayConstructor;
  55816. Float32Array: Float32ArrayConstructor;
  55817. mozURL: typeof URL;
  55818. msURL: typeof URL;
  55819. VRFrameData: any; // WebVR, from specs 1.1
  55820. DracoDecoderModule: any;
  55821. setImmediate(handler: (...args: any[]) => void): number;
  55822. }
  55823. interface HTMLCanvasElement {
  55824. requestPointerLock(): void;
  55825. msRequestPointerLock?(): void;
  55826. mozRequestPointerLock?(): void;
  55827. webkitRequestPointerLock?(): void;
  55828. /** Track wether a record is in progress */
  55829. isRecording: boolean;
  55830. /** Capture Stream method defined by some browsers */
  55831. captureStream(fps?: number): MediaStream;
  55832. }
  55833. interface CanvasRenderingContext2D {
  55834. msImageSmoothingEnabled: boolean;
  55835. }
  55836. interface MouseEvent {
  55837. mozMovementX: number;
  55838. mozMovementY: number;
  55839. webkitMovementX: number;
  55840. webkitMovementY: number;
  55841. msMovementX: number;
  55842. msMovementY: number;
  55843. }
  55844. interface Navigator {
  55845. mozGetVRDevices: (any: any) => any;
  55846. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55847. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55848. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55849. webkitGetGamepads(): Gamepad[];
  55850. msGetGamepads(): Gamepad[];
  55851. webkitGamepads(): Gamepad[];
  55852. }
  55853. interface HTMLVideoElement {
  55854. mozSrcObject: any;
  55855. }
  55856. interface Math {
  55857. fround(x: number): number;
  55858. imul(a: number, b: number): number;
  55859. }
  55860. interface WebGLRenderingContext {
  55861. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55862. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55863. vertexAttribDivisor(index: number, divisor: number): void;
  55864. createVertexArray(): any;
  55865. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55866. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55867. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55868. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55869. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55870. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55871. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55872. // Queries
  55873. createQuery(): WebGLQuery;
  55874. deleteQuery(query: WebGLQuery): void;
  55875. beginQuery(target: number, query: WebGLQuery): void;
  55876. endQuery(target: number): void;
  55877. getQueryParameter(query: WebGLQuery, pname: number): any;
  55878. getQuery(target: number, pname: number): any;
  55879. MAX_SAMPLES: number;
  55880. RGBA8: number;
  55881. READ_FRAMEBUFFER: number;
  55882. DRAW_FRAMEBUFFER: number;
  55883. UNIFORM_BUFFER: number;
  55884. HALF_FLOAT_OES: number;
  55885. RGBA16F: number;
  55886. RGBA32F: number;
  55887. R32F: number;
  55888. RG32F: number;
  55889. RGB32F: number;
  55890. R16F: number;
  55891. RG16F: number;
  55892. RGB16F: number;
  55893. RED: number;
  55894. RG: number;
  55895. R8: number;
  55896. RG8: number;
  55897. UNSIGNED_INT_24_8: number;
  55898. DEPTH24_STENCIL8: number;
  55899. /* Multiple Render Targets */
  55900. drawBuffers(buffers: number[]): void;
  55901. readBuffer(src: number): void;
  55902. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55903. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55904. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55905. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55906. // Occlusion Query
  55907. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55908. ANY_SAMPLES_PASSED: number;
  55909. QUERY_RESULT_AVAILABLE: number;
  55910. QUERY_RESULT: number;
  55911. }
  55912. interface WebGLProgram { private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55913. }
  55914. interface EXT_disjoint_timer_query {
  55915. QUERY_COUNTER_BITS_EXT: number;
  55916. TIME_ELAPSED_EXT: number;
  55917. TIMESTAMP_EXT: number;
  55918. GPU_DISJOINT_EXT: number;
  55919. QUERY_RESULT_EXT: number;
  55920. QUERY_RESULT_AVAILABLE_EXT: number;
  55921. queryCounterEXT(query: WebGLQuery, target: number): void;
  55922. createQueryEXT(): WebGLQuery;
  55923. beginQueryEXT(target: number, query: WebGLQuery): void;
  55924. endQueryEXT(target: number): void;
  55925. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55926. deleteQueryEXT(query: WebGLQuery): void;
  55927. }
  55928. interface WebGLUniformLocation { currentState: any;
  55929. }
  55930. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55931. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55932. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55933. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55934. interface WebGLRenderingContext {
  55935. readonly RASTERIZER_DISCARD: number;
  55936. readonly DEPTH_COMPONENT24: number;
  55937. readonly TEXTURE_3D: number;
  55938. readonly TEXTURE_2D_ARRAY: number;
  55939. readonly TEXTURE_COMPARE_FUNC: number;
  55940. readonly TEXTURE_COMPARE_MODE: number;
  55941. readonly COMPARE_REF_TO_TEXTURE: number;
  55942. readonly TEXTURE_WRAP_R: number;
  55943. readonly HALF_FLOAT: number;
  55944. readonly RGB8: number;
  55945. readonly RED_INTEGER: number;
  55946. readonly RG_INTEGER: number;
  55947. readonly RGB_INTEGER: number;
  55948. readonly RGBA_INTEGER: number;
  55949. readonly R8_SNORM: number;
  55950. readonly RG8_SNORM: number;
  55951. readonly RGB8_SNORM: number;
  55952. readonly RGBA8_SNORM: number;
  55953. readonly R8I: number;
  55954. readonly RG8I: number;
  55955. readonly RGB8I: number;
  55956. readonly RGBA8I: number;
  55957. readonly R8UI: number;
  55958. readonly RG8UI: number;
  55959. readonly RGB8UI: number;
  55960. readonly RGBA8UI: number;
  55961. readonly R16I: number;
  55962. readonly RG16I: number;
  55963. readonly RGB16I: number;
  55964. readonly RGBA16I: number;
  55965. readonly R16UI: number;
  55966. readonly RG16UI: number;
  55967. readonly RGB16UI: number;
  55968. readonly RGBA16UI: number;
  55969. readonly R32I: number;
  55970. readonly RG32I: number;
  55971. readonly RGB32I: number;
  55972. readonly RGBA32I: number;
  55973. readonly R32UI: number;
  55974. readonly RG32UI: number;
  55975. readonly RGB32UI: number;
  55976. readonly RGBA32UI: number;
  55977. readonly RGB10_A2UI: number;
  55978. readonly R11F_G11F_B10F: number;
  55979. readonly RGB9_E5: number;
  55980. readonly RGB10_A2: number;
  55981. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55982. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55983. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55984. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55985. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55986. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55987. 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;
  55988. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55989. readonly TRANSFORM_FEEDBACK: number;
  55990. readonly INTERLEAVED_ATTRIBS: number;
  55991. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55992. createTransformFeedback(): WebGLTransformFeedback;
  55993. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55994. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55995. beginTransformFeedback(primitiveMode: number): void;
  55996. endTransformFeedback(): void;
  55997. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55998. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55999. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56000. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56001. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56002. }
  56003. interface ImageBitmap {
  56004. readonly width: number;
  56005. readonly height: number;
  56006. close(): void;
  56007. }
  56008. interface WebGLQuery extends WebGLObject {
  56009. }
  56010. declare var WebGLQuery: {
  56011. prototype: WebGLQuery;
  56012. new(): WebGLQuery;
  56013. };
  56014. interface WebGLSampler extends WebGLObject {
  56015. }
  56016. declare var WebGLSampler: {
  56017. prototype: WebGLSampler;
  56018. new(): WebGLSampler;
  56019. };
  56020. interface WebGLSync extends WebGLObject {
  56021. }
  56022. declare var WebGLSync: {
  56023. prototype: WebGLSync;
  56024. new(): WebGLSync;
  56025. };
  56026. interface WebGLTransformFeedback extends WebGLObject {
  56027. }
  56028. declare var WebGLTransformFeedback: {
  56029. prototype: WebGLTransformFeedback;
  56030. new(): WebGLTransformFeedback;
  56031. };
  56032. interface WebGLVertexArrayObject extends WebGLObject {
  56033. }
  56034. declare var WebGLVertexArrayObject: {
  56035. prototype: WebGLVertexArrayObject;
  56036. new(): WebGLVertexArrayObject;
  56037. };
  56038. // Type definitions for WebVR API
  56039. // Project: https://w3c.github.io/webvr/
  56040. // Definitions by: six a <https://github.com/lostfictions>
  56041. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56042. interface VRDisplay extends EventTarget {
  56043. /**
  56044. * Dictionary of capabilities describing the VRDisplay.
  56045. */
  56046. readonly capabilities: VRDisplayCapabilities;
  56047. /**
  56048. * z-depth defining the far plane of the eye view frustum
  56049. * enables mapping of values in the render target depth
  56050. * attachment to scene coordinates. Initially set to 10000.0.
  56051. */
  56052. depthFar: number;
  56053. /**
  56054. * z-depth defining the near plane of the eye view frustum
  56055. * enables mapping of values in the render target depth
  56056. * attachment to scene coordinates. Initially set to 0.01.
  56057. */
  56058. depthNear: number;
  56059. /**
  56060. * An identifier for this distinct VRDisplay. Used as an
  56061. * association point in the Gamepad API.
  56062. */
  56063. readonly displayId: number;
  56064. /**
  56065. * A display name, a user-readable name identifying it.
  56066. */
  56067. readonly displayName: string;
  56068. readonly isConnected: boolean;
  56069. readonly isPresenting: boolean;
  56070. /**
  56071. * If this VRDisplay supports room-scale experiences, the optional
  56072. * stage attribute contains details on the room-scale parameters.
  56073. */
  56074. readonly stageParameters: VRStageParameters | null;
  56075. /**
  56076. * Passing the value returned by `requestAnimationFrame` to
  56077. * `cancelAnimationFrame` will unregister the callback.
  56078. * @param handle Define the hanle of the request to cancel
  56079. */
  56080. cancelAnimationFrame(handle: number): void;
  56081. /**
  56082. * Stops presenting to the VRDisplay.
  56083. * @returns a promise to know when it stopped
  56084. */
  56085. exitPresent(): Promise<void>;
  56086. /**
  56087. * Return the current VREyeParameters for the given eye.
  56088. * @param whichEye Define the eye we want the parameter for
  56089. * @returns the eye parameters
  56090. */
  56091. getEyeParameters(whichEye: string): VREyeParameters;
  56092. /**
  56093. * Populates the passed VRFrameData with the information required to render
  56094. * the current frame.
  56095. * @param frameData Define the data structure to populate
  56096. * @returns true if ok otherwise false
  56097. */
  56098. getFrameData(frameData: VRFrameData): boolean;
  56099. /**
  56100. * Get the layers currently being presented.
  56101. * @returns the list of VR layers
  56102. */
  56103. getLayers(): VRLayer[];
  56104. /**
  56105. * Return a VRPose containing the future predicted pose of the VRDisplay
  56106. * when the current frame will be presented. The value returned will not
  56107. * change until JavaScript has returned control to the browser.
  56108. *
  56109. * The VRPose will contain the position, orientation, velocity,
  56110. * and acceleration of each of these properties.
  56111. * @returns the pose object
  56112. */
  56113. getPose(): VRPose;
  56114. /**
  56115. * Return the current instantaneous pose of the VRDisplay, with no
  56116. * prediction applied.
  56117. * @returns the current instantaneous pose
  56118. */
  56119. getImmediatePose(): VRPose;
  56120. /**
  56121. * The callback passed to `requestAnimationFrame` will be called
  56122. * any time a new frame should be rendered. When the VRDisplay is
  56123. * presenting the callback will be called at the native refresh
  56124. * rate of the HMD. When not presenting this function acts
  56125. * identically to how window.requestAnimationFrame acts. Content should
  56126. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56127. * asynchronously from other displays and at differing refresh rates.
  56128. * @param callback Define the eaction to run next frame
  56129. * @returns the request handle it
  56130. */
  56131. requestAnimationFrame(callback: FrameRequestCallback): number;
  56132. /**
  56133. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56134. * Repeat calls while already presenting will update the VRLayers being displayed.
  56135. * @param layers Define the list of layer to present
  56136. * @returns a promise to know when the request has been fulfilled
  56137. */
  56138. requestPresent(layers: VRLayer[]): Promise<void>;
  56139. /**
  56140. * Reset the pose for this display, treating its current position and
  56141. * orientation as the "origin/zero" values. VRPose.position,
  56142. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56143. * updated when calling resetPose(). This should be called in only
  56144. * sitting-space experiences.
  56145. */
  56146. resetPose(): void;
  56147. /**
  56148. * The VRLayer provided to the VRDisplay will be captured and presented
  56149. * in the HMD. Calling this function has the same effect on the source
  56150. * canvas as any other operation that uses its source image, and canvases
  56151. * created without preserveDrawingBuffer set to true will be cleared.
  56152. * @param pose Define the pose to submit
  56153. */
  56154. submitFrame(pose?: VRPose): void;
  56155. }
  56156. declare var VRDisplay: {
  56157. prototype: VRDisplay;
  56158. new(): VRDisplay;
  56159. };
  56160. interface VRLayer {
  56161. leftBounds?: number[] | Float32Array | null;
  56162. rightBounds?: number[] | Float32Array | null;
  56163. source?: HTMLCanvasElement | null;
  56164. }
  56165. interface VRDisplayCapabilities {
  56166. readonly canPresent: boolean;
  56167. readonly hasExternalDisplay: boolean;
  56168. readonly hasOrientation: boolean;
  56169. readonly hasPosition: boolean;
  56170. readonly maxLayers: number;
  56171. }
  56172. interface VREyeParameters {
  56173. /** @deprecated */
  56174. readonly fieldOfView: VRFieldOfView;
  56175. readonly offset: Float32Array;
  56176. readonly renderHeight: number;
  56177. readonly renderWidth: number;
  56178. }
  56179. interface VRFieldOfView {
  56180. readonly downDegrees: number;
  56181. readonly leftDegrees: number;
  56182. readonly rightDegrees: number;
  56183. readonly upDegrees: number;
  56184. }
  56185. interface VRFrameData {
  56186. readonly leftProjectionMatrix: Float32Array;
  56187. readonly leftViewMatrix: Float32Array;
  56188. readonly pose: VRPose;
  56189. readonly rightProjectionMatrix: Float32Array;
  56190. readonly rightViewMatrix: Float32Array;
  56191. readonly timestamp: number;
  56192. }
  56193. interface VRPose {
  56194. readonly angularAcceleration: Float32Array | null;
  56195. readonly angularVelocity: Float32Array | null;
  56196. readonly linearAcceleration: Float32Array | null;
  56197. readonly linearVelocity: Float32Array | null;
  56198. readonly orientation: Float32Array | null;
  56199. readonly position: Float32Array | null;
  56200. readonly timestamp: number;
  56201. }
  56202. interface VRStageParameters {
  56203. sittingToStandingTransform?: Float32Array;
  56204. sizeX?: number;
  56205. sizeY?: number;
  56206. }
  56207. interface Navigator {
  56208. getVRDisplays(): Promise<VRDisplay[]>;
  56209. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56210. }
  56211. interface Window {
  56212. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56213. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56214. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56215. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56216. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56217. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56218. }
  56219. interface Gamepad {
  56220. readonly displayId: number;
  56221. }
  56222. interface XRDevice {
  56223. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56224. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56225. }
  56226. interface XRSession {
  56227. getInputSources(): Array<any>;
  56228. baseLayer: XRWebGLLayer;
  56229. requestFrameOfReference(type: string): Promise<void>;
  56230. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56231. end(): Promise<void>;
  56232. requestAnimationFrame: Function;
  56233. addEventListener: Function;
  56234. }
  56235. interface XRSessionCreationOptions {
  56236. outputContext?: WebGLRenderingContext | null;
  56237. immersive?: boolean;
  56238. environmentIntegration?: boolean;
  56239. }
  56240. interface XRLayer {
  56241. getViewport: Function;
  56242. framebufferWidth: number;
  56243. framebufferHeight: number;
  56244. }
  56245. interface XRView {
  56246. projectionMatrix: Float32Array;
  56247. }
  56248. interface XRFrame {
  56249. getDevicePose: Function;
  56250. getInputPose: Function;
  56251. views: Array<XRView>;
  56252. baseLayer: XRLayer;
  56253. }
  56254. interface XRFrameOfReference {
  56255. }
  56256. interface XRWebGLLayer extends XRLayer {
  56257. framebuffer: WebGLFramebuffer;
  56258. }
  56259. declare var XRWebGLLayer: {
  56260. prototype: XRWebGLLayer;
  56261. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56262. };
  56263. declare module BABYLON.GUI {
  56264. /**
  56265. * Class used to specific a value and its associated unit
  56266. */
  56267. export class ValueAndUnit {
  56268. /** defines the unit to store */
  56269. unit: number;
  56270. /** defines a boolean indicating if the value can be negative */
  56271. negativeValueAllowed: boolean;
  56272. private _value;
  56273. private _originalUnit;
  56274. /**
  56275. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56276. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56277. */
  56278. ignoreAdaptiveScaling: boolean;
  56279. /**
  56280. * Creates a new ValueAndUnit
  56281. * @param value defines the value to store
  56282. * @param unit defines the unit to store
  56283. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  56284. */
  56285. constructor(value: number,
  56286. /** defines the unit to store */
  56287. unit?: number,
  56288. /** defines a boolean indicating if the value can be negative */
  56289. negativeValueAllowed?: boolean);
  56290. /** Gets a boolean indicating if the value is a percentage */
  56291. readonly isPercentage: boolean;
  56292. /** Gets a boolean indicating if the value is store as pixel */
  56293. readonly isPixel: boolean;
  56294. /** Gets direct internal value */
  56295. readonly internalValue: number;
  56296. /**
  56297. * Gets value as pixel
  56298. * @param host defines the root host
  56299. * @param refValue defines the reference value for percentages
  56300. * @returns the value as pixel
  56301. */
  56302. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  56303. /**
  56304. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  56305. * @param value defines the value to store
  56306. * @param unit defines the unit to store
  56307. * @returns the current ValueAndUnit
  56308. */
  56309. updateInPlace(value: number, unit?: number): ValueAndUnit;
  56310. /**
  56311. * Gets the value accordingly to its unit
  56312. * @param host defines the root host
  56313. * @returns the value
  56314. */
  56315. getValue(host: AdvancedDynamicTexture): number;
  56316. /**
  56317. * Gets a string representation of the value
  56318. * @param host defines the root host
  56319. * @param decimals defines an optional number of decimals to display
  56320. * @returns a string
  56321. */
  56322. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  56323. /**
  56324. * Store a value parsed from a string
  56325. * @param source defines the source string
  56326. * @returns true if the value was successfully parsed
  56327. */
  56328. fromString(source: string | number): boolean;
  56329. private static _Regex;
  56330. private static _UNITMODE_PERCENTAGE;
  56331. private static _UNITMODE_PIXEL;
  56332. /** UNITMODE_PERCENTAGE */
  56333. static readonly UNITMODE_PERCENTAGE: number;
  56334. /** UNITMODE_PIXEL */
  56335. static readonly UNITMODE_PIXEL: number;
  56336. }
  56337. }
  56338. declare module BABYLON.GUI {
  56339. /**
  56340. * Define a style used by control to automatically setup properties based on a template.
  56341. * Only support font related properties so far
  56342. */
  56343. export class Style implements BABYLON.IDisposable {
  56344. private _fontFamily;
  56345. private _fontStyle;
  56346. private _fontWeight;
  56347. /** @hidden */ host: AdvancedDynamicTexture;
  56348. /** @hidden */ fontSize: ValueAndUnit;
  56349. /**
  56350. * BABYLON.Observable raised when the style values are changed
  56351. */
  56352. onChangedObservable: BABYLON.Observable<Style>;
  56353. /**
  56354. * Creates a new style object
  56355. * @param host defines the AdvancedDynamicTexture which hosts this style
  56356. */
  56357. constructor(host: AdvancedDynamicTexture);
  56358. /**
  56359. * Gets or sets the font size
  56360. */
  56361. fontSize: string | number;
  56362. /**
  56363. * Gets or sets the font family
  56364. */
  56365. fontFamily: string;
  56366. /**
  56367. * Gets or sets the font style
  56368. */
  56369. fontStyle: string;
  56370. /** Gets or sets font weight */
  56371. fontWeight: string;
  56372. /** Dispose all associated resources */
  56373. dispose(): void;
  56374. }
  56375. }
  56376. declare module BABYLON.GUI {
  56377. /**
  56378. * Class used to transport BABYLON.Vector2 information for pointer events
  56379. */
  56380. export class Vector2WithInfo extends BABYLON.Vector2 {
  56381. /** defines the current mouse button index */
  56382. buttonIndex: number;
  56383. /**
  56384. * Creates a new Vector2WithInfo
  56385. * @param source defines the vector2 data to transport
  56386. * @param buttonIndex defines the current mouse button index
  56387. */
  56388. constructor(source: BABYLON.Vector2,
  56389. /** defines the current mouse button index */
  56390. buttonIndex?: number);
  56391. }
  56392. /** Class used to provide 2D matrix features */
  56393. export class Matrix2D {
  56394. /** Gets the internal array of 6 floats used to store matrix data */
  56395. m: Float32Array;
  56396. /**
  56397. * Creates a new matrix
  56398. * @param m00 defines value for (0, 0)
  56399. * @param m01 defines value for (0, 1)
  56400. * @param m10 defines value for (1, 0)
  56401. * @param m11 defines value for (1, 1)
  56402. * @param m20 defines value for (2, 0)
  56403. * @param m21 defines value for (2, 1)
  56404. */
  56405. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56406. /**
  56407. * Fills the matrix from direct values
  56408. * @param m00 defines value for (0, 0)
  56409. * @param m01 defines value for (0, 1)
  56410. * @param m10 defines value for (1, 0)
  56411. * @param m11 defines value for (1, 1)
  56412. * @param m20 defines value for (2, 0)
  56413. * @param m21 defines value for (2, 1)
  56414. * @returns the current modified matrix
  56415. */
  56416. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56417. /**
  56418. * Gets matrix determinant
  56419. * @returns the determinant
  56420. */
  56421. determinant(): number;
  56422. /**
  56423. * Inverses the matrix and stores it in a target matrix
  56424. * @param result defines the target matrix
  56425. * @returns the current matrix
  56426. */
  56427. invertToRef(result: Matrix2D): Matrix2D;
  56428. /**
  56429. * Multiplies the current matrix with another one
  56430. * @param other defines the second operand
  56431. * @param result defines the target matrix
  56432. * @returns the current matrix
  56433. */
  56434. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56435. /**
  56436. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56437. * @param x defines the x coordinate to transform
  56438. * @param y defines the x coordinate to transform
  56439. * @param result defines the target vector2
  56440. * @returns the current matrix
  56441. */
  56442. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56443. /**
  56444. * Creates an identity matrix
  56445. * @returns a new matrix
  56446. */
  56447. static Identity(): Matrix2D;
  56448. /**
  56449. * Creates a translation matrix and stores it in a target matrix
  56450. * @param x defines the x coordinate of the translation
  56451. * @param y defines the y coordinate of the translation
  56452. * @param result defines the target matrix
  56453. */
  56454. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56455. /**
  56456. * Creates a scaling matrix and stores it in a target matrix
  56457. * @param x defines the x coordinate of the scaling
  56458. * @param y defines the y coordinate of the scaling
  56459. * @param result defines the target matrix
  56460. */
  56461. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56462. /**
  56463. * Creates a rotation matrix and stores it in a target matrix
  56464. * @param angle defines the rotation angle
  56465. * @param result defines the target matrix
  56466. */
  56467. static RotationToRef(angle: number, result: Matrix2D): void;
  56468. private static _TempPreTranslationMatrix;
  56469. private static _TempPostTranslationMatrix;
  56470. private static _TempRotationMatrix;
  56471. private static _TempScalingMatrix;
  56472. private static _TempCompose0;
  56473. private static _TempCompose1;
  56474. private static _TempCompose2;
  56475. /**
  56476. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56477. * @param tx defines the x coordinate of the translation
  56478. * @param ty defines the y coordinate of the translation
  56479. * @param angle defines the rotation angle
  56480. * @param scaleX defines the x coordinate of the scaling
  56481. * @param scaleY defines the y coordinate of the scaling
  56482. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56483. * @param result defines the target matrix
  56484. */
  56485. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56486. }
  56487. }
  56488. declare module BABYLON.GUI {
  56489. /**
  56490. * Class used to store 2D control sizes
  56491. */
  56492. export class Measure {
  56493. /** defines left coordinate */
  56494. left: number;
  56495. /** defines top coordinate */
  56496. top: number;
  56497. /** defines width dimension */
  56498. width: number;
  56499. /** defines height dimension */
  56500. height: number;
  56501. /**
  56502. * Creates a new measure
  56503. * @param left defines left coordinate
  56504. * @param top defines top coordinate
  56505. * @param width defines width dimension
  56506. * @param height defines height dimension
  56507. */
  56508. constructor(
  56509. /** defines left coordinate */
  56510. left: number,
  56511. /** defines top coordinate */
  56512. top: number,
  56513. /** defines width dimension */
  56514. width: number,
  56515. /** defines height dimension */
  56516. height: number);
  56517. /**
  56518. * Copy from another measure
  56519. * @param other defines the other measure to copy from
  56520. */
  56521. copyFrom(other: Measure): void;
  56522. /**
  56523. * Copy from a group of 4 floats
  56524. * @param left defines left coordinate
  56525. * @param top defines top coordinate
  56526. * @param width defines width dimension
  56527. * @param height defines height dimension
  56528. */
  56529. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56530. /**
  56531. * Computes the axis aligned bounding box measure for two given measures
  56532. * @param a Input measure
  56533. * @param b Input measure
  56534. * @param result the resulting bounding measure
  56535. */
  56536. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56537. /**
  56538. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56539. * @param transform the matrix to transform the measure before computing the AABB
  56540. * @param result the resulting AABB
  56541. */
  56542. transformToRef(transform: Matrix2D, result: Measure): void;
  56543. /**
  56544. * Check equality between this measure and another one
  56545. * @param other defines the other measures
  56546. * @returns true if both measures are equals
  56547. */
  56548. isEqualsTo(other: Measure): boolean;
  56549. /**
  56550. * Creates an empty measure
  56551. * @returns a new measure
  56552. */
  56553. static Empty(): Measure;
  56554. }
  56555. }
  56556. declare module BABYLON.GUI {
  56557. /**
  56558. * Interface used to define a control that can receive focus
  56559. */
  56560. export interface IFocusableControl {
  56561. /**
  56562. * Function called when the control receives the focus
  56563. */
  56564. onFocus(): void;
  56565. /**
  56566. * Function called when the control loses the focus
  56567. */
  56568. onBlur(): void;
  56569. /**
  56570. * Function called to let the control handle keyboard events
  56571. * @param evt defines the current keyboard event
  56572. */
  56573. processKeyboard(evt: KeyboardEvent): void;
  56574. /**
  56575. * Function called to get the list of controls that should not steal the focus from this control
  56576. * @returns an array of controls
  56577. */
  56578. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56579. }
  56580. /**
  56581. * Class used to create texture to support 2D GUI elements
  56582. * @see http://doc.babylonjs.com/how_to/gui
  56583. */
  56584. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56585. private _isDirty;
  56586. private _renderObserver;
  56587. private _resizeObserver;
  56588. private _preKeyboardObserver;
  56589. private _pointerMoveObserver;
  56590. private _pointerObserver;
  56591. private _canvasPointerOutObserver;
  56592. private _background;
  56593. /** @hidden */ rootContainer: Container;
  56594. /** @hidden */ lastPickedControl: Control;
  56595. /** @hidden */ lastControlOver: {
  56596. [pointerId: number]: Control;
  56597. };
  56598. /** @hidden */ lastControlDown: {
  56599. [pointerId: number]: Control;
  56600. };
  56601. /** @hidden */ capturingControl: {
  56602. [pointerId: number]: Control;
  56603. };
  56604. /** @hidden */ shouldBlockPointer: boolean;
  56605. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56606. /** @hidden */ linkedControls: Control[];
  56607. private _isFullscreen;
  56608. private _fullscreenViewport;
  56609. private _idealWidth;
  56610. private _idealHeight;
  56611. private _useSmallestIdeal;
  56612. private _renderAtIdealSize;
  56613. private _focusedControl;
  56614. private _blockNextFocusCheck;
  56615. private _renderScale;
  56616. private _rootCanvas;
  56617. private _cursorChanged;
  56618. /**
  56619. * Define type to string to ensure compatibility across browsers
  56620. * Safari doesn't support DataTransfer constructor
  56621. */
  56622. private _clipboardData;
  56623. /**
  56624. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56625. */
  56626. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56627. /**
  56628. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56629. */
  56630. onControlPickedObservable: BABYLON.Observable<Control>;
  56631. /**
  56632. * BABYLON.Observable event triggered before layout is evaluated
  56633. */
  56634. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56635. /**
  56636. * BABYLON.Observable event triggered after the layout was evaluated
  56637. */
  56638. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56639. /**
  56640. * BABYLON.Observable event triggered before the texture is rendered
  56641. */
  56642. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56643. /**
  56644. * BABYLON.Observable event triggered after the texture was rendered
  56645. */
  56646. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56647. /**
  56648. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56649. */
  56650. premulAlpha: boolean;
  56651. /**
  56652. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56653. * Useful when you want more antialiasing
  56654. */
  56655. renderScale: number;
  56656. /** Gets or sets the background color */
  56657. background: string;
  56658. /**
  56659. * Gets or sets the ideal width used to design controls.
  56660. * The GUI will then rescale everything accordingly
  56661. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56662. */
  56663. idealWidth: number;
  56664. /**
  56665. * Gets or sets the ideal height used to design controls.
  56666. * The GUI will then rescale everything accordingly
  56667. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56668. */
  56669. idealHeight: number;
  56670. /**
  56671. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56672. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56673. */
  56674. useSmallestIdeal: boolean;
  56675. /**
  56676. * Gets or sets a boolean indicating if adaptive scaling must be used
  56677. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56678. */
  56679. renderAtIdealSize: boolean;
  56680. /**
  56681. * Gets the underlying layer used to render the texture when in fullscreen mode
  56682. */
  56683. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56684. /**
  56685. * Gets the root container control
  56686. */
  56687. readonly rootContainer: Container;
  56688. /**
  56689. * Returns an array containing the root container.
  56690. * This is mostly used to let the Inspector introspects the ADT
  56691. * @returns an array containing the rootContainer
  56692. */
  56693. getChildren(): Array<Container>;
  56694. /**
  56695. * Will return all controls that are inside this texture
  56696. * @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
  56697. * @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
  56698. * @return all child controls
  56699. */
  56700. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56701. /**
  56702. * Gets or sets the current focused control
  56703. */
  56704. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56705. /**
  56706. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56707. */
  56708. isForeground: boolean;
  56709. /**
  56710. * Gets or set information about clipboardData
  56711. */
  56712. clipboardData: string;
  56713. /**
  56714. * Creates a new AdvancedDynamicTexture
  56715. * @param name defines the name of the texture
  56716. * @param width defines the width of the texture
  56717. * @param height defines the height of the texture
  56718. * @param scene defines the hosting scene
  56719. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56720. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56721. */
  56722. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56723. /**
  56724. * Get the current class name of the texture useful for serialization or dynamic coding.
  56725. * @returns "AdvancedDynamicTexture"
  56726. */
  56727. getClassName(): string;
  56728. /**
  56729. * Function used to execute a function on all controls
  56730. * @param func defines the function to execute
  56731. * @param container defines the container where controls belong. If null the root container will be used
  56732. */
  56733. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56734. private _useInvalidateRectOptimization;
  56735. /**
  56736. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56737. */
  56738. useInvalidateRectOptimization: boolean;
  56739. private _invalidatedRectangle;
  56740. /**
  56741. * Invalidates a rectangle area on the gui texture
  56742. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56743. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56744. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56745. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56746. */
  56747. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56748. /**
  56749. * Marks the texture as dirty forcing a complete update
  56750. */
  56751. markAsDirty(): void;
  56752. /**
  56753. * Helper function used to create a new style
  56754. * @returns a new style
  56755. * @see http://doc.babylonjs.com/how_to/gui#styles
  56756. */
  56757. createStyle(): Style;
  56758. /**
  56759. * Adds a new control to the root container
  56760. * @param control defines the control to add
  56761. * @returns the current texture
  56762. */
  56763. addControl(control: Control): AdvancedDynamicTexture;
  56764. /**
  56765. * Removes a control from the root container
  56766. * @param control defines the control to remove
  56767. * @returns the current texture
  56768. */
  56769. removeControl(control: Control): AdvancedDynamicTexture;
  56770. /**
  56771. * Release all resources
  56772. */
  56773. dispose(): void;
  56774. private _onResize;
  56775. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56776. /**
  56777. * Get screen coordinates for a vector3
  56778. * @param position defines the position to project
  56779. * @param worldMatrix defines the world matrix to use
  56780. * @returns the projected position
  56781. */
  56782. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56783. private _checkUpdate;
  56784. private _clearMeasure;
  56785. private _render;
  56786. /** @hidden */ changeCursor(cursor: string): void;
  56787. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56788. private _doPicking;
  56789. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56790. [pointerId: number]: Control;
  56791. }, control: Control): void;
  56792. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56793. /** Attach to all scene events required to support pointer events */
  56794. attach(): void;
  56795. /** @hidden */
  56796. private onClipboardCopy;
  56797. /** @hidden */
  56798. private onClipboardCut;
  56799. /** @hidden */
  56800. private onClipboardPaste;
  56801. /**
  56802. * Register the clipboard Events onto the canvas
  56803. */
  56804. registerClipboardEvents(): void;
  56805. /**
  56806. * Unregister the clipboard Events from the canvas
  56807. */
  56808. unRegisterClipboardEvents(): void;
  56809. /**
  56810. * Connect the texture to a hosting mesh to enable interactions
  56811. * @param mesh defines the mesh to attach to
  56812. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56813. */
  56814. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56815. /**
  56816. * Move the focus to a specific control
  56817. * @param control defines the control which will receive the focus
  56818. */
  56819. moveFocusToControl(control: IFocusableControl): void;
  56820. private _manageFocus;
  56821. private _attachToOnPointerOut;
  56822. /**
  56823. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56824. * @param mesh defines the mesh which will receive the texture
  56825. * @param width defines the texture width (1024 by default)
  56826. * @param height defines the texture height (1024 by default)
  56827. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56828. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56829. * @returns a new AdvancedDynamicTexture
  56830. */
  56831. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56832. /**
  56833. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56834. * In this mode the texture will rely on a layer for its rendering.
  56835. * This allows it to be treated like any other layer.
  56836. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56837. * LayerMask is set through advancedTexture.layer.layerMask
  56838. * @param name defines name for the texture
  56839. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56840. * @param scene defines the hsoting scene
  56841. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56842. * @returns a new AdvancedDynamicTexture
  56843. */
  56844. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56845. }
  56846. }
  56847. declare module BABYLON.GUI {
  56848. /**
  56849. * Root class used for all 2D controls
  56850. * @see http://doc.babylonjs.com/how_to/gui#controls
  56851. */
  56852. export class Control {
  56853. /** defines the name of the control */
  56854. name?: string | undefined;
  56855. /**
  56856. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56857. */
  56858. static AllowAlphaInheritance: boolean;
  56859. private _alpha;
  56860. private _alphaSet;
  56861. private _zIndex;
  56862. /** @hidden */ host: AdvancedDynamicTexture;
  56863. /** Gets or sets the control parent */
  56864. parent: BABYLON.Nullable<Container>;
  56865. /** @hidden */ currentMeasure: Measure;
  56866. private _fontFamily;
  56867. private _fontStyle;
  56868. private _fontWeight;
  56869. private _fontSize;
  56870. private _font;
  56871. /** @hidden */ width: ValueAndUnit;
  56872. /** @hidden */ height: ValueAndUnit;
  56873. /** @hidden */
  56874. protected _fontOffset: {
  56875. ascent: number;
  56876. height: number;
  56877. descent: number;
  56878. };
  56879. private _color;
  56880. private _style;
  56881. private _styleObserver;
  56882. /** @hidden */
  56883. protected _horizontalAlignment: number;
  56884. /** @hidden */
  56885. protected _verticalAlignment: number;
  56886. /** @hidden */
  56887. protected _isDirty: boolean;
  56888. /** @hidden */
  56889. protected _wasDirty: boolean;
  56890. /** @hidden */ tempParentMeasure: Measure;
  56891. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56892. /** @hidden */
  56893. protected _cachedParentMeasure: Measure;
  56894. private _paddingLeft;
  56895. private _paddingRight;
  56896. private _paddingTop;
  56897. private _paddingBottom;
  56898. /** @hidden */ left: ValueAndUnit;
  56899. /** @hidden */ top: ValueAndUnit;
  56900. private _scaleX;
  56901. private _scaleY;
  56902. private _rotation;
  56903. private _transformCenterX;
  56904. private _transformCenterY;
  56905. /** @hidden */ transformMatrix: Matrix2D;
  56906. /** @hidden */
  56907. protected _invertTransformMatrix: Matrix2D;
  56908. /** @hidden */
  56909. protected _transformedPosition: BABYLON.Vector2;
  56910. private _isMatrixDirty;
  56911. private _cachedOffsetX;
  56912. private _cachedOffsetY;
  56913. private _isVisible;
  56914. private _isHighlighted;
  56915. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56916. private _fontSet;
  56917. private _dummyVector2;
  56918. private _downCount;
  56919. private _enterCount;
  56920. private _doNotRender;
  56921. private _downPointerIds;
  56922. protected _isEnabled: boolean;
  56923. protected _disabledColor: string;
  56924. /** @hidden */
  56925. protected _rebuildLayout: boolean;
  56926. /** @hidden */ isClipped: boolean;
  56927. /** @hidden */ tag: any;
  56928. /**
  56929. * 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
  56930. */
  56931. uniqueId: number;
  56932. /**
  56933. * Gets or sets an object used to store user defined information for the node
  56934. */
  56935. metadata: any;
  56936. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56937. isHitTestVisible: boolean;
  56938. /** Gets or sets a boolean indicating if the control can block pointer events */
  56939. isPointerBlocker: boolean;
  56940. /** Gets or sets a boolean indicating if the control can be focusable */
  56941. isFocusInvisible: boolean;
  56942. /**
  56943. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56944. * 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
  56945. */
  56946. clipChildren: boolean;
  56947. /**
  56948. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56949. */
  56950. useBitmapCache: boolean;
  56951. private _cacheData;
  56952. private _shadowOffsetX;
  56953. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56954. shadowOffsetX: number;
  56955. private _shadowOffsetY;
  56956. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56957. shadowOffsetY: number;
  56958. private _shadowBlur;
  56959. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56960. shadowBlur: number;
  56961. private _shadowColor;
  56962. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56963. shadowColor: string;
  56964. /** Gets or sets the cursor to use when the control is hovered */
  56965. hoverCursor: string;
  56966. /** @hidden */
  56967. protected _linkOffsetX: ValueAndUnit;
  56968. /** @hidden */
  56969. protected _linkOffsetY: ValueAndUnit;
  56970. /** Gets the control type name */
  56971. readonly typeName: string;
  56972. /**
  56973. * Get the current class name of the control.
  56974. * @returns current class name
  56975. */
  56976. getClassName(): string;
  56977. /**
  56978. * An event triggered when the pointer move over the control.
  56979. */
  56980. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56981. /**
  56982. * An event triggered when the pointer move out of the control.
  56983. */
  56984. onPointerOutObservable: BABYLON.Observable<Control>;
  56985. /**
  56986. * An event triggered when the pointer taps the control
  56987. */
  56988. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56989. /**
  56990. * An event triggered when pointer up
  56991. */
  56992. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56993. /**
  56994. * An event triggered when a control is clicked on
  56995. */
  56996. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56997. /**
  56998. * An event triggered when pointer enters the control
  56999. */
  57000. onPointerEnterObservable: BABYLON.Observable<Control>;
  57001. /**
  57002. * An event triggered when the control is marked as dirty
  57003. */
  57004. onDirtyObservable: BABYLON.Observable<Control>;
  57005. /**
  57006. * An event triggered before drawing the control
  57007. */
  57008. onBeforeDrawObservable: BABYLON.Observable<Control>;
  57009. /**
  57010. * An event triggered after the control was drawn
  57011. */
  57012. onAfterDrawObservable: BABYLON.Observable<Control>;
  57013. /**
  57014. * Get the hosting AdvancedDynamicTexture
  57015. */
  57016. readonly host: AdvancedDynamicTexture;
  57017. /** Gets or set information about font offsets (used to render and align text) */
  57018. fontOffset: {
  57019. ascent: number;
  57020. height: number;
  57021. descent: number;
  57022. };
  57023. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  57024. alpha: number;
  57025. /**
  57026. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  57027. */
  57028. isHighlighted: boolean;
  57029. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  57030. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57031. */
  57032. scaleX: number;
  57033. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  57034. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57035. */
  57036. scaleY: number;
  57037. /** Gets or sets the rotation angle (0 by default)
  57038. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57039. */
  57040. rotation: number;
  57041. /** Gets or sets the transformation center on Y axis (0 by default)
  57042. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57043. */
  57044. transformCenterY: number;
  57045. /** Gets or sets the transformation center on X axis (0 by default)
  57046. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57047. */
  57048. transformCenterX: number;
  57049. /**
  57050. * Gets or sets the horizontal alignment
  57051. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57052. */
  57053. horizontalAlignment: number;
  57054. /**
  57055. * Gets or sets the vertical alignment
  57056. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57057. */
  57058. verticalAlignment: number;
  57059. /**
  57060. * Gets or sets control width
  57061. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57062. */
  57063. width: string | number;
  57064. /**
  57065. * Gets control width in pixel
  57066. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57067. */
  57068. readonly widthInPixels: number;
  57069. /**
  57070. * Gets or sets control height
  57071. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57072. */
  57073. height: string | number;
  57074. /**
  57075. * Gets control height in pixel
  57076. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57077. */
  57078. readonly heightInPixels: number;
  57079. /** Gets or set font family */
  57080. fontFamily: string;
  57081. /** Gets or sets font style */
  57082. fontStyle: string;
  57083. /** Gets or sets font weight */
  57084. fontWeight: string;
  57085. /**
  57086. * Gets or sets style
  57087. * @see http://doc.babylonjs.com/how_to/gui#styles
  57088. */
  57089. style: BABYLON.Nullable<Style>;
  57090. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  57091. /** Gets font size in pixels */
  57092. readonly fontSizeInPixels: number;
  57093. /** Gets or sets font size */
  57094. fontSize: string | number;
  57095. /** Gets or sets foreground color */
  57096. color: string;
  57097. /** Gets or sets z index which is used to reorder controls on the z axis */
  57098. zIndex: number;
  57099. /** Gets or sets a boolean indicating if the control can be rendered */
  57100. notRenderable: boolean;
  57101. /** Gets or sets a boolean indicating if the control is visible */
  57102. isVisible: boolean;
  57103. /** Gets a boolean indicating that the control needs to update its rendering */
  57104. readonly isDirty: boolean;
  57105. /**
  57106. * Gets the current linked mesh (or null if none)
  57107. */
  57108. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  57109. /**
  57110. * Gets or sets a value indicating the padding to use on the left of the control
  57111. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57112. */
  57113. paddingLeft: string | number;
  57114. /**
  57115. * Gets a value indicating the padding in pixels to use on the left of the control
  57116. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57117. */
  57118. readonly paddingLeftInPixels: number;
  57119. /**
  57120. * Gets or sets a value indicating the padding to use on the right of the control
  57121. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57122. */
  57123. paddingRight: string | number;
  57124. /**
  57125. * Gets a value indicating the padding in pixels to use on the right of the control
  57126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57127. */
  57128. readonly paddingRightInPixels: number;
  57129. /**
  57130. * Gets or sets a value indicating the padding to use on the top of the control
  57131. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57132. */
  57133. paddingTop: string | number;
  57134. /**
  57135. * Gets a value indicating the padding in pixels to use on the top of the control
  57136. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57137. */
  57138. readonly paddingTopInPixels: number;
  57139. /**
  57140. * Gets or sets a value indicating the padding to use on the bottom of the control
  57141. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57142. */
  57143. paddingBottom: string | number;
  57144. /**
  57145. * Gets a value indicating the padding in pixels to use on the bottom of the control
  57146. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57147. */
  57148. readonly paddingBottomInPixels: number;
  57149. /**
  57150. * Gets or sets a value indicating the left coordinate of the control
  57151. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57152. */
  57153. left: string | number;
  57154. /**
  57155. * Gets a value indicating the left coordinate in pixels of the control
  57156. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57157. */
  57158. readonly leftInPixels: number;
  57159. /**
  57160. * Gets or sets a value indicating the top coordinate of the control
  57161. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57162. */
  57163. top: string | number;
  57164. /**
  57165. * Gets a value indicating the top coordinate in pixels of the control
  57166. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57167. */
  57168. readonly topInPixels: number;
  57169. /**
  57170. * Gets or sets a value indicating the offset on X axis to the linked mesh
  57171. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57172. */
  57173. linkOffsetX: string | number;
  57174. /**
  57175. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  57176. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57177. */
  57178. readonly linkOffsetXInPixels: number;
  57179. /**
  57180. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  57181. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57182. */
  57183. linkOffsetY: string | number;
  57184. /**
  57185. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  57186. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57187. */
  57188. readonly linkOffsetYInPixels: number;
  57189. /** Gets the center coordinate on X axis */
  57190. readonly centerX: number;
  57191. /** Gets the center coordinate on Y axis */
  57192. readonly centerY: number;
  57193. /** Gets or sets if control is Enabled*/
  57194. isEnabled: boolean;
  57195. /** Gets or sets background color of control if it's disabled*/
  57196. disabledColor: string;
  57197. /**
  57198. * Creates a new control
  57199. * @param name defines the name of the control
  57200. */
  57201. constructor(
  57202. /** defines the name of the control */
  57203. name?: string | undefined);
  57204. /** @hidden */
  57205. protected _getTypeName(): string;
  57206. /**
  57207. * Gets the first ascendant in the hierarchy of the given type
  57208. * @param className defines the required type
  57209. * @returns the ascendant or null if not found
  57210. */
  57211. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  57212. /** @hidden */ resetFontCache(): void;
  57213. /**
  57214. * Determines if a container is an ascendant of the current control
  57215. * @param container defines the container to look for
  57216. * @returns true if the container is one of the ascendant of the control
  57217. */
  57218. isAscendant(container: Control): boolean;
  57219. /**
  57220. * Gets coordinates in local control space
  57221. * @param globalCoordinates defines the coordinates to transform
  57222. * @returns the new coordinates in local space
  57223. */
  57224. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57225. /**
  57226. * Gets coordinates in local control space
  57227. * @param globalCoordinates defines the coordinates to transform
  57228. * @param result defines the target vector2 where to store the result
  57229. * @returns the current control
  57230. */
  57231. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  57232. /**
  57233. * Gets coordinates in parent local control space
  57234. * @param globalCoordinates defines the coordinates to transform
  57235. * @returns the new coordinates in parent local space
  57236. */
  57237. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57238. /**
  57239. * Move the current control to a vector3 position projected onto the screen.
  57240. * @param position defines the target position
  57241. * @param scene defines the hosting scene
  57242. */
  57243. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  57244. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57245. /**
  57246. * Will return all controls that have this control as ascendant
  57247. * @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
  57248. * @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
  57249. * @return all child controls
  57250. */
  57251. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  57252. /**
  57253. * Link current control with a target mesh
  57254. * @param mesh defines the mesh to link with
  57255. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57256. */
  57257. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  57258. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  57259. /** @hidden */ offsetLeft(offset: number): void;
  57260. /** @hidden */ offsetTop(offset: number): void;
  57261. /** @hidden */ markMatrixAsDirty(): void;
  57262. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  57263. /** @hidden */ intersectsRect(rect: Measure): boolean;
  57264. /** @hidden */
  57265. protected invalidateRect(): void;
  57266. /** @hidden */ markAsDirty(force?: boolean): void;
  57267. /** @hidden */ markAllAsDirty(): void;
  57268. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57269. /** @hidden */
  57270. protected _transform(context?: CanvasRenderingContext2D): void;
  57271. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  57272. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57273. /** @hidden */
  57274. protected _applyStates(context: CanvasRenderingContext2D): void;
  57275. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57276. /** @hidden */
  57277. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57278. protected _evaluateClippingState(parentMeasure: Measure): void;
  57279. /** @hidden */ measure(): void;
  57280. /** @hidden */
  57281. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57282. /** @hidden */
  57283. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57284. /** @hidden */
  57285. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57286. /** @hidden */
  57287. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57288. private static _ClipMeasure;
  57289. private _tmpMeasureA;
  57290. private _clip;
  57291. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  57292. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  57293. /**
  57294. * Tests if a given coordinates belong to the current control
  57295. * @param x defines x coordinate to test
  57296. * @param y defines y coordinate to test
  57297. * @returns true if the coordinates are inside the control
  57298. */
  57299. contains(x: number, y: number): boolean;
  57300. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57301. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  57302. /** @hidden */ onPointerEnter(target: Control): boolean;
  57303. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57304. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57305. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57306. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  57307. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  57308. private _prepareFont;
  57309. /** Releases associated resources */
  57310. dispose(): void;
  57311. private static _HORIZONTAL_ALIGNMENT_LEFT;
  57312. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  57313. private static _HORIZONTAL_ALIGNMENT_CENTER;
  57314. private static _VERTICAL_ALIGNMENT_TOP;
  57315. private static _VERTICAL_ALIGNMENT_BOTTOM;
  57316. private static _VERTICAL_ALIGNMENT_CENTER;
  57317. /** HORIZONTAL_ALIGNMENT_LEFT */
  57318. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  57319. /** HORIZONTAL_ALIGNMENT_RIGHT */
  57320. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  57321. /** HORIZONTAL_ALIGNMENT_CENTER */
  57322. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  57323. /** VERTICAL_ALIGNMENT_TOP */
  57324. static readonly VERTICAL_ALIGNMENT_TOP: number;
  57325. /** VERTICAL_ALIGNMENT_BOTTOM */
  57326. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  57327. /** VERTICAL_ALIGNMENT_CENTER */
  57328. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  57329. private static _FontHeightSizes;
  57330. /** @hidden */ private static _GetFontOffset(font: string): {
  57331. ascent: number;
  57332. height: number;
  57333. descent: number;
  57334. };
  57335. /**
  57336. * Creates a stack panel that can be used to render headers
  57337. * @param control defines the control to associate with the header
  57338. * @param text defines the text of the header
  57339. * @param size defines the size of the header
  57340. * @param options defines options used to configure the header
  57341. * @returns a new StackPanel
  57342. * @ignore
  57343. * @hidden
  57344. */
  57345. static AddHeader: (control: Control, text: string, size: string | number, options: {
  57346. isHorizontal: boolean;
  57347. controlFirst: boolean;
  57348. }) => any;
  57349. /** @hidden */
  57350. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  57351. }
  57352. }
  57353. declare module BABYLON.GUI {
  57354. /**
  57355. * Root class for 2D containers
  57356. * @see http://doc.babylonjs.com/how_to/gui#containers
  57357. */
  57358. export class Container extends Control {
  57359. name?: string | undefined;
  57360. /** @hidden */
  57361. protected _children: Control[];
  57362. /** @hidden */
  57363. protected _measureForChildren: Measure;
  57364. /** @hidden */
  57365. protected _background: string;
  57366. /** @hidden */
  57367. protected _adaptWidthToChildren: boolean;
  57368. /** @hidden */
  57369. protected _adaptHeightToChildren: boolean;
  57370. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57371. adaptHeightToChildren: boolean;
  57372. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57373. adaptWidthToChildren: boolean;
  57374. /** Gets or sets background color */
  57375. background: string;
  57376. /** Gets the list of children */
  57377. readonly children: Control[];
  57378. /**
  57379. * Creates a new Container
  57380. * @param name defines the name of the container
  57381. */
  57382. constructor(name?: string | undefined);
  57383. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57384. /**
  57385. * Gets a child using its name
  57386. * @param name defines the child name to look for
  57387. * @returns the child control if found
  57388. */
  57389. getChildByName(name: string): BABYLON.Nullable<Control>;
  57390. /**
  57391. * Gets a child using its type and its name
  57392. * @param name defines the child name to look for
  57393. * @param type defines the child type to look for
  57394. * @returns the child control if found
  57395. */
  57396. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57397. /**
  57398. * Search for a specific control in children
  57399. * @param control defines the control to look for
  57400. * @returns true if the control is in child list
  57401. */
  57402. containsControl(control: Control): boolean;
  57403. /**
  57404. * Adds a new control to the current container
  57405. * @param control defines the control to add
  57406. * @returns the current container
  57407. */
  57408. addControl(control: BABYLON.Nullable<Control>): Container;
  57409. /**
  57410. * Removes all controls from the current container
  57411. * @returns the current container
  57412. */
  57413. clearControls(): Container;
  57414. /**
  57415. * Removes a control from the current container
  57416. * @param control defines the control to remove
  57417. * @returns the current container
  57418. */
  57419. removeControl(control: Control): Container;
  57420. /** @hidden */ reOrderControl(control: Control): void;
  57421. /** @hidden */ offsetLeft(offset: number): void;
  57422. /** @hidden */ offsetTop(offset: number): void;
  57423. /** @hidden */ markAllAsDirty(): void;
  57424. /** @hidden */
  57425. protected _localDraw(context: CanvasRenderingContext2D): void;
  57426. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57427. /** @hidden */
  57428. protected _beforeLayout(): void;
  57429. /** @hidden */
  57430. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57431. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57432. protected _postMeasure(): void;
  57433. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57434. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57435. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57436. /** @hidden */
  57437. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57438. /** Releases associated resources */
  57439. dispose(): void;
  57440. }
  57441. }
  57442. declare module BABYLON.GUI {
  57443. /** Class used to create rectangle container */
  57444. export class Rectangle extends Container {
  57445. name?: string | undefined;
  57446. private _thickness;
  57447. private _cornerRadius;
  57448. /** Gets or sets border thickness */
  57449. thickness: number;
  57450. /** Gets or sets the corner radius angle */
  57451. cornerRadius: number;
  57452. /**
  57453. * Creates a new Rectangle
  57454. * @param name defines the control name
  57455. */
  57456. constructor(name?: string | undefined);
  57457. protected _getTypeName(): string;
  57458. protected _localDraw(context: CanvasRenderingContext2D): void;
  57459. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57460. private _drawRoundedRect;
  57461. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57462. }
  57463. }
  57464. declare module BABYLON.GUI {
  57465. /**
  57466. * Enum that determines the text-wrapping mode to use.
  57467. */
  57468. export enum TextWrapping {
  57469. /**
  57470. * Clip the text when it's larger than Control.width; this is the default mode.
  57471. */
  57472. Clip = 0,
  57473. /**
  57474. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57475. */
  57476. WordWrap = 1,
  57477. /**
  57478. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57479. */
  57480. Ellipsis = 2
  57481. }
  57482. /**
  57483. * Class used to create text block control
  57484. */
  57485. export class TextBlock extends Control {
  57486. /**
  57487. * Defines the name of the control
  57488. */
  57489. name?: string | undefined;
  57490. private _text;
  57491. private _textWrapping;
  57492. private _textHorizontalAlignment;
  57493. private _textVerticalAlignment;
  57494. private _lines;
  57495. private _resizeToFit;
  57496. private _lineSpacing;
  57497. private _outlineWidth;
  57498. private _outlineColor;
  57499. /**
  57500. * An event triggered after the text is changed
  57501. */
  57502. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57503. /**
  57504. * An event triggered after the text was broken up into lines
  57505. */
  57506. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57507. /**
  57508. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57509. */
  57510. readonly lines: any[];
  57511. /**
  57512. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57513. */
  57514. /**
  57515. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57516. */
  57517. resizeToFit: boolean;
  57518. /**
  57519. * Gets or sets a boolean indicating if text must be wrapped
  57520. */
  57521. /**
  57522. * Gets or sets a boolean indicating if text must be wrapped
  57523. */
  57524. textWrapping: TextWrapping | boolean;
  57525. /**
  57526. * Gets or sets text to display
  57527. */
  57528. /**
  57529. * Gets or sets text to display
  57530. */
  57531. text: string;
  57532. /**
  57533. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57534. */
  57535. /**
  57536. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57537. */
  57538. textHorizontalAlignment: number;
  57539. /**
  57540. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57541. */
  57542. /**
  57543. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57544. */
  57545. textVerticalAlignment: number;
  57546. /**
  57547. * Gets or sets line spacing value
  57548. */
  57549. /**
  57550. * Gets or sets line spacing value
  57551. */
  57552. lineSpacing: string | number;
  57553. /**
  57554. * Gets or sets outlineWidth of the text to display
  57555. */
  57556. /**
  57557. * Gets or sets outlineWidth of the text to display
  57558. */
  57559. outlineWidth: number;
  57560. /**
  57561. * Gets or sets outlineColor of the text to display
  57562. */
  57563. /**
  57564. * Gets or sets outlineColor of the text to display
  57565. */
  57566. outlineColor: string;
  57567. /**
  57568. * Creates a new TextBlock object
  57569. * @param name defines the name of the control
  57570. * @param text defines the text to display (emptry string by default)
  57571. */
  57572. constructor(
  57573. /**
  57574. * Defines the name of the control
  57575. */
  57576. name?: string | undefined, text?: string);
  57577. protected _getTypeName(): string;
  57578. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57579. private _drawText;
  57580. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57581. protected _applyStates(context: CanvasRenderingContext2D): void;
  57582. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57583. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57584. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57585. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57586. protected _renderLines(context: CanvasRenderingContext2D): void;
  57587. /**
  57588. * Given a width constraint applied on the text block, find the expected height
  57589. * @returns expected height
  57590. */
  57591. computeExpectedHeight(): number;
  57592. dispose(): void;
  57593. }
  57594. }
  57595. declare module BABYLON.GUI {
  57596. /**
  57597. * Class used to create 2D images
  57598. */
  57599. export class Image extends Control {
  57600. name?: string | undefined;
  57601. private static _WorkingCanvas;
  57602. private _domImage;
  57603. private _imageWidth;
  57604. private _imageHeight;
  57605. private _loaded;
  57606. private _stretch;
  57607. private _source;
  57608. private _autoScale;
  57609. private _sourceLeft;
  57610. private _sourceTop;
  57611. private _sourceWidth;
  57612. private _sourceHeight;
  57613. private _cellWidth;
  57614. private _cellHeight;
  57615. private _cellId;
  57616. private _populateNinePatchSlicesFromImage;
  57617. private _sliceLeft;
  57618. private _sliceRight;
  57619. private _sliceTop;
  57620. private _sliceBottom;
  57621. private _detectPointerOnOpaqueOnly;
  57622. /**
  57623. * BABYLON.Observable notified when the content is loaded
  57624. */
  57625. onImageLoadedObservable: BABYLON.Observable<Image>;
  57626. /**
  57627. * Gets a boolean indicating that the content is loaded
  57628. */
  57629. readonly isLoaded: boolean;
  57630. /**
  57631. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57632. */
  57633. populateNinePatchSlicesFromImage: boolean;
  57634. /**
  57635. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57636. * Beware using this as this will comsume more memory as the image has to be stored twice
  57637. */
  57638. detectPointerOnOpaqueOnly: boolean;
  57639. /**
  57640. * Gets or sets the left value for slicing (9-patch)
  57641. */
  57642. sliceLeft: number;
  57643. /**
  57644. * Gets or sets the right value for slicing (9-patch)
  57645. */
  57646. sliceRight: number;
  57647. /**
  57648. * Gets or sets the top value for slicing (9-patch)
  57649. */
  57650. sliceTop: number;
  57651. /**
  57652. * Gets or sets the bottom value for slicing (9-patch)
  57653. */
  57654. sliceBottom: number;
  57655. /**
  57656. * Gets or sets the left coordinate in the source image
  57657. */
  57658. sourceLeft: number;
  57659. /**
  57660. * Gets or sets the top coordinate in the source image
  57661. */
  57662. sourceTop: number;
  57663. /**
  57664. * Gets or sets the width to capture in the source image
  57665. */
  57666. sourceWidth: number;
  57667. /**
  57668. * Gets or sets the height to capture in the source image
  57669. */
  57670. sourceHeight: number;
  57671. /**
  57672. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57673. * @see http://doc.babylonjs.com/how_to/gui#image
  57674. */
  57675. autoScale: boolean;
  57676. /** Gets or sets the streching mode used by the image */
  57677. stretch: number;
  57678. /**
  57679. * Gets or sets the internal DOM image used to render the control
  57680. */
  57681. domImage: HTMLImageElement;
  57682. private _onImageLoaded;
  57683. private _extractNinePatchSliceDataFromImage;
  57684. /**
  57685. * Gets or sets image source url
  57686. */
  57687. source: BABYLON.Nullable<string>;
  57688. /**
  57689. * Gets or sets the cell width to use when animation sheet is enabled
  57690. * @see http://doc.babylonjs.com/how_to/gui#image
  57691. */
  57692. cellWidth: number;
  57693. /**
  57694. * Gets or sets the cell height to use when animation sheet is enabled
  57695. * @see http://doc.babylonjs.com/how_to/gui#image
  57696. */
  57697. cellHeight: number;
  57698. /**
  57699. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57700. * @see http://doc.babylonjs.com/how_to/gui#image
  57701. */
  57702. cellId: number;
  57703. /**
  57704. * Creates a new Image
  57705. * @param name defines the control name
  57706. * @param url defines the image url
  57707. */
  57708. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57709. /**
  57710. * Tests if a given coordinates belong to the current control
  57711. * @param x defines x coordinate to test
  57712. * @param y defines y coordinate to test
  57713. * @returns true if the coordinates are inside the control
  57714. */
  57715. contains(x: number, y: number): boolean;
  57716. protected _getTypeName(): string;
  57717. /** Force the control to synchronize with its content */
  57718. synchronizeSizeWithContent(): void;
  57719. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57720. private _prepareWorkingCanvasForOpaqueDetection;
  57721. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57722. private _renderCornerPatch;
  57723. private _renderNinePatch;
  57724. dispose(): void;
  57725. /** STRETCH_NONE */
  57726. static readonly STRETCH_NONE: number;
  57727. /** STRETCH_FILL */
  57728. static readonly STRETCH_FILL: number;
  57729. /** STRETCH_UNIFORM */
  57730. static readonly STRETCH_UNIFORM: number;
  57731. /** STRETCH_EXTEND */
  57732. static readonly STRETCH_EXTEND: number;
  57733. /** NINE_PATCH */
  57734. static readonly STRETCH_NINE_PATCH: number;
  57735. }
  57736. }
  57737. declare module BABYLON.GUI {
  57738. /**
  57739. * Class used to create 2D buttons
  57740. */
  57741. export class Button extends Rectangle {
  57742. name?: string | undefined;
  57743. /**
  57744. * Function called to generate a pointer enter animation
  57745. */
  57746. pointerEnterAnimation: () => void;
  57747. /**
  57748. * Function called to generate a pointer out animation
  57749. */
  57750. pointerOutAnimation: () => void;
  57751. /**
  57752. * Function called to generate a pointer down animation
  57753. */
  57754. pointerDownAnimation: () => void;
  57755. /**
  57756. * Function called to generate a pointer up animation
  57757. */
  57758. pointerUpAnimation: () => void;
  57759. private _image;
  57760. /**
  57761. * Returns the image part of the button (if any)
  57762. */
  57763. readonly image: BABYLON.Nullable<Image>;
  57764. private _textBlock;
  57765. /**
  57766. * Returns the image part of the button (if any)
  57767. */
  57768. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57769. /**
  57770. * Creates a new Button
  57771. * @param name defines the name of the button
  57772. */
  57773. constructor(name?: string | undefined);
  57774. protected _getTypeName(): string;
  57775. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57776. /** @hidden */ onPointerEnter(target: Control): boolean;
  57777. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57778. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57779. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57780. /**
  57781. * Creates a new button made with an image and a text
  57782. * @param name defines the name of the button
  57783. * @param text defines the text of the button
  57784. * @param imageUrl defines the url of the image
  57785. * @returns a new Button
  57786. */
  57787. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57788. /**
  57789. * Creates a new button made with an image
  57790. * @param name defines the name of the button
  57791. * @param imageUrl defines the url of the image
  57792. * @returns a new Button
  57793. */
  57794. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57795. /**
  57796. * Creates a new button made with a text
  57797. * @param name defines the name of the button
  57798. * @param text defines the text of the button
  57799. * @returns a new Button
  57800. */
  57801. static CreateSimpleButton(name: string, text: string): Button;
  57802. /**
  57803. * Creates a new button made with an image and a centered text
  57804. * @param name defines the name of the button
  57805. * @param text defines the text of the button
  57806. * @param imageUrl defines the url of the image
  57807. * @returns a new Button
  57808. */
  57809. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57810. }
  57811. }
  57812. declare module BABYLON.GUI {
  57813. /**
  57814. * Class used to create a 2D stack panel container
  57815. */
  57816. export class StackPanel extends Container {
  57817. name?: string | undefined;
  57818. private _isVertical;
  57819. private _manualWidth;
  57820. private _manualHeight;
  57821. private _doNotTrackManualChanges;
  57822. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57823. isVertical: boolean;
  57824. /**
  57825. * Gets or sets panel width.
  57826. * This value should not be set when in horizontal mode as it will be computed automatically
  57827. */
  57828. width: string | number;
  57829. /**
  57830. * Gets or sets panel height.
  57831. * This value should not be set when in vertical mode as it will be computed automatically
  57832. */
  57833. height: string | number;
  57834. /**
  57835. * Creates a new StackPanel
  57836. * @param name defines control name
  57837. */
  57838. constructor(name?: string | undefined);
  57839. protected _getTypeName(): string;
  57840. /** @hidden */
  57841. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57842. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57843. protected _postMeasure(): void;
  57844. }
  57845. }
  57846. declare module BABYLON.GUI {
  57847. /**
  57848. * Class used to represent a 2D checkbox
  57849. */
  57850. export class Checkbox extends Control {
  57851. name?: string | undefined;
  57852. private _isChecked;
  57853. private _background;
  57854. private _checkSizeRatio;
  57855. private _thickness;
  57856. /** Gets or sets border thickness */
  57857. thickness: number;
  57858. /**
  57859. * BABYLON.Observable raised when isChecked property changes
  57860. */
  57861. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57862. /** Gets or sets a value indicating the ratio between overall size and check size */
  57863. checkSizeRatio: number;
  57864. /** Gets or sets background color */
  57865. background: string;
  57866. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57867. isChecked: boolean;
  57868. /**
  57869. * Creates a new CheckBox
  57870. * @param name defines the control name
  57871. */
  57872. constructor(name?: string | undefined);
  57873. protected _getTypeName(): string;
  57874. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57875. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57876. /**
  57877. * Utility function to easily create a checkbox with a header
  57878. * @param title defines the label to use for the header
  57879. * @param onValueChanged defines the callback to call when value changes
  57880. * @returns a StackPanel containing the checkbox and a textBlock
  57881. */
  57882. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57883. }
  57884. }
  57885. declare module BABYLON.GUI {
  57886. /**
  57887. * Class used to store key control properties
  57888. */
  57889. export class KeyPropertySet {
  57890. /** Width */
  57891. width?: string;
  57892. /** Height */
  57893. height?: string;
  57894. /** Left padding */
  57895. paddingLeft?: string;
  57896. /** Right padding */
  57897. paddingRight?: string;
  57898. /** Top padding */
  57899. paddingTop?: string;
  57900. /** Bottom padding */
  57901. paddingBottom?: string;
  57902. /** Foreground color */
  57903. color?: string;
  57904. /** Background color */
  57905. background?: string;
  57906. }
  57907. /**
  57908. * Class used to create virtual keyboard
  57909. */
  57910. export class VirtualKeyboard extends StackPanel {
  57911. /** BABYLON.Observable raised when a key is pressed */
  57912. onKeyPressObservable: BABYLON.Observable<string>;
  57913. /** Gets or sets default key button width */
  57914. defaultButtonWidth: string;
  57915. /** Gets or sets default key button height */
  57916. defaultButtonHeight: string;
  57917. /** Gets or sets default key button left padding */
  57918. defaultButtonPaddingLeft: string;
  57919. /** Gets or sets default key button right padding */
  57920. defaultButtonPaddingRight: string;
  57921. /** Gets or sets default key button top padding */
  57922. defaultButtonPaddingTop: string;
  57923. /** Gets or sets default key button bottom padding */
  57924. defaultButtonPaddingBottom: string;
  57925. /** Gets or sets default key button foreground color */
  57926. defaultButtonColor: string;
  57927. /** Gets or sets default key button background color */
  57928. defaultButtonBackground: string;
  57929. /** Gets or sets shift button foreground color */
  57930. shiftButtonColor: string;
  57931. /** Gets or sets shift button thickness*/
  57932. selectedShiftThickness: number;
  57933. /** Gets shift key state */
  57934. shiftState: number;
  57935. protected _getTypeName(): string;
  57936. private _createKey;
  57937. /**
  57938. * Adds a new row of keys
  57939. * @param keys defines the list of keys to add
  57940. * @param propertySets defines the associated property sets
  57941. */
  57942. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57943. /**
  57944. * Set the shift key to a specific state
  57945. * @param shiftState defines the new shift state
  57946. */
  57947. applyShiftState(shiftState: number): void;
  57948. private _currentlyConnectedInputText;
  57949. private _connectedInputTexts;
  57950. private _onKeyPressObserver;
  57951. /** Gets the input text control currently attached to the keyboard */
  57952. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57953. /**
  57954. * Connects the keyboard with an input text control
  57955. *
  57956. * @param input defines the target control
  57957. */
  57958. connect(input: InputText): void;
  57959. /**
  57960. * Disconnects the keyboard from connected InputText controls
  57961. *
  57962. * @param input optionally defines a target control, otherwise all are disconnected
  57963. */
  57964. disconnect(input?: InputText): void;
  57965. private _removeConnectedInputObservables;
  57966. /**
  57967. * Release all resources
  57968. */
  57969. dispose(): void;
  57970. /**
  57971. * Creates a new keyboard using a default layout
  57972. *
  57973. * @param name defines control name
  57974. * @returns a new VirtualKeyboard
  57975. */
  57976. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57977. }
  57978. }
  57979. declare module BABYLON.GUI {
  57980. /**
  57981. * Class used to create input text control
  57982. */
  57983. export class InputText extends Control implements IFocusableControl {
  57984. name?: string | undefined;
  57985. private _text;
  57986. private _placeholderText;
  57987. private _background;
  57988. private _focusedBackground;
  57989. private _focusedColor;
  57990. private _placeholderColor;
  57991. private _thickness;
  57992. private _margin;
  57993. private _autoStretchWidth;
  57994. private _maxWidth;
  57995. private _isFocused;
  57996. private _blinkTimeout;
  57997. private _blinkIsEven;
  57998. private _cursorOffset;
  57999. private _scrollLeft;
  58000. private _textWidth;
  58001. private _clickedCoordinate;
  58002. private _deadKey;
  58003. private _addKey;
  58004. private _currentKey;
  58005. private _isTextHighlightOn;
  58006. private _textHighlightColor;
  58007. private _highligherOpacity;
  58008. private _highlightedText;
  58009. private _startHighlightIndex;
  58010. private _endHighlightIndex;
  58011. private _cursorIndex;
  58012. private _onFocusSelectAll;
  58013. private _isPointerDown;
  58014. private _onClipboardObserver;
  58015. private _onPointerDblTapObserver;
  58016. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  58017. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  58018. promptMessage: string;
  58019. /** BABYLON.Observable raised when the text changes */
  58020. onTextChangedObservable: BABYLON.Observable<InputText>;
  58021. /** BABYLON.Observable raised just before an entered character is to be added */
  58022. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  58023. /** BABYLON.Observable raised when the control gets the focus */
  58024. onFocusObservable: BABYLON.Observable<InputText>;
  58025. /** BABYLON.Observable raised when the control loses the focus */
  58026. onBlurObservable: BABYLON.Observable<InputText>;
  58027. /**Observable raised when the text is highlighted */
  58028. onTextHighlightObservable: BABYLON.Observable<InputText>;
  58029. /**Observable raised when copy event is triggered */
  58030. onTextCopyObservable: BABYLON.Observable<InputText>;
  58031. /** BABYLON.Observable raised when cut event is triggered */
  58032. onTextCutObservable: BABYLON.Observable<InputText>;
  58033. /** BABYLON.Observable raised when paste event is triggered */
  58034. onTextPasteObservable: BABYLON.Observable<InputText>;
  58035. /** BABYLON.Observable raised when a key event was processed */
  58036. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  58037. /** Gets or sets the maximum width allowed by the control */
  58038. maxWidth: string | number;
  58039. /** Gets the maximum width allowed by the control in pixels */
  58040. readonly maxWidthInPixels: number;
  58041. /** Gets or sets the text highlighter transparency; default: 0.4 */
  58042. highligherOpacity: number;
  58043. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  58044. onFocusSelectAll: boolean;
  58045. /** Gets or sets the text hightlight color */
  58046. textHighlightColor: string;
  58047. /** Gets or sets control margin */
  58048. margin: string;
  58049. /** Gets control margin in pixels */
  58050. readonly marginInPixels: number;
  58051. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  58052. autoStretchWidth: boolean;
  58053. /** Gets or sets border thickness */
  58054. thickness: number;
  58055. /** Gets or sets the background color when focused */
  58056. focusedBackground: string;
  58057. /** Gets or sets the background color when focused */
  58058. focusedColor: string;
  58059. /** Gets or sets the background color */
  58060. background: string;
  58061. /** Gets or sets the placeholder color */
  58062. placeholderColor: string;
  58063. /** Gets or sets the text displayed when the control is empty */
  58064. placeholderText: string;
  58065. /** Gets or sets the dead key flag */
  58066. deadKey: boolean;
  58067. /** Gets or sets the highlight text */
  58068. highlightedText: string;
  58069. /** Gets or sets if the current key should be added */
  58070. addKey: boolean;
  58071. /** Gets or sets the value of the current key being entered */
  58072. currentKey: string;
  58073. /** Gets or sets the text displayed in the control */
  58074. text: string;
  58075. /** Gets or sets control width */
  58076. width: string | number;
  58077. /**
  58078. * Creates a new InputText
  58079. * @param name defines the control name
  58080. * @param text defines the text of the control
  58081. */
  58082. constructor(name?: string | undefined, text?: string);
  58083. /** @hidden */
  58084. onBlur(): void;
  58085. /** @hidden */
  58086. onFocus(): void;
  58087. protected _getTypeName(): string;
  58088. /**
  58089. * Function called to get the list of controls that should not steal the focus from this control
  58090. * @returns an array of controls
  58091. */
  58092. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  58093. /** @hidden */
  58094. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  58095. /** @hidden */
  58096. private _updateValueFromCursorIndex;
  58097. /** @hidden */
  58098. private _processDblClick;
  58099. /** @hidden */
  58100. private _selectAllText;
  58101. /**
  58102. * Handles the keyboard event
  58103. * @param evt Defines the KeyboardEvent
  58104. */
  58105. processKeyboard(evt: KeyboardEvent): void;
  58106. /** @hidden */
  58107. private _onCopyText;
  58108. /** @hidden */
  58109. private _onCutText;
  58110. /** @hidden */
  58111. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58112. protected _beforeRenderText(text: string): string;
  58113. dispose(): void;
  58114. }
  58115. }
  58116. declare module BABYLON.GUI {
  58117. /**
  58118. * Class used to create a 2D grid container
  58119. */
  58120. export class Grid extends Container {
  58121. name?: string | undefined;
  58122. private _rowDefinitions;
  58123. private _columnDefinitions;
  58124. private _cells;
  58125. private _childControls;
  58126. /**
  58127. * Gets the number of columns
  58128. */
  58129. readonly columnCount: number;
  58130. /**
  58131. * Gets the number of rows
  58132. */
  58133. readonly rowCount: number;
  58134. /** Gets the list of children */
  58135. readonly children: Control[];
  58136. /**
  58137. * Gets the definition of a specific row
  58138. * @param index defines the index of the row
  58139. * @returns the row definition
  58140. */
  58141. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58142. /**
  58143. * Gets the definition of a specific column
  58144. * @param index defines the index of the column
  58145. * @returns the column definition
  58146. */
  58147. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58148. /**
  58149. * Adds a new row to the grid
  58150. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58151. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  58152. * @returns the current grid
  58153. */
  58154. addRowDefinition(height: number, isPixel?: boolean): Grid;
  58155. /**
  58156. * Adds a new column to the grid
  58157. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58158. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58159. * @returns the current grid
  58160. */
  58161. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  58162. /**
  58163. * Update a row definition
  58164. * @param index defines the index of the row to update
  58165. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58166. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  58167. * @returns the current grid
  58168. */
  58169. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  58170. /**
  58171. * Update a column definition
  58172. * @param index defines the index of the column to update
  58173. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58174. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58175. * @returns the current grid
  58176. */
  58177. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  58178. /**
  58179. * Gets the list of children stored in a specific cell
  58180. * @param row defines the row to check
  58181. * @param column defines the column to check
  58182. * @returns the list of controls
  58183. */
  58184. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  58185. /**
  58186. * Gets a string representing the child cell info (row x column)
  58187. * @param child defines the control to get info from
  58188. * @returns a string containing the child cell info (row x column)
  58189. */
  58190. getChildCellInfo(child: Control): string;
  58191. private _removeCell;
  58192. private _offsetCell;
  58193. /**
  58194. * Remove a column definition at specified index
  58195. * @param index defines the index of the column to remove
  58196. * @returns the current grid
  58197. */
  58198. removeColumnDefinition(index: number): Grid;
  58199. /**
  58200. * Remove a row definition at specified index
  58201. * @param index defines the index of the row to remove
  58202. * @returns the current grid
  58203. */
  58204. removeRowDefinition(index: number): Grid;
  58205. /**
  58206. * Adds a new control to the current grid
  58207. * @param control defines the control to add
  58208. * @param row defines the row where to add the control (0 by default)
  58209. * @param column defines the column where to add the control (0 by default)
  58210. * @returns the current grid
  58211. */
  58212. addControl(control: Control, row?: number, column?: number): Grid;
  58213. /**
  58214. * Removes a control from the current container
  58215. * @param control defines the control to remove
  58216. * @returns the current container
  58217. */
  58218. removeControl(control: Control): Container;
  58219. /**
  58220. * Creates a new Grid
  58221. * @param name defines control name
  58222. */
  58223. constructor(name?: string | undefined);
  58224. protected _getTypeName(): string;
  58225. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  58226. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58227. /** Releases associated resources */
  58228. dispose(): void;
  58229. }
  58230. }
  58231. declare module BABYLON.GUI {
  58232. /** Class used to create color pickers */
  58233. export class ColorPicker extends Control {
  58234. name?: string | undefined;
  58235. private static _Epsilon;
  58236. private _colorWheelCanvas;
  58237. private _value;
  58238. private _tmpColor;
  58239. private _pointerStartedOnSquare;
  58240. private _pointerStartedOnWheel;
  58241. private _squareLeft;
  58242. private _squareTop;
  58243. private _squareSize;
  58244. private _h;
  58245. private _s;
  58246. private _v;
  58247. private _lastPointerDownID;
  58248. /**
  58249. * BABYLON.Observable raised when the value changes
  58250. */
  58251. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  58252. /** Gets or sets the color of the color picker */
  58253. value: BABYLON.Color3;
  58254. /**
  58255. * Gets or sets control width
  58256. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58257. */
  58258. width: string | number;
  58259. /**
  58260. * Gets or sets control height
  58261. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58262. */
  58263. /** Gets or sets control height */
  58264. height: string | number;
  58265. /** Gets or sets control size */
  58266. size: string | number;
  58267. /**
  58268. * Creates a new ColorPicker
  58269. * @param name defines the control name
  58270. */
  58271. constructor(name?: string | undefined);
  58272. protected _getTypeName(): string;
  58273. /** @hidden */
  58274. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58275. private _updateSquareProps;
  58276. private _drawGradientSquare;
  58277. private _drawCircle;
  58278. private _createColorWheelCanvas;
  58279. private _RGBtoHSV;
  58280. private _HSVtoRGB;
  58281. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  58282. private _pointerIsDown;
  58283. private _updateValueFromPointer;
  58284. private _isPointOnSquare;
  58285. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58286. /**
  58287. * This function expands the color picker by creating a color picker dialog with manual
  58288. * color value input and the ability to save colors into an array to be used later in
  58289. * subsequent launches of the dialogue.
  58290. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  58291. * @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.
  58292. * @returns picked color as a hex string and the saved colors array as hex strings.
  58293. */
  58294. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  58295. pickerWidth?: string;
  58296. pickerHeight?: string;
  58297. headerHeight?: string;
  58298. lastColor?: string;
  58299. swatchLimit?: number;
  58300. numSwatchesPerLine?: number;
  58301. savedColors?: Array<string>;
  58302. }): Promise<{
  58303. savedColors?: string[];
  58304. pickedColor: string;
  58305. }>;
  58306. }
  58307. }
  58308. declare module BABYLON.GUI {
  58309. /** Class used to create 2D ellipse containers */
  58310. export class Ellipse extends Container {
  58311. name?: string | undefined;
  58312. private _thickness;
  58313. /** Gets or sets border thickness */
  58314. thickness: number;
  58315. /**
  58316. * Creates a new Ellipse
  58317. * @param name defines the control name
  58318. */
  58319. constructor(name?: string | undefined);
  58320. protected _getTypeName(): string;
  58321. protected _localDraw(context: CanvasRenderingContext2D): void;
  58322. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58323. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  58324. }
  58325. }
  58326. declare module BABYLON.GUI {
  58327. /**
  58328. * Class used to create a password control
  58329. */
  58330. export class InputPassword extends InputText {
  58331. protected _beforeRenderText(text: string): string;
  58332. }
  58333. }
  58334. declare module BABYLON.GUI {
  58335. /** Class used to render 2D lines */
  58336. export class Line extends Control {
  58337. name?: string | undefined;
  58338. private _lineWidth;
  58339. private _x1;
  58340. private _y1;
  58341. private _x2;
  58342. private _y2;
  58343. private _dash;
  58344. private _connectedControl;
  58345. private _connectedControlDirtyObserver;
  58346. /** Gets or sets the dash pattern */
  58347. dash: Array<number>;
  58348. /** Gets or sets the control connected with the line end */
  58349. connectedControl: Control;
  58350. /** Gets or sets start coordinates on X axis */
  58351. x1: string | number;
  58352. /** Gets or sets start coordinates on Y axis */
  58353. y1: string | number;
  58354. /** Gets or sets end coordinates on X axis */
  58355. x2: string | number;
  58356. /** Gets or sets end coordinates on Y axis */
  58357. y2: string | number;
  58358. /** Gets or sets line width */
  58359. lineWidth: number;
  58360. /** Gets or sets horizontal alignment */
  58361. horizontalAlignment: number;
  58362. /** Gets or sets vertical alignment */
  58363. verticalAlignment: number;
  58364. private readonly _effectiveX2;
  58365. private readonly _effectiveY2;
  58366. /**
  58367. * Creates a new Line
  58368. * @param name defines the control name
  58369. */
  58370. constructor(name?: string | undefined);
  58371. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58372. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58373. /**
  58374. * Move one end of the line given 3D cartesian coordinates.
  58375. * @param position Targeted world position
  58376. * @param scene BABYLON.Scene
  58377. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58378. */
  58379. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58380. /**
  58381. * Move one end of the line to a position in screen absolute space.
  58382. * @param projectedPosition Position in screen absolute space (X, Y)
  58383. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58384. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58385. }
  58386. }
  58387. declare module BABYLON.GUI {
  58388. /**
  58389. * Class used to store a point for a MultiLine object.
  58390. * The point can be pure 2D coordinates, a mesh or a control
  58391. */
  58392. export class MultiLinePoint {
  58393. private _multiLine;
  58394. private _x;
  58395. private _y;
  58396. private _control;
  58397. private _mesh;
  58398. private _controlObserver;
  58399. private _meshObserver;
  58400. /** @hidden */ point: BABYLON.Vector2;
  58401. /**
  58402. * Creates a new MultiLinePoint
  58403. * @param multiLine defines the source MultiLine object
  58404. */
  58405. constructor(multiLine: MultiLine);
  58406. /** Gets or sets x coordinate */
  58407. x: string | number;
  58408. /** Gets or sets y coordinate */
  58409. y: string | number;
  58410. /** Gets or sets the control associated with this point */
  58411. control: BABYLON.Nullable<Control>;
  58412. /** Gets or sets the mesh associated with this point */
  58413. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58414. /** Resets links */
  58415. resetLinks(): void;
  58416. /**
  58417. * Gets a translation vector
  58418. * @returns the translation vector
  58419. */
  58420. translate(): BABYLON.Vector2;
  58421. private _translatePoint;
  58422. /** Release associated resources */
  58423. dispose(): void;
  58424. }
  58425. }
  58426. declare module BABYLON.GUI {
  58427. /**
  58428. * Class used to create multi line control
  58429. */
  58430. export class MultiLine extends Control {
  58431. name?: string | undefined;
  58432. private _lineWidth;
  58433. private _dash;
  58434. private _points;
  58435. private _minX;
  58436. private _minY;
  58437. private _maxX;
  58438. private _maxY;
  58439. /**
  58440. * Creates a new MultiLine
  58441. * @param name defines the control name
  58442. */
  58443. constructor(name?: string | undefined);
  58444. /** Gets or sets dash pattern */
  58445. dash: Array<number>;
  58446. /**
  58447. * Gets point stored at specified index
  58448. * @param index defines the index to look for
  58449. * @returns the requested point if found
  58450. */
  58451. getAt(index: number): MultiLinePoint;
  58452. /** Function called when a point is updated */
  58453. onPointUpdate: () => void;
  58454. /**
  58455. * Adds new points to the point collection
  58456. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58457. * @returns the list of created MultiLinePoint
  58458. */
  58459. add(...items: (AbstractMesh | Control | {
  58460. x: string | number;
  58461. y: string | number;
  58462. })[]): MultiLinePoint[];
  58463. /**
  58464. * Adds a new point to the point collection
  58465. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58466. * @returns the created MultiLinePoint
  58467. */
  58468. push(item?: (AbstractMesh | Control | {
  58469. x: string | number;
  58470. y: string | number;
  58471. })): MultiLinePoint;
  58472. /**
  58473. * Remove a specific value or point from the active point collection
  58474. * @param value defines the value or point to remove
  58475. */
  58476. remove(value: number | MultiLinePoint): void;
  58477. /**
  58478. * Resets this object to initial state (no point)
  58479. */
  58480. reset(): void;
  58481. /**
  58482. * Resets all links
  58483. */
  58484. resetLinks(): void;
  58485. /** Gets or sets line width */
  58486. lineWidth: number;
  58487. horizontalAlignment: number;
  58488. verticalAlignment: number;
  58489. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58490. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58491. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58492. dispose(): void;
  58493. }
  58494. }
  58495. declare module BABYLON.GUI {
  58496. /**
  58497. * Class used to create radio button controls
  58498. */
  58499. export class RadioButton extends Control {
  58500. name?: string | undefined;
  58501. private _isChecked;
  58502. private _background;
  58503. private _checkSizeRatio;
  58504. private _thickness;
  58505. /** Gets or sets border thickness */
  58506. thickness: number;
  58507. /** Gets or sets group name */
  58508. group: string;
  58509. /** BABYLON.Observable raised when isChecked is changed */
  58510. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58511. /** Gets or sets a value indicating the ratio between overall size and check size */
  58512. checkSizeRatio: number;
  58513. /** Gets or sets background color */
  58514. background: string;
  58515. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58516. isChecked: boolean;
  58517. /**
  58518. * Creates a new RadioButton
  58519. * @param name defines the control name
  58520. */
  58521. constructor(name?: string | undefined);
  58522. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58523. /**
  58524. * Utility function to easily create a radio button with a header
  58525. * @param title defines the label to use for the header
  58526. * @param group defines the group to use for the radio button
  58527. * @param isChecked defines the initial state of the radio button
  58528. * @param onValueChanged defines the callback to call when value changes
  58529. * @returns a StackPanel containing the radio button and a textBlock
  58530. */
  58531. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58532. }
  58533. }
  58534. declare module BABYLON.GUI {
  58535. /**
  58536. * Class used to create slider controls
  58537. */
  58538. export class BaseSlider extends Control {
  58539. name?: string | undefined;
  58540. protected _thumbWidth: ValueAndUnit;
  58541. private _minimum;
  58542. private _maximum;
  58543. private _value;
  58544. private _isVertical;
  58545. protected _barOffset: ValueAndUnit;
  58546. private _isThumbClamped;
  58547. protected _displayThumb: boolean;
  58548. private _step;
  58549. private _lastPointerDownID;
  58550. protected _effectiveBarOffset: number;
  58551. protected _renderLeft: number;
  58552. protected _renderTop: number;
  58553. protected _renderWidth: number;
  58554. protected _renderHeight: number;
  58555. protected _backgroundBoxLength: number;
  58556. protected _backgroundBoxThickness: number;
  58557. protected _effectiveThumbThickness: number;
  58558. /** BABYLON.Observable raised when the sldier value changes */
  58559. onValueChangedObservable: BABYLON.Observable<number>;
  58560. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58561. displayThumb: boolean;
  58562. /** Gets or sets a step to apply to values (0 by default) */
  58563. step: number;
  58564. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58565. barOffset: string | number;
  58566. /** Gets main bar offset in pixels*/
  58567. readonly barOffsetInPixels: number;
  58568. /** Gets or sets thumb width */
  58569. thumbWidth: string | number;
  58570. /** Gets thumb width in pixels */
  58571. readonly thumbWidthInPixels: number;
  58572. /** Gets or sets minimum value */
  58573. minimum: number;
  58574. /** Gets or sets maximum value */
  58575. maximum: number;
  58576. /** Gets or sets current value */
  58577. value: number;
  58578. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58579. isVertical: boolean;
  58580. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58581. isThumbClamped: boolean;
  58582. /**
  58583. * Creates a new BaseSlider
  58584. * @param name defines the control name
  58585. */
  58586. constructor(name?: string | undefined);
  58587. protected _getTypeName(): string;
  58588. protected _getThumbPosition(): number;
  58589. protected _getThumbThickness(type: string): number;
  58590. protected _prepareRenderingData(type: string): void;
  58591. private _pointerIsDown;
  58592. /** @hidden */
  58593. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58594. }
  58595. }
  58596. declare module BABYLON.GUI {
  58597. /**
  58598. * Class used to create slider controls
  58599. */
  58600. export class Slider extends BaseSlider {
  58601. name?: string | undefined;
  58602. private _background;
  58603. private _borderColor;
  58604. private _isThumbCircle;
  58605. protected _displayValueBar: boolean;
  58606. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58607. displayValueBar: boolean;
  58608. /** Gets or sets border color */
  58609. borderColor: string;
  58610. /** Gets or sets background color */
  58611. background: string;
  58612. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58613. isThumbCircle: boolean;
  58614. /**
  58615. * Creates a new Slider
  58616. * @param name defines the control name
  58617. */
  58618. constructor(name?: string | undefined);
  58619. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58620. }
  58621. }
  58622. declare module BABYLON.GUI {
  58623. /** Class used to create a RadioGroup
  58624. * which contains groups of radio buttons
  58625. */
  58626. export class SelectorGroup {
  58627. /** name of SelectorGroup */
  58628. name: string;
  58629. private _groupPanel;
  58630. private _selectors;
  58631. private _groupHeader;
  58632. /**
  58633. * Creates a new SelectorGroup
  58634. * @param name of group, used as a group heading
  58635. */
  58636. constructor(
  58637. /** name of SelectorGroup */
  58638. name: string);
  58639. /** Gets the groupPanel of the SelectorGroup */
  58640. readonly groupPanel: StackPanel;
  58641. /** Gets the selectors array */
  58642. readonly selectors: StackPanel[];
  58643. /** Gets and sets the group header */
  58644. header: string;
  58645. /** @hidden */
  58646. private _addGroupHeader;
  58647. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58648. /** Removes the selector at the given position
  58649. * @param selectorNb the position of the selector within the group
  58650. */
  58651. removeSelector(selectorNb: number): void;
  58652. }
  58653. /** Class used to create a CheckboxGroup
  58654. * which contains groups of checkbox buttons
  58655. */
  58656. export class CheckboxGroup extends SelectorGroup {
  58657. /** Adds a checkbox as a control
  58658. * @param text is the label for the selector
  58659. * @param func is the function called when the Selector is checked
  58660. * @param checked is true when Selector is checked
  58661. */
  58662. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58663. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58664. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58665. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58666. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58667. }
  58668. /** Class used to create a RadioGroup
  58669. * which contains groups of radio buttons
  58670. */
  58671. export class RadioGroup extends SelectorGroup {
  58672. private _selectNb;
  58673. /** Adds a radio button as a control
  58674. * @param label is the label for the selector
  58675. * @param func is the function called when the Selector is checked
  58676. * @param checked is true when Selector is checked
  58677. */
  58678. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58679. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58680. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58681. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58682. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58683. }
  58684. /** Class used to create a SliderGroup
  58685. * which contains groups of slider buttons
  58686. */
  58687. export class SliderGroup extends SelectorGroup {
  58688. /**
  58689. * Adds a slider to the SelectorGroup
  58690. * @param label is the label for the SliderBar
  58691. * @param func is the function called when the Slider moves
  58692. * @param unit is a string describing the units used, eg degrees or metres
  58693. * @param min is the minimum value for the Slider
  58694. * @param max is the maximum value for the Slider
  58695. * @param value is the start value for the Slider between min and max
  58696. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58697. */
  58698. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58699. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58700. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58701. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58702. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58703. }
  58704. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58705. * @see http://doc.babylonjs.com/how_to/selector
  58706. */
  58707. export class SelectionPanel extends Rectangle {
  58708. /** name of SelectionPanel */
  58709. name: string;
  58710. /** an array of SelectionGroups */
  58711. groups: SelectorGroup[];
  58712. private _panel;
  58713. private _buttonColor;
  58714. private _buttonBackground;
  58715. private _headerColor;
  58716. private _barColor;
  58717. private _barHeight;
  58718. private _spacerHeight;
  58719. private _labelColor;
  58720. private _groups;
  58721. private _bars;
  58722. /**
  58723. * Creates a new SelectionPanel
  58724. * @param name of SelectionPanel
  58725. * @param groups is an array of SelectionGroups
  58726. */
  58727. constructor(
  58728. /** name of SelectionPanel */
  58729. name: string,
  58730. /** an array of SelectionGroups */
  58731. groups?: SelectorGroup[]);
  58732. protected _getTypeName(): string;
  58733. /** Gets or sets the headerColor */
  58734. headerColor: string;
  58735. private _setHeaderColor;
  58736. /** Gets or sets the button color */
  58737. buttonColor: string;
  58738. private _setbuttonColor;
  58739. /** Gets or sets the label color */
  58740. labelColor: string;
  58741. private _setLabelColor;
  58742. /** Gets or sets the button background */
  58743. buttonBackground: string;
  58744. private _setButtonBackground;
  58745. /** Gets or sets the color of separator bar */
  58746. barColor: string;
  58747. private _setBarColor;
  58748. /** Gets or sets the height of separator bar */
  58749. barHeight: string;
  58750. private _setBarHeight;
  58751. /** Gets or sets the height of spacers*/
  58752. spacerHeight: string;
  58753. private _setSpacerHeight;
  58754. /** Adds a bar between groups */
  58755. private _addSpacer;
  58756. /** Add a group to the selection panel
  58757. * @param group is the selector group to add
  58758. */
  58759. addGroup(group: SelectorGroup): void;
  58760. /** Remove the group from the given position
  58761. * @param groupNb is the position of the group in the list
  58762. */
  58763. removeGroup(groupNb: number): void;
  58764. /** Change a group header label
  58765. * @param label is the new group header label
  58766. * @param groupNb is the number of the group to relabel
  58767. * */
  58768. setHeaderName(label: string, groupNb: number): void;
  58769. /** Change selector label to the one given
  58770. * @param label is the new selector label
  58771. * @param groupNb is the number of the groupcontaining the selector
  58772. * @param selectorNb is the number of the selector within a group to relabel
  58773. * */
  58774. relabel(label: string, groupNb: number, selectorNb: number): void;
  58775. /** For a given group position remove the selector at the given position
  58776. * @param groupNb is the number of the group to remove the selector from
  58777. * @param selectorNb is the number of the selector within the group
  58778. */
  58779. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58780. /** For a given group position of correct type add a checkbox button
  58781. * @param groupNb is the number of the group to remove the selector from
  58782. * @param label is the label for the selector
  58783. * @param func is the function called when the Selector is checked
  58784. * @param checked is true when Selector is checked
  58785. */
  58786. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58787. /** For a given group position of correct type add a radio button
  58788. * @param groupNb is the number of the group to remove the selector from
  58789. * @param label is the label for the selector
  58790. * @param func is the function called when the Selector is checked
  58791. * @param checked is true when Selector is checked
  58792. */
  58793. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58794. /**
  58795. * For a given slider group add a slider
  58796. * @param groupNb is the number of the group to add the slider to
  58797. * @param label is the label for the Slider
  58798. * @param func is the function called when the Slider moves
  58799. * @param unit is a string describing the units used, eg degrees or metres
  58800. * @param min is the minimum value for the Slider
  58801. * @param max is the maximum value for the Slider
  58802. * @param value is the start value for the Slider between min and max
  58803. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58804. */
  58805. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58806. }
  58807. }
  58808. declare module BABYLON.GUI {
  58809. /**
  58810. * Class used to hold a the container for ScrollViewer
  58811. * @hidden
  58812. */
  58813. export class _ScrollViewerWindow extends Container {
  58814. parentClientWidth: number;
  58815. parentClientHeight: number;
  58816. /**
  58817. * Creates a new ScrollViewerWindow
  58818. * @param name of ScrollViewerWindow
  58819. */
  58820. constructor(name?: string);
  58821. protected _getTypeName(): string;
  58822. /** @hidden */
  58823. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58824. protected _postMeasure(): void;
  58825. }
  58826. }
  58827. declare module BABYLON.GUI {
  58828. /**
  58829. * Class used to create slider controls
  58830. */
  58831. export class ScrollBar extends BaseSlider {
  58832. name?: string | undefined;
  58833. private _background;
  58834. private _borderColor;
  58835. private _thumbMeasure;
  58836. /** Gets or sets border color */
  58837. borderColor: string;
  58838. /** Gets or sets background color */
  58839. background: string;
  58840. /**
  58841. * Creates a new Slider
  58842. * @param name defines the control name
  58843. */
  58844. constructor(name?: string | undefined);
  58845. protected _getTypeName(): string;
  58846. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58847. private _first;
  58848. private _originX;
  58849. private _originY;
  58850. /** @hidden */
  58851. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58852. }
  58853. }
  58854. declare module BABYLON.GUI {
  58855. /**
  58856. * Class used to hold a viewer window and sliders in a grid
  58857. */
  58858. export class ScrollViewer extends Rectangle {
  58859. private _grid;
  58860. private _horizontalBarSpace;
  58861. private _verticalBarSpace;
  58862. private _dragSpace;
  58863. private _horizontalBar;
  58864. private _verticalBar;
  58865. private _barColor;
  58866. private _barBackground;
  58867. private _barSize;
  58868. private _endLeft;
  58869. private _endTop;
  58870. private _window;
  58871. private _pointerIsOver;
  58872. private _wheelPrecision;
  58873. private _onPointerObserver;
  58874. private _clientWidth;
  58875. private _clientHeight;
  58876. /**
  58877. * Gets the horizontal scrollbar
  58878. */
  58879. readonly horizontalBar: ScrollBar;
  58880. /**
  58881. * Gets the vertical scrollbar
  58882. */
  58883. readonly verticalBar: ScrollBar;
  58884. /**
  58885. * Adds a new control to the current container
  58886. * @param control defines the control to add
  58887. * @returns the current container
  58888. */
  58889. addControl(control: BABYLON.Nullable<Control>): Container;
  58890. /**
  58891. * Removes a control from the current container
  58892. * @param control defines the control to remove
  58893. * @returns the current container
  58894. */
  58895. removeControl(control: Control): Container;
  58896. /** Gets the list of children */
  58897. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58898. /**
  58899. * Creates a new ScrollViewer
  58900. * @param name of ScrollViewer
  58901. */
  58902. constructor(name?: string);
  58903. /** Reset the scroll viewer window to initial size */
  58904. resetWindow(): void;
  58905. protected _getTypeName(): string;
  58906. private _buildClientSizes;
  58907. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58908. protected _postMeasure(): void;
  58909. /**
  58910. * Gets or sets the mouse wheel precision
  58911. * from 0 to 1 with a default value of 0.05
  58912. * */
  58913. wheelPrecision: number;
  58914. /** Gets or sets the bar color */
  58915. barColor: string;
  58916. /** Gets or sets the size of the bar */
  58917. barSize: number;
  58918. /** Gets or sets the bar background */
  58919. barBackground: string;
  58920. /** @hidden */
  58921. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58922. /** @hidden */
  58923. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58924. /** Releases associated resources */
  58925. dispose(): void;
  58926. }
  58927. }
  58928. declare module BABYLON.GUI {
  58929. /** Class used to render a grid */
  58930. export class DisplayGrid extends Control {
  58931. name?: string | undefined;
  58932. private _cellWidth;
  58933. private _cellHeight;
  58934. private _minorLineTickness;
  58935. private _minorLineColor;
  58936. private _majorLineTickness;
  58937. private _majorLineColor;
  58938. private _majorLineFrequency;
  58939. private _background;
  58940. private _displayMajorLines;
  58941. private _displayMinorLines;
  58942. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58943. displayMinorLines: boolean;
  58944. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58945. displayMajorLines: boolean;
  58946. /** Gets or sets background color (Black by default) */
  58947. background: string;
  58948. /** Gets or sets the width of each cell (20 by default) */
  58949. cellWidth: number;
  58950. /** Gets or sets the height of each cell (20 by default) */
  58951. cellHeight: number;
  58952. /** Gets or sets the tickness of minor lines (1 by default) */
  58953. minorLineTickness: number;
  58954. /** Gets or sets the color of minor lines (DarkGray by default) */
  58955. minorLineColor: string;
  58956. /** Gets or sets the tickness of major lines (2 by default) */
  58957. majorLineTickness: number;
  58958. /** Gets or sets the color of major lines (White by default) */
  58959. majorLineColor: string;
  58960. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58961. majorLineFrequency: number;
  58962. /**
  58963. * Creates a new GridDisplayRectangle
  58964. * @param name defines the control name
  58965. */
  58966. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58967. protected _getTypeName(): string;
  58968. }
  58969. }
  58970. declare module BABYLON.GUI {
  58971. /**
  58972. * Class used to create slider controls based on images
  58973. */
  58974. export class ImageBasedSlider extends BaseSlider {
  58975. name?: string | undefined;
  58976. private _backgroundImage;
  58977. private _thumbImage;
  58978. private _valueBarImage;
  58979. private _tempMeasure;
  58980. displayThumb: boolean;
  58981. /**
  58982. * Gets or sets the image used to render the background
  58983. */
  58984. backgroundImage: Image;
  58985. /**
  58986. * Gets or sets the image used to render the value bar
  58987. */
  58988. valueBarImage: Image;
  58989. /**
  58990. * Gets or sets the image used to render the thumb
  58991. */
  58992. thumbImage: Image;
  58993. /**
  58994. * Creates a new ImageBasedSlider
  58995. * @param name defines the control name
  58996. */
  58997. constructor(name?: string | undefined);
  58998. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58999. }
  59000. }
  59001. declare module BABYLON.GUI {
  59002. /**
  59003. * Forcing an export so that this code will execute
  59004. * @hidden
  59005. */
  59006. const name = "Statics";
  59007. }
  59008. declare module BABYLON.GUI {
  59009. /**
  59010. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  59011. */
  59012. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  59013. /**
  59014. * Define the instrumented AdvancedDynamicTexture.
  59015. */
  59016. texture: AdvancedDynamicTexture;
  59017. private _captureRenderTime;
  59018. private _renderTime;
  59019. private _captureLayoutTime;
  59020. private _layoutTime;
  59021. private _onBeginRenderObserver;
  59022. private _onEndRenderObserver;
  59023. private _onBeginLayoutObserver;
  59024. private _onEndLayoutObserver;
  59025. /**
  59026. * Gets the perf counter used to capture render time
  59027. */
  59028. readonly renderTimeCounter: BABYLON.PerfCounter;
  59029. /**
  59030. * Gets the perf counter used to capture layout time
  59031. */
  59032. readonly layoutTimeCounter: BABYLON.PerfCounter;
  59033. /**
  59034. * Enable or disable the render time capture
  59035. */
  59036. captureRenderTime: boolean;
  59037. /**
  59038. * Enable or disable the layout time capture
  59039. */
  59040. captureLayoutTime: boolean;
  59041. /**
  59042. * Instantiates a new advanced dynamic texture instrumentation.
  59043. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  59044. * @param texture Defines the AdvancedDynamicTexture to instrument
  59045. */
  59046. constructor(
  59047. /**
  59048. * Define the instrumented AdvancedDynamicTexture.
  59049. */
  59050. texture: AdvancedDynamicTexture);
  59051. /**
  59052. * Dispose and release associated resources.
  59053. */
  59054. dispose(): void;
  59055. }
  59056. }
  59057. declare module BABYLON.GUI {
  59058. /**
  59059. * Class used to create containers for controls
  59060. */
  59061. export class Container3D extends Control3D {
  59062. private _blockLayout;
  59063. /**
  59064. * Gets the list of child controls
  59065. */
  59066. protected _children: Control3D[];
  59067. /**
  59068. * Gets the list of child controls
  59069. */
  59070. readonly children: Array<Control3D>;
  59071. /**
  59072. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  59073. * This is helpful to optimize layout operation when adding multiple children in a row
  59074. */
  59075. blockLayout: boolean;
  59076. /**
  59077. * Creates a new container
  59078. * @param name defines the container name
  59079. */
  59080. constructor(name?: string);
  59081. /**
  59082. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  59083. * @returns the current container
  59084. */
  59085. updateLayout(): Container3D;
  59086. /**
  59087. * Gets a boolean indicating if the given control is in the children of this control
  59088. * @param control defines the control to check
  59089. * @returns true if the control is in the child list
  59090. */
  59091. containsControl(control: Control3D): boolean;
  59092. /**
  59093. * Adds a control to the children of this control
  59094. * @param control defines the control to add
  59095. * @returns the current container
  59096. */
  59097. addControl(control: Control3D): Container3D;
  59098. /**
  59099. * This function will be called everytime a new control is added
  59100. */
  59101. protected _arrangeChildren(): void;
  59102. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59103. /**
  59104. * Removes a control from the children of this control
  59105. * @param control defines the control to remove
  59106. * @returns the current container
  59107. */
  59108. removeControl(control: Control3D): Container3D;
  59109. protected _getTypeName(): string;
  59110. /**
  59111. * Releases all associated resources
  59112. */
  59113. dispose(): void;
  59114. /** Control rotation will remain unchanged */
  59115. static readonly UNSET_ORIENTATION: number;
  59116. /** Control will rotate to make it look at sphere central axis */
  59117. static readonly FACEORIGIN_ORIENTATION: number;
  59118. /** Control will rotate to make it look back at sphere central axis */
  59119. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  59120. /** Control will rotate to look at z axis (0, 0, 1) */
  59121. static readonly FACEFORWARD_ORIENTATION: number;
  59122. /** Control will rotate to look at negative z axis (0, 0, -1) */
  59123. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  59124. }
  59125. }
  59126. declare module BABYLON.GUI {
  59127. /**
  59128. * Class used to manage 3D user interface
  59129. * @see http://doc.babylonjs.com/how_to/gui3d
  59130. */
  59131. export class GUI3DManager implements BABYLON.IDisposable {
  59132. private _scene;
  59133. private _sceneDisposeObserver;
  59134. private _utilityLayer;
  59135. private _rootContainer;
  59136. private _pointerObserver;
  59137. private _pointerOutObserver;
  59138. /** @hidden */ lastPickedControl: Control3D;
  59139. /** @hidden */ lastControlOver: {
  59140. [pointerId: number]: Control3D;
  59141. };
  59142. /** @hidden */ lastControlDown: {
  59143. [pointerId: number]: Control3D;
  59144. };
  59145. /**
  59146. * BABYLON.Observable raised when the point picked by the pointer events changed
  59147. */
  59148. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  59149. /** @hidden */ sharedMaterials: {
  59150. [key: string]: BABYLON.Material;
  59151. };
  59152. /** Gets the hosting scene */
  59153. readonly scene: BABYLON.Scene;
  59154. /** Gets associated utility layer */
  59155. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  59156. /**
  59157. * Creates a new GUI3DManager
  59158. * @param scene
  59159. */
  59160. constructor(scene?: BABYLON.Scene);
  59161. private _handlePointerOut;
  59162. private _doPicking;
  59163. /**
  59164. * Gets the root container
  59165. */
  59166. readonly rootContainer: Container3D;
  59167. /**
  59168. * Gets a boolean indicating if the given control is in the root child list
  59169. * @param control defines the control to check
  59170. * @returns true if the control is in the root child list
  59171. */
  59172. containsControl(control: Control3D): boolean;
  59173. /**
  59174. * Adds a control to the root child list
  59175. * @param control defines the control to add
  59176. * @returns the current manager
  59177. */
  59178. addControl(control: Control3D): GUI3DManager;
  59179. /**
  59180. * Removes a control from the root child list
  59181. * @param control defines the control to remove
  59182. * @returns the current container
  59183. */
  59184. removeControl(control: Control3D): GUI3DManager;
  59185. /**
  59186. * Releases all associated resources
  59187. */
  59188. dispose(): void;
  59189. }
  59190. }
  59191. declare module BABYLON.GUI {
  59192. /**
  59193. * Class used to transport BABYLON.Vector3 information for pointer events
  59194. */
  59195. export class Vector3WithInfo extends BABYLON.Vector3 {
  59196. /** defines the current mouse button index */
  59197. buttonIndex: number;
  59198. /**
  59199. * Creates a new Vector3WithInfo
  59200. * @param source defines the vector3 data to transport
  59201. * @param buttonIndex defines the current mouse button index
  59202. */
  59203. constructor(source: BABYLON.Vector3,
  59204. /** defines the current mouse button index */
  59205. buttonIndex?: number);
  59206. }
  59207. }
  59208. declare module BABYLON.GUI {
  59209. /**
  59210. * Class used as base class for controls
  59211. */
  59212. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  59213. /** Defines the control name */
  59214. name?: string | undefined;
  59215. /** @hidden */ host: GUI3DManager;
  59216. private _node;
  59217. private _downCount;
  59218. private _enterCount;
  59219. private _downPointerIds;
  59220. private _isVisible;
  59221. /** Gets or sets the control position in world space */
  59222. position: BABYLON.Vector3;
  59223. /** Gets or sets the control scaling in world space */
  59224. scaling: BABYLON.Vector3;
  59225. /** Callback used to start pointer enter animation */
  59226. pointerEnterAnimation: () => void;
  59227. /** Callback used to start pointer out animation */
  59228. pointerOutAnimation: () => void;
  59229. /** Callback used to start pointer down animation */
  59230. pointerDownAnimation: () => void;
  59231. /** Callback used to start pointer up animation */
  59232. pointerUpAnimation: () => void;
  59233. /**
  59234. * An event triggered when the pointer move over the control
  59235. */
  59236. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  59237. /**
  59238. * An event triggered when the pointer move out of the control
  59239. */
  59240. onPointerOutObservable: BABYLON.Observable<Control3D>;
  59241. /**
  59242. * An event triggered when the pointer taps the control
  59243. */
  59244. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  59245. /**
  59246. * An event triggered when pointer is up
  59247. */
  59248. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  59249. /**
  59250. * An event triggered when a control is clicked on (with a mouse)
  59251. */
  59252. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  59253. /**
  59254. * An event triggered when pointer enters the control
  59255. */
  59256. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  59257. /**
  59258. * Gets or sets the parent container
  59259. */
  59260. parent: BABYLON.Nullable<Container3D>;
  59261. private _behaviors;
  59262. /**
  59263. * Gets the list of attached behaviors
  59264. * @see http://doc.babylonjs.com/features/behaviour
  59265. */
  59266. readonly behaviors: BABYLON.Behavior<Control3D>[];
  59267. /**
  59268. * Attach a behavior to the control
  59269. * @see http://doc.babylonjs.com/features/behaviour
  59270. * @param behavior defines the behavior to attach
  59271. * @returns the current control
  59272. */
  59273. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59274. /**
  59275. * Remove an attached behavior
  59276. * @see http://doc.babylonjs.com/features/behaviour
  59277. * @param behavior defines the behavior to attach
  59278. * @returns the current control
  59279. */
  59280. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59281. /**
  59282. * Gets an attached behavior by name
  59283. * @param name defines the name of the behavior to look for
  59284. * @see http://doc.babylonjs.com/features/behaviour
  59285. * @returns null if behavior was not found else the requested behavior
  59286. */
  59287. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  59288. /** Gets or sets a boolean indicating if the control is visible */
  59289. isVisible: boolean;
  59290. /**
  59291. * Creates a new control
  59292. * @param name defines the control name
  59293. */
  59294. constructor(
  59295. /** Defines the control name */
  59296. name?: string | undefined);
  59297. /**
  59298. * Gets a string representing the class name
  59299. */
  59300. readonly typeName: string;
  59301. /**
  59302. * Get the current class name of the control.
  59303. * @returns current class name
  59304. */
  59305. getClassName(): string;
  59306. protected _getTypeName(): string;
  59307. /**
  59308. * Gets the transform node used by this control
  59309. */
  59310. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  59311. /**
  59312. * Gets the mesh used to render this control
  59313. */
  59314. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59315. /**
  59316. * Link the control as child of the given node
  59317. * @param node defines the node to link to. Use null to unlink the control
  59318. * @returns the current control
  59319. */
  59320. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  59321. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  59322. /**
  59323. * Node creation.
  59324. * Can be overriden by children
  59325. * @param scene defines the scene where the node must be attached
  59326. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  59327. */
  59328. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59329. /**
  59330. * Affect a material to the given mesh
  59331. * @param mesh defines the mesh which will represent the control
  59332. */
  59333. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59334. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  59335. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  59336. /** @hidden */ onPointerOut(target: Control3D): void;
  59337. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59338. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59339. /** @hidden */
  59340. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59341. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59342. /** @hidden */ disposeNode(): void;
  59343. /**
  59344. * Releases all associated resources
  59345. */
  59346. dispose(): void;
  59347. }
  59348. }
  59349. declare module BABYLON.GUI {
  59350. /**
  59351. * Class used as a root to all buttons
  59352. */
  59353. export class AbstractButton3D extends Control3D {
  59354. /**
  59355. * Creates a new button
  59356. * @param name defines the control name
  59357. */
  59358. constructor(name?: string);
  59359. protected _getTypeName(): string;
  59360. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59361. }
  59362. }
  59363. declare module BABYLON.GUI {
  59364. /**
  59365. * Class used to create a button in 3D
  59366. */
  59367. export class Button3D extends AbstractButton3D {
  59368. /** @hidden */
  59369. protected _currentMaterial: BABYLON.Material;
  59370. private _facadeTexture;
  59371. private _content;
  59372. private _contentResolution;
  59373. private _contentScaleRatio;
  59374. /**
  59375. * Gets or sets the texture resolution used to render content (512 by default)
  59376. */
  59377. contentResolution: BABYLON.int;
  59378. /**
  59379. * Gets or sets the texture scale ratio used to render content (2 by default)
  59380. */
  59381. contentScaleRatio: number;
  59382. protected _disposeFacadeTexture(): void;
  59383. protected _resetContent(): void;
  59384. /**
  59385. * Creates a new button
  59386. * @param name defines the control name
  59387. */
  59388. constructor(name?: string);
  59389. /**
  59390. * Gets or sets the GUI 2D content used to display the button's facade
  59391. */
  59392. content: Control;
  59393. /**
  59394. * Apply the facade texture (created from the content property).
  59395. * This function can be overloaded by child classes
  59396. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59397. */
  59398. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59399. protected _getTypeName(): string;
  59400. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59401. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59402. /**
  59403. * Releases all associated resources
  59404. */
  59405. dispose(): void;
  59406. }
  59407. }
  59408. declare module BABYLON.GUI {
  59409. /**
  59410. * Abstract class used to create a container panel deployed on the surface of a volume
  59411. */
  59412. export abstract class VolumeBasedPanel extends Container3D {
  59413. private _columns;
  59414. private _rows;
  59415. private _rowThenColum;
  59416. private _orientation;
  59417. protected _cellWidth: number;
  59418. protected _cellHeight: number;
  59419. /**
  59420. * Gets or sets the distance between elements
  59421. */
  59422. margin: number;
  59423. /**
  59424. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59425. * | Value | Type | Description |
  59426. * | ----- | ----------------------------------- | ----------- |
  59427. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59428. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59429. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59430. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59431. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59432. */
  59433. orientation: number;
  59434. /**
  59435. * Gets or sets the number of columns requested (10 by default).
  59436. * The panel will automatically compute the number of rows based on number of child controls.
  59437. */
  59438. columns: BABYLON.int;
  59439. /**
  59440. * Gets or sets a the number of rows requested.
  59441. * The panel will automatically compute the number of columns based on number of child controls.
  59442. */
  59443. rows: BABYLON.int;
  59444. /**
  59445. * Creates new VolumeBasedPanel
  59446. */
  59447. constructor();
  59448. protected _arrangeChildren(): void;
  59449. /** Child classes must implement this function to provide correct control positioning */
  59450. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59451. /** Child classes can implement this function to provide additional processing */
  59452. protected _finalProcessing(): void;
  59453. }
  59454. }
  59455. declare module BABYLON.GUI {
  59456. /**
  59457. * Class used to create a container panel deployed on the surface of a cylinder
  59458. */
  59459. export class CylinderPanel extends VolumeBasedPanel {
  59460. private _radius;
  59461. /**
  59462. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59463. */
  59464. radius: BABYLON.float;
  59465. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59466. private _cylindricalMapping;
  59467. }
  59468. }
  59469. declare module BABYLON.GUI {
  59470. /** @hidden */
  59471. export var fluentVertexShader: {
  59472. name: string;
  59473. shader: string;
  59474. };
  59475. }
  59476. declare module BABYLON.GUI {
  59477. /** @hidden */
  59478. export var fluentPixelShader: {
  59479. name: string;
  59480. shader: string;
  59481. };
  59482. }
  59483. declare module BABYLON.GUI {
  59484. /** @hidden */
  59485. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59486. INNERGLOW: boolean;
  59487. BORDER: boolean;
  59488. HOVERLIGHT: boolean;
  59489. TEXTURE: boolean;
  59490. constructor();
  59491. }
  59492. /**
  59493. * Class used to render controls with fluent desgin
  59494. */
  59495. export class FluentMaterial extends BABYLON.PushMaterial {
  59496. /**
  59497. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59498. */
  59499. innerGlowColorIntensity: number;
  59500. /**
  59501. * Gets or sets the inner glow color (white by default)
  59502. */
  59503. innerGlowColor: BABYLON.Color3;
  59504. /**
  59505. * Gets or sets alpha value (default is 1.0)
  59506. */
  59507. alpha: number;
  59508. /**
  59509. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59510. */
  59511. albedoColor: BABYLON.Color3;
  59512. /**
  59513. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59514. */
  59515. renderBorders: boolean;
  59516. /**
  59517. * Gets or sets border width (default is 0.5)
  59518. */
  59519. borderWidth: number;
  59520. /**
  59521. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59522. */
  59523. edgeSmoothingValue: number;
  59524. /**
  59525. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59526. */
  59527. borderMinValue: number;
  59528. /**
  59529. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59530. */
  59531. renderHoverLight: boolean;
  59532. /**
  59533. * Gets or sets the radius used to render the hover light (default is 1.0)
  59534. */
  59535. hoverRadius: number;
  59536. /**
  59537. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59538. */
  59539. hoverColor: BABYLON.Color4;
  59540. /**
  59541. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59542. */
  59543. hoverPosition: BABYLON.Vector3;
  59544. private _albedoTexture;
  59545. /** Gets or sets the texture to use for albedo color */
  59546. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59547. /**
  59548. * Creates a new Fluent material
  59549. * @param name defines the name of the material
  59550. * @param scene defines the hosting scene
  59551. */
  59552. constructor(name: string, scene: BABYLON.Scene);
  59553. needAlphaBlending(): boolean;
  59554. needAlphaTesting(): boolean;
  59555. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59556. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59557. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59558. getActiveTextures(): BABYLON.BaseTexture[];
  59559. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59560. dispose(forceDisposeEffect?: boolean): void;
  59561. clone(name: string): FluentMaterial;
  59562. serialize(): any;
  59563. getClassName(): string;
  59564. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59565. }
  59566. }
  59567. declare module BABYLON.GUI {
  59568. /**
  59569. * Class used to create a holographic button in 3D
  59570. */
  59571. export class HolographicButton extends Button3D {
  59572. private _backPlate;
  59573. private _textPlate;
  59574. private _frontPlate;
  59575. private _text;
  59576. private _imageUrl;
  59577. private _shareMaterials;
  59578. private _frontMaterial;
  59579. private _backMaterial;
  59580. private _plateMaterial;
  59581. private _pickedPointObserver;
  59582. private _tooltipFade;
  59583. private _tooltipTextBlock;
  59584. private _tooltipTexture;
  59585. private _tooltipMesh;
  59586. private _tooltipHoverObserver;
  59587. private _tooltipOutObserver;
  59588. private _disposeTooltip;
  59589. /**
  59590. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59591. */
  59592. tooltipText: BABYLON.Nullable<string>;
  59593. /**
  59594. * Gets or sets text for the button
  59595. */
  59596. text: string;
  59597. /**
  59598. * Gets or sets the image url for the button
  59599. */
  59600. imageUrl: string;
  59601. /**
  59602. * Gets the back material used by this button
  59603. */
  59604. readonly backMaterial: FluentMaterial;
  59605. /**
  59606. * Gets the front material used by this button
  59607. */
  59608. readonly frontMaterial: FluentMaterial;
  59609. /**
  59610. * Gets the plate material used by this button
  59611. */
  59612. readonly plateMaterial: BABYLON.StandardMaterial;
  59613. /**
  59614. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59615. */
  59616. readonly shareMaterials: boolean;
  59617. /**
  59618. * Creates a new button
  59619. * @param name defines the control name
  59620. */
  59621. constructor(name?: string, shareMaterials?: boolean);
  59622. protected _getTypeName(): string;
  59623. private _rebuildContent;
  59624. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59625. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59626. private _createBackMaterial;
  59627. private _createFrontMaterial;
  59628. private _createPlateMaterial;
  59629. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59630. /**
  59631. * Releases all associated resources
  59632. */
  59633. dispose(): void;
  59634. }
  59635. }
  59636. declare module BABYLON.GUI {
  59637. /**
  59638. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59639. */
  59640. export class MeshButton3D extends Button3D {
  59641. /** @hidden */
  59642. protected _currentMesh: BABYLON.Mesh;
  59643. /**
  59644. * Creates a new 3D button based on a mesh
  59645. * @param mesh mesh to become a 3D button
  59646. * @param name defines the control name
  59647. */
  59648. constructor(mesh: BABYLON.Mesh, name?: string);
  59649. protected _getTypeName(): string;
  59650. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59651. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59652. }
  59653. }
  59654. declare module BABYLON.GUI {
  59655. /**
  59656. * Class used to create a container panel deployed on the surface of a plane
  59657. */
  59658. export class PlanePanel extends VolumeBasedPanel {
  59659. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59660. }
  59661. }
  59662. declare module BABYLON.GUI {
  59663. /**
  59664. * Class used to create a container panel where items get randomized planar mapping
  59665. */
  59666. export class ScatterPanel extends VolumeBasedPanel {
  59667. private _iteration;
  59668. /**
  59669. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59670. */
  59671. iteration: BABYLON.float;
  59672. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59673. private _scatterMapping;
  59674. protected _finalProcessing(): void;
  59675. }
  59676. }
  59677. declare module BABYLON.GUI {
  59678. /**
  59679. * Class used to create a container panel deployed on the surface of a sphere
  59680. */
  59681. export class SpherePanel extends VolumeBasedPanel {
  59682. private _radius;
  59683. /**
  59684. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59685. */
  59686. radius: BABYLON.float;
  59687. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59688. private _sphericalMapping;
  59689. }
  59690. }
  59691. declare module BABYLON.GUI {
  59692. /**
  59693. * Class used to create a stack panel in 3D on XY plane
  59694. */
  59695. export class StackPanel3D extends Container3D {
  59696. private _isVertical;
  59697. /**
  59698. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59699. */
  59700. isVertical: boolean;
  59701. /**
  59702. * Gets or sets the distance between elements
  59703. */
  59704. margin: number;
  59705. /**
  59706. * Creates new StackPanel
  59707. * @param isVertical
  59708. */
  59709. constructor(isVertical?: boolean);
  59710. protected _arrangeChildren(): void;
  59711. }
  59712. }
  59713. declare module BABYLON {
  59714. /**
  59715. * Mode that determines the coordinate system to use.
  59716. */
  59717. export enum GLTFLoaderCoordinateSystemMode {
  59718. /**
  59719. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59720. */
  59721. AUTO = 0,
  59722. /**
  59723. * Sets the useRightHandedSystem flag on the scene.
  59724. */
  59725. FORCE_RIGHT_HANDED = 1
  59726. }
  59727. /**
  59728. * Mode that determines what animations will start.
  59729. */
  59730. export enum GLTFLoaderAnimationStartMode {
  59731. /**
  59732. * No animation will start.
  59733. */
  59734. NONE = 0,
  59735. /**
  59736. * The first animation will start.
  59737. */
  59738. FIRST = 1,
  59739. /**
  59740. * All animations will start.
  59741. */
  59742. ALL = 2
  59743. }
  59744. /**
  59745. * Interface that contains the data for the glTF asset.
  59746. */
  59747. export interface IGLTFLoaderData {
  59748. /**
  59749. * Object that represents the glTF JSON.
  59750. */
  59751. json: Object;
  59752. /**
  59753. * The BIN chunk of a binary glTF.
  59754. */
  59755. bin: Nullable<ArrayBufferView>;
  59756. }
  59757. /**
  59758. * Interface for extending the loader.
  59759. */
  59760. export interface IGLTFLoaderExtension {
  59761. /**
  59762. * The name of this extension.
  59763. */
  59764. readonly name: string;
  59765. /**
  59766. * Defines whether this extension is enabled.
  59767. */
  59768. enabled: boolean;
  59769. }
  59770. /**
  59771. * Loader state.
  59772. */
  59773. export enum GLTFLoaderState {
  59774. /**
  59775. * The asset is loading.
  59776. */
  59777. LOADING = 0,
  59778. /**
  59779. * The asset is ready for rendering.
  59780. */
  59781. READY = 1,
  59782. /**
  59783. * The asset is completely loaded.
  59784. */
  59785. COMPLETE = 2
  59786. }
  59787. /** @hidden */
  59788. export interface IGLTFLoader extends IDisposable {
  59789. readonly state: Nullable<GLTFLoaderState>;
  59790. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59791. meshes: AbstractMesh[];
  59792. particleSystems: IParticleSystem[];
  59793. skeletons: Skeleton[];
  59794. animationGroups: AnimationGroup[];
  59795. }>;
  59796. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59797. }
  59798. /**
  59799. * File loader for loading glTF files into a scene.
  59800. */
  59801. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59802. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59803. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59804. /**
  59805. * Raised when the asset has been parsed
  59806. */
  59807. onParsedObservable: Observable<IGLTFLoaderData>;
  59808. private _onParsedObserver;
  59809. /**
  59810. * Raised when the asset has been parsed
  59811. */
  59812. onParsed: (loaderData: IGLTFLoaderData) => void;
  59813. /**
  59814. * 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.
  59815. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59816. * Defaults to true.
  59817. * @hidden
  59818. */
  59819. static IncrementalLoading: boolean;
  59820. /**
  59821. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59822. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59823. * @hidden
  59824. */
  59825. static HomogeneousCoordinates: boolean;
  59826. /**
  59827. * The coordinate system mode. Defaults to AUTO.
  59828. */
  59829. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59830. /**
  59831. * The animation start mode. Defaults to FIRST.
  59832. */
  59833. animationStartMode: GLTFLoaderAnimationStartMode;
  59834. /**
  59835. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59836. */
  59837. compileMaterials: boolean;
  59838. /**
  59839. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59840. */
  59841. useClipPlane: boolean;
  59842. /**
  59843. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59844. */
  59845. compileShadowGenerators: boolean;
  59846. /**
  59847. * Defines if the Alpha blended materials are only applied as coverage.
  59848. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59849. * If true, no extra effects are applied to transparent pixels.
  59850. */
  59851. transparencyAsCoverage: boolean;
  59852. /**
  59853. * Function called before loading a url referenced by the asset.
  59854. */
  59855. preprocessUrlAsync: (url: string) => Promise<string>;
  59856. /**
  59857. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59858. */
  59859. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59860. private _onMeshLoadedObserver;
  59861. /**
  59862. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59863. */
  59864. onMeshLoaded: (mesh: AbstractMesh) => void;
  59865. /**
  59866. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59867. */
  59868. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59869. private _onTextureLoadedObserver;
  59870. /**
  59871. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59872. */
  59873. onTextureLoaded: (texture: BaseTexture) => void;
  59874. /**
  59875. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59876. */
  59877. readonly onMaterialLoadedObservable: Observable<Material>;
  59878. private _onMaterialLoadedObserver;
  59879. /**
  59880. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59881. */
  59882. onMaterialLoaded: (material: Material) => void;
  59883. /**
  59884. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59885. */
  59886. readonly onCameraLoadedObservable: Observable<Camera>;
  59887. private _onCameraLoadedObserver;
  59888. /**
  59889. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59890. */
  59891. onCameraLoaded: (camera: Camera) => void;
  59892. /**
  59893. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59894. * For assets with LODs, raised when all of the LODs are complete.
  59895. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59896. */
  59897. readonly onCompleteObservable: Observable<void>;
  59898. private _onCompleteObserver;
  59899. /**
  59900. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59901. * For assets with LODs, raised when all of the LODs are complete.
  59902. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59903. */
  59904. onComplete: () => void;
  59905. /**
  59906. * Observable raised when an error occurs.
  59907. */
  59908. readonly onErrorObservable: Observable<any>;
  59909. private _onErrorObserver;
  59910. /**
  59911. * Callback raised when an error occurs.
  59912. */
  59913. onError: (reason: any) => void;
  59914. /**
  59915. * Observable raised after the loader is disposed.
  59916. */
  59917. readonly onDisposeObservable: Observable<void>;
  59918. private _onDisposeObserver;
  59919. /**
  59920. * Callback raised after the loader is disposed.
  59921. */
  59922. onDispose: () => void;
  59923. /**
  59924. * Observable raised after a loader extension is created.
  59925. * Set additional options for a loader extension in this event.
  59926. */
  59927. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59928. private _onExtensionLoadedObserver;
  59929. /**
  59930. * Callback raised after a loader extension is created.
  59931. */
  59932. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59933. /**
  59934. * Defines if the loader logging is enabled.
  59935. */
  59936. loggingEnabled: boolean;
  59937. /**
  59938. * Defines if the loader should capture performance counters.
  59939. */
  59940. capturePerformanceCounters: boolean;
  59941. /**
  59942. * Defines if the loader should validate the asset.
  59943. */
  59944. validate: boolean;
  59945. /**
  59946. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59947. */
  59948. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59949. private _onValidatedObserver;
  59950. /**
  59951. * Callback raised after a loader extension is created.
  59952. */
  59953. onValidated: (results: IGLTFValidationResults) => void;
  59954. private _loader;
  59955. /**
  59956. * Name of the loader ("gltf")
  59957. */
  59958. name: string;
  59959. /**
  59960. * Supported file extensions of the loader (.gltf, .glb)
  59961. */
  59962. extensions: ISceneLoaderPluginExtensions;
  59963. /**
  59964. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59965. */
  59966. dispose(): void;
  59967. /** @hidden */ clear(): void;
  59968. /**
  59969. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59970. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59971. * @param scene the scene the meshes should be added to
  59972. * @param data the glTF data to load
  59973. * @param rootUrl root url to load from
  59974. * @param onProgress event that fires when loading progress has occured
  59975. * @param fileName Defines the name of the file to load
  59976. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59977. */
  59978. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59979. meshes: AbstractMesh[];
  59980. particleSystems: IParticleSystem[];
  59981. skeletons: Skeleton[];
  59982. animationGroups: AnimationGroup[];
  59983. }>;
  59984. /**
  59985. * Imports all objects from the loaded glTF data and adds them to the scene
  59986. * @param scene the scene the objects should be added to
  59987. * @param data the glTF data to load
  59988. * @param rootUrl root url to load from
  59989. * @param onProgress event that fires when loading progress has occured
  59990. * @param fileName Defines the name of the file to load
  59991. * @returns a promise which completes when objects have been loaded to the scene
  59992. */
  59993. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59994. /**
  59995. * Load into an asset container.
  59996. * @param scene The scene to load into
  59997. * @param data The data to import
  59998. * @param rootUrl The root url for scene and resources
  59999. * @param onProgress The callback when the load progresses
  60000. * @param fileName Defines the name of the file to load
  60001. * @returns The loaded asset container
  60002. */
  60003. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  60004. /**
  60005. * If the data string can be loaded directly.
  60006. * @param data string contianing the file data
  60007. * @returns if the data can be loaded directly
  60008. */
  60009. canDirectLoad(data: string): boolean;
  60010. /**
  60011. * Rewrites a url by combining a root url and response url.
  60012. */
  60013. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  60014. /**
  60015. * Instantiates a glTF file loader plugin.
  60016. * @returns the created plugin
  60017. */
  60018. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  60019. /**
  60020. * The loader state or null if the loader is not active.
  60021. */
  60022. readonly loaderState: Nullable<GLTFLoaderState>;
  60023. /**
  60024. * Returns a promise that resolves when the asset is completely loaded.
  60025. * @returns a promise that resolves when the asset is completely loaded.
  60026. */
  60027. whenCompleteAsync(): Promise<void>;
  60028. private _parseAsync;
  60029. private _validateAsync;
  60030. private _getLoader;
  60031. private _unpackBinary;
  60032. private _unpackBinaryV1;
  60033. private _unpackBinaryV2;
  60034. private static _parseVersion;
  60035. private static _compareVersion;
  60036. private static _decodeBufferToText;
  60037. private static readonly _logSpaces;
  60038. private _logIndentLevel;
  60039. private _loggingEnabled;
  60040. /** @hidden */ log: (message: string) => void;
  60041. /** @hidden */ logOpen(message: string): void;
  60042. /** @hidden */ logClose(): void;
  60043. private _logEnabled;
  60044. private _logDisabled;
  60045. private _capturePerformanceCounters;
  60046. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  60047. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  60048. private _startPerformanceCounterEnabled;
  60049. private _startPerformanceCounterDisabled;
  60050. private _endPerformanceCounterEnabled;
  60051. private _endPerformanceCounterDisabled;
  60052. }
  60053. }
  60054. declare module BABYLON.GLTF1 {
  60055. /**
  60056. * Enums
  60057. * @hidden
  60058. */
  60059. export enum EComponentType {
  60060. BYTE = 5120,
  60061. UNSIGNED_BYTE = 5121,
  60062. SHORT = 5122,
  60063. UNSIGNED_SHORT = 5123,
  60064. FLOAT = 5126
  60065. }
  60066. /** @hidden */
  60067. export enum EShaderType {
  60068. FRAGMENT = 35632,
  60069. VERTEX = 35633
  60070. }
  60071. /** @hidden */
  60072. export enum EParameterType {
  60073. BYTE = 5120,
  60074. UNSIGNED_BYTE = 5121,
  60075. SHORT = 5122,
  60076. UNSIGNED_SHORT = 5123,
  60077. INT = 5124,
  60078. UNSIGNED_INT = 5125,
  60079. FLOAT = 5126,
  60080. FLOAT_VEC2 = 35664,
  60081. FLOAT_VEC3 = 35665,
  60082. FLOAT_VEC4 = 35666,
  60083. INT_VEC2 = 35667,
  60084. INT_VEC3 = 35668,
  60085. INT_VEC4 = 35669,
  60086. BOOL = 35670,
  60087. BOOL_VEC2 = 35671,
  60088. BOOL_VEC3 = 35672,
  60089. BOOL_VEC4 = 35673,
  60090. FLOAT_MAT2 = 35674,
  60091. FLOAT_MAT3 = 35675,
  60092. FLOAT_MAT4 = 35676,
  60093. SAMPLER_2D = 35678
  60094. }
  60095. /** @hidden */
  60096. export enum ETextureWrapMode {
  60097. CLAMP_TO_EDGE = 33071,
  60098. MIRRORED_REPEAT = 33648,
  60099. REPEAT = 10497
  60100. }
  60101. /** @hidden */
  60102. export enum ETextureFilterType {
  60103. NEAREST = 9728,
  60104. LINEAR = 9728,
  60105. NEAREST_MIPMAP_NEAREST = 9984,
  60106. LINEAR_MIPMAP_NEAREST = 9985,
  60107. NEAREST_MIPMAP_LINEAR = 9986,
  60108. LINEAR_MIPMAP_LINEAR = 9987
  60109. }
  60110. /** @hidden */
  60111. export enum ETextureFormat {
  60112. ALPHA = 6406,
  60113. RGB = 6407,
  60114. RGBA = 6408,
  60115. LUMINANCE = 6409,
  60116. LUMINANCE_ALPHA = 6410
  60117. }
  60118. /** @hidden */
  60119. export enum ECullingType {
  60120. FRONT = 1028,
  60121. BACK = 1029,
  60122. FRONT_AND_BACK = 1032
  60123. }
  60124. /** @hidden */
  60125. export enum EBlendingFunction {
  60126. ZERO = 0,
  60127. ONE = 1,
  60128. SRC_COLOR = 768,
  60129. ONE_MINUS_SRC_COLOR = 769,
  60130. DST_COLOR = 774,
  60131. ONE_MINUS_DST_COLOR = 775,
  60132. SRC_ALPHA = 770,
  60133. ONE_MINUS_SRC_ALPHA = 771,
  60134. DST_ALPHA = 772,
  60135. ONE_MINUS_DST_ALPHA = 773,
  60136. CONSTANT_COLOR = 32769,
  60137. ONE_MINUS_CONSTANT_COLOR = 32770,
  60138. CONSTANT_ALPHA = 32771,
  60139. ONE_MINUS_CONSTANT_ALPHA = 32772,
  60140. SRC_ALPHA_SATURATE = 776
  60141. }
  60142. /** @hidden */
  60143. export interface IGLTFProperty {
  60144. extensions?: {
  60145. [key: string]: any;
  60146. };
  60147. extras?: Object;
  60148. }
  60149. /** @hidden */
  60150. export interface IGLTFChildRootProperty extends IGLTFProperty {
  60151. name?: string;
  60152. }
  60153. /** @hidden */
  60154. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  60155. bufferView: string;
  60156. byteOffset: number;
  60157. byteStride: number;
  60158. count: number;
  60159. type: string;
  60160. componentType: EComponentType;
  60161. max?: number[];
  60162. min?: number[];
  60163. name?: string;
  60164. }
  60165. /** @hidden */
  60166. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  60167. buffer: string;
  60168. byteOffset: number;
  60169. byteLength: number;
  60170. byteStride: number;
  60171. target?: number;
  60172. }
  60173. /** @hidden */
  60174. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  60175. uri: string;
  60176. byteLength?: number;
  60177. type?: string;
  60178. }
  60179. /** @hidden */
  60180. export interface IGLTFShader extends IGLTFChildRootProperty {
  60181. uri: string;
  60182. type: EShaderType;
  60183. }
  60184. /** @hidden */
  60185. export interface IGLTFProgram extends IGLTFChildRootProperty {
  60186. attributes: string[];
  60187. fragmentShader: string;
  60188. vertexShader: string;
  60189. }
  60190. /** @hidden */
  60191. export interface IGLTFTechniqueParameter {
  60192. type: number;
  60193. count?: number;
  60194. semantic?: string;
  60195. node?: string;
  60196. value?: number | boolean | string | Array<any>;
  60197. source?: string;
  60198. babylonValue?: any;
  60199. }
  60200. /** @hidden */
  60201. export interface IGLTFTechniqueCommonProfile {
  60202. lightingModel: string;
  60203. texcoordBindings: Object;
  60204. parameters?: Array<any>;
  60205. }
  60206. /** @hidden */
  60207. export interface IGLTFTechniqueStatesFunctions {
  60208. blendColor?: number[];
  60209. blendEquationSeparate?: number[];
  60210. blendFuncSeparate?: number[];
  60211. colorMask: boolean[];
  60212. cullFace: number[];
  60213. }
  60214. /** @hidden */
  60215. export interface IGLTFTechniqueStates {
  60216. enable: number[];
  60217. functions: IGLTFTechniqueStatesFunctions;
  60218. }
  60219. /** @hidden */
  60220. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  60221. parameters: {
  60222. [key: string]: IGLTFTechniqueParameter;
  60223. };
  60224. program: string;
  60225. attributes: {
  60226. [key: string]: string;
  60227. };
  60228. uniforms: {
  60229. [key: string]: string;
  60230. };
  60231. states: IGLTFTechniqueStates;
  60232. }
  60233. /** @hidden */
  60234. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  60235. technique?: string;
  60236. values: string[];
  60237. }
  60238. /** @hidden */
  60239. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  60240. attributes: {
  60241. [key: string]: string;
  60242. };
  60243. indices: string;
  60244. material: string;
  60245. mode?: number;
  60246. }
  60247. /** @hidden */
  60248. export interface IGLTFMesh extends IGLTFChildRootProperty {
  60249. primitives: IGLTFMeshPrimitive[];
  60250. }
  60251. /** @hidden */
  60252. export interface IGLTFImage extends IGLTFChildRootProperty {
  60253. uri: string;
  60254. }
  60255. /** @hidden */
  60256. export interface IGLTFSampler extends IGLTFChildRootProperty {
  60257. magFilter?: number;
  60258. minFilter?: number;
  60259. wrapS?: number;
  60260. wrapT?: number;
  60261. }
  60262. /** @hidden */
  60263. export interface IGLTFTexture extends IGLTFChildRootProperty {
  60264. sampler: string;
  60265. source: string;
  60266. format?: ETextureFormat;
  60267. internalFormat?: ETextureFormat;
  60268. target?: number;
  60269. type?: number;
  60270. babylonTexture?: Texture;
  60271. }
  60272. /** @hidden */
  60273. export interface IGLTFAmbienLight {
  60274. color?: number[];
  60275. }
  60276. /** @hidden */
  60277. export interface IGLTFDirectionalLight {
  60278. color?: number[];
  60279. }
  60280. /** @hidden */
  60281. export interface IGLTFPointLight {
  60282. color?: number[];
  60283. constantAttenuation?: number;
  60284. linearAttenuation?: number;
  60285. quadraticAttenuation?: number;
  60286. }
  60287. /** @hidden */
  60288. export interface IGLTFSpotLight {
  60289. color?: number[];
  60290. constantAttenuation?: number;
  60291. fallOfAngle?: number;
  60292. fallOffExponent?: number;
  60293. linearAttenuation?: number;
  60294. quadraticAttenuation?: number;
  60295. }
  60296. /** @hidden */
  60297. export interface IGLTFLight extends IGLTFChildRootProperty {
  60298. type: string;
  60299. }
  60300. /** @hidden */
  60301. export interface IGLTFCameraOrthographic {
  60302. xmag: number;
  60303. ymag: number;
  60304. zfar: number;
  60305. znear: number;
  60306. }
  60307. /** @hidden */
  60308. export interface IGLTFCameraPerspective {
  60309. aspectRatio: number;
  60310. yfov: number;
  60311. zfar: number;
  60312. znear: number;
  60313. }
  60314. /** @hidden */
  60315. export interface IGLTFCamera extends IGLTFChildRootProperty {
  60316. type: string;
  60317. }
  60318. /** @hidden */
  60319. export interface IGLTFAnimationChannelTarget {
  60320. id: string;
  60321. path: string;
  60322. }
  60323. /** @hidden */
  60324. export interface IGLTFAnimationChannel {
  60325. sampler: string;
  60326. target: IGLTFAnimationChannelTarget;
  60327. }
  60328. /** @hidden */
  60329. export interface IGLTFAnimationSampler {
  60330. input: string;
  60331. output: string;
  60332. interpolation?: string;
  60333. }
  60334. /** @hidden */
  60335. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  60336. channels?: IGLTFAnimationChannel[];
  60337. parameters?: {
  60338. [key: string]: string;
  60339. };
  60340. samplers?: {
  60341. [key: string]: IGLTFAnimationSampler;
  60342. };
  60343. }
  60344. /** @hidden */
  60345. export interface IGLTFNodeInstanceSkin {
  60346. skeletons: string[];
  60347. skin: string;
  60348. meshes: string[];
  60349. }
  60350. /** @hidden */
  60351. export interface IGLTFSkins extends IGLTFChildRootProperty {
  60352. bindShapeMatrix: number[];
  60353. inverseBindMatrices: string;
  60354. jointNames: string[];
  60355. babylonSkeleton?: Skeleton;
  60356. }
  60357. /** @hidden */
  60358. export interface IGLTFNode extends IGLTFChildRootProperty {
  60359. camera?: string;
  60360. children: string[];
  60361. skin?: string;
  60362. jointName?: string;
  60363. light?: string;
  60364. matrix: number[];
  60365. mesh?: string;
  60366. meshes?: string[];
  60367. rotation?: number[];
  60368. scale?: number[];
  60369. translation?: number[];
  60370. babylonNode?: Node;
  60371. }
  60372. /** @hidden */
  60373. export interface IGLTFScene extends IGLTFChildRootProperty {
  60374. nodes: string[];
  60375. }
  60376. /** @hidden */
  60377. export interface IGLTFRuntime {
  60378. extensions: {
  60379. [key: string]: any;
  60380. };
  60381. accessors: {
  60382. [key: string]: IGLTFAccessor;
  60383. };
  60384. buffers: {
  60385. [key: string]: IGLTFBuffer;
  60386. };
  60387. bufferViews: {
  60388. [key: string]: IGLTFBufferView;
  60389. };
  60390. meshes: {
  60391. [key: string]: IGLTFMesh;
  60392. };
  60393. lights: {
  60394. [key: string]: IGLTFLight;
  60395. };
  60396. cameras: {
  60397. [key: string]: IGLTFCamera;
  60398. };
  60399. nodes: {
  60400. [key: string]: IGLTFNode;
  60401. };
  60402. images: {
  60403. [key: string]: IGLTFImage;
  60404. };
  60405. textures: {
  60406. [key: string]: IGLTFTexture;
  60407. };
  60408. shaders: {
  60409. [key: string]: IGLTFShader;
  60410. };
  60411. programs: {
  60412. [key: string]: IGLTFProgram;
  60413. };
  60414. samplers: {
  60415. [key: string]: IGLTFSampler;
  60416. };
  60417. techniques: {
  60418. [key: string]: IGLTFTechnique;
  60419. };
  60420. materials: {
  60421. [key: string]: IGLTFMaterial;
  60422. };
  60423. animations: {
  60424. [key: string]: IGLTFAnimation;
  60425. };
  60426. skins: {
  60427. [key: string]: IGLTFSkins;
  60428. };
  60429. currentScene?: Object;
  60430. scenes: {
  60431. [key: string]: IGLTFScene;
  60432. };
  60433. extensionsUsed: string[];
  60434. extensionsRequired?: string[];
  60435. buffersCount: number;
  60436. shaderscount: number;
  60437. scene: Scene;
  60438. rootUrl: string;
  60439. loadedBufferCount: number;
  60440. loadedBufferViews: {
  60441. [name: string]: ArrayBufferView;
  60442. };
  60443. loadedShaderCount: number;
  60444. importOnlyMeshes: boolean;
  60445. importMeshesNames?: string[];
  60446. dummyNodes: Node[];
  60447. }
  60448. /** @hidden */
  60449. export interface INodeToRoot {
  60450. bone: Bone;
  60451. node: IGLTFNode;
  60452. id: string;
  60453. }
  60454. /** @hidden */
  60455. export interface IJointNode {
  60456. node: IGLTFNode;
  60457. id: string;
  60458. }
  60459. }
  60460. declare module BABYLON.GLTF1 {
  60461. /**
  60462. * Utils functions for GLTF
  60463. * @hidden
  60464. */
  60465. export class GLTFUtils {
  60466. /**
  60467. * Sets the given "parameter" matrix
  60468. * @param scene: the Scene object
  60469. * @param source: the source node where to pick the matrix
  60470. * @param parameter: the GLTF technique parameter
  60471. * @param uniformName: the name of the shader's uniform
  60472. * @param shaderMaterial: the shader material
  60473. */
  60474. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60475. /**
  60476. * Sets the given "parameter" matrix
  60477. * @param shaderMaterial: the shader material
  60478. * @param uniform: the name of the shader's uniform
  60479. * @param value: the value of the uniform
  60480. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60481. */
  60482. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60483. /**
  60484. * Returns the wrap mode of the texture
  60485. * @param mode: the mode value
  60486. */
  60487. static GetWrapMode(mode: number): number;
  60488. /**
  60489. * Returns the byte stride giving an accessor
  60490. * @param accessor: the GLTF accessor objet
  60491. */
  60492. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60493. /**
  60494. * Returns the texture filter mode giving a mode value
  60495. * @param mode: the filter mode value
  60496. */
  60497. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60498. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60499. /**
  60500. * Returns a buffer from its accessor
  60501. * @param gltfRuntime: the GLTF runtime
  60502. * @param accessor: the GLTF accessor
  60503. */
  60504. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60505. /**
  60506. * Decodes a buffer view into a string
  60507. * @param view: the buffer view
  60508. */
  60509. static DecodeBufferToText(view: ArrayBufferView): string;
  60510. /**
  60511. * Returns the default material of gltf. Related to
  60512. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60513. * @param scene: the Babylon.js scene
  60514. */
  60515. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60516. private static _DefaultMaterial;
  60517. }
  60518. }
  60519. declare module BABYLON.GLTF1 {
  60520. /**
  60521. * Implementation of the base glTF spec
  60522. * @hidden
  60523. */
  60524. export class GLTFLoaderBase {
  60525. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60526. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60527. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60528. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60529. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60530. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60531. }
  60532. /**
  60533. * glTF V1 Loader
  60534. * @hidden
  60535. */
  60536. export class GLTFLoader implements IGLTFLoader {
  60537. static Extensions: {
  60538. [name: string]: GLTFLoaderExtension;
  60539. };
  60540. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60541. state: Nullable<GLTFLoaderState>;
  60542. dispose(): void;
  60543. private _importMeshAsync;
  60544. /**
  60545. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60546. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60547. * @param scene the scene the meshes should be added to
  60548. * @param data gltf data containing information of the meshes in a loaded file
  60549. * @param rootUrl root url to load from
  60550. * @param onProgress event that fires when loading progress has occured
  60551. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60552. */
  60553. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60554. meshes: AbstractMesh[];
  60555. particleSystems: IParticleSystem[];
  60556. skeletons: Skeleton[];
  60557. animationGroups: AnimationGroup[];
  60558. }>;
  60559. private _loadAsync;
  60560. /**
  60561. * Imports all objects from a loaded gltf file and adds them to the scene
  60562. * @param scene the scene the objects should be added to
  60563. * @param data gltf data containing information of the meshes in a loaded file
  60564. * @param rootUrl root url to load from
  60565. * @param onProgress event that fires when loading progress has occured
  60566. * @returns a promise which completes when objects have been loaded to the scene
  60567. */
  60568. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60569. private _loadShadersAsync;
  60570. private _loadBuffersAsync;
  60571. private _createNodes;
  60572. }
  60573. /** @hidden */
  60574. export abstract class GLTFLoaderExtension {
  60575. private _name;
  60576. constructor(name: string);
  60577. readonly name: string;
  60578. /**
  60579. * Defines an override for loading the runtime
  60580. * Return true to stop further extensions from loading the runtime
  60581. */
  60582. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60583. /**
  60584. * Defines an onverride for creating gltf runtime
  60585. * Return true to stop further extensions from creating the runtime
  60586. */
  60587. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60588. /**
  60589. * Defines an override for loading buffers
  60590. * Return true to stop further extensions from loading this buffer
  60591. */
  60592. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60593. /**
  60594. * Defines an override for loading texture buffers
  60595. * Return true to stop further extensions from loading this texture data
  60596. */
  60597. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60598. /**
  60599. * Defines an override for creating textures
  60600. * Return true to stop further extensions from loading this texture
  60601. */
  60602. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60603. /**
  60604. * Defines an override for loading shader strings
  60605. * Return true to stop further extensions from loading this shader data
  60606. */
  60607. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60608. /**
  60609. * Defines an override for loading materials
  60610. * Return true to stop further extensions from loading this material
  60611. */
  60612. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60613. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60614. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60615. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60616. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60617. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60618. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60619. private static LoadTextureBufferAsync;
  60620. private static CreateTextureAsync;
  60621. private static ApplyExtensions;
  60622. }
  60623. }
  60624. declare module BABYLON.GLTF1 {
  60625. /** @hidden */
  60626. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60627. private _bin;
  60628. constructor();
  60629. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60630. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60631. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60632. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60633. }
  60634. }
  60635. declare module BABYLON.GLTF1 {
  60636. /** @hidden */
  60637. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60638. constructor();
  60639. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60640. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60641. private _loadTexture;
  60642. }
  60643. }
  60644. declare module BABYLON.GLTF2.Loader {
  60645. /**
  60646. * Loader interface with an index field.
  60647. */
  60648. export interface IArrayItem {
  60649. /**
  60650. * The index of this item in the array.
  60651. */
  60652. index: number;
  60653. }
  60654. /**
  60655. * Loader interface with additional members.
  60656. */
  60657. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60658. /** @hidden */ data?: Promise<ArrayBufferView>;
  60659. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60660. }
  60661. /**
  60662. * Loader interface with additional members.
  60663. */
  60664. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60665. }
  60666. /** @hidden */
  60667. export interface _IAnimationSamplerData {
  60668. input: Float32Array;
  60669. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60670. output: Float32Array;
  60671. }
  60672. /**
  60673. * Loader interface with additional members.
  60674. */
  60675. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60676. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60677. }
  60678. /**
  60679. * Loader interface with additional members.
  60680. */
  60681. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60682. channels: IAnimationChannel[];
  60683. samplers: IAnimationSampler[];
  60684. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60685. }
  60686. /**
  60687. * Loader interface with additional members.
  60688. */
  60689. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60690. /** @hidden */ data?: Promise<ArrayBufferView>;
  60691. }
  60692. /**
  60693. * Loader interface with additional members.
  60694. */
  60695. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60696. /** @hidden */ data?: Promise<ArrayBufferView>;
  60697. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60698. }
  60699. /**
  60700. * Loader interface with additional members.
  60701. */
  60702. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60703. }
  60704. /**
  60705. * Loader interface with additional members.
  60706. */
  60707. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60708. /** @hidden */ data?: Promise<ArrayBufferView>;
  60709. }
  60710. /**
  60711. * Loader interface with additional members.
  60712. */
  60713. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60714. }
  60715. /**
  60716. * Loader interface with additional members.
  60717. */
  60718. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60719. }
  60720. /**
  60721. * Loader interface with additional members.
  60722. */
  60723. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60724. baseColorTexture?: ITextureInfo;
  60725. metallicRoughnessTexture?: ITextureInfo;
  60726. }
  60727. /**
  60728. * Loader interface with additional members.
  60729. */
  60730. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60731. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60732. normalTexture?: IMaterialNormalTextureInfo;
  60733. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60734. emissiveTexture?: ITextureInfo;
  60735. /** @hidden */ data?: {
  60736. [babylonDrawMode: number]: {
  60737. babylonMaterial: Material;
  60738. babylonMeshes: AbstractMesh[];
  60739. promise: Promise<void>;
  60740. };
  60741. };
  60742. }
  60743. /**
  60744. * Loader interface with additional members.
  60745. */
  60746. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60747. primitives: IMeshPrimitive[];
  60748. }
  60749. /**
  60750. * Loader interface with additional members.
  60751. */
  60752. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60753. /** @hidden */ instanceData?: {
  60754. babylonSourceMesh: Mesh;
  60755. promise: Promise<any>;
  60756. };
  60757. }
  60758. /**
  60759. * Loader interface with additional members.
  60760. */
  60761. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60762. /**
  60763. * The parent glTF node.
  60764. */
  60765. parent?: INode;
  60766. /** @hidden */ babylonTransformNode?: TransformNode;
  60767. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60768. /** @hidden */ babylonBones?: Bone[];
  60769. /** @hidden */ numMorphTargets?: number;
  60770. }
  60771. /** @hidden */
  60772. export interface _ISamplerData {
  60773. noMipMaps: boolean;
  60774. samplingMode: number;
  60775. wrapU: number;
  60776. wrapV: number;
  60777. }
  60778. /**
  60779. * Loader interface with additional members.
  60780. */
  60781. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60782. /** @hidden */ data?: _ISamplerData;
  60783. }
  60784. /**
  60785. * Loader interface with additional members.
  60786. */
  60787. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60788. }
  60789. /**
  60790. * Loader interface with additional members.
  60791. */
  60792. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60793. /** @hidden */ data?: {
  60794. babylonSkeleton: Skeleton;
  60795. promise: Promise<void>;
  60796. };
  60797. }
  60798. /**
  60799. * Loader interface with additional members.
  60800. */
  60801. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60802. }
  60803. /**
  60804. * Loader interface with additional members.
  60805. */
  60806. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60807. }
  60808. /**
  60809. * Loader interface with additional members.
  60810. */
  60811. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60812. accessors?: IAccessor[];
  60813. animations?: IAnimation[];
  60814. buffers?: IBuffer[];
  60815. bufferViews?: IBufferView[];
  60816. cameras?: ICamera[];
  60817. images?: IImage[];
  60818. materials?: IMaterial[];
  60819. meshes?: IMesh[];
  60820. nodes?: INode[];
  60821. samplers?: ISampler[];
  60822. scenes?: IScene[];
  60823. skins?: ISkin[];
  60824. textures?: ITexture[];
  60825. }
  60826. }
  60827. declare module BABYLON.GLTF2 {
  60828. /**
  60829. * Interface for a glTF loader extension.
  60830. */
  60831. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60832. /**
  60833. * Called after the loader state changes to LOADING.
  60834. */
  60835. onLoading?(): void;
  60836. /**
  60837. * Called after the loader state changes to READY.
  60838. */
  60839. onReady?(): void;
  60840. /**
  60841. * Define this method to modify the default behavior when loading scenes.
  60842. * @param context The context when loading the asset
  60843. * @param scene The glTF scene property
  60844. * @returns A promise that resolves when the load is complete or null if not handled
  60845. */
  60846. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60847. /**
  60848. * Define this method to modify the default behavior when loading nodes.
  60849. * @param context The context when loading the asset
  60850. * @param node The glTF node property
  60851. * @param assign A function called synchronously after parsing the glTF properties
  60852. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60853. */
  60854. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60855. /**
  60856. * Define this method to modify the default behavior when loading cameras.
  60857. * @param context The context when loading the asset
  60858. * @param camera The glTF camera property
  60859. * @param assign A function called synchronously after parsing the glTF properties
  60860. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60861. */
  60862. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60863. /**
  60864. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60865. * @param context The context when loading the asset
  60866. * @param primitive The glTF mesh primitive property
  60867. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60868. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60869. /**
  60870. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60871. * @param context The context when loading the asset
  60872. * @param name The mesh name when loading the asset
  60873. * @param node The glTF node when loading the asset
  60874. * @param mesh The glTF mesh when loading the asset
  60875. * @param primitive The glTF mesh primitive property
  60876. * @param assign A function called synchronously after parsing the glTF properties
  60877. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60878. */ loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60879. /**
  60880. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60881. * @param context The context when loading the asset
  60882. * @param material The glTF material property
  60883. * @param assign A function called synchronously after parsing the glTF properties
  60884. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60885. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60886. /**
  60887. * Define this method to modify the default behavior when creating materials.
  60888. * @param context The context when loading the asset
  60889. * @param material The glTF material property
  60890. * @param babylonDrawMode The draw mode for the Babylon material
  60891. * @returns The Babylon material or null if not handled
  60892. */
  60893. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60894. /**
  60895. * Define this method to modify the default behavior when loading material properties.
  60896. * @param context The context when loading the asset
  60897. * @param material The glTF material property
  60898. * @param babylonMaterial The Babylon material
  60899. * @returns A promise that resolves when the load is complete or null if not handled
  60900. */
  60901. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60902. /**
  60903. * Define this method to modify the default behavior when loading texture infos.
  60904. * @param context The context when loading the asset
  60905. * @param textureInfo The glTF texture info property
  60906. * @param assign A function called synchronously after parsing the glTF properties
  60907. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60908. */
  60909. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60910. /**
  60911. * Define this method to modify the default behavior when loading animations.
  60912. * @param context The context when loading the asset
  60913. * @param animation The glTF animation property
  60914. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60915. */
  60916. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60917. /**
  60918. * @hidden Define this method to modify the default behavior when loading skins.
  60919. * @param context The context when loading the asset
  60920. * @param node The glTF node property
  60921. * @param skin The glTF skin property
  60922. * @returns A promise that resolves when the load is complete or null if not handled
  60923. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60924. /**
  60925. * @hidden Define this method to modify the default behavior when loading uris.
  60926. * @param context The context when loading the asset
  60927. * @param property The glTF property associated with the uri
  60928. * @param uri The uri to load
  60929. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60930. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60931. }
  60932. }
  60933. declare module BABYLON.GLTF2 {
  60934. /**
  60935. * Helper class for working with arrays when loading the glTF asset
  60936. */
  60937. export class ArrayItem {
  60938. /**
  60939. * Gets an item from the given array.
  60940. * @param context The context when loading the asset
  60941. * @param array The array to get the item from
  60942. * @param index The index to the array
  60943. * @returns The array item
  60944. */
  60945. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60946. /**
  60947. * Assign an `index` field to each item of the given array.
  60948. * @param array The array of items
  60949. */
  60950. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60951. }
  60952. /**
  60953. * The glTF 2.0 loader
  60954. */
  60955. export class GLTFLoader implements IGLTFLoader {
  60956. /** @hidden */ completePromises: Promise<any>[];
  60957. private _disposed;
  60958. private _parent;
  60959. private _state;
  60960. private _extensions;
  60961. private _rootUrl;
  60962. private _fileName;
  60963. private _uniqueRootUrl;
  60964. private _gltf;
  60965. private _babylonScene;
  60966. private _rootBabylonMesh;
  60967. private _defaultBabylonMaterialData;
  60968. private _progressCallback?;
  60969. private _requests;
  60970. private static readonly _DefaultSampler;
  60971. private static _ExtensionNames;
  60972. private static _ExtensionFactories;
  60973. /**
  60974. * Registers a loader extension.
  60975. * @param name The name of the loader extension.
  60976. * @param factory The factory function that creates the loader extension.
  60977. */
  60978. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60979. /**
  60980. * Unregisters a loader extension.
  60981. * @param name The name of the loader extenion.
  60982. * @returns A boolean indicating whether the extension has been unregistered
  60983. */
  60984. static UnregisterExtension(name: string): boolean;
  60985. /**
  60986. * Gets the loader state.
  60987. */
  60988. readonly state: Nullable<GLTFLoaderState>;
  60989. /**
  60990. * The glTF object parsed from the JSON.
  60991. */
  60992. readonly gltf: IGLTF;
  60993. /**
  60994. * The Babylon scene when loading the asset.
  60995. */
  60996. readonly babylonScene: Scene;
  60997. /**
  60998. * The root Babylon mesh when loading the asset.
  60999. */
  61000. readonly rootBabylonMesh: Mesh;
  61001. /** @hidden */
  61002. constructor(parent: GLTFFileLoader);
  61003. /** @hidden */
  61004. dispose(): void;
  61005. /** @hidden */
  61006. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61007. meshes: AbstractMesh[];
  61008. particleSystems: IParticleSystem[];
  61009. skeletons: Skeleton[];
  61010. animationGroups: AnimationGroup[];
  61011. }>;
  61012. /** @hidden */
  61013. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61014. private _loadAsync;
  61015. private _loadData;
  61016. private _setupData;
  61017. private _loadExtensions;
  61018. private _checkExtensions;
  61019. private _setState;
  61020. private _createRootNode;
  61021. /**
  61022. * Loads a glTF scene.
  61023. * @param context The context when loading the asset
  61024. * @param scene The glTF scene property
  61025. * @returns A promise that resolves when the load is complete
  61026. */
  61027. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  61028. private _forEachPrimitive;
  61029. private _getMeshes;
  61030. private _getSkeletons;
  61031. private _getAnimationGroups;
  61032. private _startAnimations;
  61033. /**
  61034. * Loads a glTF node.
  61035. * @param context The context when loading the asset
  61036. * @param node The glTF node property
  61037. * @param assign A function called synchronously after parsing the glTF properties
  61038. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  61039. */
  61040. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  61041. private _loadMeshAsync;
  61042. /**
  61043. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  61044. * @param context The context when loading the asset
  61045. * @param name The mesh name when loading the asset
  61046. * @param node The glTF node when loading the asset
  61047. * @param mesh The glTF mesh when loading the asset
  61048. * @param primitive The glTF mesh primitive property
  61049. * @param assign A function called synchronously after parsing the glTF properties
  61050. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  61051. */ loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  61052. private _loadVertexDataAsync;
  61053. private _createMorphTargets;
  61054. private _loadMorphTargetsAsync;
  61055. private _loadMorphTargetVertexDataAsync;
  61056. private static _LoadTransform;
  61057. private _loadSkinAsync;
  61058. private _loadBones;
  61059. private _loadBone;
  61060. private _loadSkinInverseBindMatricesDataAsync;
  61061. private _updateBoneMatrices;
  61062. private _getNodeMatrix;
  61063. /**
  61064. * Loads a glTF camera.
  61065. * @param context The context when loading the asset
  61066. * @param camera The glTF camera property
  61067. * @param assign A function called synchronously after parsing the glTF properties
  61068. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  61069. */
  61070. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  61071. private _loadAnimationsAsync;
  61072. /**
  61073. * Loads a glTF animation.
  61074. * @param context The context when loading the asset
  61075. * @param animation The glTF animation property
  61076. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  61077. */
  61078. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  61079. /**
  61080. * @hidden Loads a glTF animation channel.
  61081. * @param context The context when loading the asset
  61082. * @param animationContext The context of the animation when loading the asset
  61083. * @param animation The glTF animation property
  61084. * @param channel The glTF animation channel property
  61085. * @param babylonAnimationGroup The babylon animation group property
  61086. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  61087. * @returns A void promise when the channel load is complete
  61088. */ loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  61089. private _loadAnimationSamplerAsync;
  61090. private _loadBufferAsync;
  61091. /**
  61092. * Loads a glTF buffer view.
  61093. * @param context The context when loading the asset
  61094. * @param bufferView The glTF buffer view property
  61095. * @returns A promise that resolves with the loaded data when the load is complete
  61096. */
  61097. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  61098. private _loadIndicesAccessorAsync;
  61099. private _loadFloatAccessorAsync;
  61100. private _loadVertexBufferViewAsync;
  61101. private _loadVertexAccessorAsync;
  61102. private _loadMaterialMetallicRoughnessPropertiesAsync;
  61103. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  61104. private _createDefaultMaterial;
  61105. /**
  61106. * Creates a Babylon material from a glTF material.
  61107. * @param context The context when loading the asset
  61108. * @param material The glTF material property
  61109. * @param babylonDrawMode The draw mode for the Babylon material
  61110. * @returns The Babylon material
  61111. */
  61112. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  61113. /**
  61114. * Loads properties from a glTF material into a Babylon material.
  61115. * @param context The context when loading the asset
  61116. * @param material The glTF material property
  61117. * @param babylonMaterial The Babylon material
  61118. * @returns A promise that resolves when the load is complete
  61119. */
  61120. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61121. /**
  61122. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  61123. * @param context The context when loading the asset
  61124. * @param material The glTF material property
  61125. * @param babylonMaterial The Babylon material
  61126. * @returns A promise that resolves when the load is complete
  61127. */
  61128. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61129. /**
  61130. * Loads the alpha properties from a glTF material into a Babylon material.
  61131. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  61132. * @param context The context when loading the asset
  61133. * @param material The glTF material property
  61134. * @param babylonMaterial The Babylon material
  61135. */
  61136. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  61137. /**
  61138. * Loads a glTF texture info.
  61139. * @param context The context when loading the asset
  61140. * @param textureInfo The glTF texture info property
  61141. * @param assign A function called synchronously after parsing the glTF properties
  61142. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  61143. */
  61144. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  61145. private _loadTextureAsync;
  61146. private _loadSampler;
  61147. /**
  61148. * Loads a glTF image.
  61149. * @param context The context when loading the asset
  61150. * @param image The glTF image property
  61151. * @returns A promise that resolves with the loaded data when the load is complete
  61152. */
  61153. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  61154. /**
  61155. * Loads a glTF uri.
  61156. * @param context The context when loading the asset
  61157. * @param property The glTF property associated with the uri
  61158. * @param uri The base64 or relative uri
  61159. * @returns A promise that resolves with the loaded data when the load is complete
  61160. */
  61161. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  61162. private _onProgress;
  61163. /**
  61164. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  61165. * @param babylonObject the Babylon object with metadata
  61166. * @param pointer the JSON pointer
  61167. */
  61168. static AddPointerMetadata(babylonObject: {
  61169. metadata: any;
  61170. }, pointer: string): void;
  61171. private static _GetTextureWrapMode;
  61172. private static _GetTextureSamplingMode;
  61173. private static _GetTypedArray;
  61174. private static _GetNumComponents;
  61175. private static _ValidateUri;
  61176. private static _GetDrawMode;
  61177. private _compileMaterialsAsync;
  61178. private _compileShadowGeneratorsAsync;
  61179. private _forEachExtensions;
  61180. private _applyExtensions;
  61181. private _extensionsOnLoading;
  61182. private _extensionsOnReady;
  61183. private _extensionsLoadSceneAsync;
  61184. private _extensionsLoadNodeAsync;
  61185. private _extensionsLoadCameraAsync;
  61186. private _extensionsLoadVertexDataAsync;
  61187. private _extensionsLoadMeshPrimitiveAsync;
  61188. private _extensionsLoadMaterialAsync;
  61189. private _extensionsCreateMaterial;
  61190. private _extensionsLoadMaterialPropertiesAsync;
  61191. private _extensionsLoadTextureInfoAsync;
  61192. private _extensionsLoadAnimationAsync;
  61193. private _extensionsLoadSkinAsync;
  61194. private _extensionsLoadUriAsync;
  61195. /**
  61196. * Helper method called by a loader extension to load an glTF extension.
  61197. * @param context The context when loading the asset
  61198. * @param property The glTF property to load the extension from
  61199. * @param extensionName The name of the extension to load
  61200. * @param actionAsync The action to run
  61201. * @returns The promise returned by actionAsync or null if the extension does not exist
  61202. */
  61203. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61204. /**
  61205. * Helper method called by a loader extension to load a glTF extra.
  61206. * @param context The context when loading the asset
  61207. * @param property The glTF property to load the extra from
  61208. * @param extensionName The name of the extension to load
  61209. * @param actionAsync The action to run
  61210. * @returns The promise returned by actionAsync or null if the extra does not exist
  61211. */
  61212. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61213. /**
  61214. * Increments the indentation level and logs a message.
  61215. * @param message The message to log
  61216. */
  61217. logOpen(message: string): void;
  61218. /**
  61219. * Decrements the indentation level.
  61220. */
  61221. logClose(): void;
  61222. /**
  61223. * Logs a message
  61224. * @param message The message to log
  61225. */
  61226. log(message: string): void;
  61227. /**
  61228. * Starts a performance counter.
  61229. * @param counterName The name of the performance counter
  61230. */
  61231. startPerformanceCounter(counterName: string): void;
  61232. /**
  61233. * Ends a performance counter.
  61234. * @param counterName The name of the performance counter
  61235. */
  61236. endPerformanceCounter(counterName: string): void;
  61237. }
  61238. }
  61239. declare module BABYLON.GLTF2.Loader.Extensions {
  61240. /**
  61241. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  61242. */
  61243. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  61244. /** The name of this extension. */
  61245. readonly name: string;
  61246. /** Defines whether this extension is enabled. */
  61247. enabled: boolean;
  61248. private _loader;
  61249. private _lights?;
  61250. /** @hidden */
  61251. constructor(loader: GLTFLoader);
  61252. /** @hidden */
  61253. dispose(): void;
  61254. /** @hidden */
  61255. onLoading(): void;
  61256. /** @hidden */
  61257. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61258. private _loadLightAsync;
  61259. }
  61260. }
  61261. declare module BABYLON.GLTF2.Loader.Extensions {
  61262. /**
  61263. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  61264. */
  61265. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  61266. /** The name of this extension. */
  61267. readonly name: string;
  61268. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  61269. dracoCompression?: DracoCompression;
  61270. /** Defines whether this extension is enabled. */
  61271. enabled: boolean;
  61272. private _loader;
  61273. /** @hidden */
  61274. constructor(loader: GLTFLoader);
  61275. /** @hidden */
  61276. dispose(): void;
  61277. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  61278. }
  61279. }
  61280. declare module BABYLON.GLTF2.Loader.Extensions {
  61281. /**
  61282. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  61283. */
  61284. export class KHR_lights implements IGLTFLoaderExtension {
  61285. /** The name of this extension. */
  61286. readonly name: string;
  61287. /** Defines whether this extension is enabled. */
  61288. enabled: boolean;
  61289. private _loader;
  61290. private _lights?;
  61291. /** @hidden */
  61292. constructor(loader: GLTFLoader);
  61293. /** @hidden */
  61294. dispose(): void;
  61295. /** @hidden */
  61296. onLoading(): void;
  61297. /** @hidden */
  61298. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61299. }
  61300. }
  61301. declare module BABYLON.GLTF2.Loader.Extensions {
  61302. /**
  61303. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  61304. */
  61305. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  61306. /** The name of this extension. */
  61307. readonly name: string;
  61308. /** Defines whether this extension is enabled. */
  61309. enabled: boolean;
  61310. private _loader;
  61311. /** @hidden */
  61312. constructor(loader: GLTFLoader);
  61313. /** @hidden */
  61314. dispose(): void;
  61315. /** @hidden */
  61316. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61317. private _loadSpecularGlossinessPropertiesAsync;
  61318. }
  61319. }
  61320. declare module BABYLON.GLTF2.Loader.Extensions {
  61321. /**
  61322. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  61323. */
  61324. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  61325. /** The name of this extension. */
  61326. readonly name: string;
  61327. /** Defines whether this extension is enabled. */
  61328. enabled: boolean;
  61329. private _loader;
  61330. /** @hidden */
  61331. constructor(loader: GLTFLoader);
  61332. /** @hidden */
  61333. dispose(): void;
  61334. /** @hidden */
  61335. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61336. private _loadUnlitPropertiesAsync;
  61337. }
  61338. }
  61339. declare module BABYLON.GLTF2.Loader.Extensions {
  61340. /**
  61341. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  61342. */
  61343. export class KHR_texture_transform implements IGLTFLoaderExtension {
  61344. /** The name of this extension. */
  61345. readonly name: string;
  61346. /** Defines whether this extension is enabled. */
  61347. enabled: boolean;
  61348. private _loader;
  61349. /** @hidden */
  61350. constructor(loader: GLTFLoader);
  61351. /** @hidden */
  61352. dispose(): void;
  61353. /** @hidden */
  61354. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  61355. }
  61356. }
  61357. declare module BABYLON.GLTF2.Loader.Extensions {
  61358. /**
  61359. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  61360. */
  61361. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  61362. /** The name of this extension. */
  61363. readonly name: string;
  61364. /** Defines whether this extension is enabled. */
  61365. enabled: boolean;
  61366. private _loader;
  61367. private _clips;
  61368. private _emitters;
  61369. /** @hidden */
  61370. constructor(loader: GLTFLoader);
  61371. /** @hidden */
  61372. dispose(): void;
  61373. /** @hidden */
  61374. onLoading(): void;
  61375. /** @hidden */
  61376. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61377. /** @hidden */
  61378. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61379. /** @hidden */
  61380. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  61381. private _loadClipAsync;
  61382. private _loadEmitterAsync;
  61383. private _getEventAction;
  61384. private _loadAnimationEventAsync;
  61385. }
  61386. }
  61387. declare module BABYLON.GLTF2.Loader.Extensions {
  61388. /**
  61389. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  61390. */
  61391. export class MSFT_lod implements IGLTFLoaderExtension {
  61392. /** The name of this extension. */
  61393. readonly name: string;
  61394. /** Defines whether this extension is enabled. */
  61395. enabled: boolean;
  61396. /**
  61397. * Maximum number of LODs to load, starting from the lowest LOD.
  61398. */
  61399. maxLODsToLoad: number;
  61400. /**
  61401. * Observable raised when all node LODs of one level are loaded.
  61402. * The event data is the index of the loaded LOD starting from zero.
  61403. * Dispose the loader to cancel the loading of the next level of LODs.
  61404. */
  61405. onNodeLODsLoadedObservable: Observable<number>;
  61406. /**
  61407. * Observable raised when all material LODs of one level are loaded.
  61408. * The event data is the index of the loaded LOD starting from zero.
  61409. * Dispose the loader to cancel the loading of the next level of LODs.
  61410. */
  61411. onMaterialLODsLoadedObservable: Observable<number>;
  61412. private _loader;
  61413. private _nodeIndexLOD;
  61414. private _nodeSignalLODs;
  61415. private _nodePromiseLODs;
  61416. private _materialIndexLOD;
  61417. private _materialSignalLODs;
  61418. private _materialPromiseLODs;
  61419. /** @hidden */
  61420. constructor(loader: GLTFLoader);
  61421. /** @hidden */
  61422. dispose(): void;
  61423. /** @hidden */
  61424. onReady(): void;
  61425. /** @hidden */
  61426. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61427. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61428. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61429. /**
  61430. * Gets an array of LOD properties from lowest to highest.
  61431. */
  61432. private _getLODs;
  61433. private _disposeUnusedMaterials;
  61434. }
  61435. }
  61436. declare module BABYLON.GLTF2.Loader.Extensions {
  61437. /** @hidden */
  61438. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61439. readonly name: string;
  61440. enabled: boolean;
  61441. private _loader;
  61442. constructor(loader: GLTFLoader);
  61443. dispose(): void;
  61444. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61445. }
  61446. }
  61447. declare module BABYLON.GLTF2.Loader.Extensions {
  61448. /** @hidden */
  61449. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61450. readonly name: string;
  61451. enabled: boolean;
  61452. private _loader;
  61453. constructor(loader: GLTFLoader);
  61454. dispose(): void;
  61455. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61456. }
  61457. }
  61458. declare module BABYLON {
  61459. /**
  61460. * Class reading and parsing the MTL file bundled with the obj file.
  61461. */
  61462. export class MTLFileLoader {
  61463. /**
  61464. * All material loaded from the mtl will be set here
  61465. */
  61466. materials: StandardMaterial[];
  61467. /**
  61468. * This function will read the mtl file and create each material described inside
  61469. * This function could be improve by adding :
  61470. * -some component missing (Ni, Tf...)
  61471. * -including the specific options available
  61472. *
  61473. * @param scene defines the scene the material will be created in
  61474. * @param data defines the mtl data to parse
  61475. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61476. */
  61477. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61478. /**
  61479. * Gets the texture for the material.
  61480. *
  61481. * If the material is imported from input file,
  61482. * We sanitize the url to ensure it takes the textre from aside the material.
  61483. *
  61484. * @param rootUrl The root url to load from
  61485. * @param value The value stored in the mtl
  61486. * @return The Texture
  61487. */
  61488. private static _getTexture;
  61489. }
  61490. /**
  61491. * Options for loading OBJ/MTL files
  61492. */
  61493. type MeshLoadOptions = {
  61494. /**
  61495. * Defines if UVs are optimized by default during load.
  61496. */
  61497. OptimizeWithUV: boolean;
  61498. /**
  61499. * Defines custom scaling of UV coordinates of loaded meshes.
  61500. */
  61501. UVScaling: Vector2;
  61502. /**
  61503. * Invert model on y-axis (does a model scaling inversion)
  61504. */
  61505. InvertY: boolean;
  61506. /**
  61507. * Invert Y-Axis of referenced textures on load
  61508. */
  61509. InvertTextureY: boolean;
  61510. /**
  61511. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61512. */
  61513. ImportVertexColors: boolean;
  61514. /**
  61515. * Compute the normals for the model, even if normals are present in the file.
  61516. */
  61517. ComputeNormals: boolean;
  61518. /**
  61519. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61520. */
  61521. SkipMaterials: boolean;
  61522. /**
  61523. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61524. */
  61525. MaterialLoadingFailsSilently: boolean;
  61526. };
  61527. /**
  61528. * OBJ file type loader.
  61529. * This is a babylon scene loader plugin.
  61530. */
  61531. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61532. /**
  61533. * Defines if UVs are optimized by default during load.
  61534. */
  61535. static OPTIMIZE_WITH_UV: boolean;
  61536. /**
  61537. * Invert model on y-axis (does a model scaling inversion)
  61538. */
  61539. static INVERT_Y: boolean;
  61540. /**
  61541. * Invert Y-Axis of referenced textures on load
  61542. */
  61543. static INVERT_TEXTURE_Y: boolean;
  61544. /**
  61545. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61546. */
  61547. static IMPORT_VERTEX_COLORS: boolean;
  61548. /**
  61549. * Compute the normals for the model, even if normals are present in the file.
  61550. */
  61551. static COMPUTE_NORMALS: boolean;
  61552. /**
  61553. * Defines custom scaling of UV coordinates of loaded meshes.
  61554. */
  61555. static UV_SCALING: Vector2;
  61556. /**
  61557. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61558. */
  61559. static SKIP_MATERIALS: boolean;
  61560. /**
  61561. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61562. *
  61563. * Defaults to true for backwards compatibility.
  61564. */
  61565. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61566. /**
  61567. * Defines the name of the plugin.
  61568. */
  61569. name: string;
  61570. /**
  61571. * Defines the extension the plugin is able to load.
  61572. */
  61573. extensions: string;
  61574. /** @hidden */
  61575. obj: RegExp;
  61576. /** @hidden */
  61577. group: RegExp;
  61578. /** @hidden */
  61579. mtllib: RegExp;
  61580. /** @hidden */
  61581. usemtl: RegExp;
  61582. /** @hidden */
  61583. smooth: RegExp;
  61584. /** @hidden */
  61585. vertexPattern: RegExp;
  61586. /** @hidden */
  61587. normalPattern: RegExp;
  61588. /** @hidden */
  61589. uvPattern: RegExp;
  61590. /** @hidden */
  61591. facePattern1: RegExp;
  61592. /** @hidden */
  61593. facePattern2: RegExp;
  61594. /** @hidden */
  61595. facePattern3: RegExp;
  61596. /** @hidden */
  61597. facePattern4: RegExp;
  61598. /** @hidden */
  61599. facePattern5: RegExp;
  61600. private _meshLoadOptions;
  61601. /**
  61602. * Creates loader for .OBJ files
  61603. *
  61604. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61605. */
  61606. constructor(meshLoadOptions?: MeshLoadOptions);
  61607. private static readonly currentMeshLoadOptions;
  61608. /**
  61609. * Calls synchronously the MTL file attached to this obj.
  61610. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61611. * Without this function materials are not displayed in the first frame (but displayed after).
  61612. * In consequence it is impossible to get material information in your HTML file
  61613. *
  61614. * @param url The URL of the MTL file
  61615. * @param rootUrl
  61616. * @param onSuccess Callback function to be called when the MTL file is loaded
  61617. * @private
  61618. */
  61619. private _loadMTL;
  61620. /**
  61621. * Instantiates a OBJ file loader plugin.
  61622. * @returns the created plugin
  61623. */
  61624. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61625. /**
  61626. * If the data string can be loaded directly.
  61627. *
  61628. * @param data string containing the file data
  61629. * @returns if the data can be loaded directly
  61630. */
  61631. canDirectLoad(data: string): boolean;
  61632. /**
  61633. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61634. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61635. * @param scene the scene the meshes should be added to
  61636. * @param data the OBJ data to load
  61637. * @param rootUrl root url to load from
  61638. * @param onProgress event that fires when loading progress has occured
  61639. * @param fileName Defines the name of the file to load
  61640. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61641. */
  61642. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61643. meshes: AbstractMesh[];
  61644. particleSystems: IParticleSystem[];
  61645. skeletons: Skeleton[];
  61646. animationGroups: AnimationGroup[];
  61647. }>;
  61648. /**
  61649. * Imports all objects from the loaded OBJ data and adds them to the scene
  61650. * @param scene the scene the objects should be added to
  61651. * @param data the OBJ data to load
  61652. * @param rootUrl root url to load from
  61653. * @param onProgress event that fires when loading progress has occured
  61654. * @param fileName Defines the name of the file to load
  61655. * @returns a promise which completes when objects have been loaded to the scene
  61656. */
  61657. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61658. /**
  61659. * Load into an asset container.
  61660. * @param scene The scene to load into
  61661. * @param data The data to import
  61662. * @param rootUrl The root url for scene and resources
  61663. * @param onProgress The callback when the load progresses
  61664. * @param fileName Defines the name of the file to load
  61665. * @returns The loaded asset container
  61666. */
  61667. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61668. /**
  61669. * Read the OBJ file and create an Array of meshes.
  61670. * Each mesh contains all information given by the OBJ and the MTL file.
  61671. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61672. *
  61673. * @param meshesNames
  61674. * @param scene Scene The scene where are displayed the data
  61675. * @param data String The content of the obj file
  61676. * @param rootUrl String The path to the folder
  61677. * @returns Array<AbstractMesh>
  61678. * @private
  61679. */
  61680. private _parseSolid;
  61681. }
  61682. }
  61683. declare module BABYLON {
  61684. /**
  61685. * STL file type loader.
  61686. * This is a babylon scene loader plugin.
  61687. */
  61688. export class STLFileLoader implements ISceneLoaderPlugin {
  61689. /** @hidden */
  61690. solidPattern: RegExp;
  61691. /** @hidden */
  61692. facetsPattern: RegExp;
  61693. /** @hidden */
  61694. normalPattern: RegExp;
  61695. /** @hidden */
  61696. vertexPattern: RegExp;
  61697. /**
  61698. * Defines the name of the plugin.
  61699. */
  61700. name: string;
  61701. /**
  61702. * Defines the extensions the stl loader is able to load.
  61703. * force data to come in as an ArrayBuffer
  61704. * we'll convert to string if it looks like it's an ASCII .stl
  61705. */
  61706. extensions: ISceneLoaderPluginExtensions;
  61707. /**
  61708. * Import meshes into a scene.
  61709. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61710. * @param scene The scene to import into
  61711. * @param data The data to import
  61712. * @param rootUrl The root url for scene and resources
  61713. * @param meshes The meshes array to import into
  61714. * @param particleSystems The particle systems array to import into
  61715. * @param skeletons The skeletons array to import into
  61716. * @param onError The callback when import fails
  61717. * @returns True if successful or false otherwise
  61718. */
  61719. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61720. /**
  61721. * Load into a scene.
  61722. * @param scene The scene to load into
  61723. * @param data The data to import
  61724. * @param rootUrl The root url for scene and resources
  61725. * @param onError The callback when import fails
  61726. * @returns true if successful or false otherwise
  61727. */
  61728. load(scene: Scene, data: any, rootUrl: string): boolean;
  61729. /**
  61730. * Load into an asset container.
  61731. * @param scene The scene to load into
  61732. * @param data The data to import
  61733. * @param rootUrl The root url for scene and resources
  61734. * @param onError The callback when import fails
  61735. * @returns The loaded asset container
  61736. */
  61737. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61738. private _isBinary;
  61739. private _parseBinary;
  61740. private _parseASCII;
  61741. }
  61742. }
  61743. declare module BABYLON {
  61744. /**
  61745. * Class for generating OBJ data from a Babylon scene.
  61746. */
  61747. export class OBJExport {
  61748. /**
  61749. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61750. * @param mesh defines the list of meshes to serialize
  61751. * @param materials defines if materials should be exported
  61752. * @param matlibname defines the name of the associated mtl file
  61753. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61754. * @returns the OBJ content
  61755. */
  61756. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61757. /**
  61758. * Exports the material(s) of a mesh in .MTL file format (text)
  61759. * @param mesh defines the mesh to extract the material from
  61760. * @returns the mtl content
  61761. */
  61762. static MTL(mesh: Mesh): string;
  61763. }
  61764. }
  61765. declare module BABYLON {
  61766. /** @hidden */
  61767. export var __IGLTFExporterExtension: number;
  61768. /**
  61769. * Interface for extending the exporter
  61770. * @hidden
  61771. */
  61772. export interface IGLTFExporterExtension {
  61773. /**
  61774. * The name of this extension
  61775. */
  61776. readonly name: string;
  61777. /**
  61778. * Defines whether this extension is enabled
  61779. */
  61780. enabled: boolean;
  61781. /**
  61782. * Defines whether this extension is required
  61783. */
  61784. required: boolean;
  61785. }
  61786. }
  61787. declare module BABYLON.GLTF2.Exporter {
  61788. /** @hidden */
  61789. export var __IGLTFExporterExtensionV2: number;
  61790. /**
  61791. * Interface for a glTF exporter extension
  61792. * @hidden
  61793. */
  61794. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61795. /**
  61796. * Define this method to modify the default behavior before exporting a texture
  61797. * @param context The context when loading the asset
  61798. * @param babylonTexture The glTF texture info property
  61799. * @param mimeType The mime-type of the generated image
  61800. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61801. */
  61802. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61803. /**
  61804. * Define this method to modify the default behavior when exporting texture info
  61805. * @param context The context when loading the asset
  61806. * @param meshPrimitive glTF mesh primitive
  61807. * @param babylonSubMesh Babylon submesh
  61808. * @param binaryWriter glTF serializer binary writer instance
  61809. * @returns nullable IMeshPrimitive promise
  61810. */
  61811. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61812. /**
  61813. * Define this method to modify the default behavior when exporting a node
  61814. * @param context The context when exporting the node
  61815. * @param node glTF node
  61816. * @param babylonNode BabylonJS node
  61817. * @returns nullable INode promise
  61818. */
  61819. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61820. /**
  61821. * Called after the exporter state changes to EXPORTING
  61822. */
  61823. onExporting?(): void;
  61824. }
  61825. }
  61826. declare module BABYLON.GLTF2.Exporter {
  61827. /**
  61828. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61829. * @hidden
  61830. */
  61831. export class _GLTFMaterialExporter {
  61832. /**
  61833. * Represents the dielectric specular values for R, G and B
  61834. */
  61835. private static readonly _DielectricSpecular;
  61836. /**
  61837. * Allows the maximum specular power to be defined for material calculations
  61838. */
  61839. private static readonly _MaxSpecularPower;
  61840. /**
  61841. * Mapping to store textures
  61842. */
  61843. private _textureMap;
  61844. /**
  61845. * Numeric tolerance value
  61846. */
  61847. private static readonly _Epsilon;
  61848. /**
  61849. * Reference to the glTF Exporter
  61850. */
  61851. private _exporter;
  61852. constructor(exporter: _Exporter);
  61853. /**
  61854. * Specifies if two colors are approximately equal in value
  61855. * @param color1 first color to compare to
  61856. * @param color2 second color to compare to
  61857. * @param epsilon threshold value
  61858. */
  61859. private static FuzzyEquals;
  61860. /**
  61861. * Gets the materials from a Babylon scene and converts them to glTF materials
  61862. * @param scene babylonjs scene
  61863. * @param mimeType texture mime type
  61864. * @param images array of images
  61865. * @param textures array of textures
  61866. * @param materials array of materials
  61867. * @param imageData mapping of texture names to base64 textures
  61868. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61869. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61870. /**
  61871. * Makes a copy of the glTF material without the texture parameters
  61872. * @param originalMaterial original glTF material
  61873. * @returns glTF material without texture parameters
  61874. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61875. /**
  61876. * Specifies if the material has any texture parameters present
  61877. * @param material glTF Material
  61878. * @returns boolean specifying if texture parameters are present
  61879. */ hasTexturesPresent(material: IMaterial): boolean;
  61880. /**
  61881. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61882. * @param babylonStandardMaterial
  61883. * @returns glTF Metallic Roughness Material representation
  61884. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61885. /**
  61886. * Computes the metallic factor
  61887. * @param diffuse diffused value
  61888. * @param specular specular value
  61889. * @param oneMinusSpecularStrength one minus the specular strength
  61890. * @returns metallic value
  61891. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61892. /**
  61893. * Gets the glTF alpha mode from the Babylon Material
  61894. * @param babylonMaterial Babylon Material
  61895. * @returns The Babylon alpha mode value
  61896. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61897. /**
  61898. * Converts a Babylon Standard Material to a glTF Material
  61899. * @param babylonStandardMaterial BJS Standard Material
  61900. * @param mimeType mime type to use for the textures
  61901. * @param images array of glTF image interfaces
  61902. * @param textures array of glTF texture interfaces
  61903. * @param materials array of glTF material interfaces
  61904. * @param imageData map of image file name to data
  61905. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61906. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61907. /**
  61908. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61909. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61910. * @param mimeType mime type to use for the textures
  61911. * @param images array of glTF image interfaces
  61912. * @param textures array of glTF texture interfaces
  61913. * @param materials array of glTF material interfaces
  61914. * @param imageData map of image file name to data
  61915. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61916. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61917. /**
  61918. * Converts an image typed array buffer to a base64 image
  61919. * @param buffer typed array buffer
  61920. * @param width width of the image
  61921. * @param height height of the image
  61922. * @param mimeType mimetype of the image
  61923. * @returns base64 image string
  61924. */
  61925. private _createBase64FromCanvasAsync;
  61926. /**
  61927. * Generates a white texture based on the specified width and height
  61928. * @param width width of the texture in pixels
  61929. * @param height height of the texture in pixels
  61930. * @param scene babylonjs scene
  61931. * @returns white texture
  61932. */
  61933. private _createWhiteTexture;
  61934. /**
  61935. * 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
  61936. * @param texture1 first texture to resize
  61937. * @param texture2 second texture to resize
  61938. * @param scene babylonjs scene
  61939. * @returns resized textures or null
  61940. */
  61941. private _resizeTexturesToSameDimensions;
  61942. /**
  61943. * Converts an array of pixels to a Float32Array
  61944. * Throws an error if the pixel format is not supported
  61945. * @param pixels - array buffer containing pixel values
  61946. * @returns Float32 of pixels
  61947. */
  61948. private _convertPixelArrayToFloat32;
  61949. /**
  61950. * Convert Specular Glossiness Textures to Metallic Roughness
  61951. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61952. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61953. * @param diffuseTexture texture used to store diffuse information
  61954. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61955. * @param factors specular glossiness material factors
  61956. * @param mimeType the mime type to use for the texture
  61957. * @returns pbr metallic roughness interface or null
  61958. */
  61959. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61960. /**
  61961. * Converts specular glossiness material properties to metallic roughness
  61962. * @param specularGlossiness interface with specular glossiness material properties
  61963. * @returns interface with metallic roughness material properties
  61964. */
  61965. private _convertSpecularGlossinessToMetallicRoughness;
  61966. /**
  61967. * Calculates the surface reflectance, independent of lighting conditions
  61968. * @param color Color source to calculate brightness from
  61969. * @returns number representing the perceived brightness, or zero if color is undefined
  61970. */
  61971. private _getPerceivedBrightness;
  61972. /**
  61973. * Returns the maximum color component value
  61974. * @param color
  61975. * @returns maximum color component value, or zero if color is null or undefined
  61976. */
  61977. private _getMaxComponent;
  61978. /**
  61979. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61980. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61981. * @param mimeType mime type to use for the textures
  61982. * @param images array of glTF image interfaces
  61983. * @param textures array of glTF texture interfaces
  61984. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61985. * @param imageData map of image file name to data
  61986. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61987. * @returns glTF PBR Metallic Roughness factors
  61988. */
  61989. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61990. private _getGLTFTextureSampler;
  61991. private _getGLTFTextureWrapMode;
  61992. private _getGLTFTextureWrapModesSampler;
  61993. /**
  61994. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61995. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61996. * @param mimeType mime type to use for the textures
  61997. * @param images array of glTF image interfaces
  61998. * @param textures array of glTF texture interfaces
  61999. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  62000. * @param imageData map of image file name to data
  62001. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62002. * @returns glTF PBR Metallic Roughness factors
  62003. */
  62004. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  62005. /**
  62006. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  62007. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  62008. * @param mimeType mime type to use for the textures
  62009. * @param images array of glTF image interfaces
  62010. * @param textures array of glTF texture interfaces
  62011. * @param materials array of glTF material interfaces
  62012. * @param imageData map of image file name to data
  62013. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62014. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  62015. private setMetallicRoughnessPbrMaterial;
  62016. private getPixelsFromTexture;
  62017. /**
  62018. * Extracts a texture from a Babylon texture into file data and glTF data
  62019. * @param babylonTexture Babylon texture to extract
  62020. * @param mimeType Mime Type of the babylonTexture
  62021. * @return glTF texture info, or null if the texture format is not supported
  62022. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  62023. /**
  62024. * Builds a texture from base64 string
  62025. * @param base64Texture base64 texture string
  62026. * @param baseTextureName Name to use for the texture
  62027. * @param mimeType image mime type for the texture
  62028. * @param images array of images
  62029. * @param textures array of textures
  62030. * @param imageData map of image data
  62031. * @returns glTF texture info, or null if the texture format is not supported
  62032. */
  62033. private _getTextureInfoFromBase64;
  62034. }
  62035. }
  62036. declare module BABYLON {
  62037. /**
  62038. * Class for holding and downloading glTF file data
  62039. */
  62040. export class GLTFData {
  62041. /**
  62042. * Object which contains the file name as the key and its data as the value
  62043. */
  62044. glTFFiles: {
  62045. [fileName: string]: string | Blob;
  62046. };
  62047. /**
  62048. * Initializes the glTF file object
  62049. */
  62050. constructor();
  62051. /**
  62052. * Downloads the glTF data as files based on their names and data
  62053. */
  62054. downloadFiles(): void;
  62055. }
  62056. }
  62057. declare module BABYLON {
  62058. /**
  62059. * Holds a collection of exporter options and parameters
  62060. */
  62061. export interface IExportOptions {
  62062. /**
  62063. * Function which indicates whether a babylon node should be exported or not
  62064. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  62065. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  62066. */
  62067. shouldExportNode?(node: Node): boolean;
  62068. /**
  62069. * The sample rate to bake animation curves
  62070. */
  62071. animationSampleRate?: number;
  62072. /**
  62073. * Begin serialization without waiting for the scene to be ready
  62074. */
  62075. exportWithoutWaitingForScene?: boolean;
  62076. }
  62077. /**
  62078. * Class for generating glTF data from a Babylon scene.
  62079. */
  62080. export class GLTF2Export {
  62081. /**
  62082. * Exports the geometry of the scene to .gltf file format asynchronously
  62083. * @param scene Babylon scene with scene hierarchy information
  62084. * @param filePrefix File prefix to use when generating the glTF file
  62085. * @param options Exporter options
  62086. * @returns Returns an object with a .gltf file and associates texture names
  62087. * as keys and their data and paths as values
  62088. */
  62089. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62090. private static _PreExportAsync;
  62091. private static _PostExportAsync;
  62092. /**
  62093. * Exports the geometry of the scene to .glb file format asychronously
  62094. * @param scene Babylon scene with scene hierarchy information
  62095. * @param filePrefix File prefix to use when generating glb file
  62096. * @param options Exporter options
  62097. * @returns Returns an object with a .glb filename as key and data as value
  62098. */
  62099. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62100. }
  62101. }
  62102. declare module BABYLON.GLTF2.Exporter {
  62103. /**
  62104. * @hidden
  62105. */
  62106. export class _GLTFUtilities {
  62107. /**
  62108. * Creates a buffer view based on the supplied arguments
  62109. * @param bufferIndex index value of the specified buffer
  62110. * @param byteOffset byte offset value
  62111. * @param byteLength byte length of the bufferView
  62112. * @param byteStride byte distance between conequential elements
  62113. * @param name name of the buffer view
  62114. * @returns bufferView for glTF
  62115. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  62116. /**
  62117. * Creates an accessor based on the supplied arguments
  62118. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  62119. * @param name The name of the accessor
  62120. * @param type The type of the accessor
  62121. * @param componentType The datatype of components in the attribute
  62122. * @param count The number of attributes referenced by this accessor
  62123. * @param byteOffset The offset relative to the start of the bufferView in bytes
  62124. * @param min Minimum value of each component in this attribute
  62125. * @param max Maximum value of each component in this attribute
  62126. * @returns accessor for glTF
  62127. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  62128. /**
  62129. * Calculates the minimum and maximum values of an array of position floats
  62130. * @param positions Positions array of a mesh
  62131. * @param vertexStart Starting vertex offset to calculate min and max values
  62132. * @param vertexCount Number of vertices to check for min and max values
  62133. * @returns min number array and max number array
  62134. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  62135. min: number[];
  62136. max: number[];
  62137. };
  62138. /**
  62139. * Converts a new right-handed Vector3
  62140. * @param vector vector3 array
  62141. * @returns right-handed Vector3
  62142. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  62143. /**
  62144. * Converts a Vector3 to right-handed
  62145. * @param vector Vector3 to convert to right-handed
  62146. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  62147. /**
  62148. * Converts a three element number array to right-handed
  62149. * @param vector number array to convert to right-handed
  62150. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  62151. /**
  62152. * Converts a new right-handed Vector3
  62153. * @param vector vector3 array
  62154. * @returns right-handed Vector3
  62155. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  62156. /**
  62157. * Converts a Vector3 to right-handed
  62158. * @param vector Vector3 to convert to right-handed
  62159. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  62160. /**
  62161. * Converts a three element number array to right-handed
  62162. * @param vector number array to convert to right-handed
  62163. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  62164. /**
  62165. * Converts a Vector4 to right-handed
  62166. * @param vector Vector4 to convert to right-handed
  62167. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  62168. /**
  62169. * Converts a Vector4 to right-handed
  62170. * @param vector Vector4 to convert to right-handed
  62171. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  62172. /**
  62173. * Converts a Quaternion to right-handed
  62174. * @param quaternion Source quaternion to convert to right-handed
  62175. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  62176. /**
  62177. * Converts a Quaternion to right-handed
  62178. * @param quaternion Source quaternion to convert to right-handed
  62179. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  62180. }
  62181. }
  62182. declare module BABYLON.GLTF2.Exporter {
  62183. /**
  62184. * Converts Babylon Scene into glTF 2.0.
  62185. * @hidden
  62186. */
  62187. export class _Exporter {
  62188. /**
  62189. * Stores the glTF to export
  62190. */ glTF: IGLTF;
  62191. /**
  62192. * Stores all generated buffer views, which represents views into the main glTF buffer data
  62193. */ bufferViews: IBufferView[];
  62194. /**
  62195. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  62196. */ accessors: IAccessor[];
  62197. /**
  62198. * Stores all the generated nodes, which contains transform and/or mesh information per node
  62199. */
  62200. private _nodes;
  62201. /**
  62202. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  62203. */
  62204. private _scenes;
  62205. /**
  62206. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  62207. */
  62208. private _meshes;
  62209. /**
  62210. * Stores all the generated material information, which represents the appearance of each primitive
  62211. */ materials: IMaterial[]; materialMap: {
  62212. [materialID: number]: number;
  62213. };
  62214. /**
  62215. * Stores all the generated texture information, which is referenced by glTF materials
  62216. */ textures: ITexture[];
  62217. /**
  62218. * Stores all the generated image information, which is referenced by glTF textures
  62219. */ images: IImage[];
  62220. /**
  62221. * Stores all the texture samplers
  62222. */ samplers: ISampler[];
  62223. /**
  62224. * Stores all the generated animation samplers, which is referenced by glTF animations
  62225. */
  62226. /**
  62227. * Stores the animations for glTF models
  62228. */
  62229. private _animations;
  62230. /**
  62231. * Stores the total amount of bytes stored in the glTF buffer
  62232. */
  62233. private _totalByteLength;
  62234. /**
  62235. * Stores a reference to the Babylon scene containing the source geometry and material information
  62236. */ babylonScene: Scene;
  62237. /**
  62238. * Stores a map of the image data, where the key is the file name and the value
  62239. * is the image data
  62240. */ imageData: {
  62241. [fileName: string]: {
  62242. data: Uint8Array;
  62243. mimeType: ImageMimeType;
  62244. };
  62245. };
  62246. /**
  62247. * Stores a map of the unique id of a node to its index in the node array
  62248. */
  62249. private _nodeMap;
  62250. /**
  62251. * Specifies if the Babylon scene should be converted to right-handed on export
  62252. */ convertToRightHandedSystem: boolean;
  62253. /**
  62254. * Baked animation sample rate
  62255. */
  62256. private _animationSampleRate;
  62257. /**
  62258. * Callback which specifies if a node should be exported or not
  62259. */
  62260. private _shouldExportNode;
  62261. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  62262. private _extensions;
  62263. private static _ExtensionNames;
  62264. private static _ExtensionFactories;
  62265. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62266. private _forEachExtensions;
  62267. private _extensionsOnExporting;
  62268. /**
  62269. * Load glTF serializer extensions
  62270. */
  62271. private _loadExtensions;
  62272. /**
  62273. * Creates a glTF Exporter instance, which can accept optional exporter options
  62274. * @param babylonScene Babylon scene object
  62275. * @param options Options to modify the behavior of the exporter
  62276. */
  62277. constructor(babylonScene: Scene, options?: IExportOptions);
  62278. /**
  62279. * Registers a glTF exporter extension
  62280. * @param name Name of the extension to export
  62281. * @param factory The factory function that creates the exporter extension
  62282. */
  62283. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  62284. /**
  62285. * Un-registers an exporter extension
  62286. * @param name The name fo the exporter extension
  62287. * @returns A boolean indicating whether the extension has been un-registered
  62288. */
  62289. static UnregisterExtension(name: string): boolean;
  62290. /**
  62291. * Lazy load a local engine with premultiplied alpha set to false
  62292. */ getLocalEngine(): Engine;
  62293. private reorderIndicesBasedOnPrimitiveMode;
  62294. /**
  62295. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  62296. * clock-wise during export to glTF
  62297. * @param submesh BabylonJS submesh
  62298. * @param primitiveMode Primitive mode of the mesh
  62299. * @param sideOrientation the winding order of the submesh
  62300. * @param vertexBufferKind The type of vertex attribute
  62301. * @param meshAttributeArray The vertex attribute data
  62302. * @param byteOffset The offset to the binary data
  62303. * @param binaryWriter The binary data for the glTF file
  62304. */
  62305. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  62306. /**
  62307. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  62308. * clock-wise during export to glTF
  62309. * @param submesh BabylonJS submesh
  62310. * @param primitiveMode Primitive mode of the mesh
  62311. * @param sideOrientation the winding order of the submesh
  62312. * @param vertexBufferKind The type of vertex attribute
  62313. * @param meshAttributeArray The vertex attribute data
  62314. * @param byteOffset The offset to the binary data
  62315. * @param binaryWriter The binary data for the glTF file
  62316. */
  62317. private reorderTriangleFillMode;
  62318. /**
  62319. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  62320. * clock-wise during export to glTF
  62321. * @param submesh BabylonJS submesh
  62322. * @param primitiveMode Primitive mode of the mesh
  62323. * @param sideOrientation the winding order of the submesh
  62324. * @param vertexBufferKind The type of vertex attribute
  62325. * @param meshAttributeArray The vertex attribute data
  62326. * @param byteOffset The offset to the binary data
  62327. * @param binaryWriter The binary data for the glTF file
  62328. */
  62329. private reorderTriangleStripDrawMode;
  62330. /**
  62331. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  62332. * clock-wise during export to glTF
  62333. * @param submesh BabylonJS submesh
  62334. * @param primitiveMode Primitive mode of the mesh
  62335. * @param sideOrientation the winding order of the submesh
  62336. * @param vertexBufferKind The type of vertex attribute
  62337. * @param meshAttributeArray The vertex attribute data
  62338. * @param byteOffset The offset to the binary data
  62339. * @param binaryWriter The binary data for the glTF file
  62340. */
  62341. private reorderTriangleFanMode;
  62342. /**
  62343. * Writes the vertex attribute data to binary
  62344. * @param vertices The vertices to write to the binary writer
  62345. * @param byteOffset The offset into the binary writer to overwrite binary data
  62346. * @param vertexAttributeKind The vertex attribute type
  62347. * @param meshAttributeArray The vertex attribute data
  62348. * @param binaryWriter The writer containing the binary data
  62349. */
  62350. private writeVertexAttributeData;
  62351. /**
  62352. * Writes mesh attribute data to a data buffer
  62353. * Returns the bytelength of the data
  62354. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  62355. * @param meshAttributeArray Array containing the attribute data
  62356. * @param binaryWriter The buffer to write the binary data to
  62357. * @param indices Used to specify the order of the vertex data
  62358. */
  62359. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  62360. /**
  62361. * Generates glTF json data
  62362. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  62363. * @param glTFPrefix Text to use when prefixing a glTF file
  62364. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  62365. * @returns json data as string
  62366. */
  62367. private generateJSON;
  62368. /**
  62369. * Generates data for .gltf and .bin files based on the glTF prefix string
  62370. * @param glTFPrefix Text to use when prefixing a glTF file
  62371. * @returns GLTFData with glTF file data
  62372. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  62373. /**
  62374. * Creates a binary buffer for glTF
  62375. * @returns array buffer for binary data
  62376. */
  62377. private _generateBinaryAsync;
  62378. /**
  62379. * Pads the number to a multiple of 4
  62380. * @param num number to pad
  62381. * @returns padded number
  62382. */
  62383. private _getPadding;
  62384. /**
  62385. * Generates a glb file from the json and binary data
  62386. * Returns an object with the glb file name as the key and data as the value
  62387. * @param glTFPrefix
  62388. * @returns object with glb filename as key and data as value
  62389. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  62390. /**
  62391. * Sets the TRS for each node
  62392. * @param node glTF Node for storing the transformation data
  62393. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  62394. */
  62395. private setNodeTransformation;
  62396. private getVertexBufferFromMesh;
  62397. /**
  62398. * Creates a bufferview based on the vertices type for the Babylon mesh
  62399. * @param kind Indicates the type of vertices data
  62400. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  62401. * @param binaryWriter The buffer to write the bufferview data to
  62402. */
  62403. private createBufferViewKind;
  62404. /**
  62405. * The primitive mode of the Babylon mesh
  62406. * @param babylonMesh The BabylonJS mesh
  62407. */
  62408. private getMeshPrimitiveMode;
  62409. /**
  62410. * Sets the primitive mode of the glTF mesh primitive
  62411. * @param meshPrimitive glTF mesh primitive
  62412. * @param primitiveMode The primitive mode
  62413. */
  62414. private setPrimitiveMode;
  62415. /**
  62416. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62417. * @param meshPrimitive glTF mesh primitive
  62418. * @param attributeKind vertex attribute
  62419. * @returns boolean specifying if uv coordinates are present
  62420. */
  62421. private setAttributeKind;
  62422. /**
  62423. * Sets data for the primitive attributes of each submesh
  62424. * @param mesh glTF Mesh object to store the primitive attribute information
  62425. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62426. * @param binaryWriter Buffer to write the attribute data to
  62427. */
  62428. private setPrimitiveAttributesAsync;
  62429. /**
  62430. * Creates a glTF scene based on the array of meshes
  62431. * Returns the the total byte offset
  62432. * @param babylonScene Babylon scene to get the mesh data from
  62433. * @param binaryWriter Buffer to write binary data to
  62434. */
  62435. private createSceneAsync;
  62436. /**
  62437. * Creates a mapping of Node unique id to node index and handles animations
  62438. * @param babylonScene Babylon Scene
  62439. * @param nodes Babylon transform nodes
  62440. * @param shouldExportNode Callback specifying if a transform node should be exported
  62441. * @param binaryWriter Buffer to write binary data to
  62442. * @returns Node mapping of unique id to index
  62443. */
  62444. private createNodeMapAndAnimationsAsync;
  62445. /**
  62446. * Creates a glTF node from a Babylon mesh
  62447. * @param babylonMesh Source Babylon mesh
  62448. * @param binaryWriter Buffer for storing geometry data
  62449. * @returns glTF node
  62450. */
  62451. private createNodeAsync;
  62452. }
  62453. /**
  62454. * @hidden
  62455. *
  62456. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62457. */
  62458. export class _BinaryWriter {
  62459. /**
  62460. * Array buffer which stores all binary data
  62461. */
  62462. private _arrayBuffer;
  62463. /**
  62464. * View of the array buffer
  62465. */
  62466. private _dataView;
  62467. /**
  62468. * byte offset of data in array buffer
  62469. */
  62470. private _byteOffset;
  62471. /**
  62472. * Initialize binary writer with an initial byte length
  62473. * @param byteLength Initial byte length of the array buffer
  62474. */
  62475. constructor(byteLength: number);
  62476. /**
  62477. * Resize the array buffer to the specified byte length
  62478. * @param byteLength
  62479. */
  62480. private resizeBuffer;
  62481. /**
  62482. * Get an array buffer with the length of the byte offset
  62483. * @returns ArrayBuffer resized to the byte offset
  62484. */
  62485. getArrayBuffer(): ArrayBuffer;
  62486. /**
  62487. * Get the byte offset of the array buffer
  62488. * @returns byte offset
  62489. */
  62490. getByteOffset(): number;
  62491. /**
  62492. * Stores an UInt8 in the array buffer
  62493. * @param entry
  62494. * @param byteOffset If defined, specifies where to set the value as an offset.
  62495. */
  62496. setUInt8(entry: number, byteOffset?: number): void;
  62497. /**
  62498. * Gets an UInt32 in the array buffer
  62499. * @param entry
  62500. * @param byteOffset If defined, specifies where to set the value as an offset.
  62501. */
  62502. getUInt32(byteOffset: number): number;
  62503. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62504. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62505. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62506. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62507. /**
  62508. * Stores a Float32 in the array buffer
  62509. * @param entry
  62510. */
  62511. setFloat32(entry: number, byteOffset?: number): void;
  62512. /**
  62513. * Stores an UInt32 in the array buffer
  62514. * @param entry
  62515. * @param byteOffset If defined, specifies where to set the value as an offset.
  62516. */
  62517. setUInt32(entry: number, byteOffset?: number): void;
  62518. }
  62519. }
  62520. declare module BABYLON.GLTF2.Exporter {
  62521. /**
  62522. * @hidden
  62523. * Interface to store animation data.
  62524. */
  62525. export interface _IAnimationData {
  62526. /**
  62527. * Keyframe data.
  62528. */
  62529. inputs: number[];
  62530. /**
  62531. * Value data.
  62532. */
  62533. outputs: number[][];
  62534. /**
  62535. * Animation interpolation data.
  62536. */
  62537. samplerInterpolation: AnimationSamplerInterpolation;
  62538. /**
  62539. * Minimum keyframe value.
  62540. */
  62541. inputsMin: number;
  62542. /**
  62543. * Maximum keyframe value.
  62544. */
  62545. inputsMax: number;
  62546. }
  62547. /**
  62548. * @hidden
  62549. */
  62550. export interface _IAnimationInfo {
  62551. /**
  62552. * The target channel for the animation
  62553. */
  62554. animationChannelTargetPath: AnimationChannelTargetPath;
  62555. /**
  62556. * The glTF accessor type for the data.
  62557. */
  62558. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62559. /**
  62560. * Specifies if quaternions should be used.
  62561. */
  62562. useQuaternion: boolean;
  62563. }
  62564. /**
  62565. * @hidden
  62566. * Utility class for generating glTF animation data from BabylonJS.
  62567. */
  62568. export class _GLTFAnimation {
  62569. /**
  62570. * @ignore
  62571. *
  62572. * Creates glTF channel animation from BabylonJS animation.
  62573. * @param babylonTransformNode - BabylonJS mesh.
  62574. * @param animation - animation.
  62575. * @param animationChannelTargetPath - The target animation channel.
  62576. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62577. * @param useQuaternion - Specifies if quaternions are used.
  62578. * @returns nullable IAnimationData
  62579. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62580. private static _DeduceAnimationInfo;
  62581. /**
  62582. * @ignore
  62583. * Create node animations from the transform node animations
  62584. * @param babylonNode
  62585. * @param runtimeGLTFAnimation
  62586. * @param idleGLTFAnimations
  62587. * @param nodeMap
  62588. * @param nodes
  62589. * @param binaryWriter
  62590. * @param bufferViews
  62591. * @param accessors
  62592. * @param convertToRightHandedSystem
  62593. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62594. [key: number]: number;
  62595. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62596. /**
  62597. * @ignore
  62598. * Create node animations from the animation groups
  62599. * @param babylonScene
  62600. * @param glTFAnimations
  62601. * @param nodeMap
  62602. * @param nodes
  62603. * @param binaryWriter
  62604. * @param bufferViews
  62605. * @param accessors
  62606. * @param convertToRightHandedSystem
  62607. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62608. [key: number]: number;
  62609. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62610. private static AddAnimation;
  62611. /**
  62612. * Create a baked animation
  62613. * @param babylonTransformNode BabylonJS mesh
  62614. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62615. * @param animationChannelTargetPath animation target channel
  62616. * @param minFrame minimum animation frame
  62617. * @param maxFrame maximum animation frame
  62618. * @param fps frames per second of the animation
  62619. * @param inputs input key frames of the animation
  62620. * @param outputs output key frame data of the animation
  62621. * @param convertToRightHandedSystem converts the values to right-handed
  62622. * @param useQuaternion specifies if quaternions should be used
  62623. */
  62624. private static _CreateBakedAnimation;
  62625. private static _ConvertFactorToVector3OrQuaternion;
  62626. private static _SetInterpolatedValue;
  62627. /**
  62628. * Creates linear animation from the animation key frames
  62629. * @param babylonTransformNode BabylonJS mesh
  62630. * @param animation BabylonJS animation
  62631. * @param animationChannelTargetPath The target animation channel
  62632. * @param frameDelta The difference between the last and first frame of the animation
  62633. * @param inputs Array to store the key frame times
  62634. * @param outputs Array to store the key frame data
  62635. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62636. * @param useQuaternion Specifies if quaternions are used in the animation
  62637. */
  62638. private static _CreateLinearOrStepAnimation;
  62639. /**
  62640. * Creates cubic spline animation from the animation key frames
  62641. * @param babylonTransformNode BabylonJS mesh
  62642. * @param animation BabylonJS animation
  62643. * @param animationChannelTargetPath The target animation channel
  62644. * @param frameDelta The difference between the last and first frame of the animation
  62645. * @param inputs Array to store the key frame times
  62646. * @param outputs Array to store the key frame data
  62647. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62648. * @param useQuaternion Specifies if quaternions are used in the animation
  62649. */
  62650. private static _CreateCubicSplineAnimation;
  62651. private static _GetBasePositionRotationOrScale;
  62652. /**
  62653. * Adds a key frame value
  62654. * @param keyFrame
  62655. * @param animation
  62656. * @param outputs
  62657. * @param animationChannelTargetPath
  62658. * @param basePositionRotationOrScale
  62659. * @param convertToRightHandedSystem
  62660. * @param useQuaternion
  62661. */
  62662. private static _AddKeyframeValue;
  62663. /**
  62664. * Determine the interpolation based on the key frames
  62665. * @param keyFrames
  62666. * @param animationChannelTargetPath
  62667. * @param useQuaternion
  62668. */
  62669. private static _DeduceInterpolation;
  62670. /**
  62671. * Adds an input tangent or output tangent to the output data
  62672. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62673. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62674. * @param outputs The animation data by keyframe
  62675. * @param animationChannelTargetPath The target animation channel
  62676. * @param interpolation The interpolation type
  62677. * @param keyFrame The key frame with the animation data
  62678. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62679. * @param useQuaternion Specifies if quaternions are used
  62680. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62681. */
  62682. private static AddSplineTangent;
  62683. /**
  62684. * Get the minimum and maximum key frames' frame values
  62685. * @param keyFrames animation key frames
  62686. * @returns the minimum and maximum key frame value
  62687. */
  62688. private static calculateMinMaxKeyFrames;
  62689. }
  62690. }
  62691. declare module BABYLON.GLTF2.Exporter {
  62692. /** @hidden */
  62693. export var textureTransformPixelShader: {
  62694. name: string;
  62695. shader: string;
  62696. };
  62697. }
  62698. declare module BABYLON.GLTF2.Exporter.Extensions {
  62699. /**
  62700. * @hidden
  62701. */
  62702. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62703. /** Name of this extension */
  62704. readonly name: string;
  62705. /** Defines whether this extension is enabled */
  62706. enabled: boolean;
  62707. /** Defines whether this extension is required */
  62708. required: boolean;
  62709. /** Reference to the glTF exporter */
  62710. private _exporter;
  62711. constructor(exporter: _Exporter);
  62712. dispose(): void;
  62713. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62714. /**
  62715. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62716. * @param babylonTexture
  62717. * @param offset
  62718. * @param rotation
  62719. * @param scale
  62720. * @param scene
  62721. */
  62722. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62723. }
  62724. }
  62725. declare module BABYLON.GLTF2.Exporter.Extensions {
  62726. /**
  62727. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62728. */
  62729. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62730. /** The name of this extension. */
  62731. readonly name: string;
  62732. /** Defines whether this extension is enabled. */
  62733. enabled: boolean;
  62734. /** Defines whether this extension is required */
  62735. required: boolean;
  62736. /** Reference to the glTF exporter */
  62737. private _exporter;
  62738. private _lights;
  62739. /** @hidden */
  62740. constructor(exporter: _Exporter);
  62741. /** @hidden */
  62742. dispose(): void;
  62743. /** @hidden */
  62744. onExporting(): void;
  62745. /**
  62746. * Define this method to modify the default behavior when exporting a node
  62747. * @param context The context when exporting the node
  62748. * @param node glTF node
  62749. * @param babylonNode BabylonJS node
  62750. * @returns nullable INode promise
  62751. */
  62752. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62753. }
  62754. }
  62755. declare module BABYLON {
  62756. /**
  62757. * Class for generating STL data from a Babylon scene.
  62758. */
  62759. export class STLExport {
  62760. /**
  62761. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62762. * @param meshes list defines the mesh to serialize
  62763. * @param download triggers the automatic download of the file.
  62764. * @param fileName changes the downloads fileName.
  62765. * @param binary changes the STL to a binary type.
  62766. * @param isLittleEndian toggle for binary type exporter.
  62767. * @returns the STL as UTF8 string
  62768. */
  62769. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62770. }
  62771. }
  62772. /**
  62773. * @ignoreChildren
  62774. * @ignore
  62775. */
  62776. declare module "babylonjs-gltf2interface" {
  62777. export = BABYLON.GLTF2;
  62778. }
  62779. /**
  62780. * Module for glTF 2.0 Interface
  62781. * @ignoreChildren
  62782. * @ignore
  62783. */
  62784. declare module BABYLON.GLTF2 {
  62785. /**
  62786. * The datatype of the components in the attribute
  62787. */
  62788. const enum AccessorComponentType {
  62789. /**
  62790. * Byte
  62791. */
  62792. BYTE = 5120,
  62793. /**
  62794. * Unsigned Byte
  62795. */
  62796. UNSIGNED_BYTE = 5121,
  62797. /**
  62798. * Short
  62799. */
  62800. SHORT = 5122,
  62801. /**
  62802. * Unsigned Short
  62803. */
  62804. UNSIGNED_SHORT = 5123,
  62805. /**
  62806. * Unsigned Int
  62807. */
  62808. UNSIGNED_INT = 5125,
  62809. /**
  62810. * Float
  62811. */
  62812. FLOAT = 5126,
  62813. }
  62814. /**
  62815. * Specifies if the attirbute is a scalar, vector, or matrix
  62816. */
  62817. const enum AccessorType {
  62818. /**
  62819. * Scalar
  62820. */
  62821. SCALAR = "SCALAR",
  62822. /**
  62823. * Vector2
  62824. */
  62825. VEC2 = "VEC2",
  62826. /**
  62827. * Vector3
  62828. */
  62829. VEC3 = "VEC3",
  62830. /**
  62831. * Vector4
  62832. */
  62833. VEC4 = "VEC4",
  62834. /**
  62835. * Matrix2x2
  62836. */
  62837. MAT2 = "MAT2",
  62838. /**
  62839. * Matrix3x3
  62840. */
  62841. MAT3 = "MAT3",
  62842. /**
  62843. * Matrix4x4
  62844. */
  62845. MAT4 = "MAT4",
  62846. }
  62847. /**
  62848. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62849. */
  62850. const enum AnimationChannelTargetPath {
  62851. /**
  62852. * Translation
  62853. */
  62854. TRANSLATION = "translation",
  62855. /**
  62856. * Rotation
  62857. */
  62858. ROTATION = "rotation",
  62859. /**
  62860. * Scale
  62861. */
  62862. SCALE = "scale",
  62863. /**
  62864. * Weights
  62865. */
  62866. WEIGHTS = "weights",
  62867. }
  62868. /**
  62869. * Interpolation algorithm
  62870. */
  62871. const enum AnimationSamplerInterpolation {
  62872. /**
  62873. * The animated values are linearly interpolated between keyframes
  62874. */
  62875. LINEAR = "LINEAR",
  62876. /**
  62877. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62878. */
  62879. STEP = "STEP",
  62880. /**
  62881. * The animation's interpolation is computed using a cubic spline with specified tangents
  62882. */
  62883. CUBICSPLINE = "CUBICSPLINE",
  62884. }
  62885. /**
  62886. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62887. */
  62888. const enum CameraType {
  62889. /**
  62890. * A perspective camera containing properties to create a perspective projection matrix
  62891. */
  62892. PERSPECTIVE = "perspective",
  62893. /**
  62894. * An orthographic camera containing properties to create an orthographic projection matrix
  62895. */
  62896. ORTHOGRAPHIC = "orthographic",
  62897. }
  62898. /**
  62899. * The mime-type of the image
  62900. */
  62901. const enum ImageMimeType {
  62902. /**
  62903. * JPEG Mime-type
  62904. */
  62905. JPEG = "image/jpeg",
  62906. /**
  62907. * PNG Mime-type
  62908. */
  62909. PNG = "image/png",
  62910. }
  62911. /**
  62912. * The alpha rendering mode of the material
  62913. */
  62914. const enum MaterialAlphaMode {
  62915. /**
  62916. * The alpha value is ignored and the rendered output is fully opaque
  62917. */
  62918. OPAQUE = "OPAQUE",
  62919. /**
  62920. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62921. */
  62922. MASK = "MASK",
  62923. /**
  62924. * 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)
  62925. */
  62926. BLEND = "BLEND",
  62927. }
  62928. /**
  62929. * The type of the primitives to render
  62930. */
  62931. const enum MeshPrimitiveMode {
  62932. /**
  62933. * Points
  62934. */
  62935. POINTS = 0,
  62936. /**
  62937. * Lines
  62938. */
  62939. LINES = 1,
  62940. /**
  62941. * Line Loop
  62942. */
  62943. LINE_LOOP = 2,
  62944. /**
  62945. * Line Strip
  62946. */
  62947. LINE_STRIP = 3,
  62948. /**
  62949. * Triangles
  62950. */
  62951. TRIANGLES = 4,
  62952. /**
  62953. * Triangle Strip
  62954. */
  62955. TRIANGLE_STRIP = 5,
  62956. /**
  62957. * Triangle Fan
  62958. */
  62959. TRIANGLE_FAN = 6,
  62960. }
  62961. /**
  62962. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62963. */
  62964. const enum TextureMagFilter {
  62965. /**
  62966. * Nearest
  62967. */
  62968. NEAREST = 9728,
  62969. /**
  62970. * Linear
  62971. */
  62972. LINEAR = 9729,
  62973. }
  62974. /**
  62975. * Minification filter. All valid values correspond to WebGL enums
  62976. */
  62977. const enum TextureMinFilter {
  62978. /**
  62979. * Nearest
  62980. */
  62981. NEAREST = 9728,
  62982. /**
  62983. * Linear
  62984. */
  62985. LINEAR = 9729,
  62986. /**
  62987. * Nearest Mip-Map Nearest
  62988. */
  62989. NEAREST_MIPMAP_NEAREST = 9984,
  62990. /**
  62991. * Linear Mipmap Nearest
  62992. */
  62993. LINEAR_MIPMAP_NEAREST = 9985,
  62994. /**
  62995. * Nearest Mipmap Linear
  62996. */
  62997. NEAREST_MIPMAP_LINEAR = 9986,
  62998. /**
  62999. * Linear Mipmap Linear
  63000. */
  63001. LINEAR_MIPMAP_LINEAR = 9987,
  63002. }
  63003. /**
  63004. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63005. */
  63006. const enum TextureWrapMode {
  63007. /**
  63008. * Clamp to Edge
  63009. */
  63010. CLAMP_TO_EDGE = 33071,
  63011. /**
  63012. * Mirrored Repeat
  63013. */
  63014. MIRRORED_REPEAT = 33648,
  63015. /**
  63016. * Repeat
  63017. */
  63018. REPEAT = 10497,
  63019. }
  63020. /**
  63021. * glTF Property
  63022. */
  63023. interface IProperty {
  63024. /**
  63025. * Dictionary object with extension-specific objects
  63026. */
  63027. extensions?: {
  63028. [key: string]: any;
  63029. };
  63030. /**
  63031. * Application-Specific data
  63032. */
  63033. extras?: any;
  63034. }
  63035. /**
  63036. * glTF Child of Root Property
  63037. */
  63038. interface IChildRootProperty extends IProperty {
  63039. /**
  63040. * The user-defined name of this object
  63041. */
  63042. name?: string;
  63043. }
  63044. /**
  63045. * Indices of those attributes that deviate from their initialization value
  63046. */
  63047. interface IAccessorSparseIndices extends IProperty {
  63048. /**
  63049. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63050. */
  63051. bufferView: number;
  63052. /**
  63053. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63054. */
  63055. byteOffset?: number;
  63056. /**
  63057. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  63058. */
  63059. componentType: AccessorComponentType;
  63060. }
  63061. /**
  63062. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  63063. */
  63064. interface IAccessorSparseValues extends IProperty {
  63065. /**
  63066. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63067. */
  63068. bufferView: number;
  63069. /**
  63070. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63071. */
  63072. byteOffset?: number;
  63073. }
  63074. /**
  63075. * Sparse storage of attributes that deviate from their initialization value
  63076. */
  63077. interface IAccessorSparse extends IProperty {
  63078. /**
  63079. * The number of attributes encoded in this sparse accessor
  63080. */
  63081. count: number;
  63082. /**
  63083. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  63084. */
  63085. indices: IAccessorSparseIndices;
  63086. /**
  63087. * 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
  63088. */
  63089. values: IAccessorSparseValues;
  63090. }
  63091. /**
  63092. * 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
  63093. */
  63094. interface IAccessor extends IChildRootProperty {
  63095. /**
  63096. * The index of the bufferview
  63097. */
  63098. bufferView?: number;
  63099. /**
  63100. * The offset relative to the start of the bufferView in bytes
  63101. */
  63102. byteOffset?: number;
  63103. /**
  63104. * The datatype of components in the attribute
  63105. */
  63106. componentType: AccessorComponentType;
  63107. /**
  63108. * Specifies whether integer data values should be normalized
  63109. */
  63110. normalized?: boolean;
  63111. /**
  63112. * The number of attributes referenced by this accessor
  63113. */
  63114. count: number;
  63115. /**
  63116. * Specifies if the attribute is a scalar, vector, or matrix
  63117. */
  63118. type: AccessorType;
  63119. /**
  63120. * Maximum value of each component in this attribute
  63121. */
  63122. max?: number[];
  63123. /**
  63124. * Minimum value of each component in this attribute
  63125. */
  63126. min?: number[];
  63127. /**
  63128. * Sparse storage of attributes that deviate from their initialization value
  63129. */
  63130. sparse?: IAccessorSparse;
  63131. }
  63132. /**
  63133. * Targets an animation's sampler at a node's property
  63134. */
  63135. interface IAnimationChannel extends IProperty {
  63136. /**
  63137. * The index of a sampler in this animation used to compute the value for the target
  63138. */
  63139. sampler: number;
  63140. /**
  63141. * The index of the node and TRS property to target
  63142. */
  63143. target: IAnimationChannelTarget;
  63144. }
  63145. /**
  63146. * The index of the node and TRS property that an animation channel targets
  63147. */
  63148. interface IAnimationChannelTarget extends IProperty {
  63149. /**
  63150. * The index of the node to target
  63151. */
  63152. node: number;
  63153. /**
  63154. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  63155. */
  63156. path: AnimationChannelTargetPath;
  63157. }
  63158. /**
  63159. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63160. */
  63161. interface IAnimationSampler extends IProperty {
  63162. /**
  63163. * The index of an accessor containing keyframe input values, e.g., time
  63164. */
  63165. input: number;
  63166. /**
  63167. * Interpolation algorithm
  63168. */
  63169. interpolation?: AnimationSamplerInterpolation;
  63170. /**
  63171. * The index of an accessor, containing keyframe output values
  63172. */
  63173. output: number;
  63174. }
  63175. /**
  63176. * A keyframe animation
  63177. */
  63178. interface IAnimation extends IChildRootProperty {
  63179. /**
  63180. * An array of channels, each of which targets an animation's sampler at a node's property
  63181. */
  63182. channels: IAnimationChannel[];
  63183. /**
  63184. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63185. */
  63186. samplers: IAnimationSampler[];
  63187. }
  63188. /**
  63189. * Metadata about the glTF asset
  63190. */
  63191. interface IAsset extends IChildRootProperty {
  63192. /**
  63193. * A copyright message suitable for display to credit the content creator
  63194. */
  63195. copyright?: string;
  63196. /**
  63197. * Tool that generated this glTF model. Useful for debugging
  63198. */
  63199. generator?: string;
  63200. /**
  63201. * The glTF version that this asset targets
  63202. */
  63203. version: string;
  63204. /**
  63205. * The minimum glTF version that this asset targets
  63206. */
  63207. minVersion?: string;
  63208. }
  63209. /**
  63210. * A buffer points to binary geometry, animation, or skins
  63211. */
  63212. interface IBuffer extends IChildRootProperty {
  63213. /**
  63214. * 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
  63215. */
  63216. uri?: string;
  63217. /**
  63218. * The length of the buffer in bytes
  63219. */
  63220. byteLength: number;
  63221. }
  63222. /**
  63223. * A view into a buffer generally representing a subset of the buffer
  63224. */
  63225. interface IBufferView extends IChildRootProperty {
  63226. /**
  63227. * The index of the buffer
  63228. */
  63229. buffer: number;
  63230. /**
  63231. * The offset into the buffer in bytes
  63232. */
  63233. byteOffset?: number;
  63234. /**
  63235. * The lenth of the bufferView in bytes
  63236. */
  63237. byteLength: number;
  63238. /**
  63239. * The stride, in bytes
  63240. */
  63241. byteStride?: number;
  63242. }
  63243. /**
  63244. * An orthographic camera containing properties to create an orthographic projection matrix
  63245. */
  63246. interface ICameraOrthographic extends IProperty {
  63247. /**
  63248. * The floating-point horizontal magnification of the view. Must not be zero
  63249. */
  63250. xmag: number;
  63251. /**
  63252. * The floating-point vertical magnification of the view. Must not be zero
  63253. */
  63254. ymag: number;
  63255. /**
  63256. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  63257. */
  63258. zfar: number;
  63259. /**
  63260. * The floating-point distance to the near clipping plane
  63261. */
  63262. znear: number;
  63263. }
  63264. /**
  63265. * A perspective camera containing properties to create a perspective projection matrix
  63266. */
  63267. interface ICameraPerspective extends IProperty {
  63268. /**
  63269. * The floating-point aspect ratio of the field of view
  63270. */
  63271. aspectRatio?: number;
  63272. /**
  63273. * The floating-point vertical field of view in radians
  63274. */
  63275. yfov: number;
  63276. /**
  63277. * The floating-point distance to the far clipping plane
  63278. */
  63279. zfar?: number;
  63280. /**
  63281. * The floating-point distance to the near clipping plane
  63282. */
  63283. znear: number;
  63284. }
  63285. /**
  63286. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  63287. */
  63288. interface ICamera extends IChildRootProperty {
  63289. /**
  63290. * An orthographic camera containing properties to create an orthographic projection matrix
  63291. */
  63292. orthographic?: ICameraOrthographic;
  63293. /**
  63294. * A perspective camera containing properties to create a perspective projection matrix
  63295. */
  63296. perspective?: ICameraPerspective;
  63297. /**
  63298. * Specifies if the camera uses a perspective or orthographic projection
  63299. */
  63300. type: CameraType;
  63301. }
  63302. /**
  63303. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  63304. */
  63305. interface IImage extends IChildRootProperty {
  63306. /**
  63307. * 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
  63308. */
  63309. uri?: string;
  63310. /**
  63311. * The image's MIME type
  63312. */
  63313. mimeType?: ImageMimeType;
  63314. /**
  63315. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  63316. */
  63317. bufferView?: number;
  63318. }
  63319. /**
  63320. * Material Normal Texture Info
  63321. */
  63322. interface IMaterialNormalTextureInfo extends ITextureInfo {
  63323. /**
  63324. * The scalar multiplier applied to each normal vector of the normal texture
  63325. */
  63326. scale?: number;
  63327. }
  63328. /**
  63329. * Material Occlusion Texture Info
  63330. */
  63331. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  63332. /**
  63333. * A scalar multiplier controlling the amount of occlusion applied
  63334. */
  63335. strength?: number;
  63336. }
  63337. /**
  63338. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  63339. */
  63340. interface IMaterialPbrMetallicRoughness {
  63341. /**
  63342. * The material's base color factor
  63343. */
  63344. baseColorFactor?: number[];
  63345. /**
  63346. * The base color texture
  63347. */
  63348. baseColorTexture?: ITextureInfo;
  63349. /**
  63350. * The metalness of the material
  63351. */
  63352. metallicFactor?: number;
  63353. /**
  63354. * The roughness of the material
  63355. */
  63356. roughnessFactor?: number;
  63357. /**
  63358. * The metallic-roughness texture
  63359. */
  63360. metallicRoughnessTexture?: ITextureInfo;
  63361. }
  63362. /**
  63363. * The material appearance of a primitive
  63364. */
  63365. interface IMaterial extends IChildRootProperty {
  63366. /**
  63367. * 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
  63368. */
  63369. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63370. /**
  63371. * The normal map texture
  63372. */
  63373. normalTexture?: IMaterialNormalTextureInfo;
  63374. /**
  63375. * The occlusion map texture
  63376. */
  63377. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63378. /**
  63379. * The emissive map texture
  63380. */
  63381. emissiveTexture?: ITextureInfo;
  63382. /**
  63383. * 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
  63384. */
  63385. emissiveFactor?: number[];
  63386. /**
  63387. * The alpha rendering mode of the material
  63388. */
  63389. alphaMode?: MaterialAlphaMode;
  63390. /**
  63391. * The alpha cutoff value of the material
  63392. */
  63393. alphaCutoff?: number;
  63394. /**
  63395. * Specifies whether the material is double sided
  63396. */
  63397. doubleSided?: boolean;
  63398. }
  63399. /**
  63400. * Geometry to be rendered with the given material
  63401. */
  63402. interface IMeshPrimitive extends IProperty {
  63403. /**
  63404. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  63405. */
  63406. attributes: {
  63407. [name: string]: number;
  63408. };
  63409. /**
  63410. * The index of the accessor that contains the indices
  63411. */
  63412. indices?: number;
  63413. /**
  63414. * The index of the material to apply to this primitive when rendering
  63415. */
  63416. material?: number;
  63417. /**
  63418. * The type of primitives to render. All valid values correspond to WebGL enums
  63419. */
  63420. mode?: MeshPrimitiveMode;
  63421. /**
  63422. * 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
  63423. */
  63424. targets?: {
  63425. [name: string]: number;
  63426. }[];
  63427. }
  63428. /**
  63429. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63430. */
  63431. interface IMesh extends IChildRootProperty {
  63432. /**
  63433. * An array of primitives, each defining geometry to be rendered with a material
  63434. */
  63435. primitives: IMeshPrimitive[];
  63436. /**
  63437. * Array of weights to be applied to the Morph Targets
  63438. */
  63439. weights?: number[];
  63440. }
  63441. /**
  63442. * A node in the node hierarchy
  63443. */
  63444. interface INode extends IChildRootProperty {
  63445. /**
  63446. * The index of the camera referenced by this node
  63447. */
  63448. camera?: number;
  63449. /**
  63450. * The indices of this node's children
  63451. */
  63452. children?: number[];
  63453. /**
  63454. * The index of the skin referenced by this node
  63455. */
  63456. skin?: number;
  63457. /**
  63458. * A floating-point 4x4 transformation matrix stored in column-major order
  63459. */
  63460. matrix?: number[];
  63461. /**
  63462. * The index of the mesh in this node
  63463. */
  63464. mesh?: number;
  63465. /**
  63466. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63467. */
  63468. rotation?: number[];
  63469. /**
  63470. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63471. */
  63472. scale?: number[];
  63473. /**
  63474. * The node's translation along the x, y, and z axes
  63475. */
  63476. translation?: number[];
  63477. /**
  63478. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63479. */
  63480. weights?: number[];
  63481. }
  63482. /**
  63483. * Texture sampler properties for filtering and wrapping modes
  63484. */
  63485. interface ISampler extends IChildRootProperty {
  63486. /**
  63487. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63488. */
  63489. magFilter?: TextureMagFilter;
  63490. /**
  63491. * Minification filter. All valid values correspond to WebGL enums
  63492. */
  63493. minFilter?: TextureMinFilter;
  63494. /**
  63495. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63496. */
  63497. wrapS?: TextureWrapMode;
  63498. /**
  63499. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63500. */
  63501. wrapT?: TextureWrapMode;
  63502. }
  63503. /**
  63504. * The root nodes of a scene
  63505. */
  63506. interface IScene extends IChildRootProperty {
  63507. /**
  63508. * The indices of each root node
  63509. */
  63510. nodes: number[];
  63511. }
  63512. /**
  63513. * Joints and matrices defining a skin
  63514. */
  63515. interface ISkin extends IChildRootProperty {
  63516. /**
  63517. * 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
  63518. */
  63519. inverseBindMatrices?: number;
  63520. /**
  63521. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63522. */
  63523. skeleton?: number;
  63524. /**
  63525. * 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)
  63526. */
  63527. joints: number[];
  63528. }
  63529. /**
  63530. * A texture and its sampler
  63531. */
  63532. interface ITexture extends IChildRootProperty {
  63533. /**
  63534. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63535. */
  63536. sampler?: number;
  63537. /**
  63538. * The index of the image used by this texture
  63539. */
  63540. source: number;
  63541. }
  63542. /**
  63543. * Reference to a texture
  63544. */
  63545. interface ITextureInfo extends IProperty {
  63546. /**
  63547. * The index of the texture
  63548. */
  63549. index: number;
  63550. /**
  63551. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63552. */
  63553. texCoord?: number;
  63554. }
  63555. /**
  63556. * The root object for a glTF asset
  63557. */
  63558. interface IGLTF extends IProperty {
  63559. /**
  63560. * An array of accessors. An accessor is a typed view into a bufferView
  63561. */
  63562. accessors?: IAccessor[];
  63563. /**
  63564. * An array of keyframe animations
  63565. */
  63566. animations?: IAnimation[];
  63567. /**
  63568. * Metadata about the glTF asset
  63569. */
  63570. asset: IAsset;
  63571. /**
  63572. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63573. */
  63574. buffers?: IBuffer[];
  63575. /**
  63576. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63577. */
  63578. bufferViews?: IBufferView[];
  63579. /**
  63580. * An array of cameras
  63581. */
  63582. cameras?: ICamera[];
  63583. /**
  63584. * Names of glTF extensions used somewhere in this asset
  63585. */
  63586. extensionsUsed?: string[];
  63587. /**
  63588. * Names of glTF extensions required to properly load this asset
  63589. */
  63590. extensionsRequired?: string[];
  63591. /**
  63592. * An array of images. An image defines data used to create a texture
  63593. */
  63594. images?: IImage[];
  63595. /**
  63596. * An array of materials. A material defines the appearance of a primitive
  63597. */
  63598. materials?: IMaterial[];
  63599. /**
  63600. * An array of meshes. A mesh is a set of primitives to be rendered
  63601. */
  63602. meshes?: IMesh[];
  63603. /**
  63604. * An array of nodes
  63605. */
  63606. nodes?: INode[];
  63607. /**
  63608. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63609. */
  63610. samplers?: ISampler[];
  63611. /**
  63612. * The index of the default scene
  63613. */
  63614. scene?: number;
  63615. /**
  63616. * An array of scenes
  63617. */
  63618. scenes?: IScene[];
  63619. /**
  63620. * An array of skins. A skin is defined by joints and matrices
  63621. */
  63622. skins?: ISkin[];
  63623. /**
  63624. * An array of textures
  63625. */
  63626. textures?: ITexture[];
  63627. }
  63628. /**
  63629. * Interface for glTF validation results
  63630. */
  63631. interface IGLTFValidationResults {
  63632. info: {
  63633. generator: string;
  63634. hasAnimations: boolean;
  63635. hasDefaultScene: boolean;
  63636. hasMaterials: boolean;
  63637. hasMorphTargets: boolean;
  63638. hasSkins: boolean;
  63639. hasTextures: boolean;
  63640. maxAttributesUsed: number;
  63641. primitivesCount: number
  63642. };
  63643. issues: {
  63644. messages: Array<string>;
  63645. numErrors: number;
  63646. numHints: number;
  63647. numInfos: number;
  63648. numWarnings: number;
  63649. truncated: boolean
  63650. };
  63651. mimeType: string;
  63652. uri: string;
  63653. validatedAt: string;
  63654. validatorVersion: string;
  63655. }
  63656. /**
  63657. * Interface for glTF validation options
  63658. */
  63659. interface IGLTFValidationOptions {
  63660. uri?: string;
  63661. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63662. validateAccessorData?: boolean;
  63663. maxIssues?: number;
  63664. ignoredIssues?: Array<string>;
  63665. severityOverrides?: Object;
  63666. }
  63667. /**
  63668. * glTF validator object Tyyings
  63669. */
  63670. interface IGLTFValidatorTypings {
  63671. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63672. }
  63673. }
  63674. /**
  63675. * Interface for glTF validation results
  63676. */
  63677. interface IGLTFValidationResults {
  63678. info: {
  63679. generator: string;
  63680. hasAnimations: boolean;
  63681. hasDefaultScene: boolean;
  63682. hasMaterials: boolean;
  63683. hasMorphTargets: boolean;
  63684. hasSkins: boolean;
  63685. hasTextures: boolean;
  63686. maxAttributesUsed: number;
  63687. primitivesCount: number
  63688. };
  63689. issues: {
  63690. messages: Array<string>;
  63691. numErrors: number;
  63692. numHints: number;
  63693. numInfos: number;
  63694. numWarnings: number;
  63695. truncated: boolean
  63696. };
  63697. mimeType: string;
  63698. uri: string;
  63699. validatedAt: string;
  63700. validatorVersion: string;
  63701. }
  63702. /**
  63703. * Interface for glTF validation options
  63704. */
  63705. interface IGLTFValidationOptions {
  63706. uri?: string;
  63707. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63708. validateAccessorData?: boolean;
  63709. maxIssues?: number;
  63710. ignoredIssues?: Array<string>;
  63711. severityOverrides?: Object;
  63712. }
  63713. /**
  63714. * glTF validator object Tyyings
  63715. */
  63716. interface IGLTFValidatorTypings {
  63717. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63718. }
  63719. declare module BABYLON {
  63720. /** @hidden */
  63721. export var cellPixelShader: {
  63722. name: string;
  63723. shader: string;
  63724. };
  63725. }
  63726. declare module BABYLON {
  63727. /** @hidden */
  63728. export var cellVertexShader: {
  63729. name: string;
  63730. shader: string;
  63731. };
  63732. }
  63733. declare module BABYLON {
  63734. export class CellMaterial extends BABYLON.PushMaterial {
  63735. private _diffuseTexture;
  63736. diffuseTexture: BABYLON.BaseTexture;
  63737. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63738. computeHighLevel: boolean;
  63739. private _disableLighting;
  63740. disableLighting: boolean;
  63741. private _maxSimultaneousLights;
  63742. maxSimultaneousLights: number;
  63743. private _renderId;
  63744. constructor(name: string, scene: BABYLON.Scene);
  63745. needAlphaBlending(): boolean;
  63746. needAlphaTesting(): boolean;
  63747. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63748. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63749. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63750. getAnimatables(): BABYLON.IAnimatable[];
  63751. getActiveTextures(): BABYLON.BaseTexture[];
  63752. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63753. dispose(forceDisposeEffect?: boolean): void;
  63754. getClassName(): string;
  63755. clone(name: string): CellMaterial;
  63756. serialize(): any;
  63757. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63758. }
  63759. }
  63760. declare module BABYLON {
  63761. export class CustomShaderStructure {
  63762. FragmentStore: string;
  63763. VertexStore: string;
  63764. constructor();
  63765. }
  63766. export class ShaderSpecialParts {
  63767. constructor();
  63768. Fragment_Begin: string;
  63769. Fragment_Definitions: string;
  63770. Fragment_MainBegin: string;
  63771. Fragment_Custom_Diffuse: string;
  63772. Fragment_Before_Lights: string;
  63773. Fragment_Before_Fog: string;
  63774. Fragment_Custom_Alpha: string;
  63775. Fragment_Before_FragColor: string;
  63776. Vertex_Begin: string;
  63777. Vertex_Definitions: string;
  63778. Vertex_MainBegin: string;
  63779. Vertex_Before_PositionUpdated: string;
  63780. Vertex_Before_NormalUpdated: string;
  63781. Vertex_MainEnd: string;
  63782. }
  63783. export class CustomMaterial extends BABYLON.StandardMaterial {
  63784. static ShaderIndexer: number;
  63785. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63786. FragmentShader: string;
  63787. VertexShader: string;
  63788. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63789. ReviewUniform(name: string, arr: string[]): string[];
  63790. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63791. constructor(name: string, scene: BABYLON.Scene);
  63792. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63793. Fragment_Begin(shaderPart: string): CustomMaterial;
  63794. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63795. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63796. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63797. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63798. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63799. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63800. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63801. Vertex_Begin(shaderPart: string): CustomMaterial;
  63802. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63803. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63804. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63805. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63806. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63807. }
  63808. }
  63809. declare module BABYLON {
  63810. export class ShaderAlebdoParts {
  63811. constructor();
  63812. Fragment_Begin: string;
  63813. Fragment_Definitions: string;
  63814. Fragment_MainBegin: string;
  63815. Fragment_Custom_Albedo: string;
  63816. Fragment_Before_Lights: string;
  63817. Fragment_Custom_MetallicRoughness: string;
  63818. Fragment_Custom_MicroSurface: string;
  63819. Fragment_Before_Fog: string;
  63820. Fragment_Custom_Alpha: string;
  63821. Fragment_Before_FragColor: string;
  63822. Vertex_Begin: string;
  63823. Vertex_Definitions: string;
  63824. Vertex_MainBegin: string;
  63825. Vertex_Before_PositionUpdated: string;
  63826. Vertex_Before_NormalUpdated: string;
  63827. Vertex_MainEnd: string;
  63828. }
  63829. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63830. static ShaderIndexer: number;
  63831. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63832. FragmentShader: string;
  63833. VertexShader: string;
  63834. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63835. ReviewUniform(name: string, arr: string[]): string[];
  63836. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63837. constructor(name: string, scene: BABYLON.Scene);
  63838. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63839. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63840. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63841. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63842. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63843. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63844. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63845. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  63846. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  63847. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63848. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63849. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63850. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63851. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63852. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63853. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63854. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63855. }
  63856. }
  63857. declare module BABYLON {
  63858. /** @hidden */
  63859. export var firePixelShader: {
  63860. name: string;
  63861. shader: string;
  63862. };
  63863. }
  63864. declare module BABYLON {
  63865. /** @hidden */
  63866. export var fireVertexShader: {
  63867. name: string;
  63868. shader: string;
  63869. };
  63870. }
  63871. declare module BABYLON {
  63872. export class FireMaterial extends BABYLON.PushMaterial {
  63873. private _diffuseTexture;
  63874. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63875. private _distortionTexture;
  63876. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63877. private _opacityTexture;
  63878. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63879. diffuseColor: BABYLON.Color3;
  63880. speed: number;
  63881. private _scaledDiffuse;
  63882. private _renderId;
  63883. private _lastTime;
  63884. constructor(name: string, scene: BABYLON.Scene);
  63885. needAlphaBlending(): boolean;
  63886. needAlphaTesting(): boolean;
  63887. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63888. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63889. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63890. getAnimatables(): BABYLON.IAnimatable[];
  63891. getActiveTextures(): BABYLON.BaseTexture[];
  63892. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63893. getClassName(): string;
  63894. dispose(forceDisposeEffect?: boolean): void;
  63895. clone(name: string): FireMaterial;
  63896. serialize(): any;
  63897. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63898. }
  63899. }
  63900. declare module BABYLON {
  63901. /** @hidden */
  63902. export var furPixelShader: {
  63903. name: string;
  63904. shader: string;
  63905. };
  63906. }
  63907. declare module BABYLON {
  63908. /** @hidden */
  63909. export var furVertexShader: {
  63910. name: string;
  63911. shader: string;
  63912. };
  63913. }
  63914. declare module BABYLON {
  63915. export class FurMaterial extends BABYLON.PushMaterial {
  63916. private _diffuseTexture;
  63917. diffuseTexture: BABYLON.BaseTexture;
  63918. private _heightTexture;
  63919. heightTexture: BABYLON.BaseTexture;
  63920. diffuseColor: BABYLON.Color3;
  63921. furLength: number;
  63922. furAngle: number;
  63923. furColor: BABYLON.Color3;
  63924. furOffset: number;
  63925. furSpacing: number;
  63926. furGravity: BABYLON.Vector3;
  63927. furSpeed: number;
  63928. furDensity: number;
  63929. furOcclusion: number;
  63930. furTexture: BABYLON.DynamicTexture;
  63931. private _disableLighting;
  63932. disableLighting: boolean;
  63933. private _maxSimultaneousLights;
  63934. maxSimultaneousLights: number;
  63935. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63936. private _renderId;
  63937. private _furTime;
  63938. constructor(name: string, scene: BABYLON.Scene);
  63939. furTime: number;
  63940. needAlphaBlending(): boolean;
  63941. needAlphaTesting(): boolean;
  63942. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63943. updateFur(): void;
  63944. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63945. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63946. getAnimatables(): BABYLON.IAnimatable[];
  63947. getActiveTextures(): BABYLON.BaseTexture[];
  63948. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63949. dispose(forceDisposeEffect?: boolean): void;
  63950. clone(name: string): FurMaterial;
  63951. serialize(): any;
  63952. getClassName(): string;
  63953. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63954. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63955. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63956. }
  63957. }
  63958. declare module BABYLON {
  63959. /** @hidden */
  63960. export var gradientPixelShader: {
  63961. name: string;
  63962. shader: string;
  63963. };
  63964. }
  63965. declare module BABYLON {
  63966. /** @hidden */
  63967. export var gradientVertexShader: {
  63968. name: string;
  63969. shader: string;
  63970. };
  63971. }
  63972. declare module BABYLON {
  63973. export class GradientMaterial extends BABYLON.PushMaterial {
  63974. private _maxSimultaneousLights;
  63975. maxSimultaneousLights: number;
  63976. topColor: BABYLON.Color3;
  63977. topColorAlpha: number;
  63978. bottomColor: BABYLON.Color3;
  63979. bottomColorAlpha: number;
  63980. offset: number;
  63981. scale: number;
  63982. smoothness: number;
  63983. private _disableLighting;
  63984. disableLighting: boolean;
  63985. private _renderId;
  63986. constructor(name: string, scene: BABYLON.Scene);
  63987. needAlphaBlending(): boolean;
  63988. needAlphaTesting(): boolean;
  63989. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63990. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63991. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63992. getAnimatables(): BABYLON.IAnimatable[];
  63993. dispose(forceDisposeEffect?: boolean): void;
  63994. clone(name: string): GradientMaterial;
  63995. serialize(): any;
  63996. getClassName(): string;
  63997. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63998. }
  63999. }
  64000. declare module BABYLON {
  64001. /** @hidden */
  64002. export var gridPixelShader: {
  64003. name: string;
  64004. shader: string;
  64005. };
  64006. }
  64007. declare module BABYLON {
  64008. /** @hidden */
  64009. export var gridVertexShader: {
  64010. name: string;
  64011. shader: string;
  64012. };
  64013. }
  64014. declare module BABYLON {
  64015. /**
  64016. * The grid materials allows you to wrap any shape with a grid.
  64017. * Colors are customizable.
  64018. */
  64019. export class GridMaterial extends BABYLON.PushMaterial {
  64020. /**
  64021. * Main color of the grid (e.g. between lines)
  64022. */
  64023. mainColor: BABYLON.Color3;
  64024. /**
  64025. * Color of the grid lines.
  64026. */
  64027. lineColor: BABYLON.Color3;
  64028. /**
  64029. * The scale of the grid compared to unit.
  64030. */
  64031. gridRatio: number;
  64032. /**
  64033. * Allows setting an offset for the grid lines.
  64034. */
  64035. gridOffset: BABYLON.Vector3;
  64036. /**
  64037. * The frequency of thicker lines.
  64038. */
  64039. majorUnitFrequency: number;
  64040. /**
  64041. * The visibility of minor units in the grid.
  64042. */
  64043. minorUnitVisibility: number;
  64044. /**
  64045. * The grid opacity outside of the lines.
  64046. */
  64047. opacity: number;
  64048. /**
  64049. * Determine RBG output is premultiplied by alpha value.
  64050. */
  64051. preMultiplyAlpha: boolean;
  64052. private _opacityTexture;
  64053. opacityTexture: BABYLON.BaseTexture;
  64054. private _gridControl;
  64055. private _renderId;
  64056. /**
  64057. * constructor
  64058. * @param name The name given to the material in order to identify it afterwards.
  64059. * @param scene The scene the material is used in.
  64060. */
  64061. constructor(name: string, scene: BABYLON.Scene);
  64062. /**
  64063. * Returns wehter or not the grid requires alpha blending.
  64064. */
  64065. needAlphaBlending(): boolean;
  64066. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64067. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64068. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64069. /**
  64070. * Dispose the material and its associated resources.
  64071. * @param forceDisposeEffect will also dispose the used effect when true
  64072. */
  64073. dispose(forceDisposeEffect?: boolean): void;
  64074. clone(name: string): GridMaterial;
  64075. serialize(): any;
  64076. getClassName(): string;
  64077. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. /** @hidden */
  64082. export var lavaPixelShader: {
  64083. name: string;
  64084. shader: string;
  64085. };
  64086. }
  64087. declare module BABYLON {
  64088. /** @hidden */
  64089. export var lavaVertexShader: {
  64090. name: string;
  64091. shader: string;
  64092. };
  64093. }
  64094. declare module BABYLON {
  64095. export class LavaMaterial extends BABYLON.PushMaterial {
  64096. private _diffuseTexture;
  64097. diffuseTexture: BABYLON.BaseTexture;
  64098. noiseTexture: BABYLON.BaseTexture;
  64099. fogColor: BABYLON.Color3;
  64100. speed: number;
  64101. movingSpeed: number;
  64102. lowFrequencySpeed: number;
  64103. fogDensity: number;
  64104. private _lastTime;
  64105. diffuseColor: BABYLON.Color3;
  64106. private _disableLighting;
  64107. disableLighting: boolean;
  64108. private _unlit;
  64109. unlit: boolean;
  64110. private _maxSimultaneousLights;
  64111. maxSimultaneousLights: number;
  64112. private _scaledDiffuse;
  64113. private _renderId;
  64114. constructor(name: string, scene: BABYLON.Scene);
  64115. needAlphaBlending(): boolean;
  64116. needAlphaTesting(): boolean;
  64117. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64118. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64119. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64120. getAnimatables(): BABYLON.IAnimatable[];
  64121. getActiveTextures(): BABYLON.BaseTexture[];
  64122. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64123. dispose(forceDisposeEffect?: boolean): void;
  64124. clone(name: string): LavaMaterial;
  64125. serialize(): any;
  64126. getClassName(): string;
  64127. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  64128. }
  64129. }
  64130. declare module BABYLON {
  64131. /** @hidden */
  64132. export var mixPixelShader: {
  64133. name: string;
  64134. shader: string;
  64135. };
  64136. }
  64137. declare module BABYLON {
  64138. /** @hidden */
  64139. export var mixVertexShader: {
  64140. name: string;
  64141. shader: string;
  64142. };
  64143. }
  64144. declare module BABYLON {
  64145. export class MixMaterial extends BABYLON.PushMaterial {
  64146. /**
  64147. * Mix textures
  64148. */
  64149. private _mixTexture1;
  64150. mixTexture1: BABYLON.BaseTexture;
  64151. private _mixTexture2;
  64152. mixTexture2: BABYLON.BaseTexture;
  64153. /**
  64154. * Diffuse textures
  64155. */
  64156. private _diffuseTexture1;
  64157. diffuseTexture1: BABYLON.Texture;
  64158. private _diffuseTexture2;
  64159. diffuseTexture2: BABYLON.Texture;
  64160. private _diffuseTexture3;
  64161. diffuseTexture3: BABYLON.Texture;
  64162. private _diffuseTexture4;
  64163. diffuseTexture4: BABYLON.Texture;
  64164. private _diffuseTexture5;
  64165. diffuseTexture5: BABYLON.Texture;
  64166. private _diffuseTexture6;
  64167. diffuseTexture6: BABYLON.Texture;
  64168. private _diffuseTexture7;
  64169. diffuseTexture7: BABYLON.Texture;
  64170. private _diffuseTexture8;
  64171. diffuseTexture8: BABYLON.Texture;
  64172. /**
  64173. * Uniforms
  64174. */
  64175. diffuseColor: BABYLON.Color3;
  64176. specularColor: BABYLON.Color3;
  64177. specularPower: number;
  64178. private _disableLighting;
  64179. disableLighting: boolean;
  64180. private _maxSimultaneousLights;
  64181. maxSimultaneousLights: number;
  64182. private _renderId;
  64183. constructor(name: string, scene: BABYLON.Scene);
  64184. needAlphaBlending(): boolean;
  64185. needAlphaTesting(): boolean;
  64186. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64187. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64188. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64189. getAnimatables(): BABYLON.IAnimatable[];
  64190. getActiveTextures(): BABYLON.BaseTexture[];
  64191. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64192. dispose(forceDisposeEffect?: boolean): void;
  64193. clone(name: string): MixMaterial;
  64194. serialize(): any;
  64195. getClassName(): string;
  64196. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  64197. }
  64198. }
  64199. declare module BABYLON {
  64200. /** @hidden */
  64201. export var normalPixelShader: {
  64202. name: string;
  64203. shader: string;
  64204. };
  64205. }
  64206. declare module BABYLON {
  64207. /** @hidden */
  64208. export var normalVertexShader: {
  64209. name: string;
  64210. shader: string;
  64211. };
  64212. }
  64213. declare module BABYLON {
  64214. export class NormalMaterial extends BABYLON.PushMaterial {
  64215. private _diffuseTexture;
  64216. diffuseTexture: BABYLON.BaseTexture;
  64217. diffuseColor: BABYLON.Color3;
  64218. private _disableLighting;
  64219. disableLighting: boolean;
  64220. private _maxSimultaneousLights;
  64221. maxSimultaneousLights: number;
  64222. private _renderId;
  64223. constructor(name: string, scene: BABYLON.Scene);
  64224. needAlphaBlending(): boolean;
  64225. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64226. needAlphaTesting(): boolean;
  64227. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64228. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64229. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64230. getAnimatables(): BABYLON.IAnimatable[];
  64231. getActiveTextures(): BABYLON.BaseTexture[];
  64232. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64233. dispose(forceDisposeEffect?: boolean): void;
  64234. clone(name: string): NormalMaterial;
  64235. serialize(): any;
  64236. getClassName(): string;
  64237. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /** @hidden */
  64242. export var shadowOnlyPixelShader: {
  64243. name: string;
  64244. shader: string;
  64245. };
  64246. }
  64247. declare module BABYLON {
  64248. /** @hidden */
  64249. export var shadowOnlyVertexShader: {
  64250. name: string;
  64251. shader: string;
  64252. };
  64253. }
  64254. declare module BABYLON {
  64255. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  64256. private _renderId;
  64257. private _activeLight;
  64258. constructor(name: string, scene: BABYLON.Scene);
  64259. shadowColor: BABYLON.Color3;
  64260. needAlphaBlending(): boolean;
  64261. needAlphaTesting(): boolean;
  64262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64263. activeLight: BABYLON.IShadowLight;
  64264. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64265. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64266. clone(name: string): ShadowOnlyMaterial;
  64267. serialize(): any;
  64268. getClassName(): string;
  64269. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  64270. }
  64271. }
  64272. declare module BABYLON {
  64273. /** @hidden */
  64274. export var simplePixelShader: {
  64275. name: string;
  64276. shader: string;
  64277. };
  64278. }
  64279. declare module BABYLON {
  64280. /** @hidden */
  64281. export var simpleVertexShader: {
  64282. name: string;
  64283. shader: string;
  64284. };
  64285. }
  64286. declare module BABYLON {
  64287. export class SimpleMaterial extends BABYLON.PushMaterial {
  64288. private _diffuseTexture;
  64289. diffuseTexture: BABYLON.BaseTexture;
  64290. diffuseColor: BABYLON.Color3;
  64291. private _disableLighting;
  64292. disableLighting: boolean;
  64293. private _maxSimultaneousLights;
  64294. maxSimultaneousLights: number;
  64295. private _renderId;
  64296. constructor(name: string, scene: BABYLON.Scene);
  64297. needAlphaBlending(): boolean;
  64298. needAlphaTesting(): boolean;
  64299. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64300. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64301. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64302. getAnimatables(): BABYLON.IAnimatable[];
  64303. getActiveTextures(): BABYLON.BaseTexture[];
  64304. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64305. dispose(forceDisposeEffect?: boolean): void;
  64306. clone(name: string): SimpleMaterial;
  64307. serialize(): any;
  64308. getClassName(): string;
  64309. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  64310. }
  64311. }
  64312. declare module BABYLON {
  64313. /** @hidden */
  64314. export var skyPixelShader: {
  64315. name: string;
  64316. shader: string;
  64317. };
  64318. }
  64319. declare module BABYLON {
  64320. /** @hidden */
  64321. export var skyVertexShader: {
  64322. name: string;
  64323. shader: string;
  64324. };
  64325. }
  64326. declare module BABYLON {
  64327. /**
  64328. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  64329. * @see https://doc.babylonjs.com/extensions/sky
  64330. */
  64331. export class SkyMaterial extends BABYLON.PushMaterial {
  64332. /**
  64333. * Defines the overall luminance of sky in interval ]0, 1[.
  64334. */
  64335. luminance: number;
  64336. /**
  64337. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  64338. */
  64339. turbidity: number;
  64340. /**
  64341. * Defines the sky appearance (light intensity).
  64342. */
  64343. rayleigh: number;
  64344. /**
  64345. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  64346. */
  64347. mieCoefficient: number;
  64348. /**
  64349. * Defines the amount of haze particles following the Mie scattering theory.
  64350. */
  64351. mieDirectionalG: number;
  64352. /**
  64353. * Defines the distance of the sun according to the active scene camera.
  64354. */
  64355. distance: number;
  64356. /**
  64357. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  64358. * "inclined".
  64359. */
  64360. inclination: number;
  64361. /**
  64362. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  64363. * an object direction and a reference direction.
  64364. */
  64365. azimuth: number;
  64366. /**
  64367. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  64368. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  64369. */
  64370. sunPosition: BABYLON.Vector3;
  64371. /**
  64372. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  64373. * .sunPosition property.
  64374. */
  64375. useSunPosition: boolean;
  64376. /**
  64377. * Defines an offset vector used to get a horizon offset.
  64378. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  64379. */
  64380. cameraOffset: BABYLON.Vector3;
  64381. private _cameraPosition;
  64382. private _renderId;
  64383. /**
  64384. * Instantiates a new sky material.
  64385. * This material allows to create dynamic and texture free
  64386. * effects for skyboxes by taking care of the atmosphere state.
  64387. * @see https://doc.babylonjs.com/extensions/sky
  64388. * @param name Define the name of the material in the scene
  64389. * @param scene Define the scene the material belong to
  64390. */
  64391. constructor(name: string, scene: BABYLON.Scene);
  64392. /**
  64393. * Specifies if the material will require alpha blending
  64394. * @returns a boolean specifying if alpha blending is needed
  64395. */
  64396. needAlphaBlending(): boolean;
  64397. /**
  64398. * Specifies if this material should be rendered in alpha test mode
  64399. * @returns false as the sky material doesn't need alpha testing.
  64400. */
  64401. needAlphaTesting(): boolean;
  64402. /**
  64403. * Get the texture used for alpha test purpose.
  64404. * @returns null as the sky material has no texture.
  64405. */
  64406. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64407. /**
  64408. * Get if the submesh is ready to be used and all its information available.
  64409. * Child classes can use it to update shaders
  64410. * @param mesh defines the mesh to check
  64411. * @param subMesh defines which submesh to check
  64412. * @param useInstances specifies that instances should be used
  64413. * @returns a boolean indicating that the submesh is ready or not
  64414. */
  64415. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64416. /**
  64417. * Binds the submesh to this material by preparing the effect and shader to draw
  64418. * @param world defines the world transformation matrix
  64419. * @param mesh defines the mesh containing the submesh
  64420. * @param subMesh defines the submesh to bind the material to
  64421. */
  64422. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64423. /**
  64424. * Get the list of animatables in the material.
  64425. * @returns the list of animatables object used in the material
  64426. */
  64427. getAnimatables(): BABYLON.IAnimatable[];
  64428. /**
  64429. * Disposes the material
  64430. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64431. */
  64432. dispose(forceDisposeEffect?: boolean): void;
  64433. /**
  64434. * Makes a duplicate of the material, and gives it a new name
  64435. * @param name defines the new name for the duplicated material
  64436. * @returns the cloned material
  64437. */
  64438. clone(name: string): SkyMaterial;
  64439. /**
  64440. * Serializes this material in a JSON representation
  64441. * @returns the serialized material object
  64442. */
  64443. serialize(): any;
  64444. /**
  64445. * Gets the current class name of the material e.g. "SkyMaterial"
  64446. * Mainly use in serialization.
  64447. * @returns the class name
  64448. */
  64449. getClassName(): string;
  64450. /**
  64451. * Creates a sky material from parsed material data
  64452. * @param source defines the JSON representation of the material
  64453. * @param scene defines the hosting scene
  64454. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64455. * @returns a new sky material
  64456. */
  64457. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64458. }
  64459. }
  64460. declare module BABYLON {
  64461. /** @hidden */
  64462. export var terrainPixelShader: {
  64463. name: string;
  64464. shader: string;
  64465. };
  64466. }
  64467. declare module BABYLON {
  64468. /** @hidden */
  64469. export var terrainVertexShader: {
  64470. name: string;
  64471. shader: string;
  64472. };
  64473. }
  64474. declare module BABYLON {
  64475. export class TerrainMaterial extends BABYLON.PushMaterial {
  64476. private _mixTexture;
  64477. mixTexture: BABYLON.BaseTexture;
  64478. private _diffuseTexture1;
  64479. diffuseTexture1: BABYLON.Texture;
  64480. private _diffuseTexture2;
  64481. diffuseTexture2: BABYLON.Texture;
  64482. private _diffuseTexture3;
  64483. diffuseTexture3: BABYLON.Texture;
  64484. private _bumpTexture1;
  64485. bumpTexture1: BABYLON.Texture;
  64486. private _bumpTexture2;
  64487. bumpTexture2: BABYLON.Texture;
  64488. private _bumpTexture3;
  64489. bumpTexture3: BABYLON.Texture;
  64490. diffuseColor: BABYLON.Color3;
  64491. specularColor: BABYLON.Color3;
  64492. specularPower: number;
  64493. private _disableLighting;
  64494. disableLighting: boolean;
  64495. private _maxSimultaneousLights;
  64496. maxSimultaneousLights: number;
  64497. private _renderId;
  64498. constructor(name: string, scene: BABYLON.Scene);
  64499. needAlphaBlending(): boolean;
  64500. needAlphaTesting(): boolean;
  64501. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64502. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64503. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64504. getAnimatables(): BABYLON.IAnimatable[];
  64505. getActiveTextures(): BABYLON.BaseTexture[];
  64506. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64507. dispose(forceDisposeEffect?: boolean): void;
  64508. clone(name: string): TerrainMaterial;
  64509. serialize(): any;
  64510. getClassName(): string;
  64511. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64512. }
  64513. }
  64514. declare module BABYLON {
  64515. /** @hidden */
  64516. export var triplanarPixelShader: {
  64517. name: string;
  64518. shader: string;
  64519. };
  64520. }
  64521. declare module BABYLON {
  64522. /** @hidden */
  64523. export var triplanarVertexShader: {
  64524. name: string;
  64525. shader: string;
  64526. };
  64527. }
  64528. declare module BABYLON {
  64529. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64530. mixTexture: BABYLON.BaseTexture;
  64531. private _diffuseTextureX;
  64532. diffuseTextureX: BABYLON.BaseTexture;
  64533. private _diffuseTextureY;
  64534. diffuseTextureY: BABYLON.BaseTexture;
  64535. private _diffuseTextureZ;
  64536. diffuseTextureZ: BABYLON.BaseTexture;
  64537. private _normalTextureX;
  64538. normalTextureX: BABYLON.BaseTexture;
  64539. private _normalTextureY;
  64540. normalTextureY: BABYLON.BaseTexture;
  64541. private _normalTextureZ;
  64542. normalTextureZ: BABYLON.BaseTexture;
  64543. tileSize: number;
  64544. diffuseColor: BABYLON.Color3;
  64545. specularColor: BABYLON.Color3;
  64546. specularPower: number;
  64547. private _disableLighting;
  64548. disableLighting: boolean;
  64549. private _maxSimultaneousLights;
  64550. maxSimultaneousLights: number;
  64551. private _renderId;
  64552. constructor(name: string, scene: BABYLON.Scene);
  64553. needAlphaBlending(): boolean;
  64554. needAlphaTesting(): boolean;
  64555. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64556. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64557. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64558. getAnimatables(): BABYLON.IAnimatable[];
  64559. getActiveTextures(): BABYLON.BaseTexture[];
  64560. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64561. dispose(forceDisposeEffect?: boolean): void;
  64562. clone(name: string): TriPlanarMaterial;
  64563. serialize(): any;
  64564. getClassName(): string;
  64565. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64566. }
  64567. }
  64568. declare module BABYLON {
  64569. /** @hidden */
  64570. export var waterPixelShader: {
  64571. name: string;
  64572. shader: string;
  64573. };
  64574. }
  64575. declare module BABYLON {
  64576. /** @hidden */
  64577. export var waterVertexShader: {
  64578. name: string;
  64579. shader: string;
  64580. };
  64581. }
  64582. declare module BABYLON {
  64583. export class WaterMaterial extends BABYLON.PushMaterial {
  64584. renderTargetSize: BABYLON.Vector2;
  64585. private _bumpTexture;
  64586. bumpTexture: BABYLON.BaseTexture;
  64587. diffuseColor: BABYLON.Color3;
  64588. specularColor: BABYLON.Color3;
  64589. specularPower: number;
  64590. private _disableLighting;
  64591. disableLighting: boolean;
  64592. private _maxSimultaneousLights;
  64593. maxSimultaneousLights: number;
  64594. /**
  64595. * @param {number}: Represents the wind force
  64596. */
  64597. windForce: number;
  64598. /**
  64599. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64600. */
  64601. windDirection: BABYLON.Vector2;
  64602. /**
  64603. * @param {number}: Wave height, represents the height of the waves
  64604. */
  64605. waveHeight: number;
  64606. /**
  64607. * @param {number}: Bump height, represents the bump height related to the bump map
  64608. */
  64609. bumpHeight: number;
  64610. /**
  64611. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64612. */
  64613. private _bumpSuperimpose;
  64614. bumpSuperimpose: boolean;
  64615. /**
  64616. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64617. */
  64618. private _fresnelSeparate;
  64619. fresnelSeparate: boolean;
  64620. /**
  64621. * @param {boolean}: bump Waves modify the reflection.
  64622. */
  64623. private _bumpAffectsReflection;
  64624. bumpAffectsReflection: boolean;
  64625. /**
  64626. * @param {number}: The water color blended with the refraction (near)
  64627. */
  64628. waterColor: BABYLON.Color3;
  64629. /**
  64630. * @param {number}: The blend factor related to the water color
  64631. */
  64632. colorBlendFactor: number;
  64633. /**
  64634. * @param {number}: The water color blended with the reflection (far)
  64635. */
  64636. waterColor2: BABYLON.Color3;
  64637. /**
  64638. * @param {number}: The blend factor related to the water color (reflection, far)
  64639. */
  64640. colorBlendFactor2: number;
  64641. /**
  64642. * @param {number}: Represents the maximum length of a wave
  64643. */
  64644. waveLength: number;
  64645. /**
  64646. * @param {number}: Defines the waves speed
  64647. */
  64648. waveSpeed: number;
  64649. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64650. private _mesh;
  64651. private _refractionRTT;
  64652. private _reflectionRTT;
  64653. private _reflectionTransform;
  64654. private _lastTime;
  64655. private _lastDeltaTime;
  64656. private _renderId;
  64657. private _useLogarithmicDepth;
  64658. private _waitingRenderList;
  64659. /**
  64660. * Gets a boolean indicating that current material needs to register RTT
  64661. */
  64662. readonly hasRenderTargetTextures: boolean;
  64663. /**
  64664. * Constructor
  64665. */
  64666. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64667. useLogarithmicDepth: boolean;
  64668. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64669. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64670. addToRenderList(node: any): void;
  64671. enableRenderTargets(enable: boolean): void;
  64672. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64673. readonly renderTargetsEnabled: boolean;
  64674. needAlphaBlending(): boolean;
  64675. needAlphaTesting(): boolean;
  64676. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64677. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64678. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64679. private _createRenderTargets;
  64680. getAnimatables(): BABYLON.IAnimatable[];
  64681. getActiveTextures(): BABYLON.BaseTexture[];
  64682. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64683. dispose(forceDisposeEffect?: boolean): void;
  64684. clone(name: string): WaterMaterial;
  64685. serialize(): any;
  64686. getClassName(): string;
  64687. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64688. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64689. }
  64690. }
  64691. declare module BABYLON {
  64692. /** @hidden */
  64693. export var asciiartPixelShader: {
  64694. name: string;
  64695. shader: string;
  64696. };
  64697. }
  64698. declare module BABYLON {
  64699. /**
  64700. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64701. *
  64702. * It basically takes care rendering the font front the given font size to a texture.
  64703. * This is used later on in the postprocess.
  64704. */
  64705. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64706. private _font;
  64707. private _text;
  64708. private _charSize;
  64709. /**
  64710. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64711. */
  64712. readonly charSize: number;
  64713. /**
  64714. * Create a new instance of the Ascii Art FontTexture class
  64715. * @param name the name of the texture
  64716. * @param font the font to use, use the W3C CSS notation
  64717. * @param text the caracter set to use in the rendering.
  64718. * @param scene the scene that owns the texture
  64719. */
  64720. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64721. /**
  64722. * Gets the max char width of a font.
  64723. * @param font the font to use, use the W3C CSS notation
  64724. * @return the max char width
  64725. */
  64726. private getFontWidth;
  64727. /**
  64728. * Gets the max char height of a font.
  64729. * @param font the font to use, use the W3C CSS notation
  64730. * @return the max char height
  64731. */
  64732. private getFontHeight;
  64733. /**
  64734. * Clones the current AsciiArtTexture.
  64735. * @return the clone of the texture.
  64736. */
  64737. clone(): AsciiArtFontTexture;
  64738. /**
  64739. * Parses a json object representing the texture and returns an instance of it.
  64740. * @param source the source JSON representation
  64741. * @param scene the scene to create the texture for
  64742. * @return the parsed texture
  64743. */
  64744. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64745. }
  64746. /**
  64747. * Option available in the Ascii Art Post Process.
  64748. */
  64749. export interface IAsciiArtPostProcessOptions {
  64750. /**
  64751. * The font to use following the w3c font definition.
  64752. */
  64753. font?: string;
  64754. /**
  64755. * The character set to use in the postprocess.
  64756. */
  64757. characterSet?: string;
  64758. /**
  64759. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64760. * This number is defined between 0 and 1;
  64761. */
  64762. mixToTile?: number;
  64763. /**
  64764. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64765. * This number is defined between 0 and 1;
  64766. */
  64767. mixToNormal?: number;
  64768. }
  64769. /**
  64770. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64771. *
  64772. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64773. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64774. */
  64775. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64776. /**
  64777. * The font texture used to render the char in the post process.
  64778. */
  64779. private _asciiArtFontTexture;
  64780. /**
  64781. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64782. * This number is defined between 0 and 1;
  64783. */
  64784. mixToTile: number;
  64785. /**
  64786. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64787. * This number is defined between 0 and 1;
  64788. */
  64789. mixToNormal: number;
  64790. /**
  64791. * Instantiates a new Ascii Art Post Process.
  64792. * @param name the name to give to the postprocess
  64793. * @camera the camera to apply the post process to.
  64794. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64795. */
  64796. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64797. }
  64798. }
  64799. declare module BABYLON {
  64800. /** @hidden */
  64801. export var digitalrainPixelShader: {
  64802. name: string;
  64803. shader: string;
  64804. };
  64805. }
  64806. declare module BABYLON {
  64807. /**
  64808. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64809. *
  64810. * It basically takes care rendering the font front the given font size to a texture.
  64811. * This is used later on in the postprocess.
  64812. */
  64813. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64814. private _font;
  64815. private _text;
  64816. private _charSize;
  64817. /**
  64818. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64819. */
  64820. readonly charSize: number;
  64821. /**
  64822. * Create a new instance of the Digital Rain FontTexture class
  64823. * @param name the name of the texture
  64824. * @param font the font to use, use the W3C CSS notation
  64825. * @param text the caracter set to use in the rendering.
  64826. * @param scene the scene that owns the texture
  64827. */
  64828. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64829. /**
  64830. * Gets the max char width of a font.
  64831. * @param font the font to use, use the W3C CSS notation
  64832. * @return the max char width
  64833. */
  64834. private getFontWidth;
  64835. /**
  64836. * Gets the max char height of a font.
  64837. * @param font the font to use, use the W3C CSS notation
  64838. * @return the max char height
  64839. */
  64840. private getFontHeight;
  64841. /**
  64842. * Clones the current DigitalRainFontTexture.
  64843. * @return the clone of the texture.
  64844. */
  64845. clone(): DigitalRainFontTexture;
  64846. /**
  64847. * Parses a json object representing the texture and returns an instance of it.
  64848. * @param source the source JSON representation
  64849. * @param scene the scene to create the texture for
  64850. * @return the parsed texture
  64851. */
  64852. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64853. }
  64854. /**
  64855. * Option available in the Digital Rain Post Process.
  64856. */
  64857. export interface IDigitalRainPostProcessOptions {
  64858. /**
  64859. * The font to use following the w3c font definition.
  64860. */
  64861. font?: string;
  64862. /**
  64863. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64864. * This number is defined between 0 and 1;
  64865. */
  64866. mixToTile?: number;
  64867. /**
  64868. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64869. * This number is defined between 0 and 1;
  64870. */
  64871. mixToNormal?: number;
  64872. }
  64873. /**
  64874. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64875. *
  64876. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64877. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64878. */
  64879. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64880. /**
  64881. * The font texture used to render the char in the post process.
  64882. */
  64883. private _digitalRainFontTexture;
  64884. /**
  64885. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64886. * This number is defined between 0 and 1;
  64887. */
  64888. mixToTile: number;
  64889. /**
  64890. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64891. * This number is defined between 0 and 1;
  64892. */
  64893. mixToNormal: number;
  64894. /**
  64895. * Instantiates a new Digital Rain Post Process.
  64896. * @param name the name to give to the postprocess
  64897. * @camera the camera to apply the post process to.
  64898. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64899. */
  64900. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64901. }
  64902. }
  64903. declare module BABYLON {
  64904. /** @hidden */
  64905. export var oceanPostProcessPixelShader: {
  64906. name: string;
  64907. shader: string;
  64908. };
  64909. }
  64910. declare module BABYLON {
  64911. /**
  64912. * Option available in the Ocean Post Process.
  64913. */
  64914. export interface IOceanPostProcessOptions {
  64915. /**
  64916. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64917. */
  64918. reflectionSize?: number | {
  64919. width: number;
  64920. height: number;
  64921. } | {
  64922. ratio: number;
  64923. };
  64924. /**
  64925. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64926. */
  64927. refractionSize?: number | {
  64928. width: number;
  64929. height: number;
  64930. } | {
  64931. ratio: number;
  64932. };
  64933. }
  64934. /**
  64935. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64936. *
  64937. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64938. * Example usage:
  64939. * var pp = new OceanPostProcess("myOcean", camera);
  64940. * pp.reflectionEnabled = true;
  64941. * pp.refractionEnabled = true;
  64942. */
  64943. export class OceanPostProcess extends BABYLON.PostProcess {
  64944. /**
  64945. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64946. */
  64947. /**
  64948. * Sets weither or not the real-time reflection is enabled on the ocean.
  64949. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64950. */
  64951. reflectionEnabled: boolean;
  64952. /**
  64953. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64954. */
  64955. /**
  64956. * Sets weither or not the real-time refraction is enabled on the ocean.
  64957. * Is set to true, the refraction render target texture will be used as refraction texture.
  64958. */
  64959. refractionEnabled: boolean;
  64960. /**
  64961. * Gets wether or not the post-processes is supported by the running hardware.
  64962. * This requires draw buffer supports.
  64963. */
  64964. readonly isSupported: boolean;
  64965. /**
  64966. * This is the reflection mirror texture used to display reflections on the ocean.
  64967. * By default, render list is empty.
  64968. */
  64969. reflectionTexture: BABYLON.MirrorTexture;
  64970. /**
  64971. * This is the refraction render target texture used to display refraction on the ocean.
  64972. * By default, render list is empty.
  64973. */
  64974. refractionTexture: BABYLON.RenderTargetTexture;
  64975. private _time;
  64976. private _cameraRotation;
  64977. private _cameraViewMatrix;
  64978. private _reflectionEnabled;
  64979. private _refractionEnabled;
  64980. private _geometryRenderer;
  64981. /**
  64982. * Instantiates a new Ocean Post Process.
  64983. * @param name the name to give to the postprocess.
  64984. * @camera the camera to apply the post process to.
  64985. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64986. */
  64987. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64988. /**
  64989. * Returns the appropriate defines according to the current configuration.
  64990. */
  64991. private _getDefines;
  64992. /**
  64993. * Computes the current camera rotation as the shader requires a camera rotation.
  64994. */
  64995. private _computeCameraRotation;
  64996. }
  64997. }
  64998. declare module BABYLON {
  64999. /** @hidden */
  65000. export var brickProceduralTexturePixelShader: {
  65001. name: string;
  65002. shader: string;
  65003. };
  65004. }
  65005. declare module BABYLON {
  65006. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  65007. private _numberOfBricksHeight;
  65008. private _numberOfBricksWidth;
  65009. private _jointColor;
  65010. private _brickColor;
  65011. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65012. updateShaderUniforms(): void;
  65013. numberOfBricksHeight: number;
  65014. numberOfBricksWidth: number;
  65015. jointColor: BABYLON.Color3;
  65016. brickColor: BABYLON.Color3;
  65017. /**
  65018. * Serializes this brick procedural texture
  65019. * @returns a serialized brick procedural texture object
  65020. */
  65021. serialize(): any;
  65022. /**
  65023. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  65024. * @param parsedTexture defines parsed texture data
  65025. * @param scene defines the current scene
  65026. * @param rootUrl defines the root URL containing brick procedural texture information
  65027. * @returns a parsed Brick Procedural BABYLON.Texture
  65028. */
  65029. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /** @hidden */
  65034. export var cloudProceduralTexturePixelShader: {
  65035. name: string;
  65036. shader: string;
  65037. };
  65038. }
  65039. declare module BABYLON {
  65040. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  65041. private _skyColor;
  65042. private _cloudColor;
  65043. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65044. updateShaderUniforms(): void;
  65045. skyColor: BABYLON.Color4;
  65046. cloudColor: BABYLON.Color4;
  65047. /**
  65048. * Serializes this cloud procedural texture
  65049. * @returns a serialized cloud procedural texture object
  65050. */
  65051. serialize(): any;
  65052. /**
  65053. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  65054. * @param parsedTexture defines parsed texture data
  65055. * @param scene defines the current scene
  65056. * @param rootUrl defines the root URL containing cloud procedural texture information
  65057. * @returns a parsed Cloud Procedural BABYLON.Texture
  65058. */
  65059. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  65060. }
  65061. }
  65062. declare module BABYLON {
  65063. /** @hidden */
  65064. export var fireProceduralTexturePixelShader: {
  65065. name: string;
  65066. shader: string;
  65067. };
  65068. }
  65069. declare module BABYLON {
  65070. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  65071. private _time;
  65072. private _speed;
  65073. private _autoGenerateTime;
  65074. private _fireColors;
  65075. private _alphaThreshold;
  65076. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65077. updateShaderUniforms(): void;
  65078. render(useCameraPostProcess?: boolean): void;
  65079. static readonly PurpleFireColors: BABYLON.Color3[];
  65080. static readonly GreenFireColors: BABYLON.Color3[];
  65081. static readonly RedFireColors: BABYLON.Color3[];
  65082. static readonly BlueFireColors: BABYLON.Color3[];
  65083. autoGenerateTime: boolean;
  65084. fireColors: BABYLON.Color3[];
  65085. time: number;
  65086. speed: BABYLON.Vector2;
  65087. alphaThreshold: number;
  65088. /**
  65089. * Serializes this fire procedural texture
  65090. * @returns a serialized fire procedural texture object
  65091. */
  65092. serialize(): any;
  65093. /**
  65094. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  65095. * @param parsedTexture defines parsed texture data
  65096. * @param scene defines the current scene
  65097. * @param rootUrl defines the root URL containing fire procedural texture information
  65098. * @returns a parsed Fire Procedural BABYLON.Texture
  65099. */
  65100. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  65101. }
  65102. }
  65103. declare module BABYLON {
  65104. /** @hidden */
  65105. export var grassProceduralTexturePixelShader: {
  65106. name: string;
  65107. shader: string;
  65108. };
  65109. }
  65110. declare module BABYLON {
  65111. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  65112. private _grassColors;
  65113. private _groundColor;
  65114. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65115. updateShaderUniforms(): void;
  65116. grassColors: BABYLON.Color3[];
  65117. groundColor: BABYLON.Color3;
  65118. /**
  65119. * Serializes this grass procedural texture
  65120. * @returns a serialized grass procedural texture object
  65121. */
  65122. serialize(): any;
  65123. /**
  65124. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  65125. * @param parsedTexture defines parsed texture data
  65126. * @param scene defines the current scene
  65127. * @param rootUrl defines the root URL containing grass procedural texture information
  65128. * @returns a parsed Grass Procedural BABYLON.Texture
  65129. */
  65130. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  65131. }
  65132. }
  65133. declare module BABYLON {
  65134. /** @hidden */
  65135. export var marbleProceduralTexturePixelShader: {
  65136. name: string;
  65137. shader: string;
  65138. };
  65139. }
  65140. declare module BABYLON {
  65141. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  65142. private _numberOfTilesHeight;
  65143. private _numberOfTilesWidth;
  65144. private _amplitude;
  65145. private _jointColor;
  65146. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65147. updateShaderUniforms(): void;
  65148. numberOfTilesHeight: number;
  65149. amplitude: number;
  65150. numberOfTilesWidth: number;
  65151. jointColor: BABYLON.Color3;
  65152. /**
  65153. * Serializes this marble procedural texture
  65154. * @returns a serialized marble procedural texture object
  65155. */
  65156. serialize(): any;
  65157. /**
  65158. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  65159. * @param parsedTexture defines parsed texture data
  65160. * @param scene defines the current scene
  65161. * @param rootUrl defines the root URL containing marble procedural texture information
  65162. * @returns a parsed Marble Procedural BABYLON.Texture
  65163. */
  65164. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  65165. }
  65166. }
  65167. declare module BABYLON {
  65168. /** @hidden */
  65169. export var normalMapProceduralTexturePixelShader: {
  65170. name: string;
  65171. shader: string;
  65172. };
  65173. }
  65174. declare module BABYLON {
  65175. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  65176. private _baseTexture;
  65177. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65178. updateShaderUniforms(): void;
  65179. render(useCameraPostProcess?: boolean): void;
  65180. resize(size: any, generateMipMaps: any): void;
  65181. baseTexture: BABYLON.Texture;
  65182. /**
  65183. * Serializes this normal map procedural texture
  65184. * @returns a serialized normal map procedural texture object
  65185. */
  65186. serialize(): any;
  65187. /**
  65188. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  65189. * @param parsedTexture defines parsed texture data
  65190. * @param scene defines the current scene
  65191. * @param rootUrl defines the root URL containing normal map procedural texture information
  65192. * @returns a parsed Normal Map Procedural BABYLON.Texture
  65193. */
  65194. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  65195. }
  65196. }
  65197. declare module BABYLON {
  65198. /** @hidden */
  65199. export var perlinNoiseProceduralTexturePixelShader: {
  65200. name: string;
  65201. shader: string;
  65202. };
  65203. }
  65204. declare module BABYLON {
  65205. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  65206. time: number;
  65207. timeScale: number;
  65208. translationSpeed: number;
  65209. private _currentTranslation;
  65210. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65211. updateShaderUniforms(): void;
  65212. render(useCameraPostProcess?: boolean): void;
  65213. resize(size: any, generateMipMaps: any): void;
  65214. /**
  65215. * Serializes this perlin noise procedural texture
  65216. * @returns a serialized perlin noise procedural texture object
  65217. */
  65218. serialize(): any;
  65219. /**
  65220. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  65221. * @param parsedTexture defines parsed texture data
  65222. * @param scene defines the current scene
  65223. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  65224. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  65225. */
  65226. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  65227. }
  65228. }
  65229. declare module BABYLON {
  65230. /** @hidden */
  65231. export var roadProceduralTexturePixelShader: {
  65232. name: string;
  65233. shader: string;
  65234. };
  65235. }
  65236. declare module BABYLON {
  65237. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  65238. private _roadColor;
  65239. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65240. updateShaderUniforms(): void;
  65241. roadColor: BABYLON.Color3;
  65242. /**
  65243. * Serializes this road procedural texture
  65244. * @returns a serialized road procedural texture object
  65245. */
  65246. serialize(): any;
  65247. /**
  65248. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  65249. * @param parsedTexture defines parsed texture data
  65250. * @param scene defines the current scene
  65251. * @param rootUrl defines the root URL containing road procedural texture information
  65252. * @returns a parsed Road Procedural BABYLON.Texture
  65253. */
  65254. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  65255. }
  65256. }
  65257. declare module BABYLON {
  65258. /** @hidden */
  65259. export var starfieldProceduralTexturePixelShader: {
  65260. name: string;
  65261. shader: string;
  65262. };
  65263. }
  65264. declare module BABYLON {
  65265. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  65266. private _time;
  65267. private _alpha;
  65268. private _beta;
  65269. private _zoom;
  65270. private _formuparam;
  65271. private _stepsize;
  65272. private _tile;
  65273. private _brightness;
  65274. private _darkmatter;
  65275. private _distfading;
  65276. private _saturation;
  65277. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65278. updateShaderUniforms(): void;
  65279. time: number;
  65280. alpha: number;
  65281. beta: number;
  65282. formuparam: number;
  65283. stepsize: number;
  65284. zoom: number;
  65285. tile: number;
  65286. brightness: number;
  65287. darkmatter: number;
  65288. distfading: number;
  65289. saturation: number;
  65290. /**
  65291. * Serializes this starfield procedural texture
  65292. * @returns a serialized starfield procedural texture object
  65293. */
  65294. serialize(): any;
  65295. /**
  65296. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  65297. * @param parsedTexture defines parsed texture data
  65298. * @param scene defines the current scene
  65299. * @param rootUrl defines the root URL containing startfield procedural texture information
  65300. * @returns a parsed Starfield Procedural BABYLON.Texture
  65301. */
  65302. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  65303. }
  65304. }
  65305. declare module BABYLON {
  65306. /** @hidden */
  65307. export var woodProceduralTexturePixelShader: {
  65308. name: string;
  65309. shader: string;
  65310. };
  65311. }
  65312. declare module BABYLON {
  65313. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  65314. private _ampScale;
  65315. private _woodColor;
  65316. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65317. updateShaderUniforms(): void;
  65318. ampScale: number;
  65319. woodColor: BABYLON.Color3;
  65320. /**
  65321. * Serializes this wood procedural texture
  65322. * @returns a serialized wood procedural texture object
  65323. */
  65324. serialize(): any;
  65325. /**
  65326. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  65327. * @param parsedTexture defines parsed texture data
  65328. * @param scene defines the current scene
  65329. * @param rootUrl defines the root URL containing wood procedural texture information
  65330. * @returns a parsed Wood Procedural BABYLON.Texture
  65331. */
  65332. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  65333. }
  65334. }